[
  {
    "path": ".devcontainer/Dockerfile",
    "content": "# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/typescript-node/.devcontainer/base.Dockerfile\n\n# [Choice] Node.js version: 16, 14, 12\nARG VARIANT=\"16-buster\"\nFROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}\n\n# [Optional] Uncomment this section to install additional OS packages.\n# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \\\n#     && apt-get -y install --no-install-recommends <your-package-list-here>\n\n# [Optional] Uncomment if you want to install an additional version of node using nvm\n# ARG EXTRA_NODE_VERSION=10\n# RUN su node -c \"source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}\"\n\n# [Optional] Uncomment if you want to install more global node packages\n# RUN su node -c \"npm install -g <your-package-list -here>\"\n"
  },
  {
    "path": ".devcontainer/devcontainer.json",
    "content": "// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:\n// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/typescript-node\n{\n  \"name\": \"Node.js & TypeScript\",\n  \"build\": {\n    \"dockerfile\": \"Dockerfile\",\n    // Update 'VARIANT' to pick a Node version: 12, 14, 16\n    \"args\": {\n      \"VARIANT\": \"16\"\n    }\n  },\n\n  // Set *default* container specific settings.json values on container create.\n  \"settings\": {},\n\n  // Add the IDs of extensions you want installed when the container is created.\n  \"extensions\": [\n    \"dbaeumer.vscode-eslint\",\n    \"esbenp.prettier-vscode\",\n    \"dsznajder.es7-react-js-snippets\",\n    \"eamodio.gitlens\",\n    \"github.vscode-pull-request-github\"\n  ],\n\n  // Use 'forwardPorts' to make a list of ports inside the container available locally.\n  \"forwardPorts\": [3000, 8000],\n\n  // Use 'postCreateCommand' to run commands after the container is created.\n  \"postCreateCommand\": \"npm ci\",\n\n  // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.\n  \"remoteUser\": \"node\"\n}\n"
  },
  {
    "path": ".empty_module.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\n\nconst Null = () => null;\n\nexport default Null;\n"
  },
  {
    "path": ".eslintignore",
    "content": "examples/\ndist/\nnode_modules/\ncoverage/\nnpm/\ndocs/\nintegration/\n"
  },
  {
    "path": ".eslintrc",
    "content": "extends:\n- eslint:recommended\n- plugin:jest/recommended\n- plugin:unicorn/recommended\n- plugin:react/recommended\n- plugin:@typescript-eslint/recommended\n- plugin:prettier/recommended\n\nplugins:\n- \"@typescript-eslint\"\n\nparser: \"@typescript-eslint/parser\"\n\nenv:\n  node: true\n  browser: true\n  es6: true\n\nrules:\n  # eslint\n  no-console: off\n  prefer-const:\n    - error\n    - destructuring: all\n\n  # plugin:unicorn\n  unicorn/consistent-function-scoping: off\n  unicorn/no-array-for-each: off\n  unicorn/no-array-reduce: off\n  unicorn/no-fn-reference-in-iterator: off\n  unicorn/no-null: off\n  unicorn/no-reduce: off\n  unicorn/no-useless-undefined: off\n  unicorn/prevent-abbreviations: off\n\n  # plugin:@typescript-eslint\n  \"@typescript-eslint/consistent-type-imports\": error\n  \"@typescript-eslint/explicit-module-boundary-types\": off\n  \"@typescript-eslint/no-empty-function\": off\n  \"@typescript-eslint/no-explicit-any\": off\n  \"@typescript-eslint/no-namespace\": off\n  \"@typescript-eslint/no-unused-vars\":\n    - warn\n    - args: after-used\n      ignoreRestSiblings: true\n  \"@typescript-eslint/no-var-requires\": off\n\nsettings:\n  react:\n    version: detect\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [boardgameio]\nopen_collective: boardgameio\n"
  },
  {
    "path": ".github/pull_request_template.md",
    "content": "#### Checklist\n\n- [ ] Use a separate branch in your local repo (not `main`).\n- [ ] Test coverage is 100% (or you have a story for why it's ok).\n"
  },
  {
    "path": ".github/workflows/npm-publish.yml",
    "content": "name: Publish\n\non:\n  push:\n    tags: [ 'v0.[0-9]+.[0-9]+' ]\n\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n\n      - name: Use Node v12\n        uses: actions/setup-node@v1\n        with:\n          node-version: 12\n\n      - name: Install Dependencies\n        run: npm ci\n\n      - name: Run Tests\n        run: |\n          npm run lint\n          npm run test\n\n      - name: Publish to NPM\n        id: publish\n        uses: JS-DevTools/npm-publish@v1\n        with:\n          token: ${{ secrets.NPM_TOKEN }}\n\n      - name: Version already published\n        if: steps.publish.outputs.type == 'none'\n        run: |\n          echo \"Version ${{ steps.publish.outputs.old-version }} already exists.\"\n\n      - name: New version published\n        if: steps.publish.outputs.type != 'none'\n        run: |\n          echo \"New ${{ steps.publish.outputs.type }} version ${{ steps.publish.outputs.version }} published. Was ${{ steps.publish.outputs.old-version }}.\"\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: Tests\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    branches: [ main ]\n\njobs:\n  unit:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node-version: [10.x, 12.x, 14.x, 16.x]\n\n    steps:\n    - uses: actions/checkout@v2\n      \n    - name: Use Node v${{ matrix.node-version }}\n      uses: actions/setup-node@v1\n      with:\n        node-version: ${{ matrix.node-version }}\n\n    - name: Install Dependencies\n      run: npm install\n\n    - name: Run Tests\n      run: |\n        npm run lint\n        npm run test:coverage\n\n    - name: Coveralls\n      uses: coverallsapp/github-action@master\n      with:\n        github-token: ${{ secrets.GITHUB_TOKEN }}\n\n  integration:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node-version: [10.x, 12.x, 14.x, 16.x]\n\n    steps:\n    - uses: actions/checkout@v2\n      \n    - name: Use Node v${{ matrix.node-version }}\n      uses: actions/setup-node@v1\n      with:\n        node-version: ${{ matrix.node-version }}\n\n    - name: Install Dependencies\n      run: npm install\n\n    - name: Run Integration Test\n      run: npm run test:integration\n"
  },
  {
    "path": ".gitignore",
    "content": ".cache\nyarn.lock\n.DS_Store\n*.swp\nnpm-debug.log*\ndist\nnode_modules\ncoverage\n.coveralls.yml\n.npm\nnpm\n.idea/\n.vscode/*\n.rpt2_cache/\n.rush/"
  },
  {
    "path": ".lintstagedrc",
    "content": "{\n  \"*.{ts,js,css,md}\": \"prettier --write\"\n}\n"
  },
  {
    "path": ".prettierignore",
    "content": "*.bundle.js\n*.min.js\nnode_modules\ndist\nGame.md\npackage.json\ndocs\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"printWidth\": 80,\n  \"singleQuote\": true,\n}\n"
  },
  {
    "path": "AUTHORS",
    "content": "# List of contributors. This is by no means meant to be\n# comprehensive (git history is a good way to get the\n# exhaustive list). Feel free to add your name here whenever\n# you send a Pull Request, though.\n\nNicolo John Davis\nGoogle Inc.\nSaeid Alidadi\nLee Allen\nVinicius Felizardo\nJoshua Christman\nSelim Ajimi\nRobert Sandu\nRifat Nabi\nSatana Charuwichitratana\nPete Nykänen\nPhilihp Busby\nJason Harrison\nBrendon Roberto\nLuca Vallisa\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Community Guidelines\n\nA safe, respectful, productive and collaborative environment is important for the boardgame.io community. These guidelines apply to all community communications channels (such as the official Gitter group, GitHub issues and pull requests etc.).\n\n1. Be welcoming to all. Help newcomers with questions about the project (even if these are answered elsewhere).\n\n1. Do not make personal attacks or disparaging personal remarks.\n\n1. When interpreting the words and actions of others, assume good faith and intentions.\n\n1. Do not engage in harassing or bullying behavior of any kind.\n\n## What to do if you see a violation of these guidelines\n\nYou may do either or both of the following:\n\n1. Politely message the perpetrator to steer them in the right direction.\n\n1. Contact a moderator privately (or email moderators@boardgame.io) to report bad behavior and request intervention.\n\nModerators will encourage better behavior or issue a warning as appropriate. Further action (like banning a member) may be necessary as a last resort when other measures fail.\n\n## Moderators\n\n- Chris Swithinbank\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# How to Contribute\n\n## Finding things to contribute to\n\nPlease use the [Issue Tracker](https://github.com/boardgameio/boardgame.io/issues) to discuss\npotential improvements you want to make before sending a Pull Request.\nThe [roadmap](roadmap.md) is probably the best place to find areas where help would\nmost be appreciated.\n\nThe Issue Tracker may contain items labelled [**good first issue**][gfi] or [**help wanted**][hw] from time to time.\n\n[hw]: https://github.com/boardgameio/boardgame.io/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22+\n[gfi]: https://github.com/boardgameio/boardgame.io/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22\n\n## Pull Requests\n\n[Pull Requests](https://help.github.com/articles/about-pull-requests/) are used for contributions. Code must be well-tested and not decrease the test coverage significantly.\n\n#### Use a separate branch (not `main`)\n\nPlease commit changes to a separate branch in your fork\nso that we can work together making changes to it before it\nis ready to be merged. Name your branch something like\n`<username>/feature`.\n\nOnce you are ready, you can create a Pull Request for it to be\nmerged into the `main` branch in this repo.\n\n#### Testing\n\nThe following commands must pass for a Pull Request to be considered:\n\n```\n$ npm test\n$ npm run lint\n```\n\nYou can also check the test coverage by running:\n\n```\n$ npm run test:coverage\n```\n\n#### If you make changes to the docs\n\nUse the following command to preview them:\n\n```\n$ npm run docs\n```\n\n## VS Code remote dev container support\n\nFor minimal effort, the repository is configured to run in a remote dev container from VS Code.\n\n- No need to install Node.js or any other project-specific tooling and dependencies\n- No risk of your local machine environment getting in the way\n- Consistent development environment no matter what OS is used\n- Useful extensions preinstalled in the container, independent of your local VS Code settings\n\n### Prerequisites\n\n- [VS Code](https://code.visualstudio.com/) + [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension\n- [git](https://git-scm.com/)\n- [Docker](https://www.docker.com/)\n\n### Getting started\n\n- Launch VS Code\n- Click the Remote Development icon in the bottom left corner of the UI, then \"Clone repository in Container Volume...\"\n- Paste `https://github.com/boardgameio/boardgame.io` or use your own fork, any branch, or a pull request\n- The container will start up and install all required dependencies automatically\n- Terminal output will cease when everything is set up and ready to go\n\n### Running the examples from the VS Code Explorer\n\n- Open \"NPM Scripts\" panel in the sidebar\n- Click on `package.json > start`\n\nIf the NPM scripts panel is not visible in the Explorer sidebar, open the Explorer settings (3 dots) and check \"NPM Scripts\".\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 The boardgame.io Authors.\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": "README.md",
    "content": "<p align=\"center\">\n  <a href=\"https://boardgame.io/\">\n    <img src=\"https://raw.githubusercontent.com/boardgameio/boardgame.io/main/docs/logo-optimized.svg?sanitize=true\" alt=\"boardgame.io\" />\n  </a>\n</p>\n\n<p align=\"center\">\n<a href=\"https://www.npmjs.com/package/boardgame.io\"><img src=\"https://badge.fury.io/js/boardgame.io.svg\" alt=\"npm version\" /></a>\n<a href=\"https://github.com/boardgameio/boardgame.io/actions?query=workflow%3ATests\"> <img src=\"https://github.com/boardgameio/boardgame.io/workflows/Tests/badge.svg\" alt='Build Status'></a>\n<a href='https://coveralls.io/github/boardgameio/boardgame.io?branch=main'><img src='https://coveralls.io/repos/github/boardgameio/boardgame.io/badge.svg?branch=main' alt='Coverage Status' /></a>\n<a href=\"https://gitter.im/boardgame-io\"><img src=\"https://badges.gitter.im/boardgame-io.svg\" alt=\"Gitter\" /></a>\n</p>\n\n<p align=\"center\">\n  <strong><a href=\"https://boardgame.io/documentation/#/\">Read the Documentation</a></strong>\n</p>\n\n<p align=\"center\">\n  <strong>boardgame.io</strong> is an engine for creating turn-based games using JavaScript.\n</p>\n\nWrite simple functions that describe how the game state changes\nwhen a particular move is made. This is automatically converted\ninto a playable game complete with online multiplayer\nfeatures, all without requiring you to write a single line of\nnetworking or storage code.\n\n### Features\n\n- **State Management**: Game state is managed seamlessly across clients, server and storage automatically.\n- **Multiplayer**: Game state is kept in sync in realtime and across platforms.\n- **AI**: Automatically generated bots that can play your game.\n- **Game Phases**: with different game rules and turn orders per phase.\n- **Lobby**: Player matchmaking and game creation.\n- **Prototyping**: Interface to simulate moves even before you render the game.\n- **Extendable**: Plugin system that allows creating new abstractions.\n- **View-layer Agnostic**: Use the vanilla JS client or the bindings for React / React Native.\n- **Logs**: Game logs with the ability to time travel (viewing the board at an earlier state).\n\n## Usage\n\n### Installation\n\n```sh\nnpm install boardgame.io\n```\n\n### Documentation\n\nRead our [Full Documentation](https://boardgame.io/documentation/) to learn how to\nuse boardgame.io, and join the [community on gitter](https://gitter.im/boardgame-io/General)\nto ask your questions!\n\n### Running examples in this repository\n\n```sh\nnpm install\nnpm start\n```\n\nThe examples can be found in the [examples](examples/) folder.\n\n#### Using VS Code?\n\nThis repository is ready to run in a dev container in VS Code. See [the contributing guidelines for details](CONTRIBUTING.md).\n\n## Changelog\n\nSee [changelog](docs/documentation/CHANGELOG.md).\n\n## Get involved\n\nWe welcome contributions of all kinds!\nPlease take a moment to review our [Code of Conduct](CODE_OF_CONDUCT.md).\n\n🐛 **Found a bug?**  \nLet us know by [creating an issue][new-issue].\n\n❓ **Have a question?**  \nOur [Gitter channel][gitter] and [GitHub Discussions][discussions]\nare good places to start.\n\n⚙️ **Interested in fixing a [bug][bugs] or adding a [feature][features]?**  \nCheck out the [contributing guidelines](CONTRIBUTING.md)\nand the [project roadmap](roadmap.md).\n\n📖 **Can we improve [our documentation][docs]?**  \nPull requests even for small changes can be helpful. Each page in the\ndocs can be edited by clicking the “Edit on GitHub” link at the top right.\n\n[new-issue]: https://github.com/boardgameio/boardgame.io/issues/new/choose\n[gitter]: https://gitter.im/boardgame-io/General\n[discussions]: https://github.com/boardgameio/boardgame.io/discussions\n[bugs]: https://github.com/boardgameio/boardgame.io/issues?q=is%3Aissue+is%3Aopen+label%3Abug\n[features]: https://github.com/boardgameio/boardgame.io/issues?q=is%3Aissue+is%3Aopen+label%3Afeature\n[docs]: https://boardgame.io/documentation/\n[sponsors]: https://github.com/sponsors/boardgameio\n[collective]: https://opencollective.com/boardgameio#support\n\n## License\n\n[MIT](LICENSE)\n"
  },
  {
    "path": "babel.config.js",
    "content": "module.exports = {\n  presets: [\n    [\n      '@babel/preset-env',\n      {\n        modules: false,\n        exclude: ['transform-regenerator', 'transform-async-to-generator'],\n      },\n    ],\n    '@babel/preset-react',\n    '@babel/typescript',\n  ],\n  env: {\n    test: {\n      plugins: ['@babel/plugin-transform-modules-commonjs'],\n    },\n  },\n  plugins: [\n    [\n      'module-resolver',\n      {\n        alias: {\n          'boardgame.io': './packages',\n        },\n      },\n    ],\n    '@babel/plugin-proposal-class-properties',\n    '@babel/proposal-object-rest-spread',\n  ],\n};\n"
  },
  {
    "path": "benchmark/index.js",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Benchmark from 'benchmark';\nimport { Client } from '../dist/esm/client';\nimport { InitializeGame } from '../src/core/initialize';\nimport { CreateGameReducer } from '../src/core/reducer';\nimport { makeMove, gameEvent } from '../src/core/action-creators';\n\nconst game = {\n  moves: {\n    A: ({ G }) => G,\n  },\n  endIf: () => false,\n};\n\nconst reducer = CreateGameReducer({ game });\nconst state = InitializeGame({ game });\nconst client = Client({ game });\n\nnew Benchmark.Suite()\n  .add('reducer::makeMove', function () {\n    reducer(state, makeMove('A'));\n  })\n  .add('reducer::endTurn', function () {\n    reducer(state, gameEvent('endTurn'));\n  })\n  .add('client::move', function () {\n    client.moves.A();\n  })\n  .add('client::endTurn', function () {\n    client.events.endTurn();\n  })\n  .on('cycle', function (event) {\n    console.log(String(event.target));\n  })\n  .on('complete', function () {\n    console.log('Fastest is ' + this.filter('fastest').map('name'));\n  })\n  .run({ async: true });\n"
  },
  {
    "path": "docs/CNAME",
    "content": "boardgame.io"
  },
  {
    "path": "docs/documentation/.nojekyll",
    "content": ""
  },
  {
    "path": "docs/documentation/CHANGELOG.md",
    "content": "### v0.50.2\n\nThis release includes dependency upgrades only.\n\n### v0.50.1\n\nThis release fixes compatibility with React v18. Thanks [@mbrinkl](https://github.com/mbrinkl)!\n\n#### Bugfixes\n\n* [[2afffb13](https://github.com/boardgameio/boardgame.io/commit/2afffb13)] Fix React 18 compatibility ([#1104](https://github.com/boardgameio/boardgame.io/pull/1104))\n* [[74722165](https://github.com/boardgameio/boardgame.io/commit/74722165)] Use correct CSS margin syntax in debug panel\n\n\n## v0.50.0\n\nThis release includes a large refactor in boardgame.io API. Callbacks that used to be `(G, ctx) => {}` now becomes `({ G, ctx }) => {}` ... Thanks [@delucis](https://github.com/delucis) for the great contribution!\n\n### Features\n\n* [[da1ccb1](https://github.com/boardgameio/boardgame.io/commit/da1ccb18819fa265144da075a445e003d8a2fcc8)] feat: Change move and hook signature ([#891](https://github.com/boardgameio/boardgame.io/pull/891))\n\n### v0.49.13\n\n### Features\n\n* [[aa99a9c](https://github.com/boardgameio/boardgame.io/commit/aa99a9cce28012cb747fa6db8b3f8ad73c28be0a)] feat: Conditional log redacting in long form move ([#1089](https://github.com/boardgameio/boardgame.io/pull/1089))\n* [[4bf203c](https://github.com/boardgameio/boardgame.io/commit/4bf203c1c1ec42e3193935a39e4cfb54a5658627)] TypeScript: AiEnumerate return type ([#1080](https://github.com/boardgameio/boardgame.io/pull/1080))\n\n### v0.49.12\n\n#### Bugfixes\n\n* [[96b26bb9](https://github.com/boardgameio/boardgame.io/commit/96b26bb9)] lobby: block creation of matches with invalid player counts ([#1060](https://github.com/boardgameio/boardgame.io/pull/1060))\n* [[453f530c](https://github.com/boardgameio/boardgame.io/commit/453f530c)] types: Use correct socket.io options typing\n* [[3692199](https://github.com/boardgameio/boardgame.io/commit/3692199), [1e57a9c](https://github.com/boardgameio/boardgame.io/commit/1e57a9c)] Update dependencies: socket.io and koa-body\n\n\n### v0.49.11\n\n#### Bugfixes\n\n* [[453f530c](https://github.com/boardgameio/boardgame.io/commit/453f530c)] types: Use correct socket.io options typing\n* [[7e55d118](https://github.com/boardgameio/boardgame.io/commit/7e55d118), [75428111](https://github.com/boardgameio/boardgame.io/commit/75428111), [4fa2c4f1](https://github.com/boardgameio/boardgame.io/commit/4fa2c4f1), [52450607](https://github.com/boardgameio/boardgame.io/commit/52450607)] Update dependencies: engine.io, nanoid, ajv, and node-fetch\n\n\n### v0.49.10\n\n#### Bugfixes\n\n* [[6756419a](https://github.com/boardgameio/boardgame.io/commit/6756419a)] Include `testing/package.json` in npm files\n\n\n### v0.49.9\n\n#### Features\n\n* [[636ce8f6](https://github.com/boardgameio/boardgame.io/commit/636ce8f6)] Add testing utility for mocking the randomness API\n\n#### Bugfixes\n\n* [[99639c41](https://github.com/boardgameio/boardgame.io/commit/99639c41)] lobby: only poll matches when match list is displayed ([#1044](https://github.com/boardgameio/boardgame.io/pull/1044))\n\n\n### v0.49.8\n\n#### Features\n\n* [[bd34bc39](https://github.com/boardgameio/boardgame.io/commit/bd34bc39)] debug: Add collapse on load & hide toggle button options (PR [#1040](https://github.com/boardgameio/boardgame.io/pull/1040), Issue [#1039](https://github.com/boardgameio/boardgame.io/issues/1039))\n\n#### Bugfixes\n\n* [[ee230c14](https://github.com/boardgameio/boardgame.io/commit/ee230c14)] types: Always allow player ID array as active players argument (Issue [#1041](https://github.com/boardgameio/boardgame.io/issues/1041))\n\n\n### v0.49.7\n\n#### Bugfixes\n\n* [[39e1f187](https://github.com/boardgameio/boardgame.io/commit/39e1f187)] Bump `rfc6902` dependency to address prototype pollution vulnerability\n\n\n### v0.49.6\n\n#### Bugfixes\n\n* [[cf6ade54](https://github.com/boardgameio/boardgame.io/commit/cf6ade54)] Add `ctx` type parameter to client ([#1035](https://github.com/boardgameio/boardgame.io/pull/1035))\n\n\n### v0.49.5\n\n#### Bugfixes\n\n* [[279a822f](https://github.com/boardgameio/boardgame.io/commit/279a822f)] flow: Pass correct `ctx` to `onMove` hooks\n\n\n### v0.49.4\n\n#### Features\n\n* [[94472c0a](https://github.com/boardgameio/boardgame.io/commit/94472c0a)] react-native: handle multiplayer loading state in client ([#1026](https://github.com/boardgameio/boardgame.io/pull/1026))\n\n#### Bugfixes\n\n* [[43019562](https://github.com/boardgameio/boardgame.io/commit/43019562)] Update gameover metadata when `null` ([#1025](https://github.com/boardgameio/boardgame.io/pull/1025))\n\n\n### v0.49.3\n\n#### Bugfixes\n\n* [[220823bb](https://github.com/boardgameio/boardgame.io/commit/220823bb)] Update gameover metadata when `undefined` ([#1023](https://github.com/boardgameio/boardgame.io/pull/1023))\n* [[df6b7c40](https://github.com/boardgameio/boardgame.io/commit/df6b7c40)] include `chatMessages` property in React client types ([#1022](https://github.com/boardgameio/boardgame.io/pull/1022))\n\n\n### v0.49.2\n\n#### Features\n\n* [[ff4c7564](https://github.com/boardgameio/boardgame.io/commit/ff4c7564)] core: Expose `ctx.playerID` in `onMove` hook ([#1019](https://github.com/boardgameio/boardgame.io/pull/1019))\n\n#### Bugfixes\n\n* [[fa7544f5](https://github.com/boardgameio/boardgame.io/commit/fa7544f5)] api: Update query string types and handle array queries\n* [[4813fa15](https://github.com/boardgameio/boardgame.io/commit/4813fa15), [0f6076b5](https://github.com/boardgameio/boardgame.io/commit/0f6076b5), [06b4172d](https://github.com/boardgameio/boardgame.io/commit/06b4172d), [54c0b4c0](https://github.com/boardgameio/boardgame.io/commit/54c0b4c0)] Update dependencies\n\n### v0.49.1\n\n#### Features\n\n* [[7b151798](https://github.com/boardgameio/boardgame.io/commit/7b151798)] Expose `getFilterPlayerView` from `internal` package\n\n#### Bugfixes\n\n* [[20817aa3](https://github.com/boardgameio/boardgame.io/commit/20817aa3)] transport: More accurately type `TransportOpts`\n\n\n## v0.49.0\n\n#### Features\n\n* [[604d12e6](https://github.com/boardgameio/boardgame.io/commit/604d12e6)] lobby: use first available `playerID` when joining a match ([#1013](https://github.com/boardgameio/boardgame.io/pull/1013))\n* [[510a082a](https://github.com/boardgameio/boardgame.io/commit/510a082a)] transport: Consolidate transport interface ([#1002](https://github.com/boardgameio/boardgame.io/pull/1002))\n* [[d30d5776](https://github.com/boardgameio/boardgame.io/commit/d30d5776)] Expose `createMatch` utility\n\n#### Bugfixes\n\n* [[ca94f3a5](https://github.com/boardgameio/boardgame.io/commit/ca94f3a5)] lobby: Prevent error accessing fetch response twice ([#1005](https://github.com/boardgameio/boardgame.io/pull/1005))\n\n\n## v0.48.0\n\n#### Features\n\n* [[4165d45d](https://github.com/boardgameio/boardgame.io/commit/4165d45d)] Deprecate `moveLimit` in favour of `minMoves`/`maxMoves` ([#985](https://github.com/boardgameio/boardgame.io/pull/985))\n\n    Migration:\n    \n    - Replace `turn.moveLimit` with both `turn.minMoves` and `turn.maxMoves`.\n    - Replace `moveLimit` in `setStage` and `setActivePlayers` with `maxMoves`.\n\n### v0.47.10\n\n#### Bugfixes\n\n* [[ad78eded](https://github.com/boardgameio/boardgame.io/commit/ad78eded)] ai: Run AI iterations using `setImmediate` for improved performance ([#999](https://github.com/boardgameio/boardgame.io/pull/999))\n* [[feb08a12](https://github.com/boardgameio/boardgame.io/commit/feb08a12)] lobby: Clean up & update refresh polling interval properly ([#996](https://github.com/boardgameio/boardgame.io/pull/996))\n\n\n### v0.47.9\n\n#### Bugfixes\n\n* [[a240bbee](https://github.com/boardgameio/boardgame.io/commit/a240bbee)] client: Fix React Native support\n* [[8b871ab5](https://github.com/boardgameio/boardgame.io/commit/8b871ab5)] server: Support custom Lobby API middleware ([#992](https://github.com/boardgameio/boardgame.io/pull/992))\n\n\n### v0.47.8\n\n#### Bugfixes\n\n* [[06bc7479](https://github.com/boardgameio/boardgame.io/commit/06bc7479)] debug: Improve AI panel accessibility\n* [[d2b611d7](https://github.com/boardgameio/boardgame.io/commit/d2b611d7)] debug: Stop panel intercepting clicks in transparent parts\n\n\n### v0.47.7\n\n#### Features\n\n* [[98c860ec](https://github.com/boardgameio/boardgame.io/commit/98c860ec)] debug: Support toggling debug panel visibility without a keyboard ([#991](https://github.com/boardgameio/boardgame.io/pull/991))\n\n#### Bugfixes\n\n* [[f18c63a1](https://github.com/boardgameio/boardgame.io/commit/f18c63a1)] types: playerID in `playerView` can be string or null ([#990](https://github.com/boardgameio/boardgame.io/pull/990))\n\n\n### v0.47.6\n\n#### Bugfixes\n\n* [[62f97e54](https://github.com/boardgameio/boardgame.io/commit/62f97e54)] Allow plugins to use events in `fnWrap`\n\n\n### v0.47.5\n\n#### Bugfixes\n\n* [[fa30fcca](https://github.com/boardgameio/boardgame.io/commit/fa30fcca)] types: Expect `Game.setup` method to return `G` ([#987](https://github.com/boardgameio/boardgame.io/pull/987))\n\n\n### v0.47.4\n\n#### Bugfixes\n\n* [[d54af1f4](https://github.com/boardgameio/boardgame.io/commit/d54af1f4)] events: Don’t use const enum for better backwards compatibility\n\n\n### v0.47.3\n\n* Dependency changes only\n\n### v0.47.2\n\n#### Features\n\n* [[8267e36c](https://github.com/boardgameio/boardgame.io/commit/8267e36c)] events: Add stack traces to events plugin errors\n\n### v0.47.1\n\n#### Features\n\n* [[f97a08d8](https://github.com/boardgameio/boardgame.io/commit/f97a08d8)] Improve events errors & expose method types to plugin `fnWrap` ([#980](https://github.com/boardgameio/boardgame.io/pull/980))  \n  - See [the Events guide](events#calling-events-from-hooks) for details of event support in game hooks\n* [[95be8b90](https://github.com/boardgameio/boardgame.io/commit/95be8b90)] events: Accurately type events API arguments\n\n## v0.47.0\n\n#### Features\n\n* [[b6a4fed](https://github.com/boardgameio/boardgame.io/commit/b6a4fed)] Adds pub-sub support for horizontally scaling bgio server ([#978](https://github.com/boardgameio/boardgame.io/pull/978))\n\n#### Bugfixes\n\n* [[241701f](https://github.com/boardgameio/boardgame.io/commit/241701f)] master: Don’t crash on missing `chatMessage` ([#977](https://github.com/boardgameio/boardgame.io/pull/977))\n\n### v0.46.2\n\n#### Features\n\n* [[064b7507](https://github.com/boardgameio/boardgame.io/commit/064b7507)] Support setting next phase with a function ([#972](https://github.com/boardgameio/boardgame.io/pull/972))\n\n#### Bugfixes\n\n* [[bff1d294](https://github.com/boardgameio/boardgame.io/commit/bff1d294)] flow: Run `turn.endIf` after `setActivePlayers` event\n\n### v0.46.1\n\n#### Bugfixes\n\n* [[f0bc8b9](https://github.com/boardgameio/boardgame.io/commit/f0bc8b9)] flow: Run `turn.endIf` hook after updating stages\n\n## v0.46.0\n\n#### Features\n\n* [[91cf25e](https://github.com/boardgameio/boardgame.io/commit/91cf25e)] Events Plugin: Don’t leak stage events across turns & allow self-ending turns/phases ([#957](https://github.com/boardgameio/boardgame.io/pull/957))\n* [[afee0b7](https://github.com/boardgameio/boardgame.io/commit/afee0b7), [1e435c2](https://github.com/boardgameio/boardgame.io/commit/1e435c2), [1078b13](https://github.com/boardgameio/boardgame.io/commit/1078b13)] Allow plugins to declare an action invalid ([#963](https://github.com/boardgameio/boardgame.io/pull/963), [#970](https://github.com/boardgameio/boardgame.io/pull/970))\n* [[262d867](https://github.com/boardgameio/boardgame.io/commit/262d867)] Server: Decouple player view calculation from Master ([#966](https://github.com/boardgameio/boardgame.io/pull/966))\n\n#### Bugfixes\n\n* [[dcaca7f](https://github.com/boardgameio/boardgame.io/commit/dcaca7f)] types: Remove `turn.moves` from `Game` type\n* [[b753094](https://github.com/boardgameio/boardgame.io/commit/b753094), [2aa9db5](https://github.com/boardgameio/boardgame.io/commit/2aa9db5)] Update dependencies ([#965](https://github.com/boardgameio/boardgame.io/pull/965), [#968](https://github.com/boardgameio/boardgame.io/pull/968))\n\n#### Other\n\n* [[be63602](https://github.com/boardgameio/boardgame.io/commit/be63602)] Update development dependencies ([#969](https://github.com/boardgameio/boardgame.io/pull/969))\n* [[4efec1a](https://github.com/boardgameio/boardgame.io/commit/4efec1a)] Update linter tooling & refactor errors ([#967](https://github.com/boardgameio/boardgame.io/pull/967))\n\n### v0.45.2\n\n#### Bugfixes\n\n* [[9753c0e](https://github.com/boardgameio/boardgame.io/commit/9753c0e)] fix: Don’t leak `STRIP_TRANSIENTS` action ([#961](https://github.com/boardgameio/boardgame.io/pull/961))\n\n### v0.45.1\n\n#### Breaking Changes\n\nPlease see notes for v0.45.0. This release extends CORS security restrictions to the Lobby API (0.45.0 only applied the `origins` config to the socket.io server).\n\n#### Features\n\n* [[8b950a0](https://github.com/boardgameio/boardgame.io/commit/8b950a0)] server: Use `origins` option to configure Lobby API CORS ([#955](https://github.com/boardgameio/boardgame.io/pull/955))\n\n#### Bugfixes\n\n* [[2b1d013](https://github.com/boardgameio/boardgame.io/commit/2b1d013)] server: Update to latest `@types/cors` to provide better origins configuration defaults\n\n## v0.45.0\n\n#### Breaking Changes\n\nPreviously boardgame.io servers allowed CORS requests from all origins by default. After updating socket.io in 0.45.0, an `origins` option must now be provided when creating the server to enable cross-origin requests:\n\n```js\nconst { Server } = require('boardgame.io/server');\n\nServer({\n  origins: ['https://www.mygame.com'],\n  // ...\n});\n```\n\nSee [the Server reference page](https://boardgame.io/documentation/#/api/Server) for more details.\n\n#### Features\n\n* [[dffcb18](https://github.com/boardgameio/boardgame.io/commit/dffcb18)] chore(deps): Upgrade socket.io packages ([#946](https://github.com/boardgameio/boardgame.io/pull/946))\n\n### v0.44.4\n\n#### Features\n\n* [[2eca252](https://github.com/boardgameio/boardgame.io/commit/2eca252)] Improve error handling (work in progress) (PR [#940](https://github.com/boardgameio/boardgame.io/pull/940), Issue [#723](https://github.com/boardgameio/boardgame.io/issues/723))\n* [[cceb0f2](https://github.com/boardgameio/boardgame.io/commit/cceb0f2)] package: Add funding field\n\n#### Bugfixes\n\n* [[49c2c12](https://github.com/boardgameio/boardgame.io/commit/49c2c12)] reducer: Don’t crash when undoing stage events ([#942](https://github.com/boardgameio/boardgame.io/pull/942))\n\n### v0.44.3\n\n#### Bugfixes\n\n* [[f1c60ee](https://github.com/boardgameio/boardgame.io/commit/f1c60ee), [3718124](https://github.com/boardgameio/boardgame.io/commit/3718124), [2685470](https://github.com/boardgameio/boardgame.io/commit/2685470), [ac78e82](https://github.com/boardgameio/boardgame.io/commit/ac78e82), [5b0de40](https://github.com/boardgameio/boardgame.io/commit/5b0de40)] Dependency updates\n\n### v0.44.2\n\n#### Bugfixes\n\n* [[b832b07](https://github.com/boardgameio/boardgame.io/commit/b832b07)] Make custom plugins available in event hooks ([#932](https://github.com/boardgameio/boardgame.io/pull/932))\n\n### v0.44.1\n\n#### Bugfixes\n\n* [[1d20e7e](https://github.com/boardgameio/boardgame.io/commit/1d20e7e)] client: Correct signature type for `sendChatMessage`\n* [[a7c8776](https://github.com/boardgameio/boardgame.io/commit/a7c8776)] debug panel: Handle all possible argument types in the log pane\n\n## v0.44.0\n\n#### Features\n\n* [[abc516b](https://github.com/boardgameio/boardgame.io/commit/abc516b)] Add an option to use JSON patches for state updates ([#920](https://github.com/boardgameio/boardgame.io/pull/920))\n* [[0bab885](https://github.com/boardgameio/boardgame.io/commit/0bab885)] Support spying on logs after framework is loaded ([#918](https://github.com/boardgameio/boardgame.io/pull/918))\n* [[a57fe19](https://github.com/boardgameio/boardgame.io/commit/a57fe19)] Export additional game API types ([#927](https://github.com/boardgameio/boardgame.io/pull/927))\n\n#### Bugfixes\n\n* [[e94d476](https://github.com/boardgameio/boardgame.io/commit/e94d476)] Improve TypeScript typings for the player plugin and React client ([#922](https://github.com/boardgameio/boardgame.io/pull/922))\n\n### v0.43.3\n\n#### Features\n\n* [[01c522c](https://github.com/boardgameio/boardgame.io/commit/01c522c)] Throw error in development if non-serializable state is used in a move ([#896](https://github.com/boardgameio/boardgame.io/pull/896))\n* [[ccc9ada](https://github.com/boardgameio/boardgame.io/commit/ccc9ada)] Add details to exceptions raised in LobbyClient ([#898](https://github.com/boardgameio/boardgame.io/pull/898))\n\n#### Bugfixes\n\n* [[ae790e8](https://github.com/boardgameio/boardgame.io/commit/ae790e8)] dependencies: bump immer from 7.0.8 to 8.0.1 ([#895](https://github.com/boardgameio/boardgame.io/pull/895))\n* [[6f9bc27](https://github.com/boardgameio/boardgame.io/commit/6f9bc27)] dependencies: Run `npm audit fix`\n\n### v0.43.2\n\n#### Bugfixes\n\n* [[3d614b8](https://github.com/boardgameio/boardgame.io/commit/3d614b8)] server: Improve security of socket.io transport layer ([#894](https://github.com/boardgameio/boardgame.io/pull/894))\n* [[dc96b26](https://github.com/boardgameio/boardgame.io/commit/dc96b26)] master: Disallow `onSync` match creation if game requires `setupData` ([#890](https://github.com/boardgameio/boardgame.io/pull/890))\n\n### v0.43.1\n\n#### Bugfixes\n\n* [[b14ea29](https://github.com/boardgameio/boardgame.io/commit/b14ea29)] client: Always include `chatMessages` and `sendChatMessage` on client instances\n\n## v0.43.0\n\n#### Features\n\n* [[0ad1d6d](https://github.com/boardgameio/boardgame.io/commit/0ad1d6d)] [[c178a41](https://github.com/boardgameio/boardgame.io/commit/c178a41)] Add in-game chat support ([#871](https://github.com/boardgameio/boardgame.io/pull/871), [#879](https://github.com/boardgameio/boardgame.io/pull/879))\n* [[3918cc9](https://github.com/boardgameio/boardgame.io/commit/3918cc9)] Add plugin to allow adding custom metadata to logs ([#865](https://github.com/boardgameio/boardgame.io/pull/865))\n* [[243388d](https://github.com/boardgameio/boardgame.io/commit/243388d)] Centralise lobby API and master authentication logic ([#853](https://github.com/boardgameio/boardgame.io/pull/853))\n\n#### Bugfixes\n\n* [[e515573](https://github.com/boardgameio/boardgame.io/commit/e515573)] Handle random plugin redacted state on multiplayer clients ([#885](https://github.com/boardgameio/boardgame.io/pull/885))\n* [[3b8ac79](https://github.com/boardgameio/boardgame.io/commit/3b8ac79)] Prevent `TypeError: state.deltalog is not iterable` ([#888](https://github.com/boardgameio/boardgame.io/pull/888))\n* [[2cc6104](https://github.com/boardgameio/boardgame.io/commit/2cc6104)] Support latest Safari & Firefox when running examples\n\n### v0.42.2\n\n#### Features\n\n* [[8f8d30e](https://github.com/boardgameio/boardgame.io/commit/8f8d30e)] plugins: Add `playerView` option to plugin API (closes [#671](https://github.com/boardgameio/boardgame.io/issues/671)) ([#857](https://github.com/boardgameio/boardgame.io/pull/857))\n\n#### Bugfixes\n\n* [[c51bc09](https://github.com/boardgameio/boardgame.io/commit/c51bc09)] debug: prevent `endStage` event crashing debug log panel ([#856](https://github.com/boardgameio/boardgame.io/pull/856))\n\n### v0.42.1\n\n#### Features\n\n* [[6c4e94f](https://github.com/boardgameio/boardgame.io/commit/6c4e94f)] Add option to long-form move to ignore stale `stateID` (closes [#828](https://github.com/boardgameio/boardgame.io/issues/828)) ([#832](https://github.com/boardgameio/boardgame.io/pull/832))\n\n#### Bugfixes\n\n* [[5207be5](https://github.com/boardgameio/boardgame.io/commit/5207be5)] core: `setStage(Stage.NULL)` makes player active (closes [#848](https://github.com/boardgameio/boardgame.io/issues/848)) ([#849](https://github.com/boardgameio/boardgame.io/pull/849))\n\n## v0.42.0\n\n#### Features\n\n* [[6ba5536](https://github.com/boardgameio/boardgame.io/commit/6ba5536)] Add localStorage support to Local master ([#691](https://github.com/boardgameio/boardgame.io/pull/691))\n* [[257a735](https://github.com/boardgameio/boardgame.io/commit/257a735)] Track players connection status ([#839](https://github.com/boardgameio/boardgame.io/pull/839))\n* [[d071e98](https://github.com/boardgameio/boardgame.io/commit/d071e98)] Add game method to validate setup data ([#831](https://github.com/boardgameio/boardgame.io/pull/831))\n\n#### Bugfixes\n\n* [[ace1144](https://github.com/boardgameio/boardgame.io/commit/ace1144)] local: Use shared local master with bots ([#838](https://github.com/boardgameio/boardgame.io/pull/838))\n* [[9fcbed7](https://github.com/boardgameio/boardgame.io/commit/9fcbed7)] client: Correctly type state returned by client to subscribers\n\n### v0.41.1\n\nPush another release to fix NPM weirdness.\n\n## v0.41.0\n\n#### Features\n\n* [[c8c648e](https://github.com/boardgameio/boardgame.io/commit/c8c648e)] Add global manager to track client & debug panel instances ([#816](https://github.com/boardgameio/boardgame.io/pull/816))\n* [[af43561](https://github.com/boardgameio/boardgame.io/commit/af43561)] Add log entries for undo/redo actions ([#825](https://github.com/boardgameio/boardgame.io/pull/825))\n* [[2595399](https://github.com/boardgameio/boardgame.io/commit/2595399)] Improve undo/redo ([#823](https://github.com/boardgameio/boardgame.io/pull/823))\n* [[3d2131e](https://github.com/boardgameio/boardgame.io/commit/3d2131e)] master: Use `createMatch` for implicit match creation ([#821](https://github.com/boardgameio/boardgame.io/pull/821))\n* [[f74f953](https://github.com/boardgameio/boardgame.io/commit/f74f953)] Improve match term consistency ([#806](https://github.com/boardgameio/boardgame.io/pull/806))\n\n#### Bugfixes\n\n* [[f5d3a97](https://github.com/boardgameio/boardgame.io/commit/f5d3a97)] debug: Improve debug panel accessibility ([#827](https://github.com/boardgameio/boardgame.io/pull/827))\n* [[0040a5d](https://github.com/boardgameio/boardgame.io/commit/0040a5d)] reducer: Restore plugin state on undo/redo\n* [[4f2ffc4](https://github.com/boardgameio/boardgame.io/commit/4f2ffc4)] debug: Include plugin data in log rewind gamestate override\n* [[197a9bb](https://github.com/boardgameio/boardgame.io/commit/197a9bb)] reducer: Fix stateID increment & build deltalog on server only ([#817](https://github.com/boardgameio/boardgame.io/pull/817))\n* [[600caa8](https://github.com/boardgameio/boardgame.io/commit/600caa8)] debug: Use local reducer in Log rewind\n* [[3c2aadd](https://github.com/boardgameio/boardgame.io/commit/3c2aadd)] client: Don’t run playerView locally on multiplayer clients ([#819](https://github.com/boardgameio/boardgame.io/pull/819))\n* [[abd9695](https://github.com/boardgameio/boardgame.io/commit/abd9695)] fix: Simplify local transport typing\n* [[9a2a609](https://github.com/boardgameio/boardgame.io/commit/9a2a609)] fix: improve socketio.ts typings ([#811](https://github.com/boardgameio/boardgame.io/pull/811))\n* [[0f8882a](https://github.com/boardgameio/boardgame.io/commit/0f8882a)] core: Fix EndPhase deltalog ([#812](https://github.com/boardgameio/boardgame.io/pull/812))\n* [[4bd283c](https://github.com/boardgameio/boardgame.io/commit/4bd283c)] fix: FlatFile.listGames filter ([#802](https://github.com/boardgameio/boardgame.io/pull/802))\n* [[0062e55](https://github.com/boardgameio/boardgame.io/commit/0062e55)] client: Improve client types ([#801](https://github.com/boardgameio/boardgame.io/pull/801))\n\n## v0.40.0\n\n#### Breaking Changes\n\nSee [PR #709 on GitHub](https://github.com/boardgameio/boardgame.io/pull/709) for a full list and migration guide.\n\n#### Features\n\n* [[43c7fbb](https://github.com/boardgameio/boardgame.io/commit/43c7fbb)] Add plain JS lobby client ([#728](https://github.com/boardgameio/boardgame.io/pull/728))\n* [[adb251d](https://github.com/boardgameio/boardgame.io/commit/adb251d)] [[6fcf695](https://github.com/boardgameio/boardgame.io/commit/6fcf695)] Use “match” instead of “game”/“room” in Lobby API ([#704](https://github.com/boardgameio/boardgame.io/pull/704), [#765](https://github.com/boardgameio/boardgame.io/pull/765))\n* [[88b0ee7](https://github.com/boardgameio/boardgame.io/commit/88b0ee7)] debug: Display live object view in debug panel ([#781](https://github.com/boardgameio/boardgame.io/pull/781), [#790](https://github.com/boardgameio/boardgame.io/pull/790))\n* [[3984ee7](https://github.com/boardgameio/boardgame.io/commit/3984ee7)] debug: Events shortcuts, stages support & minor fixes ([#791](https://github.com/boardgameio/boardgame.io/pull/791))\n* [[3c8777b](https://github.com/boardgameio/boardgame.io/commit/3c8777b)] server: Timestamp metadata and match filtering in the Lobby API ([#740](https://github.com/boardgameio/boardgame.io/pull/740))\n* [[a0c34fd](https://github.com/boardgameio/boardgame.io/commit/a0c34fd)] server: Expose API router ([#698](https://github.com/boardgameio/boardgame.io/pull/698))\n\n#### Bugfixes\n\n* [[2586022](https://github.com/boardgameio/boardgame.io/commit/2586022)] debug: Keep debug panel above other page elements ([#780](https://github.com/boardgameio/boardgame.io/pull/780))\n* [[f32dc76](https://github.com/boardgameio/boardgame.io/commit/f32dc76)] api: Expose gameover metadata in lobby endpoints ([#666](https://github.com/boardgameio/boardgame.io/pull/666))\n* [[fa865da](https://github.com/boardgameio/boardgame.io/commit/fa865da)] fixes build in rushjs monorepo context ([#550](https://github.com/boardgameio/boardgame.io/pull/550))\n\n### v0.39.16\n\n#### Bugfixes\n\n* [[84e93b4](https://github.com/boardgameio/boardgame.io/commit/84e93b4)] build: Exclude svelte from Rollup’s external module list (#767)\n* [[72ed591](https://github.com/boardgameio/boardgame.io/commit/72ed591)] fix: Tidy up type provision (#764)\n\n### v0.39.15\n\n#### Bugfixes\n\n* [[271aecd](https://github.com/boardgameio/boardgame.io/commit/271aecd)] fix: Fix client types & move BoardProps to React package (#752)\n\n### v0.39.14\n\n#### Features\n\n* [[c115087](https://github.com/boardgameio/boardgame.io/commit/c115087)] game: add disableUndo flag to game config (#742)\n\n#### Bugfixes\n\n* [[a6698e6](https://github.com/boardgameio/boardgame.io/commit/a6698e6)] debug: Fix save & restore in Debug panel (#746)\n\n### v0.39.13\n\n#### Features\n\n* [[2b1bd19](https://github.com/boardgameio/boardgame.io/commit/2b1bd19)] ai: Convert to Typescript (#734)\n* [[872b58b](https://github.com/boardgameio/boardgame.io/commit/872b58b)] client: Make argument optional in Local transport (#731)\n\n#### Bugfixes\n\n* [[0088cb5](https://github.com/boardgameio/boardgame.io/commit/0088cb5)] fix: Re-sync client on reconnect, fixes #713 (#727)\n\n### v0.39.12\n\n#### Features\n\n* [[0ca1cef](https://github.com/boardgameio/boardgame.io/commit/0ca1cef)] lobby: use previous game config as defaults in playAgain (#719)\n* [[60b32e5](https://github.com/boardgameio/boardgame.io/commit/60b32e5)] Add support for socket.io-adapter implementations (#706)\n* [[eb236df](https://github.com/boardgameio/boardgame.io/commit/eb236df)] db: FlatFile per-file request queues enhancement (#705)\n\n#### Bugfixes\n\n* [[ef97441](https://github.com/boardgameio/boardgame.io/commit/ef97441)] debug: Save all state to localStorage, not just G and ctx (#716)\n* [[4d45ff1](https://github.com/boardgameio/boardgame.io/commit/4d45ff1)] client: Fix restore in debug controls (#712)\n* [[d728425](https://github.com/boardgameio/boardgame.io/commit/d728425)] core: Fix undo/redo if the move changed the stage (#701)\n* [[3a622f1](https://github.com/boardgameio/boardgame.io/commit/3a622f1)] Use Promise chaining to enforce read/write queue (#699)\n\n### v0.39.11\n\n#### Features\n\n* [[cfeaf67](https://github.com/boardgameio/boardgame.io/commit/cfeaf67)] plugins: Let moves return INVALID_MOVE after mutating G (#688)\n* [[b2d6b06](https://github.com/boardgameio/boardgame.io/commit/b2d6b06)] server: Lobby API improvements (#675)\n* [[dc668ec](https://github.com/boardgameio/boardgame.io/commit/dc668ec)] server: Expose SocketIO transport & convert to TS (#658)\n\n#### Bugfixes\n\n* [[1483a08](https://github.com/boardgameio/boardgame.io/commit/1483a08)] fix UX issues in move debugger (#640)\n* [[814621b](https://github.com/boardgameio/boardgame.io/commit/814621b)] Make package.json scripts work on Windows (#657)\n\n### v0.39.10\n\n#### Features\n\n* [[cf96955](https://github.com/boardgameio/boardgame.io/commit/cf96955)] Add option to exclude games from public listing (#653)\n* [[2e5b902](https://github.com/boardgameio/boardgame.io/commit/2e5b902)] core: Support moves that don’t contribute to numMoves (#646)\n* [[e4fc7bd](https://github.com/boardgameio/boardgame.io/commit/e4fc7bd)] master: Update metadata with gameover value on game end (#645)\n* [[05eacb8](https://github.com/boardgameio/boardgame.io/commit/05eacb8)] Enable adding additional metadata to players in Lobby (#642)\n\n#### Bugfixes\n\n* [[d2f668b](https://github.com/boardgameio/boardgame.io/commit/d2f668b)] Fix plugins in hooks triggered by moves (#656)\n* [[334f8d6](https://github.com/boardgameio/boardgame.io/commit/334f8d6)] [Documentation] Remove references to removed MongoDB adapter (#659)\n* [[a4c4c7c](https://github.com/boardgameio/boardgame.io/commit/a4c4c7c)] Test warning is logged when using deprecated `/rename` API endpoint. (#655)\n* [[6aff09c](https://github.com/boardgameio/boardgame.io/commit/6aff09c)] Add playAgain endpoint to Lobby documentation (#652)\n* [[9f4acfe](https://github.com/boardgameio/boardgame.io/commit/9f4acfe)] Add link to Azure Storage database connector (#651)\n* [[78113aa](https://github.com/boardgameio/boardgame.io/commit/78113aa)] Add mosaic to notable_projects.md (#649)\n* [[c51b277](https://github.com/boardgameio/boardgame.io/commit/c51b277)] expose log as a prop in the React client (#641)\n\n### v0.39.9\n\n#### Bugfixes\n\n* [[b4bd8b7](https://github.com/boardgameio/boardgame.io/commit/b4bd8b7)] package: update npm files field for new server bundle (#639)\n* [[0552efb](https://github.com/boardgameio/boardgame.io/commit/0552efb)] add src/ to NPM\n\n### v0.39.8\n\n#### Bugfixes\n\n* [[3569408](https://github.com/boardgameio/boardgame.io/commit/3569408)] Add option to run server over HTTPS (#631)\n* [[c56d9b9](https://github.com/boardgameio/boardgame.io/commit/c56d9b9)] Adding playerID to Ctx (#627)\n* [[882a25d](https://github.com/boardgameio/boardgame.io/commit/882a25d)] export only the client in the browser-minified package\n* [[3d1c07c](https://github.com/boardgameio/boardgame.io/commit/3d1c07c)] server: Proxy server module with package.json (#622)\n* [[bd44678](https://github.com/boardgameio/boardgame.io/commit/bd44678)] Fix passing params to db adapter (#621)\n\n### v0.39.7\n\n#### Bugfixes\n\n* [[44d0d4f](https://github.com/boardgameio/boardgame.io/commit/44d0d4f)] fix bad merge that undid https://github.com/boardgameio/boardgame.io/pull/614\n\n### v0.39.6\n\n#### Features\n\n* [[c5211c2](https://github.com/boardgameio/boardgame.io/commit/c5211c2)] Typescript enhancements (#612)\n\n#### Bugfixes\n\n* [[eb1e060](https://github.com/boardgameio/boardgame.io/commit/eb1e060)] make plugins available in turn order functions\n* [[0688f4d](https://github.com/boardgameio/boardgame.io/commit/0688f4d)] Include credentials in undo/redo actions (#595)\n* [[f34f46b](https://github.com/boardgameio/boardgame.io/commit/f34f46b)] core: Don’t error if turn.order.next returns undefined (#614)\n\n### v0.39.5\n\n#### Features\n\n* [[78729eb](https://github.com/boardgameio/boardgame.io/commit/78729eb)] core: More Typescript conversion (#597)\n* [[3a41cf7](https://github.com/boardgameio/boardgame.io/commit/3a41cf7)] plugins: Make player plugin a factory function (#604)\n\n#### Bugfixes\n\n* [[1877268](https://github.com/boardgameio/boardgame.io/commit/1877268)] plugins: More Typescript & pass playerID to Enhance (#598)\n* [[5696dc4](https://github.com/boardgameio/boardgame.io/commit/5696dc4)] server: Correctly wait for server.listen event (#589)\n\n### v0.39.4\n\n#### Features\n\n* [[167690c](https://github.com/boardgameio/boardgame.io/commit/167690c)] add plugin types to ctx interface (#579)\n* [[618618e](https://github.com/boardgameio/boardgame.io/commit/618618e)] db: Make listGames options optional (#585)\n* [[f3c62a3](https://github.com/boardgameio/boardgame.io/commit/f3c62a3)] db: Make log handling explicit in StorageAPI.setState (#581)\n* [[c7dad76](https://github.com/boardgameio/boardgame.io/commit/c7dad76)] add the ability for plugins to define their own actions\n\n#### Bugfixes\n\n* [[9a21fee](https://github.com/boardgameio/boardgame.io/commit/9a21fee)] Remove namespacing in gameIDs on client side (#583)\n\n### v0.39.3\n\n#### Features\n\n* [[c507cf0](https://github.com/boardgameio/boardgame.io/commit/c507cf0)] Typescript improvements (#578)\n\n### v0.39.1\n\n#### Bugfixes\n\n* [[ca3cc0f](https://github.com/boardgameio/boardgame.io/commit/ca3cc0f)] avoid document reference error in some versions of Node\n\n## v0.39.0\n\n#### Features\n\n* [[ca52b01](https://github.com/boardgameio/boardgame.io/commit/ca52b01)] export some types in the NPM\n* [[6a091de](https://github.com/boardgameio/boardgame.io/commit/6a091de)] retrieve initial state using a separate code path\n* [[62f58d2](https://github.com/boardgameio/boardgame.io/commit/62f58d2)] add createGame to StorageAPI\n* [[21c3ef4](https://github.com/boardgameio/boardgame.io/commit/21c3ef4)] make listGames take an opts argument\n* [[bff685d](https://github.com/boardgameio/boardgame.io/commit/bff685d)] rename remove to wipe\n* [[d4de9e2](https://github.com/boardgameio/boardgame.io/commit/d4de9e2)] move log out of game state\n* [[045a8f5](https://github.com/boardgameio/boardgame.io/commit/045a8f5)] rename list to listGames\n* [[7b70cab](https://github.com/boardgameio/boardgame.io/commit/7b70cab)] remove MongoDB\n* [[0fb67fe](https://github.com/boardgameio/boardgame.io/commit/0fb67fe)] remove Firebase\n* [[c96e228](https://github.com/boardgameio/boardgame.io/commit/c96e228)] separate metadata and state in storage API\n\n#### Bugfixes\n\n* [[a75605d](https://github.com/boardgameio/boardgame.io/commit/a75605d)] remove unused has()\n* [[4157bc1](https://github.com/boardgameio/boardgame.io/commit/4157bc1)] remove namespacing in gameIDs\n* [[8c80785](https://github.com/boardgameio/boardgame.io/commit/8c80785)] remove namespace\n\n### v0.38.1\n\n#### Features\n\n* [[0d59c2c](https://github.com/boardgameio/boardgame.io/commit/0d59c2c)] move Events code into plugin\n* [[4b1c135](https://github.com/boardgameio/boardgame.io/commit/4b1c135)] move Random code into plugin\n\n#### Bugfixes\n\n* [[a624c9e](https://github.com/boardgameio/boardgame.io/commit/a624c9e)] update @babel/preset-env\n* [[c1dba9f](https://github.com/boardgameio/boardgame.io/commit/c1dba9f)] update prettier\n* [[60c6d88](https://github.com/boardgameio/boardgame.io/commit/60c6d88)] update rollup-plugin-terser\n* [[6378659](https://github.com/boardgameio/boardgame.io/commit/6378659)] npm run audit\n\n## v0.38.0\n\n#### Breaking Changes\n\nThe Plugin API is revamped. This also includes changing the way\n`PluginPlayer` works.  Please take a look at the\n[documentation](https://boardgame.io/documentation/#/plugins).  Feel free to comment on the public Gitter\nchannel if you have use-cases that are not covered by the rewrite\nor need help migrating.\n\n#### Features\n\n* [[d84e6af](https://github.com/boardgameio/boardgame.io/commit/d84e6af)] add onEnd hook for Game\n* [[94b69cb](https://github.com/boardgameio/boardgame.io/commit/94b69cb)] Plugin API cleanup (#560)\n\n#### Bugfixes\n\n* [[aede3b6](https://github.com/boardgameio/boardgame.io/commit/aede3b6)] check that document exists before mounting debug panel\n* [[ec7f0ad](https://github.com/boardgameio/boardgame.io/commit/ec7f0ad)] master: Remove credentials from action payloads after use (#556)\n* [[a080ce3](https://github.com/boardgameio/boardgame.io/commit/a080ce3)] fix: #552 (#553)\n* [[79ebcc3](https://github.com/boardgameio/boardgame.io/commit/79ebcc3)] remove graceful-fs patch\n* [[9370366](https://github.com/boardgameio/boardgame.io/commit/9370366)] remove some unused Svelte props\n\n### v0.37.2\n\n#### Bugfixes\n\n* [[8c120d2](https://github.com/boardgameio/boardgame.io/commit/8c120d2)] trigger bot if it needs to play at game start\n* [[aed5cd1](https://github.com/boardgameio/boardgame.io/commit/aed5cd1)] don't run bot once game is over\n* [[7c65046](https://github.com/boardgameio/boardgame.io/commit/7c65046)] fix redacted move example\n\n### v0.37.1\n\n#### Bugfixes\n\n* [[66021f7](https://github.com/boardgameio/boardgame.io/commit/66021f7)] fix bug causing AI section to not activate\n* [[fd34df9](https://github.com/boardgameio/boardgame.io/commit/fd34df9)] plugins: Fix PluginPlayer setup (#543)\n\n## v0.37.0\n\n#### Breaking Changes\n\nThe `ai` section has been moved from the `Client` to the game config:\n\n```js\nconst game = {\n  moves: { ... },\n  ...\n  ai: { ... }\n}\n```\n\n#### Features\n\n* [[0eff1c6](https://github.com/boardgameio/boardgame.io/commit/0eff1c6)] make the lobby assign bots to remaining players when there is only one human player\n* [[ef8df65](https://github.com/boardgameio/boardgame.io/commit/ef8df65)] add ability for Local multiplayer mode to run bots\n\n## v0.36.0\n\n#### Features\n\n* [[b974260](https://github.com/boardgameio/boardgame.io/commit/b974260)] Improve Lobby API: room instances (#542)\n* [[afdb79e](https://github.com/boardgameio/boardgame.io/commit/afdb79e)] refactor: Harmonise Master’s auth signature with authenticateCredentials (#539)\n* [[61a45ee](https://github.com/boardgameio/boardgame.io/commit/61a45ee)] rename optimistic to client and document it\n* [[4d33faa](https://github.com/boardgameio/boardgame.io/commit/4d33faa)] server: Lobby server improvements (#532)\n* [[08404e2](https://github.com/boardgameio/boardgame.io/commit/08404e2)] change MCTS visualization to table format\n\n#### Bugfixes\n\n* [[2d931e9](https://github.com/boardgameio/boardgame.io/commit/2d931e9)] server: Use namespaced ID to delete persisted game data (#531)\n* [[9ce176c](https://github.com/boardgameio/boardgame.io/commit/9ce176c)] client: Scope global CSS selectors in Debug panel (#527)\n* [[ef4f24d](https://github.com/boardgameio/boardgame.io/commit/ef4f24d)] Fix events in hooks triggered by a move (#525)\n* [[a2c64f8](https://github.com/boardgameio/boardgame.io/commit/a2c64f8)] increment turn before calling turn.onBegin\n\n### v0.35.1\n\n#### Bugfixes\n\n* [[26a73e4](https://github.com/boardgameio/boardgame.io/commit/26a73e4)] fix error in AI panel\n\n## v0.35.0\n\n#### Features\n\n- [[e7d47ee](https://github.com/boardgameio/boardgame.io/commit/e7d47ee)] export Debug Panel in boardgame.io/debug\n- [[cae05fd](https://github.com/boardgameio/boardgame.io/commit/cae05fd)] Replace `player` with `currentPlayer` option in `setActivePlayers` (#523)\n- [[2a7435a](https://github.com/boardgameio/boardgame.io/commit/2a7435a)] rename step to play\n- [[05572ca](https://github.com/boardgameio/boardgame.io/commit/05572ca)] add progress bar to AI panel\n- [[ad08b8a](https://github.com/boardgameio/boardgame.io/commit/ad08b8a)] Increment current player at start of phase in TurnOrder.DEFAULT (#521)\n- [[3cd5667](https://github.com/boardgameio/boardgame.io/commit/3cd5667)] speed up bot async mode by running 25 iterations per chunk\n- [[f19f1de](https://github.com/boardgameio/boardgame.io/commit/f19f1de)] add async mode to MCTS bot\n- [[7d22a47](https://github.com/boardgameio/boardgame.io/commit/7d22a47)] make bot play functions async\n- [[4efddb4](https://github.com/boardgameio/boardgame.io/commit/4efddb4)] lobby auto refresh + leave game ready to play (#510)\n- [[a8b7028](https://github.com/boardgameio/boardgame.io/commit/a8b7028)] add sliders to adjust iterations and playoutDepth of MCTS bot\n- [[1687ff8](https://github.com/boardgameio/boardgame.io/commit/1687ff8)] Add pass event (#492)\n- [[5fb3c4c](https://github.com/boardgameio/boardgame.io/commit/5fb3c4c)] allow switching between MCTS and Random bots in AI panel\n- [[9d74966](https://github.com/boardgameio/boardgame.io/commit/9d74966)] allow setting bot options from Debug Panel\n- [[bbfa304](https://github.com/boardgameio/boardgame.io/commit/bbfa304)] add AI tab\n\n#### Bugfixes\n\n- [[ba9dca8](https://github.com/boardgameio/boardgame.io/commit/ba9dca8)] add server.js to files section\n- [[457b29d](https://github.com/boardgameio/boardgame.io/commit/457b29d)] call notifySubscribers in update{Player,Game}ID\n- [[b4edd55](https://github.com/boardgameio/boardgame.io/commit/b4edd55)] Add server to proxy-dirs and clean scripts to fix #518 (#519)\n- [[6c0a9b7](https://github.com/boardgameio/boardgame.io/commit/6c0a9b7)] allow switching playerID from Debug Panel\n\n## v0.34.0\n\nThe main feature in this release is that the Debug Panel is now baked into the Vanilla JS client. This\nmeans that non-React users will have access to it as well!\n\nIt is guarded by process.env.NODE_ENV !== 'production', which means that most bundlers will strip it\nout in a production build.\n\nThe other big change is that the NPM package now contains both CJS and ES builds for every subpackage. This should have no user visible impact, but might break some non-standard bundler configurations.\n\n#### Features\n\n- [[e9351dc](https://github.com/boardgameio/boardgame.io/commit/e9351dc)] log a message when INVALID_MOVE is returned\n- [[2f86d92](https://github.com/boardgameio/boardgame.io/commit/2f86d92)] rename mount/unmount to start/stop\n- [[1ad87d0](https://github.com/boardgameio/boardgame.io/commit/1ad87d0)] remove INFO log in production, but not ERROR logs\n- [[83810ea](https://github.com/boardgameio/boardgame.io/commit/83810ea)] guard Debug Panel with process.env.NODE_ENV\n- [[156cf07](https://github.com/boardgameio/boardgame.io/commit/156cf07)] generate CJS and ES version of main package\n- [[881278a](https://github.com/boardgameio/boardgame.io/commit/881278a)] Migrate Debug Panel + Log + MCTS Visualizer to Svelte (#498)\n- [[49f5a52](https://github.com/boardgameio/boardgame.io/commit/49f5a52)] allow multiple client subscriptions\n\n#### Bugfixes\n\n- [[3206548](https://github.com/boardgameio/boardgame.io/commit/3206548)] don't invoke callback on subscribe in multiplayer mode unless client is already connected\n- [[9596fa4](https://github.com/boardgameio/boardgame.io/commit/9596fa4)] only notify the latest subscriber during client.subscribe\n- [[5a13f00](https://github.com/boardgameio/boardgame.io/commit/5a13f00)] fix bug in the way the transport notifies client subscribers of connection changes\n- [[c77ba53](https://github.com/boardgameio/boardgame.io/commit/c77ba53)] handle multiple subscriptions correctly\n- [[b045de3](https://github.com/boardgameio/boardgame.io/commit/b045de3)] use Parcel instead of Webpack in examples\n\n### v0.33.2\n\n#### Features\n\n- [[18d9be5](https://github.com/boardgameio/boardgame.io/commit/18d9be5)] Allowing support for both numbers and functions for MCTS bot iterations and playoutDepth (#475)\n- [[901c746](https://github.com/boardgameio/boardgame.io/commit/901c746)] feat: Apply `value` argument last in `setActivePlayers` (#489)\n\n#### Bugfixes\n\n- [[bed18ce](https://github.com/boardgameio/boardgame.io/commit/bed18ce)] reintroduce InitializeGame in boardgame.io/core\n\n### v0.33.1\n\n#### Features\n\n- [[6eb4ebd](https://github.com/boardgameio/boardgame.io/commit/6eb4ebd)] rewrite one of the snippets in Svelte\n- [[86e65fe](https://github.com/boardgameio/boardgame.io/commit/86e65fe)] fix: Move player to “next” stage on `endStage` (#484)\n\n## v0.33.0\n\nHuge release with a more streamlined API and the much\nawaited feature: Stages!\n\nCheck out this [migration guide](https://nicolodavis.com/blog/boardgame.io-0.33/).\n\n#### Features\n\n- [[6762219](https://github.com/boardgameio/boardgame.io/commit/6762219)] refactor: Change moveLimit syntax in setActivePlayers (#481)\n- [[64971ee](https://github.com/boardgameio/boardgame.io/commit/64971ee)] Disallow game names with spaces (#474)\n- [[d43d239](https://github.com/boardgameio/boardgame.io/commit/d43d239)] short form syntax for literal value in setActivePlayers\n- [[462f452](https://github.com/boardgameio/boardgame.io/commit/462f452)] allow all players to call events\n- [[2409729](https://github.com/boardgameio/boardgame.io/commit/2409729)] enable all events by default\n- [[1261475](https://github.com/boardgameio/boardgame.io/commit/1261475)] remove UI toolkit\n- [[b2f5160](https://github.com/boardgameio/boardgame.io/commit/b2f5160)] feat: Add `endStage` and `setStage` events (#458)\n- [[ca61bf6](https://github.com/boardgameio/boardgame.io/commit/ca61bf6)] feat: Support move limits in `setActivePlayers` (#452)\n- [[ec15ad2](https://github.com/boardgameio/boardgame.io/commit/ec15ad2)] TurnOrder.RESET\n- [[d251f4a](https://github.com/boardgameio/boardgame.io/commit/d251f4a)] set phase to null instead of empty string\n- [[9c6f55d](https://github.com/boardgameio/boardgame.io/commit/9c6f55d)] set currentPlayer to null instead of empty string\n- [[da2f0ea](https://github.com/boardgameio/boardgame.io/commit/da2f0ea)] add stages\n- [[d5e2b55](https://github.com/boardgameio/boardgame.io/commit/d5e2b55)] start turn at 1\n- [[35a34a0](https://github.com/boardgameio/boardgame.io/commit/35a34a0)] nest turns inside phases\n- [[cff284b](https://github.com/boardgameio/boardgame.io/commit/cff284b)] convert startingPhase into boolean option\n- [[b9ce7f1](https://github.com/boardgameio/boardgame.io/commit/b9ce7f1)] move event disablers inside separate section in config\n- [[61eb8d8](https://github.com/boardgameio/boardgame.io/commit/61eb8d8)] rename movesPerTurn to moveLimit\n- [[3a97a16](https://github.com/boardgameio/boardgame.io/commit/3a97a16)] make optimistic an option in long-form move syntax\n- [[10ef457](https://github.com/boardgameio/boardgame.io/commit/10ef457)] retire Game(). call it internally instead.\n- [[3d46a4a](https://github.com/boardgameio/boardgame.io/commit/3d46a4a)] rename endGameIf to endIf\n- [[33ac684](https://github.com/boardgameio/boardgame.io/commit/33ac684)] retire flow section\n- [[d75fe44](https://github.com/boardgameio/boardgame.io/commit/d75fe44)] move undoableMoves into boolean inside long form move syntax\n- [[8924e84](https://github.com/boardgameio/boardgame.io/commit/8924e84)] move redactedMoves into a boolean option in the long form move syntax\n- [[4b202ee](https://github.com/boardgameio/boardgame.io/commit/4b202ee)] long form move syntax\n- [[f00e736](https://github.com/boardgameio/boardgame.io/commit/f00e736)] rename some hooks\n- [[19ca21f](https://github.com/boardgameio/boardgame.io/commit/19ca21f)] move onTurnBegin/onTurnEnd/endTurnIf/movesPerTurn into turn object\n- [[53b7ac7](https://github.com/boardgameio/boardgame.io/commit/53b7ac7)] convert turnOrder into a turn object\n- [[fa58e5b](https://github.com/boardgameio/boardgame.io/commit/fa58e5b)] retire allowedMoves\n- [[7a411c9](https://github.com/boardgameio/boardgame.io/commit/7a411c9)] introduce namespaced moves that are defined within phases\n- [[a0d5f36](https://github.com/boardgameio/boardgame.io/commit/a0d5f36)] Surface game metadata and player nicknames in client / react props (#436)\n- [[221b0d5](https://github.com/boardgameio/boardgame.io/commit/221b0d5)] add benchmark\n\n#### Bugfixes\n\n- [[fd70ed5](https://github.com/boardgameio/boardgame.io/commit/fd70ed5)] No payload is not an authentic player (#430)\n\n### v0.32.1\n\n#### Features\n\n- [[9cff03e](https://github.com/boardgameio/boardgame.io/commit/9cff03e)] Create play again endpoint (#428)\n\n#### Bugfixes\n\n- [[0a75e4b](https://github.com/boardgameio/boardgame.io/commit/0a75e4b)] fix: Fix join/leave a room when playerID is 0 (#425)\n\n## v0.32.0\n\n#### Features\n\n- [[2b98fb6](https://github.com/boardgameio/boardgame.io/commit/2b98fb6)] change custom client transport to a constructor (#417)\n- [[89faece](https://github.com/boardgameio/boardgame.io/commit/89faece)] Rename playerCredentials to credentials for /leave endpoint, update src/lobby/connection.js accordingly (#416)\n- [[25c2263](https://github.com/boardgameio/boardgame.io/commit/25c2263)] Fix #345; restrict undo/redo to currentPlayer (#408)\n- [[6de7b64](https://github.com/boardgameio/boardgame.io/commit/6de7b64)] Add /rename endpoint for lobby (#414)\n\n### v0.31.7\n\n#### Features\n\n- [[febb1c0](https://github.com/boardgameio/boardgame.io/commit/febb1c0)] Check if required parameters are passed to API (#407)\n\n#### Bugfixes\n\n- [[a6145a5](https://github.com/boardgameio/boardgame.io/commit/a6145a5)] upgrade koa and koa-body\n\n### v0.31.6\n\n#### Bugfixes\n\n- [[5ad5c3f](https://github.com/boardgameio/boardgame.io/commit/5ad5c3f)] Remove some secrets from client in multiplayer game (#400)\n- [[3e50dca](https://github.com/boardgameio/boardgame.io/commit/3e50dca)] Get specific instance of a room by its ID (#405)\n- [[4964e3f](https://github.com/boardgameio/boardgame.io/commit/4964e3f)] Creating lobby API config and making the UUID customizable (#396)\n- [[efece0c](https://github.com/boardgameio/boardgame.io/commit/efece0c)] Auto-add trailing slash to server only if needed (#403)\n- [[f289379](https://github.com/boardgameio/boardgame.io/commit/f289379)] Rename gameInstances to rooms (#402)\n- [[1d5586c](https://github.com/boardgameio/boardgame.io/commit/1d5586c)] export FlatFile in server.js\n- [[eda9728](https://github.com/boardgameio/boardgame.io/commit/eda9728)] update undo to reflect current ctx (#393)\n- [[e46f195](https://github.com/boardgameio/boardgame.io/commit/e46f195)] add turn and phase to log entries\n\n### v0.31.5\n\n#### Features\n\n- [[3982150](https://github.com/boardgameio/boardgame.io/commit/3982150)] synchronous mode for game master\n- [[8732d9f](https://github.com/boardgameio/boardgame.io/commit/8732d9f)] Add adminClient option for Firebase storage (#386)\n\n#### Bugfixes\n\n- [[8ed812e](https://github.com/boardgameio/boardgame.io/commit/8ed812e)] handle default number of players bigger than 2 for 1st game of the list (#392)\n- [[ec7dde5](https://github.com/boardgameio/boardgame.io/commit/ec7dde5)] Don't leak undefined ctx properties from turnOrder.actionPlayers (#382)\n\n### v0.31.4\n\n#### Features\n\n- [[3bde0ca](https://github.com/boardgameio/boardgame.io/commit/3bde0ca)] Adding step props to the Board (#376)\n- [[4c3056c](https://github.com/boardgameio/boardgame.io/commit/4c3056c)] Making step accept a Promise from bot.play() (#375)\n\n#### Bugfixes\n\n- [[c24e0cd](https://github.com/boardgameio/boardgame.io/commit/c24e0cd)] upgrade Expo and fix React Native example\n- [[c1ee6f3](https://github.com/boardgameio/boardgame.io/commit/c1ee6f3)] python bot: fix #379 (#380)\n\n### v0.31.3\n\n#### Features\n\n- [[94b1d65](https://github.com/boardgameio/boardgame.io/commit/94b1d65)] Add flatfile database with node-persist (#372)\n- [[f6e70fd](https://github.com/boardgameio/boardgame.io/commit/f6e70fd)] Add custom renderer parameter to lobby + clean up code (#353)\n\n### v0.31.2\n\n#### Features\n\n- [[01a7e79](https://github.com/boardgameio/boardgame.io/commit/01a7e79)] 3D Grid and Token (#352)\n- [[1f33d43](https://github.com/boardgameio/boardgame.io/commit/1f33d43)] Serve API and Game Server on same port with option to split (#343)\n\n#### Bugfixes\n\n- [[87d1e5b](https://github.com/boardgameio/boardgame.io/commit/87d1e5b)] Changed default Firebase return value to undefined (#361)\n- [[d7d6b44](https://github.com/boardgameio/boardgame.io/commit/d7d6b44)] Fix lobby example (#351)\n- [[a285fbf](https://github.com/boardgameio/boardgame.io/commit/a285fbf)] Allow https urls to be passed to lobby (#350)\n\n### v0.31.1\n\n#### Bugfixes\n\n- [[4a796dc](https://github.com/boardgameio/boardgame.io/commit/4a796dc)] remove three from minified rollup bundle\n\n## v0.31.0\n\n#### Features\n\n- [[a32d3d5](https://github.com/boardgameio/boardgame.io/commit/a32d3d5)] Generic lobby (#294)\n- [[fb19e9b](https://github.com/boardgameio/boardgame.io/commit/fb19e9b)] move examples into a create-react-app package (#335)\n- [[1f71bbd](https://github.com/boardgameio/boardgame.io/commit/1f71bbd)] Upgrade Babel 7 (#332)\n\n#### Bugfixes\n\n- [[3334d38](https://github.com/boardgameio/boardgame.io/commit/3334d38)] fix race condition in game instantiation inside onSync\n- [[f544511](https://github.com/boardgameio/boardgame.io/commit/f544511)] Allow result of onPhaseBegin to influence turn order (#341)\n- [[e1c1f6b](https://github.com/boardgameio/boardgame.io/commit/e1c1f6b)] fail integration test if any subcommand fails\n\n## v0.30.0\n\n#### Features\n\n- [[6cf81e8](https://github.com/boardgameio/boardgame.io/commit/6cf81e8)] create initial game state outside reducer\n- [[8d08381](https://github.com/boardgameio/boardgame.io/commit/8d08381)] add a loading component for multiplayer clients\n\n#### Bugfixes\n\n- [[d20d26c](https://github.com/boardgameio/boardgame.io/commit/d20d26c)] make master write to proper namepspaced keys\n\n### v0.29.5\n\n#### Features\n\n- [[7188222](https://github.com/boardgameio/boardgame.io/commit/7188222)] add plugin.onPhaseBegin\n\n### v0.29.4\n\n#### Features\n\n- [[c1b4a03](https://github.com/boardgameio/boardgame.io/commit/c1b4a03)] add playerSetup option to PluginPlayer\n\n### v0.29.3\n\n#### Features\n\n- [[da1eac6](https://github.com/boardgameio/boardgame.io/commit/da1eac6)] rename plugin api functions\n- [[659007a](https://github.com/boardgameio/boardgame.io/commit/659007a)] pass game object to plugins\n\n### v0.29.2\n\n#### Bugfixes\n\n- [[5d74c95](https://github.com/boardgameio/boardgame.io/commit/5d74c95)] fix immer plugin order\n\n### v0.29.1\n\n#### Features\n\n- [[ff749e3](https://github.com/boardgameio/boardgame.io/commit/ff749e3)] add addTo / removeFrom to plugin API\n- [[9df8145](https://github.com/boardgameio/boardgame.io/commit/9df8145)] split plugin.setup into setupG and setupCtx\n- [[d2d44f9](https://github.com/boardgameio/boardgame.io/commit/d2d44f9)] rename plugin.wrapper to plugin.fnWrap\n- [[ca5da32](https://github.com/boardgameio/boardgame.io/commit/ca5da32)] Passing arbitrary data to game setup (#315)\n\n## v0.29.0\n\n#### Features\n\n- [[d1bd1d1](https://github.com/boardgameio/boardgame.io/commit/d1bd1d1)] Plugin API\n\n### v0.28.1\n\n#### Features\n\n- [[10de6f8](https://github.com/boardgameio/boardgame.io/commit/10de6f8)] Turn order active player changes (#320)\n- [[58cbd1e](https://github.com/boardgameio/boardgame.io/commit/58cbd1e)] Redact Log Events (#268)\n- [[ed165a8](https://github.com/boardgameio/boardgame.io/commit/ed165a8)] Add a server sync status field (#307)\n\n#### Bugfixes\n\n- [[b8ec845](https://github.com/boardgameio/boardgame.io/commit/b8ec845)] package refactor\n- [[2b5920f](https://github.com/boardgameio/boardgame.io/commit/2b5920f)] Add Immer to other events (#327)\n- [[873e1f5](https://github.com/boardgameio/boardgame.io/commit/873e1f5)] server: fix name of property 'credentials' in server API handler for 'leave' (#326)\n\n## v0.28.0\n\nWe now support an alternative style for moves that allows modifying `G` directly.\nThe old style is still supported.\n\n#### Features\n\n- [[6bdfb11](https://github.com/boardgameio/boardgame.io/commit/6bdfb11)] add immer\n\n#### Breaking Changes\n\n`undefined` is no longer used to indicate invalid moves. Use the new `INVALID_MOVE`\nconstant to accomplish this.\n\n```js\nimport { INVALID_MOVE } from 'boardgame.io/core';\n\nconst TicTacToe = Game({\n  moves: {\n    clickCell: (G, ctx, id) => {\n      if (G.cells[id] !== null) {\n        return INVALID_MOVE;\n      }\n      G.cells[id] = ctx.currentPlayer;\n    },\n  },\n});\n```\n\n### v0.27.1\n\n#### Features\n\n- [[2d02558](https://github.com/boardgameio/boardgame.io/commit/2d02558)] add TurnOrder.CUSTOM and TurnOrder.CUSTOM_FROM\n\n#### Bugfixes\n\n- [[8699350](https://github.com/boardgameio/boardgame.io/commit/8699350)] Prohibit second log event during Update (#303)\n\n## v0.27.0\n\nThis is a pretty exciting release with lots of goodies but\nwith some breaking changes, so make sure to read the section\nat the end with tips on migration. The main theme in this\nrelease is the reworking of Phases and Turn Orders to support\nmore complex game types and other common patterns like the\nability to quickly pop into a phase and back.\n\n#### Features\n\n- [[b7abc57](https://github.com/boardgameio/boardgame.io/commit/b7abc57)] more turn orders\n- [[5fb663a](https://github.com/boardgameio/boardgame.io/commit/5fb663a)] allow calling setActionPlayers via TurnOrder objects\n- [[53473ef](https://github.com/boardgameio/boardgame.io/commit/53473ef)] change semantics of enabling/disabling events\n- [[992416a](https://github.com/boardgameio/boardgame.io/commit/992416a)] change format of args to endPhase and endTurn\n- [[0568857](https://github.com/boardgameio/boardgame.io/commit/0568857)] change phases syntax\n\n#### Bugfixes\n\n- [[96def53](https://github.com/boardgameio/boardgame.io/commit/96def53)] add MONGO_DATABASE env variable (#290)\n\n#### Breaking Changes\n\n1. The syntax for phases has changed:\n\n```\n// old\nphases: [\n{ name: 'A', ...opts },\n{ name: 'B', ...opts },\n]\n\n// new\nphases: {\n'A': { ...opts },\n'B': { ...opts },\n}\n```\n\n2. There is no implicit ordering of phases. You can specify an\n   explicit order via `next` (optional). Note that this allows you to create\n   more complex graphs of phases compared to the previous linear\n   approach.\n\n```\nphases: {\n'A': { next: 'B' },\n'B': { next: 'A' },\n}\n```\n\nTake a look at [phases.md](phases.md) to see how `endPhase`\ndetermines which phase to move to.\n\n3. A phase called `default` is always created. This is the phase\n   that the game begins in. This is also the phase that the\n   game reverts to in case it detects an infinite loop of\n   `endPhase` events caused by a cycle.\n\nYou can have the game start in a phase different from `default`\nusing `startingPhase`:\n\n```\nflow: {\nstartingPhase: 'A',\nphases: {\nA: {},\nB: {},\n}\n}\n```\n\n4. The format of the argument to `endPhase` or the return\n   value of `endPhaseIf` is now an object of type `{ next: 'phase name' }`\n\n```\n// old\nendPhase('new phase')\nendPhaseIf: () => 'new phase'\n\n// new\nendPhase({ next: 'new phase' })\nendPhaseIf: () => ({ next: 'new phase' })\n```\n\n5. The format of the argument to `endTurn` or the return\n   value of `endTurnIf` is now an object of type `{ next: playerID }`\n\n```\n// old\nendTurn(playerID)\nendTurnIf: () => playerID\n\n// new\nendTurn({ next: playerID })\nendTurnIf: () => ({ next: playerID })\n```\n\n6. The semantics of enabling / disabling events has changed\n   a bit: see https://boardgame.io/#/events for more details.\n\n7. TurnOrder objects now support `setActionPlayers` args.\n   Instead of returning `actionPlayers` in `first` / `next`,\n   add an `actionPlayers` section instead.\n\n```\n// old\n{\nfirst: (G, ctx) => {\nplayOrderPos: 0,\nactionPlayers: [...ctx.playOrder],\n}\n\nnext: (G, ctx) => {\nplayOrderPos: ctx.playOrderPos + 1,\nactionPlayers: [...ctx.playOrder],\n},\n}\n\n// new\n{\nfirst: (G, ctx) => 0,\nnext: (G, ctx) => ctx.playOrderPos + 1,\nactionPlayers: { all: true },\n}\n```\n\n### v0.26.3\n\n#### Features\n\n- [[d50015d](https://github.com/boardgameio/boardgame.io/commit/d50015d)] turn order simulator\n\n#### Bugfixes\n\n- [[58e135b](https://github.com/boardgameio/boardgame.io/commit/58e135b)] fix bug that was causing ctx.events to be undefined\n- [[ea3754b](https://github.com/boardgameio/boardgame.io/commit/ea3754b)] player needs to be in actionPlayers in order to call events\n\n### v0.26.2\n\n#### Features\n\n- [[a352d1e](https://github.com/boardgameio/boardgame.io/commit/a352d1e)] decouple once and allOthers\n\n### v0.26.1\n\n#### Bugfixes\n\n- [[aa5f2cf](https://github.com/boardgameio/boardgame.io/commit/aa5f2cf)] added the useNewUrlParser option to the Mongo connect() (#285)\n\n## v0.26.0\n\n#### Features\n\n- [[e8f165a](https://github.com/boardgameio/boardgame.io/commit/e8f165a)] server: add new API endpoints 'list' and 'leave' (#276)\n- [[8ff4745](https://github.com/boardgameio/boardgame.io/commit/8ff4745)] drag-n-drop for cards and decks\n- [[a558092](https://github.com/boardgameio/boardgame.io/commit/a558092)] return state as first argument to client.subscribe callback\n- [[965f9b7](https://github.com/boardgameio/boardgame.io/commit/965f9b7)] Allow to set payload onto a log event (#267)\n- [[2efdbc1](https://github.com/boardgameio/boardgame.io/commit/2efdbc1)] utils for working with hexagonal boards (#271)\n- [[137dd7c](https://github.com/boardgameio/boardgame.io/commit/137dd7c)] allow overriding client-side transport\n- [[63311ac](https://github.com/boardgameio/boardgame.io/commit/63311ac)] local game master\n- [[0b7a0a0](https://github.com/boardgameio/boardgame.io/commit/0b7a0a0)] add allOthers option to setActionPlayers (#269)\n\n#### Bugfixes\n\n- [[d1a1a8a](https://github.com/boardgameio/boardgame.io/commit/d1a1a8a)] shouldEndPhase can see the results of onTurnEnd\n- [[b4874a6](https://github.com/boardgameio/boardgame.io/commit/b4874a6)] call the client subscribe callback after LogMiddleware has run\n- [[9b9d735](https://github.com/boardgameio/boardgame.io/commit/9b9d735)] reset deltalog properly\n\n### v0.25.5\n\n#### Features\n\n- [[4ed6b94](https://github.com/boardgameio/boardgame.io/commit/4ed6b94)] add server startup message\n- [[1688639](https://github.com/boardgameio/boardgame.io/commit/1688639)] decouple transport layer from server logic\n\n### v0.25.4\n\n#### Bugfixes\n\n- Fixed babelHelpers error in npm.\n\n### v0.25.3\n\nBroken, do not use (complains about babelHelpers missing).\n\n#### Bugfixes\n\n- [[ebf7e73](https://github.com/boardgameio/boardgame.io/commit/ebf7e73)] fix bug that was preventing playerID from being overriden by the debug ui\n\n### v0.25.2\n\n#### Bugfixes\n\n- [[a42e07b](https://github.com/boardgameio/boardgame.io/commit/a42e07b)] npm audit fix --only=prod\n- [[cfe7296](https://github.com/boardgameio/boardgame.io/commit/cfe7296)] update koa and socket.io\n\n### v0.25.1\n\n#### Bugfixes\n\n- [[09b523e](https://github.com/boardgameio/boardgame.io/commit/09b523e)] require mongo and firebase only if used\n\n## v0.25.0\n\n#### Features\n\n- [[fe8a9d0](https://github.com/boardgameio/boardgame.io/commit/fe8a9d0)] Added ability to specify server protocol (#247)\n- [[43dcaac](https://github.com/boardgameio/boardgame.io/commit/43dcaac)] write turn / phase stats in ctx.stats\n- [[bd8208a](https://github.com/boardgameio/boardgame.io/commit/bd8208a)] fabricate playerID in singleplayer mode\n- [[b4e3e09](https://github.com/boardgameio/boardgame.io/commit/b4e3e09)] { all: true } option for setActionPlayers\n- [[5d3a34d](https://github.com/boardgameio/boardgame.io/commit/5d3a34d)] { once: true } option for setActionPlayers\n- [[75a274c](https://github.com/boardgameio/boardgame.io/commit/75a274c)] rename changeActionPlayers to setActionPlayers\n- [[4ec3a61](https://github.com/boardgameio/boardgame.io/commit/4ec3a61)] end phase when a turn order runs out\n- [[cb6111b](https://github.com/boardgameio/boardgame.io/commit/cb6111b)] retire the string constant 'any'\n- [[36fc47f](https://github.com/boardgameio/boardgame.io/commit/36fc47f)] basic support for objective-based AI\n- [[d1f0a3e](https://github.com/boardgameio/boardgame.io/commit/d1f0a3e)] improved rendering of turns and phases in the log\n- [[0bc31d6](https://github.com/boardgameio/boardgame.io/commit/0bc31d6)] better MCTS visualization\n- [[14a5ad7](https://github.com/boardgameio/boardgame.io/commit/14a5ad7)] update redux to 4.0.0\n\n#### Bugfixes\n\n- [[84f07c6](https://github.com/boardgameio/boardgame.io/commit/84f07c6)] Do not fabricate playerID for playerView\n- [[c4a11a7](https://github.com/boardgameio/boardgame.io/commit/c4a11a7)] ignore events from all but currentPlayer\n- [[6a8b657](https://github.com/boardgameio/boardgame.io/commit/6a8b657)] move mongodb and firebase deps to devDependencies\n- [[239f8dd](https://github.com/boardgameio/boardgame.io/commit/239f8dd)] Use parse/stringify from flatted lib to support circular structures (fixes #222) (#240)\n- [[edd1df0](https://github.com/boardgameio/boardgame.io/commit/edd1df0)] Differentiate automatic game events in the log\n- [[570f40e](https://github.com/boardgameio/boardgame.io/commit/570f40e)] don't render AI metadata if visualize is not specified\n- [[a8431c7](https://github.com/boardgameio/boardgame.io/commit/a8431c7)] set default RNG seed once per game, not game type\n- [[5090429](https://github.com/boardgameio/boardgame.io/commit/5090429)] API: check secret _before_ handling the request (#231)\n- [[1a24791](https://github.com/boardgameio/boardgame.io/commit/1a24791)] attach events API early so that it can be used on the first onTurnBegin\n- [[acb9d8c](https://github.com/boardgameio/boardgame.io/commit/acb9d8c)] enable events API in initial onTurnBegin/onPhaseBegin\n\n#### Breaking Changes\n\n- `changeActionPlayers` is now `setActionPlayers`. It also supports more advanced [options](http://boardgame.io/#/events?id=setactionplayers).\n- Returning `undefined` from a `TurnOrder` results in the phase ending, not setting `currentPlayer` to `any`.\n- Only the `currentPlayer` can call events (`endTurn`, `endPhase` etc.).\n\n## v0.24.0\n\n#### Features\n\n- [[b28ee74](https://github.com/boardgameio/boardgame.io/commit/b28ee74)] ability to change playerID from Debug UI\n- [[fe1230e](https://github.com/boardgameio/boardgame.io/commit/fe1230e)] Firebase integration (#223)\n\n### v0.23.3\n\n#### Bugfixes\n\n- [[6194986](https://github.com/boardgameio/boardgame.io/commit/6194986)] remove async/await from client code\n\n### v0.23.2\n\n#### Bugfixes\n\n- [[7a61f09](https://github.com/boardgameio/boardgame.io/commit/7a61f09)] make Random API present in first onTurnBegin and onPhaseBegin\n\n#### Features\n\n- [[99b9844](https://github.com/boardgameio/boardgame.io/commit/99b9844)] Python Bots\n- [[a7134a5](https://github.com/boardgameio/boardgame.io/commit/a7134a5)] List available games API\n\n### v0.23.1\n\n#### Bugfixes\n\n- [[f26328c](https://github.com/boardgameio/boardgame.io/commit/f26328c)] add ai.js to rollup config\n\n## v0.23.0\n\n#### Features\n\n- [[dda540a](https://github.com/boardgameio/boardgame.io/commit/dda540a)] AI framework\n- [[8e2f8c4](https://github.com/boardgameio/boardgame.io/commit/8e2f8c4)] lobby API support (#189)\n\n#### Bugfixes\n\n- [[7a80f66](https://github.com/boardgameio/boardgame.io/commit/7a80f66)] make changeActionPlayers an opt-in event\n- [[40cd4b8](https://github.com/boardgameio/boardgame.io/commit/40cd4b8)] Add config update on phase change Fixes #211 (#212)\n\n### v0.22.1\n\n#### Bugfixes\n\n- [[bb39ca7](https://github.com/boardgameio/boardgame.io/commit/bb39ca7)] fix bug that was causing isActive to return false\n- [[81ed088](https://github.com/boardgameio/boardgame.io/commit/81ed088)] ensure endTurn is called only once after a move\n- [[ca9f6ca](https://github.com/boardgameio/boardgame.io/commit/ca9f6ca)] disable move if playerID is null\n\n## v0.22.0\n\n#### Features\n\n- [[5362955](https://github.com/boardgameio/boardgame.io/commit/5362955)] React Native Client (#128)\n- [[b329df2](https://github.com/boardgameio/boardgame.io/commit/b329df2)] Pass through props (#173)\n\n### v0.21.5\n\n#### Bugfixes\n\n- [[55715c9](https://github.com/boardgameio/boardgame.io/commit/55715c9)] Fix undefined ctx in onPhaseBegin\n\n### v0.21.4\n\n#### Features\n\n- [[387d413](https://github.com/boardgameio/boardgame.io/commit/387d413)] Debug UI CSS improvements\n- [[2105f46](https://github.com/boardgameio/boardgame.io/commit/2105f46)] call endTurnIf inside endPhase\n- [[9b0324c](https://github.com/boardgameio/boardgame.io/commit/9b0324c)] allow setting the next player via endTurn\n- [[f76f97e](https://github.com/boardgameio/boardgame.io/commit/f76f97e)] correct isMultiplayer\n\n#### Bugfixes\n\n- [[278b369](https://github.com/boardgameio/boardgame.io/commit/278b369)] Fix bug that was ending phase incorrectly (#176)\n\n### v0.21.3\n\n#### Features\n\n- [[dc31a66](https://github.com/boardgameio/boardgame.io/commit/dc31a66)] expose allowedMoves in ctx\n- [[da4711a](https://github.com/boardgameio/boardgame.io/commit/da4711a)] make allowedMoves both global and phase-specific\n- [[9324c58](https://github.com/boardgameio/boardgame.io/commit/9324c58)] Allowed moves as function (#164)\n\n#### Bugfixes\n\n- [[5e49448](https://github.com/boardgameio/boardgame.io/commit/5e49448)] convert multiplayer move whitelist to blacklist\n\n### v0.21.2\n\n#### Bugfixes\n\n- [[27705d5](https://github.com/boardgameio/boardgame.io/commit/27705d5)] pass Events API correctly inside events.update\n\n### v0.21.1\n\n#### Bugfixes\n\n- [[87e77c1](https://github.com/boardgameio/boardgame.io/commit/87e77c1)] correctly detach APIs from ctx in startTurn\n\n## v0.21.0\n\n#### Features\n\n- [[2ee244e](https://github.com/boardgameio/boardgame.io/commit/2ee244e)] Reset Game (#155)\n- [[9cd3fdf](https://github.com/boardgameio/boardgame.io/commit/9cd3fdf)] allow to modify actionPlayers via Events (#157)\n- [[767362f](https://github.com/boardgameio/boardgame.io/commit/767362f)] endGame event\n- [[78634ee](https://github.com/boardgameio/boardgame.io/commit/78634ee)] Events API\n- [[a240e45](https://github.com/boardgameio/boardgame.io/commit/a240e45)] undoableMoves implementation (#149)\n- [[c12e911](https://github.com/boardgameio/boardgame.io/commit/c12e911)] Process only known moves (#151)\n- [[7fcdbfe](https://github.com/boardgameio/boardgame.io/commit/7fcdbfe)] Custom turn order (#130)\n- [[748f36f](https://github.com/boardgameio/boardgame.io/commit/748f36f)] UI: add mouse hover action props to grid, hex, and token (#153)\n- [[f664237](https://github.com/boardgameio/boardgame.io/commit/f664237)] Add notion of actionPlayers (#145)\n\n### v0.20.2\n\n#### Features\n\n- [[43ba0ff](https://github.com/boardgameio/boardgame.io/commit/43ba0ff)] allow optional redux enhancer (#139)\n- [[dd6c110](https://github.com/boardgameio/boardgame.io/commit/dd6c110)] Run endPhase event (analogue to endTurn) when game ends (#144)\n\n#### Bugfixes\n\n- [[8969433](https://github.com/boardgameio/boardgame.io/commit/8969433)] Fix bug that was causing Random code to return the same numbers.\n\n#### Breaking Changes\n\n- The `Random` API is different. There is no longer a `Random` package\n  that you need to import. The API is attached to the `ctx` parameter that\n  is passed to the moves. Take a look at http://boardgame.io/#/random for\n  more details.\n\n### v0.20.1\n\n#### Bugfixes\n\n- [[06d78e2](https://github.com/boardgameio/boardgame.io/commit/06d78e2)] Enable SSR\n- [[ed09f51](https://github.com/boardgameio/boardgame.io/commit/ed09f51)] Allow calling Random during setup\n- [[c50d5ea](https://github.com/boardgameio/boardgame.io/commit/c50d5ea)] fix log rendering of phases\n\n## v0.20.0\n\n#### Features\n\n- [[eec8896](https://github.com/boardgameio/boardgame.io/commit/eec8896)] undo/redo\n\n## v0.19.0\n\n#### Features\n\n- MongoDB connector\n  - [[eaa372f](https://github.com/boardgameio/boardgame.io/commit/eaa372f)] add Mongo to package\n  - [[63c3cdf](https://github.com/boardgameio/boardgame.io/commit/63c3cdf)] mongo race condition checks\n  - [[65cefdf](https://github.com/boardgameio/boardgame.io/commit/65cefdf)] allow setting Mongo location using MONGO_URI\n  - [[557b66c](https://github.com/boardgameio/boardgame.io/commit/557b66c)] add run() to Server\n  - [[2a85b40](https://github.com/boardgameio/boardgame.io/commit/2a85b40)] replace lru-native with lru-cache\n  - [[003fe46](https://github.com/boardgameio/boardgame.io/commit/003fe46)] MongoDB connector\n\n#### Breaking Changes\n\n- `boardgame.io/server` no longer has a default export, but returns\n  `Server` and `Mongo`.\n\n```\n// v0.19\nconst Server = require('boardgame.io/server').Server;\n```\n\n```\n// v0.18\nconst Server = require('boardgame.io/server');\n```\n\n### v0.18.1\n\n#### Bugfixes\n\n[[0c894bd](https://github.com/boardgameio/boardgame.io/commit/0c894bd)] add react.js to rollup config\n\n## v0.18.0\n\n#### Features\n\n- [[4b90e84](https://github.com/boardgameio/boardgame.io/commit/4b90e84)] decouple client from React\n\nThis adds a new package `boardgame.io/react`. Migrate all your\ncalls from:\n\n```\nimport { Client } from 'boardgame.io/client'\n```\n\nto:\n\n```\nimport { Client } from 'boardgame.io/react'\n```\n\n`boardgame.io/client` exposes a raw JS client that isn't tied\nto any particular UI framework.\n\n- Random API:\n\n  - [[ebe7758](https://github.com/boardgameio/boardgame.io/commit/ebe7758)] allow to throw multiple dice (#120)\n  - [[8c88b70](https://github.com/boardgameio/boardgame.io/commit/8c88b70)] Simplify Random API (#119)\n  - [[45599e5](https://github.com/boardgameio/boardgame.io/commit/45599e5)] Server-side array shuffling. (#116)\n  - [[d296b36](https://github.com/boardgameio/boardgame.io/commit/d296b36)] Random API (#103)\n\n- [[f510b69](https://github.com/boardgameio/boardgame.io/commit/f510b69)] onTurnBegin (#109)\n\n#### Bugfixes\n\n- [[6a010c8](https://github.com/boardgameio/boardgame.io/commit/6a010c8)] Debug UI: fixes related to errors in arguments (#123)\n\n### v0.17.2\n\n#### Features\n\n- [[0572210](https://github.com/boardgameio/boardgame.io/commit/0572210)] Exposing Client connection status to board. (#97)\n- [[c2ea197](https://github.com/boardgameio/boardgame.io/commit/c2ea197)] make db interface async (#86)\n- [[9e507ce](https://github.com/boardgameio/boardgame.io/commit/9e507ce)] exclude dependencies from package\n\n#### Bugfixes\n\n- [[a768f1f](https://github.com/boardgameio/boardgame.io/commit/a768f1f)] remove entries from clientInfo and roomInfo on disconnect\n\n### v0.17.1\n\n#### Features\n\n- [[f23c5dd](https://github.com/boardgameio/boardgame.io/commit/f23c5dd)] Card and Deck (#74)\n- [[a21c1dd](https://github.com/boardgameio/boardgame.io/commit/a21c1dd)] prevent endTurn when movesPerTurn have not been made\n\n#### Bugfixes\n\n- [[11e215e](https://github.com/boardgameio/boardgame.io/commit/11e215e)] fix bug that was using the wrong playerID when calculating playerView\n\n## v0.17.0\n\n#### Features\n\n- [[0758c7e](https://github.com/boardgameio/boardgame.io/commit/0758c7e)] cascade endPhase\n- [[cc7d44f](https://github.com/boardgameio/boardgame.io/commit/cc7d44f)] retire triggers and introduce onMove instead\n- [[17e88ce](https://github.com/boardgameio/boardgame.io/commit/17e88ce)] convert events whitelist to boolean options\n- [[e315b9e](https://github.com/boardgameio/boardgame.io/commit/e315b9e)] add ui to NPM package\n- [[5b34c5d](https://github.com/boardgameio/boardgame.io/commit/5b34c5d)] remove pass event and make it a standard move\n- [[f3da742](https://github.com/boardgameio/boardgame.io/commit/f3da742)] make playerID available in ctx\n- [[cb09d9a](https://github.com/boardgameio/boardgame.io/commit/cb09d9a)] make turnOrder a globally configurable option\n\n### v0.16.8\n\n#### Features\n\n- [[a482469](https://github.com/boardgameio/boardgame.io/commit/a482469b2f6a317a50fb25f23b7ffc0c2f597c1e)] ability to specify socket server\n\n#### Bugfixes\n\n- [[2ab3dfc](https://github.com/boardgameio/boardgame.io/commit/2ab3dfc6928eb8f0bfdf1ce319ac53021a2f905b)] end turn automatically when game ends\n\n### v0.16.7\n\n#### Bugfixes\n\n- [[c65580d](https://github.com/boardgameio/boardgame.io/commit/c65580d)] Fix bug introduced in af3a7b5.\n\n### v0.16.6\n\n#### Bugfixes\n\n- [[af3a7b5](https://github.com/boardgameio/boardgame.io/commit/af3a7b5)] Only process move reducers (on the client) and nothing else when in multiplayer mode.\n\nBuggy fix (fixed in 0.16.7).\n\n#### Features\n\n- [[2721ad4](https://github.com/boardgameio/boardgame.io/commit/2721ad4)] Allow overriding `db` implementation in Server.\n\n### v0.16.5\n\n#### Features\n\n- `PlayerView.STRIP_SECRETS`\n\n### v0.16.4\n\n#### Bugfixes\n\n- `endPhaseIf` is called after each move (in addition to at the end of a turn).\n- `gameID` is namespaced on the server so that there are no clashes across game types.\n\n#### Breaking Changes\n\n- `props.game` is now `props.events` (to avoid confusing it with the `game` object).\n\n```\n// OLD\nonClick() {\nthis.props.game.endTurn();\n}\n\n// NEW\nonClick() {\nthis.props.events.endTurn();\n}\n```\n\n### v0.16.3\n\n#### Features\n\n- Multiple game types per server!\n\n#### Breaking Changes\n\n- `Server` now accepts an array `games`, and no longer takes `game` and `numPlayers`.\n\n```\nconst app = Server({\ngames: [ TicTacToe, Chess ]\n};\n```\n\n### v0.16.2\n\n#### Bugfixes\n\n- [[a61ceca](https://github.com/boardgameio/boardgame.io/commit/a61ceca8cc8e973d786678e1bcc7ec50739ebeaa)]: Log turn ends correctly (even when triggered automatically by `endTurnIf`)\n\n#### Features\n\n- [[9ce42b2](https://github.com/boardgameio/boardgame.io/commit/9ce42b297372160f3ece4203b4c92000334d85e0)]: Change color in `GameLog` based on the player that made the move.\n\n### v0.16.1\n\n#### Bugfixes\n\n- [[23d9726](https://github.com/boardgameio/boardgame.io/commit/23d972677c6ff43b77d5c30352dd9959b517a93c)]: Fix bug that was causing `log` to be erased after `flow.processMove`.\n\n#### Features\n\n- [Triggers](https://github.com/boardgameio/boardgame.io/commit/774e540b20d7402184a00abdb7c512d7c8e85995)\n- [movesPerTurn](https://github.com/boardgameio/boardgame.io/commit/73d5b73d00eaba9aaf73a3576dfcfb25fc2b311d)\n\n## v0.16.0\n\n#### Features\n\n- [Phases](http://boardgame.io/#/phases)\n\n#### Breaking Changes\n\n- `boardgame.io/game` is now `boardgame.io/core`, and does not have a default export.\n- `boardgame.io/client` no longer has a default export.\n\n```\n// v0.16\nimport { Game } from 'boardgame.io/core'\nimport { Client } from 'boardgame.io/client'\n```\n\n```\n// v0.15\nimport Game from 'boardgame.io/game'\nimport Client from 'boardgame.io/client'\n```\n\n- `victory` is now `endGameIf`, and goes inside a `flow` section.\n- The semantics of `endGameIf` are subtly different. The game ends if\n  the function returns anything at all.\n- `ctx.winner` is now `ctx.gameover`, and contains the return value of `endGameIf`.\n- `props.endTurn` is now `props.game.endTurn`.\n"
  },
  {
    "path": "docs/documentation/api/Client.md",
    "content": "# Client\n\nCreates a `boardgame.io` client. This is the entry point for\nthe client application.\n\n<!-- tabs:start -->\n\n### **Plain JS**\n\n#### Import\n\n```js\nimport { Client } from 'boardgame.io/client';\n```\n\n### Creating a client\n\n#### Arguments\n\n1. `options` (_object_): An object with the following options:\n\n```js\nconst client = Client({\n  // A game definition object.\n  game: game,\n\n  // The number of players.\n  numPlayers: 2,\n\n  // Set this to one of the following to enable multiplayer:\n  //\n  // SocketIO\n  //   Implementation that talks to a remote server using socket.io.\n  //\n  //   How to import:\n  //     import { SocketIO } from 'boardgame.io/multiplayer'\n  //\n  //   Arguments:\n  //     Object with 2 parameters\n  //        1. 'socketOpts' options to pass directly to socket.io client.\n  //        2. 'server' specifies the server location in the format: [http[s]://]hostname[:port];\n  //            defaults to current page host.\n  //\n  // Local\n  //   Special local mode that uses an in-memory game master. Useful\n  //   for testing multiplayer interactions locally without having to\n  //   connect to a server.\n  //\n  //   How to import:\n  //     import { Local } from 'boardgame.io/multiplayer'\n  //\n  // Additionally, you can write your own transport implementation.\n  // See `src/client/client.js` for details.\n  multiplayer: false,\n\n  // Match to connect to (multiplayer).\n  matchID: 'matchID',\n\n  // Associate the client with a player (multiplayer).\n  playerID: 'playerID',\n\n  // The player’s authentication credentials (multiplayer).\n  credentials: 'credentials',\n\n  // Set to false to disable the Debug Panel\n  debug: true/false,\n\n  // Add a Redux enhancer to the internal store.\n  // See “Debugging” guide for more details\n  enhancer: enhancer,\n});\n```\n\n### Using a client\n\n#### Properties\n\nThe following properties are available on a client instance:\n\n- `moves`: An object containing functions to dispatch the\n   moves that you have defined. The functions are named after the\n   moves you created in your [game object](/api/Game.md). Each function\n   can take any number of arguments, and they are passed to the\n   move function after `G` and `ctx`.\n\n\n- `events`: An object containing functions to dispatch various\n   game events like `endTurn` and `endPhase`.\n\n\n- `log`: The game log.\n\n\n- `matchID`: The match ID associated with the client.\n\n\n- `playerID`: The player ID associated with the client.\n\n\n- `credentials`: Multiplayer authentication credentials for this player.\n\n\n- `matchData`: An array containing the players that have joined\n  the current match via the [Lobby API](/api/Lobby.md).\n\n  Example:\n\n  ```js\n  [\n    { id: 0, name: 'Alice' },\n    { id: 1, name: 'Bob', isConnected: true }\n  ]\n  ```\n\n\n- `chatMessages`: An array containing chat messages this client has received.\n  Each message is an object with the following properties:\n\n    - `id`: a unique ID string\n    - `sender`: the `playerID` of the sender\n    - `payload`: the value passed to `sendChatMessage`\n\n  Example:\n\n  ```js\n  [\n    { id: 'foo', sender: '0', payload: 'Ready to play?' },\n    { id: 'bar', sender: '1', payload: 'Let’s go!' },\n  ]\n  ```\n\n\n#### Methods\n\nThe following methods are available on a client instance:\n\n- `start()`: Start running the client. Connects to the multiplayer\n  transport and creates the Debug Panel.\n\n\n- `stop()`: Stop running the client. Disconnects the multiplayer\n  transport and unmounts the Debug Panel.\n\n\n- `getState()`: Get the current game state. Returns `null` if the client\n  still needs to sync with a remote master, otherwise an object:\n\n  ```js\n  {\n    // The game state object `G`.\n    G: { /* ... */ },\n\n    // The game `ctx` (turn, currentPlayer, etc.)\n    ctx: { /* ... */ },\n\n    // State for plugins.\n    plugins: { /* ... */ },\n\n    // The game log.\n    log: [ /* ... */ ],\n\n    // `true` if the client is able to currently make\n    // a move or interact with the game.\n    isActive: true/false,\n\n    // `true` if connection to the server is active.\n    isConnected: true/false,\n  }\n  ```\n\n\n- `subscribe(callback)`: Add a callback for every state change.\n  The passed function will be called with the same value as returned by\n  `getState`. `subscribe` returns an unsubscribe function.\n\n  ```js\n  const unsubscribe = client.subscribe(state => {\n    // use updated state\n  });\n\n  // unsubscribe from the client\n  unsubscribe();\n  ```\n\n\n- `reset()`: Function that resets the game.\n\n\n- `undo()`: Function that undoes the last move.\n\n\n- `redo()`: Function that redoes the previously undone move.\n\n\n- `sendChatMessage(message)`: Function that sends a chat message to other\n  players. The `message` argument can be a string or you can send objects\n  to include more metadata.\n\n\n- `updateMatchID(id)`: Function to update the client’s match ID.\n\n\n- `updatePlayerID(id)`: Function to update the client’s player ID.\n\n\n- `updateCredentials(credentials)`: Function to update the client’s credentials.\n\n\n### **React**\n\n#### Import\n\n```js\nimport { Client } from 'boardgame.io/react';\n```\n\n#### Arguments\n\n1. `options` (_object_): An object with the options shown below under ‘Usage’.\n\n#### Returns\n\nA React component that runs the client.\n\nThe component supports the following `props`:\n\n1. `matchID` (_string_):\n   Connect to a particular match (multiplayer).\n\n2. `playerID` (_string_):\n   Associate the client with a player (multiplayer).\n\n3. `credentials` (_string_):\n   The player’s authentication credentials (multiplayer).\n\n4. `debug` (_boolean_):\n   Set to `false` to disable the Debug UI.\n\n### Usage\n\n```js\nconst App = Client({\n  // A game object.\n  game: game,\n\n  // The number of players.\n  numPlayers: 2,\n\n  // Your React component representing the game board.\n  // The props that this component receives are listed below.\n  // When using TypeScript, type the component's properties as\n  // extending BoardProps.\n  board: Board,\n\n  // Optional: React component to display while the client\n  // is in the \"loading\" state prior to the initial sync\n  // with the game master. Relevant only in multiplayer mode.\n  // If this is not provided, the client displays \"connecting...\".\n  loading: LoadingComponent,\n\n  // Set this to one of the following to enable multiplayer:\n  //\n  // SocketIO\n  //   Implementation that talks to a remote server using socket.io.\n  //\n  //   How to import:\n  //     import { SocketIO } from 'boardgame.io/multiplayer'\n  //\n  //   Arguments:\n  //     Object with 2 parameters\n  //        1. 'socketOpts' options to pass directly to socket.io client.\n  //        2. 'server' specifies the server location in the format: [http[s]://]hostname[:port];\n  //            defaults to current page host.\n  //\n  // Local\n  //   Special local mode that uses an in-memory game master. Useful\n  //   for testing multiplayer interactions locally without having to\n  //   connect to a server.\n  //\n  //   How to import:\n  //     import { Local } from 'boardgame.io/multiplayer'\n  //\n  // Additionally, you can write your own transport implementation.\n  // See `src/client/client.js` for details.\n  multiplayer: false,\n\n  // Set to false to disable the Debug UI.\n  debug: true,\n\n  // An optional Redux store enhancer.\n  // This is useful for augmenting the Redux store\n  // for purposes of debugging or simply intercepting\n  // events in order to kick off other side-effects in\n  // response to moves.\n  enhancer: applyMiddleware(your_middleware),\n});\n\nReactDOM.render(<App />, document.getElementById('app'));\n```\n\n#### Board Props\n\nThe component you pass as the `board` option will receive the\nfollowing as `props`:\n\n- `G`: The game state.\n\n\n- `ctx`: The game metadata.\n\n\n- `moves`: An object containing functions to dispatch various\n   moves that you have defined. The functions are named after the\n   moves you created in your [game object](/api/Game.md). Each function\n   can take any number of arguments, and they are passed to the\n   move function after `G` and `ctx`.\n\n\n- `events`: An object containing functions to dispatch various\n   game events like `endTurn` and `endPhase`.\n\n\n- `reset`: Function that resets the game.\n\n\n- `undo`: Function that undoes the last move.\n\n\n- `redo`: Function that redoes the previously undone move.\n\n\n- `sendChatMessage(message)`: Function that sends a chat message to other\n  players. The `message` argument can be a string or you can send objects\n  to include more metadata.\n\n\n- `chatMessages`: An array containing chat messages this client has received.\n  Each message is an object with the following properties:\n\n    - `id`: a unique ID string\n    - `sender`: the `playerID` of the sender\n    - `payload`: the value passed to `sendChatMessage`\n\n  Example:\n\n  ```js\n  [\n    { id: 'foo', sender: '0', payload: 'Ready to play?' },\n    { id: 'bar', sender: '1', payload: 'Let’s go!' },\n  ]\n  ```\n\n\n- `log`: The game log.\n\n\n- `matchID`: The match ID associated with the client.\n\n\n- `playerID`: The player ID associated with the client.\n\n\n- `matchData`: An array containing the players that have joined\n  the current match via the [Lobby API](/api/Lobby.md).\n\n    Example:\n\n    ```js\n    [\n      { id: 0, name: 'Alice' },\n      { id: 1, name: 'Bob', isConnected: true }\n    ]\n    ```\n\n\n- `isActive`: `true` if the client is able to currently make\n    a move or interact with the game.\n\n\n- `isMultiplayer`: `true` if it is a multiplayer game.\n\n\n- `isConnected`: `true` if connection to the server is active.\n\n\n- `credentials`: Authentication token for this player when using\n    the [Lobby REST API](/api/Lobby.md#server-side-api).\n\n<!-- tabs:end -->\n"
  },
  {
    "path": "docs/documentation/api/Game.md",
    "content": "# Game\n\n?> Using TypeScript? Check out [the TypeScript docs](typescript.md) on how to type your game object.\n\n```js\n{\n  // The name of the game.\n  name: 'tic-tac-toe',\n\n  // Function that returns the initial value of G.\n  // setupData is an optional custom object that is\n  // passed through the Game Creation API.\n  setup: ({ ctx, ...plugins }, setupData) => G,\n\n  // Optional function to validate the setupData before\n  // matches are created. If this returns a value,\n  // an error will be reported to the user and match\n  // creation is aborted.\n  validateSetupData: (setupData, numPlayers) => 'setupData is not valid!',\n\n  moves: {\n    // short-form move.\n    A: ({ G, ctx, playerID, events, random, ...plugins }, ...args) => {},\n\n    // long-form move.\n    B: {\n      // The move function.\n      move: ({ G, ctx, playerID, events, random, ...plugins }, ...args) => {},\n      // Prevents undoing the move.\n      // Can also be a function: ({ G, ctx }) => true/false\n      undoable: false,\n      // Prevents the move arguments from showing up in the log.\n      redact: true,\n      // Prevents the move from running on the client.\n      client: false,\n      // Prevents the move counting towards a player’s number of moves.\n      noLimit: true,\n      // Processes the move even if it was dispatched from an out-of-date client.\n      // This can be risky; check the validity of the state update in your move.\n      ignoreStaleStateID: true,\n    },\n  },\n\n  // Everything below is OPTIONAL.\n\n  // Function that allows you to tailor the game state to a specific player.\n  playerView: ({ G, ctx, playerID }) => G,\n\n  // The seed used by the pseudo-random number generator.\n  seed: 'random-string',\n\n  turn: {\n    // The turn order.\n    order: TurnOrder.DEFAULT,\n\n    // Called at the beginning of a turn.\n    onBegin: ({ G, ctx, events, random, ...plugins }) => G,\n\n    // Called at the end of a turn.\n    onEnd: ({ G, ctx, events, random, ...plugins }) => G,\n\n    // Ends the turn if this returns true.\n    // Returning { next }, sets next playerID.\n    endIf: ({ G, ctx, random, ...plugins }) => (\n      true | { next: '0' }\n    ),\n\n    // Called after each move.\n    onMove: ({ G, ctx, events, random, ...plugins }) => G,\n\n    // Prevents ending the turn before a minimum number of moves.\n    minMoves: 1,\n\n    // Ends the turn automatically after a number of moves.\n    maxMoves: 1,\n\n    // Calls setActivePlayers with this as argument at the\n    // beginning of the turn.\n    activePlayers: { ... },\n\n    stages: {\n      A: {\n        // Players in this stage are restricted to moves defined here.\n        moves: { ... },\n\n        // Players in this stage will be moved to the stage specified\n        // here when the endStage event is called.\n        next: 'B'\n      },\n\n      ...\n    },\n  },\n\n  phases: {\n    A: {\n      // Called at the beginning of a phase.\n      onBegin: ({ G, ctx, events, random, ...plugins }) => G,\n\n      // Called at the end of a phase.\n      onEnd: ({ G, ctx, events, random, ...plugins }) => G,\n\n      // Ends the phase if this returns true.\n      endIf: ({ G, ctx, random, ...plugins }) => true,\n\n      // Overrides `moves` for the duration of this phase.\n      moves: { ... },\n\n      // Overrides `turn` for the duration of this phase.\n      turn: { ... },\n\n      // Make this phase the first phase of the game.\n      start: true,\n\n      // Set the phase to enter when this phase ends.\n      // Can also be a function: ({ G, ctx }) => 'nextPhaseName'\n      next: 'nextPhaseName',\n    },\n\n    ...\n  },\n\n  // The minimum and maximum number of players supported\n  // (This is only enforced when using the Lobby server component.)\n  minPlayers: 1,\n  maxPlayers: 4,\n\n  // Ends the game if this returns anything.\n  // The return value is available in `ctx.gameover`.\n  endIf: ({ G, ctx, random, ...plugins }) => obj,\n\n  // Called at the end of the game.\n  // `ctx.gameover` is available at this point.\n  onEnd: ({ G, ctx, events, random, ...plugins }) => G,\n\n  // Disable undo feature for all the moves in the game\n  disableUndo: true,\n\n  // Transfer delta state with JSON Patch in multiplayer\n  deltaState: true,\n}\n```\n"
  },
  {
    "path": "docs/documentation/api/Lobby.md",
    "content": "# Lobby\n\nThe [Server](/api/Server) hosts the Lobby REST API that can be used to create\nand join matches. It is particularly useful when you want to\nauthenticate clients to prove that they have the right to send\nactions on behalf of a player.\n\nAuthenticated matches are created with server-side tokens for each player.\nYou can create a match with the `create` API call, and join a player to a\nmatch with the `join` API call.\n\nA match that is authenticated will not accept moves from a client on behalf\nof a player without the appropriate credential token.\n\nUse the `create` API call to create a match that requires credential tokens.\nWhen you call the `join` API, you can retrieve the credential token for a\nparticular player.\n\n## Clients\n\n<!-- tabs:start -->\n### **Plain JS**\n\nboardgame.io provides a lightweight wrapper around the Fetch API to simplify\nusing a Lobby API server from the client.\n\n\n```js\nimport { LobbyClient } from 'boardgame.io/client';\n\nconst lobbyClient = new LobbyClient({ server: 'http://localhost:8000' });\n\nlobbyClient.listGames()\n  .then(console.log) // => ['chess', 'tic-tac-toe']\n  .catch(console.error);\n```\n\n### **React**\n\nThe React lobby component provides a more high-level client, including UI\nfor listing, joining, and creating matches.\n\n```js\nimport { Lobby } from 'boardgame.io/react';\nimport { TicTacToe } from './Game';\nimport { TicTacToeBoard } from './Board';\n\n<Lobby\n  gameServer={`https://${window.location.hostname}:8000`}\n  lobbyServer={`https://${window.location.hostname}:8000`}\n  gameComponents={[\n    { game: TicTacToe, board: TicTacToeBoard }\n  ]}\n/>;\n```\n\n`gameComponents` expects an array of objects with these fields:\n\n- `game`: A boardgame.io `Game` definition.\n- `board`: The React component that will render the board.\n\n<!-- tabs:end -->\n\n## REST API\n\n### Listing available game types\n\n#### GET `/games`\n\nReturns an array of names for the games this server is running.\n\n#### Using a LobbyClient instance\n\n```js\nconst games = await lobbyClient.listGames();\n```\n\n### Listing all matches for a given game\n\n#### GET `/games/{name}`\n\nReturns all match instances of the game named `name`.\n\nReturns an array of `matches`. Each instance has fields:\n\n- `matchID`: the ID of the match instance.\n\n- `players`: the list of seats and players that have joined the game, if any.\n\n- `setupData` (optional): custom object that was passed to the game `setup` function.\n\n#### Using a LobbyClient instance\n\n```js\nconst { matches } = await lobbyClient.listMatches('tic-tac-toe');\n```\n\n### Getting a specific match by its ID\n\n#### GET `/games/{name}/{id}`\n\nReturns a match instance given its matchID.\n\nReturns a match instance. Each instance has fields:\n\n- `matchID`: the ID of the match instance.\n\n- `players`: the list of seats and players that have joined the match, if any.\n\n- `setupData` (optional): custom object that was passed to the game `setup` function.\n\n#### Using a LobbyClient instance\n\n```js\nconst match = await lobbyClient.getMatch('tic-tac-toe', 'matchID');\n```\n\n### Creating a match\n\n#### POST `/games/{name}/create`\n\nCreates a new authenticated match for a game named `name`.\n\nAccepts three parameters:\n\n- `numPlayers` (required): the number of players.\n\n- `setupData` (optional): custom object that is passed to the game `setup` function.\n\n- `unlisted` (optional): if set to `true`, the match will be excluded from the public list of match instances.\n\nReturns `matchID`, which is the ID of the newly created game instance.\n\n#### Using a LobbyClient instance\n\n```js\nconst { matchID } = await lobbyClient.createMatch('tic-tac-toe', {\n  numPlayers: 2\n});\n```\n\n### Joining a match\n\n#### POST `/games/{name}/{id}/join`\n\nAllows a player to join a particular match instance `id` of a game named `name`.\n\nAccepts three JSON body parameters:\n\n- `playerName` (required): the display name of the player joining the match.\n\n- `playerID` (optional): the ordinal player in the match that is being joined (`'0'`, `'1'`...).  \nIf not sent, will be automatically assigned to the first available ordinal.\n\n- `data` (optional): additional metadata to associate with the player.\n\nReturns `playerCredentials` which is the token this player will require to authenticate their actions in the future and `playerID`, which can be useful if you didn’t specify a `playerID` when making the request.\n\n#### Using a LobbyClient instance\n\n```js\nconst { playerCredentials } = await lobbyClient.joinMatch(\n  'tic-tac-toe',\n  'matchID',\n  {\n    playerID: '0',\n    playerName: 'Alice',\n  }\n);\n```\n\n### Updating a player’s metadata\n\n#### POST `/games/{name}/{id}/update`\n\nRename and/or update additional metadata for a player in the match instance `id` of a game named `name` previously joined by the player.\n\nAccepts four JSON body parameters, requires at least one of the two optional parameters:\n\n- `playerID` (required): the ID used by the player in the match (0,1...).\n\n- `credentials` (required): the authentication token of the player.\n\n- `newName` (optional): the new name of the player.\n\n- `data` (optional): additional metadata to associate with the player.\n\n#### Using a LobbyClient instance\n\n```js\nawait lobbyClient.updatePlayer('tic-tac-toe', 'matchID', {\n  playerID: '0',\n  credentials: 'playerCredentials',\n  newName: 'Al',\n});\n```\n\n### Leaving a match\n\n#### POST `/games/{name}/{id}/leave`\n\nLeave the match instance `id` of a game named `name` previously joined by the player.\n\nAccepts two JSON body parameters, all required:\n\n- `playerID`: the ID used by the player in the match (0, 1...).\n\n- `credentials`: the authentication token of the player.\n\n#### Using a LobbyClient instance\n\n```js\nawait lobbyClient.leaveMatch('tic-tac-toe', 'matchID', {\n  playerID: '0',\n  credentials: 'playerCredentials',\n});\n```\n\n### Playing again\n\n#### POST `/games/{name}/{id}/playAgain`\n\n- `{name}` (required): the name of the game being played again.\n\n- `{id}` (required): the ID of the previous finished match.\n\nGiven a previous match, generates a match ID where users should go if they want to play again. Creates this new match if it didn't exist before.\n\nAccepts these parameters:\n\n- `playerID` (required): the player ID of the player in the previous match.\n\n- `credentials` (required): player's credentials.\n\n- `numPlayers` (optional): the number of players. Defaults to the `numPlayers` value of the previous match.\n\n- `setupData` (optional): custom object that was passed to the game `setup` function. Defaults to the `setupData` object of the previous room.\n\nReturns `nextMatchID`, which is the ID of the newly created match that the user should go to play again.\n\n#### Using a LobbyClient instance\n\n```js\nconst { nextMatchID } = await lobbyClient.playAgain('tic-tac-toe', 'matchID', {\n  playerID: '0',\n  credentials: 'playerCredentials',\n});\n```\n"
  },
  {
    "path": "docs/documentation/api/Server.md",
    "content": "# Server\n\nCreates a `boardgame.io` server. This is only required when\n`multiplayer` is set to `true` on the client. It creates a\n[Koa](http://koajs.com/) app that keeps track of the game\nstates of the various clients connected to it, and also\nbroadcasts updates to those clients so that all browsers\nthat are connected to the same game are kept in sync in\nrealtime.\n\nThe server also hosts a REST [API](https://boardgame.io/documentation/#/api/Lobby?id=server-side-api) that is used for creating\nand joining games. This is hosted on the same port, but can\nbe configured to run on a separate port.\n\n#### Arguments\n\nA config object with the following options:\n\n1. `games` (_array_) (required): a list of game implementations\n   (each should be an object conforming to the [Game API](/api/Game.md)).\n\n2. `origins` (_array_) (required): a list of allowed origins for\n    [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS \"Cross-Origin Resource Sharing\").\n    \n    The list can contain strings or regular expressions, matching the origins\n    that are allowed to access the game server. For example, this could be\n    `['https://example.com']` if that’s where your game is running. While\n    developing locally you probably want to allow any page running on localhost\n    to connect. See [Usage](#usage) below for an example.\n\n[cors]: https://github.com/expressjs/cors#configuration-options\n\n3. `db` (_object_): the [database connector](/storage).\n   If not provided, an in-memory implementation is used.\n\n4. `transport` (_object_): the transport implementation.\n   If not provided, socket.io is used.\n\n5. `uuid` (_function_): an optional function that returns a unique identifier, used to create new game IDs and — if `generateCredentials` is not specified — player credentials. Defaults to [nanoid](https://www.npmjs.com/package/nanoid).\n\n6. `generateCredentials` (_function_): an optional function that returns player credentials to store in the game metadata and validate against. If not specified, the `uuid` function will be used.\n\n7. `authenticateCredentials` (_function_): an optional function that tests if a player’s move is made with the correct credentials when using the default socket.io transport implementation.\n\n8. `apiOrigins` (_array_): a list of allowed origins for requests to the Lobby API. Defaults\n   to the value provided as the `origins` option (which also applies to the socket transport).\n\n#### Returns\n\nAn object that contains:\n\n1. `run` (_function_): A function to run the server.\n    `(portOrConfig, callback) => ({ apiServer, appServer })`\n\n2. `kill` (_function_): A function to stop the server.\n    `({ apiServer, appServer }) => void`\n\n3. `app` (_object_): The Koa app.\n\n4. `db` (_object_): The database implementation.\n\n5. `router` (_object_): The Koa Router for the server API.\n\n### Usage\n\n#### Basic\n\n```js\nconst { Server, Origins } = require('boardgame.io/server');\n\nconst server = Server({\n  // Provide the definitions for your game(s).\n  games: [game1, game2, ...],\n\n  // Provide the database storage class to use.\n  db: new DbConnector(),\n\n  origins: [\n    // Allow your game site to connect.\n    'https://www.mygame.domain',\n    // Allow localhost to connect, except when NODE_ENV is 'production'.\n    Origins.LOCALHOST_IN_DEVELOPMENT\n  ],\n});\n\nserver.run(8000);\n```\n\n#### With callback\n\n```js\nserver.run(8000, () => console.log(\"server running...\"));\n```\n\n#### With custom Lobby settings\n\nYou can pass `lobbyConfig` to configure the Lobby API during server startup:\n\n```js\nconst lobbyConfig = {\n  apiPort: 8080,\n  apiCallback: () => console.log('Running Lobby API on port 8080...'),\n};\n\nserver.run({ port: 8000, lobbyConfig });\n```\n\nOptions are:\n\n- `apiPort`: If specified, it runs the Lobby API in a separate Koa server on\nthis port. Otherwise, it shares the same Koa server running on the default\nboardgame.io `port`.\n- `apiCallback`: Called when the Koa server is ready. Only applicable if\n`apiPort` is specified.\n\n#### With HTTPS\n\n```js\nconst { Server } = require('boardgame.io/server');\nconst fs = require('fs');\n\nconst server = Server({\n  games: [game1, game2, ...],\n\n  https: {\n    cert: fs.readFileSync('/path/to/cert'),\n    key: fs.readFileSync('/path/to/key'),\n  },\n});\n\nserver.run(8000);\n```\n\n#### With custom authentication\n\n`generateCredentials` is called when a player joins a game with:\n\n- `ctx`: The Koa context object, which can be used to generate tailored credentials from request headers etc.\n\n`authenticateCredentials` is called when a player makes a move with:\n\n  - `credentials`: The credentials sent from the player’s client\n  - `playerMetadata`: The metadata object for the `playerID` making a move\n\nBelow is an example of how you might implement custom authentication with a hypothetical `authService` library.\n\nThe `generateCredentials` method checks for the Authorization header on incoming requests and tries to use it to decode a token. It returns an ID from the result, storing a public user ID as “credentials” in the game metadata.\n\nThe `authenticateCredentials` method passed to the `Server` also expects a similar token, which when decoded matches the ID stored in game metadata.\n\n\n```js\nconst { Server } = require('boardgame.io/server');\n\nconst generateCredentials = async ctx => {\n  const authHeader = ctx.request.headers['authorization'];\n  const token = await authService.decodeToken(authHeader);\n  return token.uid;\n}\n\nconst authenticateCredentials = async (credentials, playerMetadata) => {\n  if (credentials) {\n    const token = await authService.decodeToken(credentials);\n    if (token.uid === playerMetadata.credentials) return true;\n  }\n  return false;\n}\n\nconst server = Server({\n  games: [game1, game2, ...],\n  generateCredentials,\n  authenticateCredentials,\n});\n\nserver.run(8000);\n```\n\n!> N.B. This approach is not currently compatible with how the React `<Lobby>` provides credentials.\n\n### Extending the server\n\nThe boardgame.io server uses [Koa](koajs.com/) and\n[`@koa/router`](https://github.com/koajs/router). You can customise the\nLobby API by accessing the router instance, for example to add routes or\nto add custom middleware for existing routes. See an example of customising\nthe entire Koa app [in the Heroku deployment guide](/deployment.md#frontend-and-backend).\n\n#### Add a custom route\n\n```js\nconst server = Server({ /* options */ });\n\nserver.router.get('/custom-endpoint', (ctx, next) => {\n  ctx.body = 'Hello World!';\n});\n\nserver.run(8000);\n```\n\n#### Add middleware\n\n```js\nconst server = Server({ /* options */ });\n\n// Add middleware to the create game route.\nserver.router.use('/games/:name/create', async (ctx, next) => {\n  // Decide number of players etc. based on some other API.\n  const { numPlayers, setupData } = await fetchDataFromSomeCustomAPI();\n  // Set request body to be used by the create game route.\n  ctx.request.body.numPlayers = numPlayers;\n  ctx.request.body.setupData = setupData;\n  next();\n});\n\nserver.run(8000);\n```\n"
  },
  {
    "path": "docs/documentation/chat.md",
    "content": "# Chat\n\nThe boardgame.io client provides a basic API for sending chat messages between players in a match using the [multiplayer server](multiplayer?id=remote-master).\n\nThe [plain JS client](api/Client?id=properties) and the [React client](api/Client?id=board-props) (via board props) both provide the following properties:\n\n- `sendChatMessage(message)`: Function that sends a chat message to other players. The message argument can be a string or you can send objects to include more metadata. For example, you might decide to include a timestamp along with message text:\n\n    ```js\n    sendChatMessage({ message: 'Hello', time: Date.now() });\n    ```\n\n- `chatMessages`: An array containing chat messages this client has received. Each message is an object with the following properties:\n\n    - `id`: a unique message ID string\n    - `sender`: the `playerID` of the message’s sender\n    - `payload`: the value of the `message` argument passed to `sendChatMessage`\n\n  Example `chatMessages` array:\n\n  ```js\n  [\n      { id: 'foo', sender: '0', payload: 'Ready to play?' },\n      { id: 'bar', sender: '1', payload: 'Let’s go!' },\n  ]\n  ```\n\n### Notes\n\n- **Chat messages are ephemeral and are not stored by the boardgame.io server.** A client only receives messages sent while it is connected to the server. If messages are sent amongst players before another player has connected, the new player will not receive those prior messages. Similarly, if the page is refreshed, any previously received messages will be lost.\n\n- **Only players can send chat messages.** Assuming the match is authenticated via [the Lobby server](api/Lobby), only players are permitted to send messages, which are authenticated using the same logic as other game actions. Spectator clients can receive and view chat messages, but not send messages of their own.\n"
  },
  {
    "path": "docs/documentation/concepts.md",
    "content": "# Concepts\n\n### State\n\nboardgame.io captures game state in two objects: `G` and `ctx`.\n\n```js\n{\n  // The game state (managed by you).\n  G: {},\n\n  // Read-only metadata (managed by the framework).\n  ctx: {\n    turn: 0,\n    currentPlayer: '0',\n    numPlayers: 2,\n  }\n}\n```\n\nThese state objects are passed around everywhere and maintained\non both client and server seamlessly. The state in `ctx` is\nincrementally adoptable, meaning that you can manage all the\nstate manually in `G` if you so desire.\n\n?> `ctx` contains other fields not shown here that games\ncan take advantage of, including support for game phases and complex\nturn orders.\n\n!> Because state can be sent between client and server,\n`G` must be a JSON-serializable object; in particular, it must\nnot contain classes or functions.\n\n### Moves\n\nThese are functions that tell the framework how to change `G`\nwhen a particular game move is made. They must not depend on\nexternal state or have any side-effects (except modifying `G`).\nSee the guide on [Immutability](immutability.md) for how\nimmutability is handled by the framework.\n\n```js\nmoves: {\n  drawCard: ({ G, ctx }) => {\n    const card = G.deck.pop();\n    G.hand.push(card);\n  },\n\n  // ...\n}\n```\n\nOn the client, you use a `moves` object to dispatch your\nmove functions.\n\n<!-- tabs:start -->\n#### **Plain JS**\n\nYou can access `moves` from an instance of the plain JavaScript client:\n\n```js\nclient.moves.drawCard();\n```\n\n#### **React**\n\nUsing React, `moves` is provided through your component’s `props`:\n\n```js\nprops.moves.drawCard();\n```\n\n<!-- tabs:end -->\n\n### Events\n\nThese are framework-provided functions that are analogous to moves, except that they work on `ctx`. These typically advance the game state by doing things like\nending the turn, changing the game phase etc.\nEvents are dispatched from the client in a similar way to moves.\n\n<!-- tabs:start -->\n#### **Plain JS**\n```js\nclient.events.endTurn();\n```\n\n#### **React**\n```js\nprops.events.endTurn();\n```\n<!-- tabs:end -->\n\nFor more details, see the guide on [Events](events.md).\n\n### Phase\n\nA phase is a period in the game that overrides the game\nconfiguration while it is active. For example, you can use\na different set of moves or a different turn order during\na phase. The game can transition between different phases, and turns\noccur inside phases. See the guide on [Phases](phases.md) for more details.\n\n### Turn\n\nA turn is a period of the game that is associated with an individual\nplayer. It typically consists of one or more moves made by\nthat player before it passes on to another player. You can\nalso allow other players to play during your turn, although\nthis is less common. See the guide on\n[Turn Orders](turn-order.md) for more details.\n\n### Stage\n\nA stage is similar to a phase, except that it happens within a turn, and\napplies to individual players rather than the game as a whole.\nA turn may be subdivided into many stages, each allowing a different set of moves\nand overriding other game configuration options while that stage is active.\nAlso, different players can be in different stages during a turn.\nSee the guide on [Stages](stages.md) for more details.\n"
  },
  {
    "path": "docs/documentation/debugging.md",
    "content": "# Debugging\n\n### Using the Debug Panel in production\n\nboardgame.io comes bundled with a debug panel that lets you\ninteract with your game and game clients. When you build your app\nfor production (i.e. when `NODE_ENV === 'production'`) this is stripped\nout from the final bundle.\n\nIf you want to include the debug panel in a production build you can\ndo so explicitly when creating your client:\n\n```js\nimport { Debug } from 'boardgame.io/debug';\n\nconst client = Client({\n  // ...\n  debug: { impl: Debug },\n});\n```\n\n### Debug Panel options\n\nYou can use the `collapseOnLoad` option to hide the panel by default when the client loads. The `hideToggleButton` option removes the toggle button on the side of the panel which means you can only use the keyboard shortcut to toggle its visibility.\n\n```js\nconst client = Client({\n  // ...\n  debug: {\n    // ...\n    collapseOnLoad: true/false,\n    hideToggleButton: true/false\n  },\n});\n```\n\n### Custom metadata in game logs\n\nIt can sometimes be helpful to surface some metadata during a move.\nYou can do this by using the log plugin. For example,\n\n```js\nconst move = ({ log }) => {\n  log.setMetadata('metadata for this move');\n};\n```\n\nThis metadata is stored in the `log` client property and displayed\nin the Log section of the debug panel.\n\n### Redux\n\nThe framework uses Redux under the hood.\nYou may sometimes want to debug this Redux store directly.\nIn order to do so, you can pass along a Redux store enhancer\nwith your client. For example,\n\n```js\nimport logger from 'redux-logger';\nimport { applyMiddleware } from 'redux';\n\nClient({\n  // ...\n  enhancer: applyMiddleware(logger),\n});\n```\n\nDoing so will `console.log` on state changes. This can also hook into the [Chrome Redux DevTools](http://extension.remotedev.io/) browser extension like this:\n\n```js\nClient({\n  // ...\n  enhancer: (\n    window.__REDUX_DEVTOOLS_EXTENSION__\n    && window.__REDUX_DEVTOOLS_EXTENSION__()\n  ),\n})\n```\n\nor both\n\n```js\nimport logger from 'redux-logger';\nimport { applyMiddleware, compose } from 'redux';\n\nClient({\n  // ...\n  enhancer: compose(\n    applyMiddleware(logger),\n    (window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__())\n  ),\n})\n```\n\n### Server + Sockets\n\nThe Koa-server can be debugged by setting the `DEBUG` environment variable before starting it.\nThis will give you access to logs of incoming requests as well as the socket.io logs.\nTo set the environment variable prepend your npm script to run the server like so:\n\n```\nDEBUG=* node server.js\n```\n\n> NOTE: For various debugging scopes have a look at the [socket.io-docs](https://socket.io/docs/v4/logging-and-debugging/#available-debugging-scopes)\n"
  },
  {
    "path": "docs/documentation/deployment.md",
    "content": "# Deployment\n\n## Serverless Options\n\nFor one-player or pass-and-play games, you may not need the boardgame.io game\nserver and prefer to serve an app that runs entirely on the client. If you\ndon’t need multiplayer features, this can be a lot simpler than getting a\nNode.js server deployed.\n\nThere are many services that can help deploy a static app, including some that\noffer free options like [Netlify](https://www.netlify.com/) and\n[Render](https://render.com/).\n\n<!-- tabs:start -->\n\n### **Plain JS**\n\nIf you followed along with the Plain JS tutorial, you can also use Parcel to\nbuild your app for production.\n\nAdd a build script to your `package.json`:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"parcel build index.html --out-dir build\",\n  }\n}\n```\n\nRunning `npm run build` will now create an optimised production build in\n`/build`, which you can host just about anywhere.\n\n#### Deployment configuration\n\nBoth Netlify and Render offer options to continuously deploy the latest version\nof your app from a Git repository. These configurations should help you get\nup and running with these services.\n\n<details>\n<summary><strong>Netlify</strong></summary>\n\n1. Create a new deployment (see [Netlify docs](https://docs.netlify.com/site-deploys/create-deploys/)).\n\n2. Use the following values for the deployment:\n\n  | Option            | Value           |\n  |-------------------|-----------------|\n  | Build Command     | `npm run build` |\n  | Publish Directory | `build`         |\n\n</details>\n\n<details>\n<summary><strong>Render</strong></summary>\n\n1. Create a new Web Service on Render and connect it to your project repository.\n\n2. Use the following values during creation:\n\n  | Option            | Value           |\n  |-------------------|-----------------|\n  | Environment       | `Static Site`   |\n  | Build Command     | `npm run build` |\n  | Publish Directory | `build`         |\n\n</details>\n\n### **React**\n\nRunning `npm run build` in a Create React App project will create an optimised\nproduction build in `/build`, which you can host just about anywhere.\n\n#### Deployment guides\n\n- **Netlify:** See [the guide on how to deploy to Netlify](https://create-react-app.dev/docs/deployment/#netlify) in the Create React App docs.\n\n- **Render:** See [“Deploy a Create React App Static Site”](https://render.com/docs/deploy-create-react-app) in the Render docs.\n\n<!-- tabs:end -->\n\n## Heroku\n[Heroku](https://heroku.com) uses 2 different ways to determine the run command of a node application. It is possible to either:\n\n- Add a Procfile to the project root directory with the following line  \n  `web: node -r esm server.js`\n\n- Update the start script in the package.json to  \n  `\"start\": \"node -r esm server.js\"`\n\nOn Heroku, a regular heroku/nodejs buildpack is necessary to build your app which is usually selected by default for node applications.  \n\n### Frontend and Backend\nIn order to deploy a game to Heroku, the game has to be running on a single port. To do so, the [Server](/api/Server.md) has to handle both the API requests and serving the pages.  \nBelow is an example of how to achieve that.\n\nFirst install these extra dependencies:\n\n```\nnpm i koa-static\n```\nThen adjust your `server.js` file like this:\n\n```js\n// server.js\n\nimport { Server } from 'boardgame.io/server';\nimport path from 'path';\nimport serve from 'koa-static';\nimport { TicTacToe } from './game';\n\nconst server = Server({ games: [TicTacToe] });\nconst PORT = process.env.PORT || 8000;\n\n// Build path relative to the server.js file\nconst frontEndAppBuildPath = path.resolve(__dirname, './build');\nserver.app.use(serve(frontEndAppBuildPath))\n\nserver.run(PORT, () => {\n  server.app.use(\n    async (ctx, next) => await serve(frontEndAppBuildPath)(\n      Object.assign(ctx, { path: 'index.html' }),\n      next\n    )\n  )\n});\n```\n\nThe [Lobby](/api/Lobby.md) might be as follows:\n\n```jsx\nimport React from 'react';\nimport { Lobby } from 'boardgame.io/react';\nimport { TicTacToeBoard } from './board';\nimport { TicTacToe } from './game';\n\nconst { protocol, hostname, port } = window.location;\nconst server = `${protocol}//${hostname}:${port}`;\nconst importedGames = [{ game: TicTacToe, board: TicTacToeBoard }];\n\nexport default () => (\n  <div>\n    <h1>Lobby</h1>\n    <Lobby gameServer={server} lobbyServer={server} gameComponents={importedGames} />\n  </div>\n);\n```\n\nOr, without the lobby, pass the server address when calling `SocketIO`:\n\n```js\nimport { SocketIO } from 'boardgame.io/multiplayer';\n\nconst { protocol, hostname, port } = window.location;\nconst server = `${protocol}//${hostname}:${port}`;\n\nconst GameClient = Client({\n  // ...\n  multiplayer: SocketIO({ server }),\n});\n```\n\n### Backend Only\nIf you only need to publish your backend to Heroku, your `server.js` can be simplified to this:\n\n```js\n// server.js\n\nimport { Server } from 'boardgame.io/server';\nimport { TicTacToe } from './game';\n\nconst server = Server({ games: [TicTacToe] });\nconst PORT = process.env.PORT || 8000;\n\nserver.run(PORT);\n```\n\nAnd your [Lobby](/api/Lobby.md) would now be pointing to your Heroku app URL:\n```jsx\nimport React from 'react';\nimport { Lobby } from 'boardgame.io/react';\nimport { TicTacToeBoard } from './board';\nimport { TicTacToe } from './game';\n\nconst server = `https://yourapplication.herokuapp.com`;\nconst importedGames = [{ game: TicTacToe, board: TicTacToeBoard }];\n\nexport default () => (\n  <div>\n    <h1>Lobby</h1>\n    <Lobby gameServer={server} lobbyServer={server} gameComponents={importedGames} />\n  </div>\n);\n```\n\nOr, without the lobby, pass the Heroku app URL when calling `SocketIO`:\n\n```js\nimport { SocketIO } from 'boardgame.io/multiplayer';\n\nconst GameClient = Client({\n  // ...\n  multiplayer: SocketIO({ server: 'https://yourapplication.herokuapp.com' }),\n});\n```\n"
  },
  {
    "path": "docs/documentation/events.md",
    "content": "# Events\n\nAn event is used to advance the game state. It is somewhat\nanalogous to a move, except that while a move changes\n`G`, an event changes `ctx`. Also, events are provided by the\nframework (as opposed to moves, which are written by you).\n\n### Event Types\n\n#### endStage\n\nThis event takes the player that called it out of the stage\nthat they are in. If the definition for the current stage\nin the game object specifies a `next` option, then the player\nis taken to the next stage. If not, the player is\nreturned to a state where they are not in any stage.\n\n```js\nendStage();\n```\n\n#### endTurn\n\nThis event ends the turn.\nThe default behavior is to increment `ctx.turn` by `1`\nand advance `currentPlayer` to the next player according\nto the configured [turn order](turn-order.md) (the default being a round-robin).\n\nThis event also accepts an argument, which (if provided)\nswitches the turn to the specified player instead.\n\n```js\nendTurn(); // without argument\nendTurn({ next: '2' }); // Player 2 is the next player.\n```\n\n#### endPhase\n\nThis event ends the current phase. If the definition for the\ncurrent phase in the game object specifies a\n`next` option, then the game moves to that phase. If not, the\ngame returns to a state where no phase is active.\n\n```js\nendPhase();\n```\n\n#### endGame\n\nThis event ends the game. If you pass an argument to it,\nthen that argument is made available in `ctx.gameover`.\nAfter the game is over, further state changes to the game\n(via a move or event) are not possible.\n\n```js\nendGame();\n```\n\n#### setStage\n\nTakes the player that called the event into the stage specified.\n\n```js\nsetStage('stage-name');\n```\n\n#### setPhase\n\nTakes the game into the phase specified. Ends the active phase first.\n\n```js\nsetPhase('phase-name');\n```\n\n#### setActivePlayers\n\nAllows adding additional players to the set of \"active players\", and\nalso any stages that you want to put them in. See the guide on [Stages](stages.md)\nfor more details.\n\n### Triggering an event from game logic.\n\nYou can trigger events from a move or code inside\nyour game logic (a phase’s `onBegin` hook, for example).\nThis is done through the `events` API in the object passed\nas the first argument to moves:\n\n```js\nmoves: {\n  drawCard: ({ G, ctx, events }) => {\n    events.endPhase();\n  };\n}\n```\n\n!> Events are queued up and triggered **after** a move.\nAny changes you make to `G` will be applied before events are\ntriggered, even if the event is called first in your move function.\n\n### Triggering an event from the client\n\n<!-- tabs:start -->\n\n#### **Plain JS**\n\nEvents are available inside the `events` property of\na boardgame.io client instance. For example:\n\n```js\nimport { Client } from 'boardgame.io/client';\n\nconst client = Client({ /* options */ });\n\nconst clickHandler = () => {\n  client.events.endTurn();\n}\n```\n\n#### **React**\n\nEvents are available through `props` inside the\n`events` object. For example:\n\n```js\nimport React from 'react';\n\nfunction Board({ events }) {\n  const onClick = () => {\n    events.endTurn();\n  };\n\n  return <button onClick={onClick}>End Turn</button>;\n}\n```\n<!-- tabs:end -->\n\n### Disabling events\n\nEvents can be disabled. For example, you might not want a\nplayer to be able to end the game directly by simply calling\nthe `endGame` event.\n\nIn order to disable an event, just add `eventName: false` to\nthe `events` section in your game config.\n\n```js\nconst game = {\n  events: {\n    endGame: false,\n    // ...\n  },\n};\n```\n\n!> This doesn't apply to events in moves or hooks, but just the\nability to call an event directly from a client.\n\n### Calling events from hooks\n\nThe events API is available in game hooks like it is inside moves. However,\nbecause of how hooks and events interact, certain events cannot be called from\ncertain hooks. The following table shows which hooks support which events.\n\n|                    | turn<br>`onMove` | turn<br>`onBegin` | turn<br>`onEnd` | phase<br>`onBegin` | phase<br>`onEnd` | game<br>`onEnd` |\n|-------------------:|:----------------:|:-----------------:|:---------------:|:------------------:|:----------------:|:---------------:|\n|         `setStage` |         ✅        |         ❌         |        ❌        |          ❌         |         ❌        |        ❌        |\n|         `endStage` |         ✅        |         ❌         |        ❌        |          ❌         |         ❌        |        ❌        |\n| `setActivePlayers` |         ✅        |         ✅         |        ❌        |          ❌         |         ❌        |        ❌        |\n|          `endTurn` |         ✅        |         ✅         |        ❌        |          ✅         |         ❌        |        ❌        |\n|         `setPhase` |         ✅        |         ✅         |        ✅        |          ✅         |         ❌        |        ❌        |\n|         `endPhase` |         ✅        |         ✅         |        ✅        |          ✅         |         ❌        |        ❌        |\n|          `endGame` |         ✅        |         ✅         |        ✅        |          ✅         |         ✅        |        ❌        |\n\n✅ = supported &nbsp;&nbsp;&nbsp; ❌ = not supported\n"
  },
  {
    "path": "docs/documentation/immutability.md",
    "content": "# Immutability\n\nThe principle of immutability as applied to state changing\nfunctions like moves in [boardgame.io](https://boardgame.io/)\nmandates that they be pure functions. What this means is that\nyou cannot depend on any **external state**, nor can you have any\n**side-effects**, i.e. you cannot modify anything that isn't\na local variable (not even the arguments).\n\nThe benefits of architecting a system with this principle are\nthat you can ensure repeatability (moves can be replayed\nover a particular state value multiple times in different places)\nand you can do cheap comparisons to check if something changed.\n\nA traditional pure function just accepts arguments and then\nreturns the new state. Something like this:\n\n```js\nfunction move({ G }) {\n  // Return new value of G without modifying the arguments.\n  return { ...G, hand: G.hand + 1 };\n}\n```\n\n?> The example above uses the\n[spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) to create a new object.\n\n[boardgame.io](https://boardgame.io/) provides a more convenient\nsyntax by allowing you to mutate `G` directly while using\na [library](https://github.com/mweststrate/immer) under the hood\nto convert your move into a pure function that respects the\nimmutability principle. Both styles are supported interchangeably,\nso use the one that you prefer.\n\n```js\nfunction move({ G }) {\n  G.hand++;\n}\n```\n\n?> Note that in this style you do not return the new state.\nIn fact, returning something while also mutating `G` is\nconsidered an error.\n\n!> You can only modify `G`. Other values passed to your moves\n   are read-only and should never be modified in either style.\n   Changes to `ctx` can be made using [events](events.md).\n\n### Invalid moves\n\nIn both styles, invalid moves are indicated by returning a\nspecial constant. This tells the framework that the current\nset of arguments passed in is illegal and that the move\nought to be discarded. For example, you might do this if\nthe user tries to click on an already filled cell in\nTic-Tac-Toe.\n\n```js\nimport { INVALID_MOVE } from 'boardgame.io/core';\n\nmoves: {\n  clickCell: function({ G, ctx }, id) {\n    // Illegal move: Cell is filled.\n    if (G.cells[id] !== null) {\n      return INVALID_MOVE;\n    }\n\n    // Fill cell with 0 or 1 depending on the current player.\n    G.cells[id] = ctx.currentPlayer;\n  }\n}\n```\n\n### Additional Reading\n\n[Immutable Update Patterns](https://redux.js.org/recipes/structuring-reducers/immutable-update-patterns)\n"
  },
  {
    "path": "docs/documentation/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <title>boardgame.io</title>\n  <meta name=\"description\" content=\"Open-Source JavaScript Game Engine for Turn-Based Games\">\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n  <meta name=\"twitter:card\" content=\"summary_large_image\">\n  <meta name=\"twitter:creator\" content=\"@nicolodavis\">\n  <meta name=\"twitter:title\" content=\"boardgame.io\">\n  <meta name=\"twitter:image\" content=\"https://res.cloudinary.com/dyfmhmho5/image/upload/v1543585150/logo_w1snck.png\">\n  <meta name=\"twitter:description\" content=\"Open Source Game Engine for Turn-Based Games\">\n  <link rel=\"shortcut icon\" href=\"https://raw.githubusercontent.com/boardgameio/boardgame.io/main/docs/favicon.png\" type=\"image/png\" sizes=\"16x16\">\n  <link rel=\"stylesheet\" href=\"//unpkg.com/docsify-themeable@0/dist/css/theme-simple.css\">\n  <link rel=\"stylesheet\" href=\"theme.css\">\n\n  <style>\n  .gitter-open-chat-button {\n    right: 1%;\n    font-family: var(--base-font-family);\n    letter-spacing: .2ch;\n    background: var(--theme-color);\n    box-shadow: 0 4px 13px var(--mono-base);\n  }\n\n  @media screen and (min-width: 768px) {\n    .gitter-open-chat-button {\n      font-size: .9375em;\n    }\n  }\n\n  iframe {\n    box-shadow: 0 0 10px var(--mono-tint2);\n    border-radius: var(--border-radius-l);\n    background: var(--mono-tint3);\n  }\n\n  iframe.plain {\n    box-shadow: none;\n    border: none;\n    background: transparent;\n    min-width: 0;\n    width: 100%;\n  }\n\n  @media only screen and (max-device-width: 500px) {\n    iframe.react {\n      max-height: 60vh;\n    }\n  }\n  </style>\n</head>\n\n<body>\n  <div id=\"app\"></div>\n</body>\n\n<script>\n  window.$docsify = {\n    name: 'boardgame.io',\n    nameLink: {\n      '/': '..'\n    },\n    repo: 'https://github.com/boardgameio/boardgame.io',\n    logo: '../logo-optimized.svg',\n    homepage: 'concepts.md',\n    loadSidebar: 'sidebar.md',\n    subMaxLevel: 2,\n    auto2top: true,\n    search: 'auto', // default\n    pagination: {}, // default\n    plugins: [],\n    markdown: {\n      renderer: {\n        code: function(code, lang) {\n          if (lang == 'codepen') {\n            return code;\n          }\n          if (lang == 'react') {\n            return code;\n          }\n          return this.origin.code.apply(this, arguments);\n        }\n      }\n    }\n  }\n</script>\n\n<script src=\"//unpkg.com/docsify@4\"></script>\n<script src=\"//unpkg.com/docsify-themeable@0\"></script>\n<script src=\"//unpkg.com/docsify@4/lib/plugins/search.min.js\"></script>\n<script src=\"//unpkg.com/docsify-pagination@2/dist/docsify-pagination.min.js\"></script>\n<script src=\"//unpkg.com/docsify-tabs@1\"></script>\n<script src=\"//unpkg.com/docsify-edit-on-github@1/index.js\"></script>\n<script src=\"//cdn.jsdelivr.net/npm/prismjs@1/components/prism-json.min.js\"></script>\n<script src=\"//cdn.jsdelivr.net/npm/prismjs@1/components/prism-jsx.min.js\"></script>\n<script src=\"//cdn.jsdelivr.net/npm/prismjs@1/components/prism-typescript.min.js\"></script>\n<script>\n  window.$docsify.plugins.push(EditOnGithubPlugin.create(\n    'https://github.com/boardgameio/boardgame.io/blob/main/docs/documentation/',\n    null,\n    'Edit on GitHub'\n  ));\n</script>\n\n<script>\n  ((window.gitter = {}).chat = {}).options = {\n    room: 'boardgame-io/General'\n  };\n</script>\n<script src=\"https://sidecar.gitter.im/dist/sidecar.v1.js\" async defer></script>\n\n</html>\n"
  },
  {
    "path": "docs/documentation/multiplayer.md",
    "content": "# Multiplayer\n\nIn this section, we'll explain how the framework converts your\ngame logic into a multiplayer implementation without requiring\nyou to write any networking or storage layer code. We will continue\nworking with our Tic-Tac-Toe example from the [tutorial](tutorial.md).\n\n### Clients and Masters\n\nA boardgame.io client is what you create using the `Client` call.\nYou initialize it with your game object (which contains the moves),\nso it has all the information that is needed to run the game.\nThis is where the story ends in a single player setup.\n\nIn a multiplayer setup, clients no longer act as authoritative\nstores of the game state. Instead, they delegate the running of the\ngame to a game master. In this mode clients emit moves / events,\nbut the game logic runs on the master, which computes the next game state\nbefore broadcasting it to other clients.\n\nHowever, since clients are aware of the game rules, they also\nrun the game in parallel (this is called an optimistic update and is\nan optimization that provides a lag-free experience).\nIn case a particular client computes the new game state incorrectly,\nit is overridden by the master eventually, so the entire setup still\nhas a single source of authority. If a move accesses state that is not\naccessible to the client (for instance secret state), then optimistic\nupdates may need to be disabled for that move. See the\n[secret state documentation](secret-state.md) for more details.\n\n## Local Master\n\nThe game master can run completely on the browser. This is useful to set\nup pass-and-play multiplayer or for prototyping the multiplayer experience\nwithout having to set up a server to test it.\n\nTo do this `import { Local } from 'boardgame.io/multiplayer'`,\nand add `multiplayer: Local()` to the client options.\nNow you can instantiate as many of these clients in your app as you like and\nyou will notice that they’re all kept in sync, sharing the same state.\n\n<!-- tabs:start -->\n\n#### **Plain JS**\n\nLet’s update our `TicTacToeClient` to receive an additional `playerID`\noption in its constructor. We’ll use this so that each client knows\nwhich player it is playing for.\n\nThen, we’ll update how we create the boardgame.io client, passing\n`playerID` and setting `multiplayer` to use the Local Master.\n\n```js\nimport { Client } from 'boardgame.io/client';\nimport { Local } from 'boardgame.io/multiplayer';\nimport { TicTacToe } from './Game';\n\nclass TicTacToeClient {\n  constructor(rootElement, { playerID } = {}) {\n    this.client = Client({\n      game: TicTacToe,\n      multiplayer: Local(),\n      playerID,\n    });\n    // ...\n  }\n  // ...\n}\n````\n\nNow instead of rendering one client into our app, we’ll render\none for each player ID:\n\n```js\nconst appElement = document.getElementById('app');\nconst playerIDs = ['0', '1'];\nconst clients = playerIDs.map(playerID => {\n  const rootElement = document.createElement('div');\n  appElement.append(rootElement);\n  return new TicTacToeClient(rootElement, { playerID });\n});\n```\n\n[![Edit bgio-plain-js-multiplayer](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/bgio-plain-js-multiplayer-re48t?fontsize=14&hidenavigation=1&module=%2Fsrc%2FApp.js&theme=dark)\n\n#### **React**\n\n```js\n// src/App.js\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport { TicTacToe } from './Game';\nimport { TicTacToeBoard } from './Board';\n\nconst TicTacToeClient = Client({\n  game: TicTacToe,\n  board: TicTacToeBoard,\n  multiplayer: Local(),\n});\n\nconst App = () => (\n  <div>\n    <TicTacToeClient playerID=\"0\" />\n    <TicTacToeClient playerID=\"1\" />\n  </div>\n);\n\nexport default App;\n```\n\n[![Edit boardgame.io](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/boardgameio-dibw3)\n<!-- tabs:end -->\n\n?> You may be wondering what the `playerID` parameter is from the\nexample above. Clients needs to be associated with a particular player\nseat in order to make moves in a multiplayer setup. (If a client doesn’t have\na `playerID` it is a spectator that can see the live game state, but can't\nactually make any moves.)\n\n```react\n<iframe class='plain' src='snippets/multiplayer' height='250' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>\n```\n\nIn the example above you can play as Player 0 and Player 1 alternately\non the two boards. Clicking on a particular board when it is not that\nplayer's turn has no effect.\n\n### Storing state in the browser\n\nIf you want game state to be saved in the browser using `localStorage`,\nyou can pass additional options when creating a local master:\n\n```js\nLocal({\n  // Enable localStorage cache.\n  persist: true,\n\n  // Set custom prefix to store data under. Default: 'bgio'.\n  storageKey: 'bgio',\n});\n```\n\n## Remote Master\n\nYou can also run the game master on a separate server. Any boardgame.io\nclient can connect to this master (whether it is a browser, an Android\napp etc.) and it will be kept in sync with other clients in realtime.\n\nIn order to connect a client to a remote master, we use the `multiplayer`\noption again, but this time we import `SocketIO` instead of `Local`,\nand specify the location of the server.\n\n<!-- tabs:start -->\n\n#### **Plain JS**\n\n```js\nimport { SocketIO } from 'boardgame.io/multiplayer'\n\nclass TicTacToeClient {\n  constructor(rootElement, { playerID } = {}) {\n    this.client = Client({\n      game: TicTacToe,\n      multiplayer: SocketIO({ server: 'localhost:8000' }),\n      playerID,\n    });\n    // ...\n  }\n  // ...\n}\n```\n\nWe also need to make a small tweak to our `update` method.\nWhen using a remote master, the client won’t know the game state\nwhen it first runs, so `update` will be called first with `null`,\nthen with the full game state after it connects to the server.\n\nIn a real implementation you might show a loading spinner to indicate\nthis, but we’ll just skip our `update` for now if state is `null`:\n\n```js\nupdate(state) {\n  if (state === null) return;\n  // ...\n}\n```\n\n#### **React**\n\n```js\nimport { SocketIO } from 'boardgame.io/multiplayer'\n\nconst TicTacToeClient = Client({\n  game: TicTacToe,\n  board: TicTacToeBoard,\n  multiplayer: SocketIO({ server: 'localhost:8000' }),\n});\n```\n\n<!-- tabs:end -->\n\nBehind the scenes, the client now sends updates to the remote master\nvia a WebSocket whenever you make a move. Of course, we now need to run\na server at the location specified, which is discussed below.\n\n### Setting up the server\n\nWe’ll create a new file at `src/server.js` to write our server code.\n\nboardgame.io provides a server module that simplifies running the game\nmaster on a Node server. We import that module and configure it with our\n`TicTacToe` game object and a list of URL origins we want to allow to\nconnect to the server. Later you would set `origins` with your game’s domain\nname, but for now we’ll import a default value that allows any locally served\npage to connect.\n\n```js\n// src/server.js\nconst { Server, Origins } = require('boardgame.io/server');\nconst { TicTacToe } = require('./Game');\n\nconst server = Server({\n  games: [TicTacToe],\n  origins: [Origins.LOCALHOST],\n});\n\nserver.run(8000);\n```\n\n?> See [the Server reference page](api/Server.md) for more detail on\n   the various configuration options.\n\nBecause `Game.js` is an ES module, we will use [esm](https://github.com/standard-things/esm)\nwhich enables us to use `import` statements in a Node environment:\n\n```\nnpm install esm\n```\n\nWe can then add a new script to our `package.json` to simplify\nrunning the server:\n\n```json\n{\n  \"scripts\": {\n    \"serve\": \"node -r esm src/server.js\"\n  }\n}\n```\n\nWe can now run `npm run serve` in one terminal to start the server and\n`npm start` in another to serve our web app.\nYou can connect multiple clients to the same game by opening\nyour app in several different browser tabs.\nYou will notice that everything is kept in sync as you play\n(state is not lost even if you refresh the page).\n\nThis example still has both players on the same screen. A more natural\nsetup would be to have each client just have a single (but distinct)\nplayer.\n\n<!-- tabs:start -->\n#### **Plain JS**\n\nYou want one client to render:\n```js\nnew TicTacToeClient(appElement, { playerID: '0' });\n```\n\nand another to render:\n```js\nnew TicTacToeClient(appElement, { playerID: '1' });\n```\n\n#### **React**\n\nYou want one client to render:\n```\n<TicTacToeClient playerID=\"0\" />\n```\n\nand another to render:\n```\n<TicTacToeClient playerID=\"1\" />\n```\n<!-- tabs:end -->\n\nOne way to do this is to ask the player which seat they\nwant to take when they open your app and then set the\n`playerID` accordingly. You can also use a URL path to\ndetermine the player or use a matchmaking lobby.\n\nComplete code from this section is available on CodeSandbox for both\n[React](https://codesandbox.io/s/boardgameio-fsl8y) and\n[Plain JS](https://codesandbox.io/s/bgio-plain-js-multiplayer-server-742oh)\nversions.\nTo run the server, you can click **File** > **Export to ZIP** to download\nthe project, then run the server and client as described\nabove. Don't forget to run `npm install` in the project directory first!\n\n?> **TIP** You can also set the `playerID` to point to any player while\nprototyping by clicking on the box of that respective player on the debug UI.\n\n### Multiple Game Types\n\nYou can serve multiple types of games from the same server:\n\n```js\nconst app = Server({ games: [TicTacToe, Chess] });\n```\n\nFor this to work correctly, make sure that each game\nimplementation specifies a name:\n\n```js\nconst TicTacToe = {\n  name: 'tic-tac-toe',\n  // ...\n};\n```\n\n### Game Instances\n\nBy default all client instances connect to a game with\nan ID `'default'`. To play a new game instance, you can pass\n`matchID` to your client. All clients that use\nthis ID will now see the same game state.\n\n<!-- tabs:start -->\n\n#### **Plain JS**\n\nPass `matchID` when creating your boardgame.io client:\n```js\nconst client = Client({\n  game: TicTacToe,\n  matchID: 'matchID',\n  // ...\n});\n```\n\nYou an also update a `matchID` on an already instantiated client:\n```js\nclient.updateMatchID('newID');\n```\n\n#### **React**\n\n```\n<TicTacToeClient matchID=\"match-id\"/>\n```\n<!-- tabs:end -->\n\nThe `matchID`, similar to the `playerID` can again be determined\neither by a URL path or a lobby implementation.\n\n### Storage\n\nThe default storage implementation is an in-memory map.\nIf you want something that's more persistent, you can use one\nof the available database connectors, or even implement your own.\n\nSee [the storage docs](storage.md) for more details.\n"
  },
  {
    "path": "docs/documentation/notable_projects.md",
    "content": "# Projects\n\nNonexhaustive list of notable projects using boardgame.io. Feel free to send a PR to add your project to this list, but please have a demo that's accessible via a URL.\n\n\n#### [![GitHub stars][b-ark]][c-ark] [Arknights: The Card Game (明日方舟: 采掘行动)][p-ark] \\[[code][c-ark]\\]\n&nbsp;&nbsp;\nA challenging single-player roguelike card game that is played locally, in Chinese.\n\n[b-ark]: https://img.shields.io/github/stars/dadiaogames/arknights-card-game?label=%E2%98%85&logo=github\n[p-ark]: https://dadiaogames.github.io/arknights-card-game/\n[c-ark]: https://github.com/dadiaogames/arknights-card-game\n\n#### [![GitHub stars][b1]][c1] Bad Flamingo \\[[code][c1]\\]\n&nbsp;&nbsp;\nFool the computer, but not your friends! Adversarial \"Quick, Draw\".\n\n[b1]: https://img.shields.io/github/stars/jayelm/bad-flamingo?label=%E2%98%85&logo=github\n[c1]: https://github.com/jayelm/bad-flamingo\n\n#### [![GitHub stars][b-bl]][c-bl]  [Battle Line][p-bl] \\[[code][c-bl]\\]\n&nbsp;&nbsp;\nClone of Battle Line, a 2 player card game.\n\n[b-bl]: https://img.shields.io/github/stars/rsandzimier/battleline?label=%E2%98%85&logo=github\n[c-bl]: https://github.com/rsandzimier/battleline\n[p-bl]: https://rsandzimier.github.io/battleline/\n\n#### [![GitHub stars][jwbj-3]][jwbj-2]  [Black Jack (John Wick theme)][jwbj-1] \\[[code][jwbj-2]\\]\n&nbsp;&nbsp;\nA John Wick-themed Black Jack card game with custom graphics and sound.\n\n[jwbj-3]: https://img.shields.io/github/stars/ipkevin/Blackjack-Builder?label=%E2%98%85&logo=github\n[jwbj-2]: https://github.com/ipkevin/Blackjack-Builder\n[jwbj-1]: https://johnwickblackjack.netlify.app/\n\n#### [![GitHub stars][b2]][c2] boardgame.io-angular \\[[code][c2] | [demo][d2]\\]\n&nbsp;&nbsp;\nUnofficial Angular client for boardgame.io.\n\n[b2]: https://img.shields.io/github/stars/turn-based/boardgame.io-angular?label=%E2%98%85&logo=github\n[c2]: https://github.com/turn-based/boardgame.io-angular\n[d2]: https://turn-based-209306.firebaseapp.com/\n\n#### [![GitHub stars][b-bri]][c-bri] [Briscola][p-bri] \\[[code][c-bri] | [demo][d-bri]\\]\n&nbsp;&nbsp;\nOnline 2-player variant of the Briscola card game.\n\n[p-bri]: https://instant-briscola.herokuapp.com/\n[c-bri]: https://github.com/aflorj/briscola\n[d-bri]: https://instant-briscola.herokuapp.com/demo\n[b-bri]: https://img.shields.io/github/stars/aflorj/briscola?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b3]][c3]  [Camelot][p3] \\[[code][c3]\\]\n&nbsp;&nbsp;\nPlay the Camelot board game online.\n\n[b3]: https://img.shields.io/github/stars/blunket/camelot?label=%E2%98%85&logo=github\n[c3]: https://github.com/blunket/camelot\n[p3]: https://www.playcamelot.com\n\n\n#### [![GitHub stars][b4]][c4] [Can't Stop!][p4] \\[[code][c4]\\]\n&nbsp;&nbsp;\nThe classic \"push your luck\" dice game.\n\n[b4]: https://img.shields.io/github/stars/simlmx/cantstop?label=%E2%98%85&logo=github\n[c4]: https://github.com/simlmx/cantstop\n[p4]: https://cantstop.fun\n\n\n#### [![GitHub stars][b5]][c5] [Cardman Multiplayer][p5] \\[[code][c5]\\]\n&nbsp;&nbsp;\nA cross between Hangman and a card game.\n\n[p5]: http://cardman-multiplayer.herokuapp.com\n[c5]: https://github.com/VengelStudio/cardman-multiplayer\n[b5]: https://img.shields.io/github/stars/VengelStudio/cardman-multiplayer?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b-chessweeper]][c-chessweeper] [Chessweeper][p-chessweeper] \\[[code][c-chessweeper]\\]\n&nbsp;&nbsp;\nA mix between Chess and Minesweeper \n\n[p-chessweeper]: https://chessweeper.zirk.eu\n[c-chessweeper]: https://github.com/Xwilarg/Chessweeper\n[b-chessweeper]: https://img.shields.io/github/stars/xwilarg/chessweeper?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b26]][c26] [Chinchon][p26] \\[[code][c26]\\]\n&nbsp;&nbsp;\nMultiplayer online card game similar to gin rummy. \n\n[p26]: https://chinchon-game.herokuapp.com/\n[c26]: https://github.com/maxpaulus43/chinchon\n[b26]: https://img.shields.io/github/stars/maxpaulus43/chinchon?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b21]][c21] [Coup][p21] \\[[code][c21]\\]\n&nbsp;&nbsp;\nOnline multiplayer version of Coup, a strategy board game.\n\n[p21]: https://online-coup.herokuapp.com/\n[c21]: https://github.com/vyang1222/online-coup\n[b21]: https://img.shields.io/github/stars/vyang1222/online-coup?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b6]][c6] [Elevation of Privilege][p6] \\[[code][c6]\\]\n&nbsp;&nbsp;\nAn online multiplayer version of the threat modeling card game.\n\n[b6]: https://img.shields.io/github/stars/dehydr8/elevation-of-privilege?label=%E2%98%85&logo=github\n[p6]: https://elevation-of-privilege.herokuapp.com/\n[c6]: https://github.com/dehydr8/elevation-of-privilege\n\n\n#### [![GitHub stars][b7]][c7] [Fields of Arle simulator][p7] \\[[code][c7]\\]\n&nbsp;&nbsp;\nOpen source simulator of Fields of Arle.\n\n[b7]: https://img.shields.io/github/stars/philihp/fields-of-arle?label=%E2%98%85&logo=github\n[p7]: https://arle.philihp.com\n[c7]: https://github.com/philihp/fields-of-arle\n\n\n#### [![GitHub stars][b-fd]][c-fd] [Forbidden Desert][p-fd] \\[[code][c-fd]\\]\n&nbsp;&nbsp;\nClone of Forbidden Desert, a 2-5 player cooperative board game played locally.\n\n[b-fd]: https://img.shields.io/github/stars/hwabis/forbidden-desert?label=%E2%98%85&logo=github\n[p-fd]: https://hwabis.github.io/forbidden-desert/\n[c-fd]: https://github.com/hwabis/forbidden-desert\n\n\n#### [![GitHub stars][b8]][c8] Four in a row \\[[code][c8] | [tutorial][t8]\\]\n&nbsp;&nbsp;\nFour in a Row using boardgame.io.\n\n[c8]: https://github.com/PJohannessen/four-in-a-row\n[t8]: https://www.lonesomecrowdedweb.com/blog/four-in-a-row-boardgameio/\n[b8]: https://img.shields.io/github/stars/PJohannessen/four-in-a-row?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b9]][c9] [FreeBoardGames.org][p9] \\[[code][c9]\\]\n&nbsp;&nbsp;\nPWA framework for publishing board games.\n\n[p9]: https://www.freeboardgames.org\n[c9]: https://github.com/freeboardgames/FreeBoardGames.org\n[b9]: https://img.shields.io/github/stars/freeboardgames/FreeBoardGames.org?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b28]][c28] [Garden][p28] \\[[code][c28]\\]\n&nbsp;&nbsp;\nA single-player puzzle game.\n\n[p28]: https://0x682.itch.io/garden\n[c28]: https://github.com/steambap/garden\n[b28]: https://img.shields.io/github/stars/steambap/garden?label=%E2%98%85&logo=github\n\n\n#### [2048 Game][c27]\n&nbsp;&nbsp;\nThe classic 2048 puzzle game. Implemented using React and Greensock.\n\n[c27]: https://2048-online.io/\n\n\n#### [![GitHub stars][b10]][c10] [Hex game][p10] \\[[code][c10]\\]\n&nbsp;&nbsp;\nSimple hexagonal board game.\n\n[p10]: https://korla.github.io/hexgame/build/\n[c10]: https://github.com/Korla/hexgame\n[b10]: https://img.shields.io/github/stars/Korla/hexgame?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b-lhog]][c-lhog] [Lewis' House of Games][p-lhog] \\[[code][c-lhog]\\]\n&nbsp;&nbsp;\nLobby framework for boardgame.io games. Play Splendor or Powergrid clones here.\n\n[p-lhog]: https://lhog.lewissilletto.com/\n[c-lhog]: https://github.com/sillle14/lhog\n[b-lhog]: https://img.shields.io/github/stars/sillle14/lhog?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b11]][c11] [Matchimals.fun][p11] \\[[code][c11]\\]\n&nbsp;&nbsp;\nAn animal matching puzzle card game.\n\n[p11]: https://www.matchimals.fun/\n[c11]: https://github.com/chrisheninger/matchimals.fun\n[b11]: https://img.shields.io/github/stars/chrisheninger/matchimals.fun?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b12]][c12] [Mosaic Multiplayer][p12] \\[[code][c12]\\]\n&nbsp;&nbsp;\nAzul board game clone you can play online with friends.\n\n[p12]: https://playmosaic.online/\n[c12]: https://github.com/maciejmatu/mosaic\n[b12]: https://img.shields.io/github/stars/maciejmatu/mosaic?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b13]][c13] [Multibuzzer][p13] \\[[code][c13]\\]\n&nbsp;&nbsp;\nSimple multiplayer buzzer system for trivia night or quiz bowl.\n\n[p13]: https://multibuzz.app\n[c13]: https://github.com/wsun/multibuzzer\n[b13]: https://img.shields.io/github/stars/wsun/multibuzzer?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b14]][c14] [Pong420's Boardgame][p14] \\[[code][c14]\\]\n&nbsp;&nbsp;\nA project for building board games with React and boardgame.io.\n\n[p14]: http://play-boardgame.herokuapp.com\n[c14]: https://github.com/Pong420/Boardgame\n[b14]: https://img.shields.io/github/stars/Pong420/Boardgame?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b25]][c25] [Santorini][p25] \\[[code][c25]\\]\n&nbsp;&nbsp;\nMultiplayer online boardgame with 3D board using three.js.\n\n[p25]: https://santorini.onrender.com\n[c25]: https://github.com/mbrinkl/santorini\n[b25]: https://img.shields.io/github/stars/mbrinkl/santorini?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][bsixpieces]][csixpieces] [SixPieces][psixpieces] \\[[code][csixpieces]\\]\n&nbsp;&nbsp;\nA 3-D online version of the tile-based boardgame \"Qwirkle\" for two to four players.\n\n[psixpieces]: https://zwo.uber.space/SixPieces/\n[csixpieces]: https://github.com/fuenfundachtzig/SixPieces\n[bsixpieces]: https://img.shields.io/github/stars/fuenfundachtzig/SixPieces?label=%E2%98%85&logo=github\n\n\n#### [Splendor][p15]\n&nbsp;&nbsp;\nA minimal splendor game you can play with up to 4 players.\n\n[p15]: http://bestboards.ir\n\n\n#### [Steel Civilizations][p16]\n&nbsp;&nbsp;\nTurn-based mobile strategy game for Android with real-time online multiplayer ranking ladder system.\n\n[p16]: https://play.google.com/store/apps/details?id=com.hydra.steelcivs\n\n\n#### [![GitHub stars][b17]][c17] [Territories][p17] \\[[code][c17]\\]\n&nbsp;&nbsp;\nSimple board game Territories.\n\n[p17]: https://lehasvv2009.github.io/territories/\n[c17]: https://github.com/lehaSVV2009/territories\n[b17]: https://img.shields.io/github/stars/lehaSVV2009/territories?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b18]][c18] [Thinktank][p18] \\[[code][c18]\\]\n&nbsp;&nbsp;\nA 2-player strategy game inspired by Conundrum.\n\n[p18]: https://thinktank.crespi.dev\n[c18]: https://github.com/averycrespi/thinktank\n[b18]: https://img.shields.io/github/stars/averycrespi/thinktank?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b19]][c19] [Tiến Lên][p19] \\[[code][c19]\\]\n&nbsp;&nbsp;\nThe 4-player Vietnamese game that uses a standard 52-card deck, in English, with online multiplayer.\n\n[p19]: http://tienlen-en.herokuapp.com/\n[c19]: https://github.com/nguyenank/tien-len\n[b19]: https://img.shields.io/github/stars/nguyenank/tien-len?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b20]][c20] [Udaipur][p20] \\[[code][c20]\\]\n&nbsp;&nbsp;\nClone of Jaipur, a 2 Player Card game, with online multiplayer support.\n\n[p20]: https://udaipur-game.herokuapp.com/\n[c20]: https://github.com/skvrahul/UdaipurGame\n[b20]:https://img.shields.io/github/stars/skvrahul/UdaipurGame?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b24]][c24] [Unmuted: 2021][p24] \\[[code][c24]\\]\n&nbsp;&nbsp;\nA single-player deckbuilder game.\n\n[p24]: https://shaoster.github.io/unmuted2021\n[c24]: https://github.com/shaoster/unmuted2021\n[b24]: https://img.shields.io/github/stars/shaoster/unmuted2021?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b23]][c23] [Unstable Unicorns][p23] \\[[code][c23]\\]\n&nbsp;&nbsp;\nOnline game variant of the popular card game Unstable Unicorns 🦄. Playable with your friends.\n\n[p23]: https://unstable-unicorns-online.herokuapp.com/hello-world/6/0\n[c23]: https://github.com/geniegeist/unstable-unicorns\n[b23]: https://img.shields.io/github/stars/geniegeist/unstable-unicorns?label=%E2%98%85&logo=github\n\n\n#### [![GitHub stars][b22]][c22] [Yatzy][p22] \\[[code][c22] | [tutorial][t22]\\]\n&nbsp;&nbsp;\nA 1-4 player dice game played locally.\n\n[p22]: https://www.lonesomecrowdedweb.com/yatzy/\n[c22]: https://github.com/pjohannessen/yatzy\n[t22]: https://www.lonesomecrowdedweb.com/blog/yatzy-boardgameio/\n[b22]: https://img.shields.io/github/stars/pjohannessen/yatzy?label=%E2%98%85&logo=github\n\n#### [![GitHub stars][b-wd]][c-wd] [Wizard Duel][p-wd] \\[[code][c-wd]\\]\n&nbsp;&nbsp;\nA single-player battle card game featuring epic fantasy card art and sound effects.\n\n[b-wd]: https://img.shields.io/github/stars/ruichen199801/wizard-duel?label=%E2%98%85&logo=github\n[p-wd]: https://wizard-duel-ten.vercel.app/\n[c-wd]: https://github.com/ruichen199801/wizard-duel\n"
  },
  {
    "path": "docs/documentation/phases.md",
    "content": "# Phases\n\nMost games beyond very simple ones tend to have different\nbehaviors at various phases. A game might have a phase\nat the beginning where players are drafting cards before\nentering a playing phase, for example.\n\nEach phase in [boardgame.io](https://boardgame.io/) defines a set\nof game configuration options that are applied for the duration\nof that phase. This includes the ability to define a different\nset of moves, use a different turn order etc. Turns happen\ninside phases.\n\n### Card Game\n\nLet us start with a contrived example of a game that has exactly\ntwo moves:\n\n- draw a card from the deck into your hand.\n- play a card from your hand onto the deck.\n\n```js\nfunction DrawCard({ G, playerID }) {\n  G.deck--;\n  G.hand[playerID]++;\n}\n\nfunction PlayCard({ G, playerID }) {\n  G.deck++;\n  G.hand[playerID]--;\n}\n\nconst game = {\n  setup: ({ ctx }) => ({ deck: 6, hand: Array(ctx.numPlayers).fill(0) }),\n  moves: { DrawCard, PlayCard },\n  turn: { minMoves: 1, maxMoves: 1 },\n};\n```\n\n?> Notice how we moved the moves out into standalone functions\ninstead of inlining them in the game object.\n\nWe'll ignore the rendering part of this game, but this is how it might look. Note that you can draw or play a card at any time, including taking a card when the deck is empty.\n\n```react\n<iframe class='plain' src='snippets/phases-1' height='350' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true'></iframe>\n```\n\n### Phases\n\nNow let's say we want the game to work in two phases:\n\n- a first phase where the players only draw cards (until the deck is empty).\n- a second phase where the players only play cards.\n\nIn order to do this, we define two `phases`. Each phase can specify its own\nlist of moves, which come into effect during that phase:\n\n```js\nconst game = {\n  setup: ({ ctx }) => ({ deck: 6, hand: Array(ctx.numPlayers).fill(0) }),\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  phases: {\n    draw: {\n      moves: { DrawCard },\n    },\n\n    play: {\n      moves: { PlayCard },\n    },\n  },\n};\n```\n\n!> A phase that doesn't specify any moves just uses moves from\nthe main `moves` section in the game. However, if it does,\nthen the `moves` section in the phase overrides the global\none.\n\nThe game doesn't begin in any of these phases. In order to begin\nin the \"draw\" phase, we add a `start: true` to its config. Only\none phase can have `start: true`.\n\n```js\nphases: {\n  draw: {\n    moves: { DrawCard },\n+   start: true,\n  },\n\n  play: {\n    moves: { PlayCard },\n  },\n}\n```\n\nLet's also end the \"draw\" phase automatically once the deck is\nempty.\n\n```js\nphases: {\n  draw: {\n    moves: { DrawCard },\n+   endIf: ({ G }) => (G.deck <= 0),\n+   next: 'play',\n    start: true,\n  },\n\n  play: {\n    moves: { PlayCard },\n  },\n}\n```\n\n`endIf` ends the phase that it is defined in when it returns\n`true`. The game is returned to a state where no phase is\nactive. However, for this game, we want to move to\nthe \"play\" phase once the \"draw\" phase is done. We specify a\n`next` option for this, which tells the framework to go to that\nphase.\n\nWatch our game in action (now with phases). Notice that you can only draw cards in the first\nphase, and you can only play cards in the second phase.\n\n```react\n<iframe class='plain' src='snippets/phases-2' height='350' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true'></iframe>\n```\n\n### Setup and Cleanup hooks\n\nYou can also run code automatically at the beginning or end of a phase. These are specified just like normal moves in `onBegin` and `onEnd`.\n\n```js\nphases: {\n  phaseA: {\n    onBegin: ({ G, ctx }) => { ... },\n    onEnd: ({ G, ctx }) => { ... },\n  },\n};\n```\n\n?> Hooks like `onBegin` and `onEnd` are run only on the server in\nmultiplayer games. Moves, on the other hand, run on both client\nand server. They are run on the client in order to facilitate\na lag-free experience, and are run on the server to calculate the\nauthoritative game state.\n\n### Moving between Phases\n\n#### Using events\n\nThe two primary ways of moving between phases are by calling the\nfollowing events:\n\n1. `endPhase`: This ends the current phase and returns the game\n   to a state where no phase is active. If the phase specifies a\n   `next` option, then the game will move into that phase instead.\n\n2. `setPhase`: This ends the current phase and moves the game into\n   the phase specified by the argument.\n\n\n#### Using an `endIf` condition\n\nYou can also end a phase by returning a truthy value from its\n`endIf` method:\n\n```js\nphases: {\n  phaseA: {\n    next: 'phaseB',\n    endIf: ({ G, ctx }) => true,\n  },\n  phaseB: { ... },\n},\n```\n\n!> Whenever a phase ends, the current player's turn is first ended automatically.\n\n\n### Setting the next phase dynamically\n\nInstead of setting a phase’s `next` option with a string, you can\nprovide a function that will return the next phase based on game\nstate at the end of the phase:\n\n```js\nphases: {\n  phaseA: {\n    next: ({ G }) => {\n      return G.condition ? 'phaseC' : 'phaseB';\n    },\n  },\n  phaseB: { ... },\n  phaseC: { ... },\n},\n```\n\n\n### Override Behavior\n\nAs observed above, a phase can specify its own `moves` section\nwhich comes into effect when the phase is active. This `moves`\nsection completely replaces the global `moves` section\nfor the duration of the phase. The moves may have the\nsame name as their global equivalents, but they are not related\nto them in any way.\n\nA phase can similarly also override the `turn` section. You will\ntypically do this if you want to use a different\n[Turn Order](turn-order.md) during the phase.\n"
  },
  {
    "path": "docs/documentation/plugins.md",
    "content": "# Plugins\n\nThe Plugin API allows you to create objects that expose\ncustom functionality to [boardgame.io](https://boardgame.io/).\nYou can create wrappers around moves, add API's to `ctx` etc.\n\n### Creating a Plugin\n\nA plugin is an object that contains the following fields.\n\n```js\n{\n  // Required.\n  name: 'plugin-name',\n\n  // Initialize the plugin's data.\n  // This is stored in a special area of the state object\n  // and not exposed to the move functions.\n  setup: ({ G, ctx, game }) => data object,\n\n  // Create an object that becomes available in `ctx`\n  // under `ctx['plugin-name']`.\n  // This is called at the beginning of a move or event.\n  // This object will be held in memory until flush (below)\n  // is called.\n  api: ({ G, ctx, game, data, playerID }) => api object,\n\n  // Return an updated version of data that is persisted\n  // in the game's state object.\n  flush: ({ G, ctx, game, data, api }) => data object,\n\n  // Function that accepts a move / trigger function\n  // and returns another function that wraps it. This\n  // wrapper can modify G before passing it down to\n  // the wrapped function. It is a good practice to\n  // undo the change at the end of the call. \n  // `fnType` gives the type of hook being wrapped\n  // and will be one of the `GameMethod` values —\n  // import { GameMethod } from 'boardgame.io/core' \n  fnWrap: (fn, fnType) => ({ G, ...rest }, ...args) => {\n    G = preprocess(G);\n    G = fn({ G, ...rest }, ...args);\n    if (fnType === GameMethod.TURN_ON_END) {\n      // only run when wrapping a turn’s onEnd function\n    }\n    G = postprocess(G);\n    return G;\n  },\n\n  // Function that allows the plugin to indicate that it\n  // should not be run on the client. If it returns true,\n  // the client will discard the state update and wait\n  // for the master instead.\n  noClient: ({ G, ctx, game, data, api }) => boolean,\n\n  // Function that allows the plugin to indicate that the\n  // current action should be declared invalid and cancelled.\n  // If `isInvalid` returns an error message, the whole update\n  // will be abandoned and an error returned to the client.\n  isInvalid: ({ G, ctx, game, data, api }) => false | string,\n\n  // Function that can filter `data` to hide secret state\n  // before sending it to a specific client.\n  // `playerID` could also be null or undefined for spectators.\n  playerView: ({ G, ctx, game, data, playerID }) => filtered data object,\n}\n```\n\n### Adding Plugins to Games\n\nThe list of plugins is specified in the game spec.\n\n```js\nimport { PluginA, PluginB } from 'boardgame.io/plugins';\n\nconst game = {\n  name: 'my-game',\n\n  plugins: [PluginA, PluginB],\n\n  // ...\n};\n```\n\n?> Plugins are applied one after the other in the order\nthat they are specified (from left to right).\n\n### Configuring Plugins\n\nSome plugins may need a user to provide some configuration. The recommended way to do that is to design the plugin as a factory function that takes configuration as its arguments and returns a plugin object.\n\n```js\nimport { ConfigurablePlugin } from './plugins';\n\nconst game = {\n  name: 'my-game',\n  plugins: [\n    ConfigurablePlugin(options),\n  ],\n}\n```\n\n?> See `PluginPlayer` below for an example of this in practice.\n\n### Available Plugins\n\n#### PluginPlayer\n\n```js\nimport { PluginPlayer } from 'boardgame.io/plugins';\n\n// define a function to initialize each player’s state\nconst playerSetup = (playerID) => ({ ... });\n\n// filter data returned to each client to hide secret state (OPTIONAL)\nconst playerView = (players, playerID) => ({\n  [playerID]: players[playerID],\n});\n\nconst game = {\n  plugins: [\n    // pass your function to the player plugin\n    PluginPlayer({\n      setup: playerSetup,\n      playerView: playerView,\n    }),\n  ],\n};\n```\n\n`PluginPlayer` makes it easy to manage player state.\nIt creates an object `players` that\nstores state for individual players.  This object is\nstored in the plugin's private storage area:\n\n```\nplayers: {\n  '0': { ... },\n  '1': { ... },\n  '2': { ... },\n  ...\n}\n```\n\nThe initial values of these states are determined by the `setup` function in its options object, which creates the state for a particular `playerID`.\n\nThe record associated with the current player can be accessed\nvia `ctx.player.get()`. If this is a 2 player game,\nthen the opponent's record is available using `ctx.player.opponent.get()`. These fields can be modified using their corresponding\n`set()` versions.\n\n```js\nctx.player.get() // Get the current player's record.\nctx.player.set() // Update the current player's record.\nctx.player.opponent.get() // Get the opponent player's record.\nctx.player.opponent.set() // Update the opponent player's record.\n```\n"
  },
  {
    "path": "docs/documentation/random.md",
    "content": "# Randomness\n\nMany games allow moves whose outcome depends on shuffled cards or rolled dice.\nTake e.g. the game [Yahtzee](https://en.wikipedia.org/wiki/Yahtzee).\nA player rolls dice, chooses some, rolls another time, chooses some more, and does a final dice roll.\nDepending on the face-up sides the player now must choose where they will score.\n\nThis poses interesting challenges regarding the implementation.\n\n- **AI**. Randomness makes games interesting since you cannot predict the future, but it\n  needs to be controlled in order for allowing games that can be replayed exactly (e.g. for AI purposes).\n\n- **<abbr title=\"Pseudo-Random Number Generator\">PRNG</abbr> State**.\n  The game runs on both the server and client.\n  All code and data on the client can be viewed and used to a player's advantage.\n  If a client could predict the next random numbers that are to be generated, the future flow of a game stops being unpredictable.\n  The library must not allow such a scenario. The RNG and its state must stay on the server.\n\n- **Pure Functions**. The library is built using Redux. This is important for games since each move is a [reducer](https://redux.js.org/docs/basics/Reducers.html),\n  and thus must be pure. Calling `Math.random()` and other functions that\n  maintain external state would make the game logic impure and not idempotent.\n\n### Using Randomness in Games\n\nThe object passed to moves and other game logic contains an object `random`,\nwhich exposes a range of functions for generating randomness.\n\nFor example, the `random.D6` function is similar to rolling six-sided dice:\n\n```js\n{\n  moves: {\n    rollDie: ({ G, random }) => {\n      G.dieRoll = random.D6(); // dieRoll = 1–6\n    },\n\n    rollThreeDice: ({ G, random }) => {\n      G.diceRoll = random.D6(3); // diceRoll = [1–6, 1–6, 1–6]\n    }\n  },\n}\n```\n\nYou can see details for all the available random functions below.\n\n### Seed\n\nYou can set the initial `seed` used for the random number generator\non your game object:\n\n```js\nconst game = {\n  seed: 42,\n  // ...\n};\n```\n\n?> `seed` can be either a string or a number.\n\n## API Reference\n\n### 1. Die\n\n#### Arguments\n\n1. `spotvalue` (_number_): The die dimension (_default: 6_).\n2. `diceCount` (_number_): The number of dice to throw.\n\n#### Returns\n\nThe die roll value (or an array of values if `diceCount` is greater than `1`).\n\n#### Usage\n\n```js\nconst game = {\n  moves: {\n    move({ random }) {\n      const die = random.Die(6);      // die = 1-6\n      const dice = random.Die(6, 3);  // dice = [1-6, 1-6, 1-6]\n    },\n  }\n};\n```\n\n### 2. Number\n\nReturns a random number between `0` and `1`.\n\n#### Usage\n\n```js\nconst game = {\n  moves: {\n    move({ random }) {\n      const n = random.Number();\n    },\n  }\n};\n```\n\n### 3. Shuffle\n\n#### Arguments\n\n1. `deck` (_array_): An array to shuffle.\n\n#### Returns\n\nThe shuffled array.\n\n#### Usage\n\n```js\nconst game = {\n  moves: {\n    move({ G, random }) {\n      G.deck = random.Shuffle(G.deck);\n    },\n  },\n};\n```\n\n### 4. Wrappers\n\n`D4`, `D6`, `D8`, `D10`, `D12` and `D20` are wrappers around\n`Die(n)`.\n\n#### Arguments\n\n1. `diceCount` (_number_): The number of dice to throw.\n\n#### Usage\n\n```js\nconst game = {\n  moves: {\n    move({ random }) {\n      const die = random.D6();\n    },\n  }\n};\n```\n"
  },
  {
    "path": "docs/documentation/secret-state.md",
    "content": "# Secret State\n\nIn some games you might need to hide information from\nplayers or spectators. For example, you might not want to reveal the\nhands of opponents in card games.\n\nThis is easily accomplished at the UI layer (by not\nrendering secret information), but the framework also\nprovides support for not even sending such data to\nthe client.\n\nIn order to do this, use the `playerView` setting in\nthe game object. It accepts a function that receives an\nobject containing `G`, `ctx`, and `playerID`, and returns a version of `G`\nthat is stripped of any information that should be hidden\nfrom that specific player.\n\n```js\nconst game = {\n  // `playerID` could also be null or undefined for spectators.\n  playerView: ({ G, ctx, playerID }) => {\n    return StripSecrets(G, playerID);\n  },\n  // ...\n};\n```\n\n!> Make sure that you associate the game clients with individual\nplayers (as discussed in the [Multiplayer](multiplayer.md) section).\n\n### PlayerView.STRIP_SECRETS\n\nThe framework comes bundled with an implementation of `playerView`\nthat does the following:\n\n- It removes a key named `secret` from `G`.\n- If `G` contains a `players` object, it removes all keys except\n  for the one that matches `playerID`.\n\n```js\nG: {\n  secret: { ... },\n\n  players: {\n    '0': { ... },\n    '1': { ... },\n    '2': { ... },\n  }\n}\n```\n\nbecomes the following for player `1`:\n\n```js\nG: {\n  players: {\n    '1': { ... },\n  }\n}\n```\n\nUsage:\n\n```js\nimport { PlayerView } from 'boardgame.io/core';\n\nconst game = {\n  // ...\n  playerView: PlayerView.STRIP_SECRETS,\n};\n```\n\n### Disabling moves that manipulate secret state on the client\n\nMoves that manipulate secret state often cannot run on the client because\nthe client doesn't have all the necessary data to process such moves.\nThese can be marked as server-only by setting `client: false` on move:\n\n```js\nmoves: {\n  moveThatUsesSecret: {\n    move: ({ G, random }) => {\n      G.secret.value = random.Number();\n    },\n\n    client: false,\n  }\n}\n```\n"
  },
  {
    "path": "docs/documentation/sidebar.md",
    "content": "- **Getting Started**\n  - [Concepts](/)\n  - [Tutorial](tutorial.md)\n- **Guides**\n  - [Multiplayer](multiplayer.md)\n  - [Turn Order](turn-order.md)\n  - [Phases](phases.md)\n  - [Stages](stages.md)\n  - [Events](events.md)\n  - [Undo / Redo](undo.md)\n  - [Randomness](random.md)\n  - [Secret State](secret-state.md)\n  - [Immutability](immutability.md)\n  - [Plugins](plugins.md)\n  - [Debugging](debugging.md)\n  - [Testing](testing.md)\n  - [Deployment](deployment.md)\n  - [Storage](storage.md)\n  - [Chat](chat.md)\n  - [TypeScript](typescript.md)\n- **Reference**\n  - [Game](api/Game.md)\n  - [Client](api/Client.md)\n  - [Server](api/Server.md)\n  - [Lobby](api/Lobby.md)\n- **More**\n  - [Changelog](/CHANGELOG.md)\n  - [Projects](/notable_projects.md)\n"
  },
  {
    "path": "docs/documentation/snippets/example-1/index.html",
    "content": "<!DOCTYPE html><html><head><style>body{padding:20px}.msg{position:absolute;bottom:0;left:20px;color:#aaa;font-size:12px;margin-bottom:20px}</style></head><body> <div class=\"msg\">interactive (not an image)</div> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/example-1.c952ec6d.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/example-1.c952ec6d.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"J4Nk\":[function(require,module,exports) {\n\"use strict\";var r=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(r){if(null==r)throw new TypeError(\"Object.assign cannot be called with null or undefined\");return Object(r)}function o(){try{if(!Object.assign)return!1;var r=new String(\"abc\");if(r[5]=\"de\",\"5\"===Object.getOwnPropertyNames(r)[0])return!1;for(var t={},e=0;e<10;e++)t[\"_\"+String.fromCharCode(e)]=e;if(\"0123456789\"!==Object.getOwnPropertyNames(t).map(function(r){return t[r]}).join(\"\"))return!1;var n={};return\"abcdefghijklmnopqrst\".split(\"\").forEach(function(r){n[r]=r}),\"abcdefghijklmnopqrst\"===Object.keys(Object.assign({},n)).join(\"\")}catch(o){return!1}}module.exports=o()?Object.assign:function(o,c){for(var a,i,s=n(o),f=1;f<arguments.length;f++){for(var u in a=Object(arguments[f]))t.call(a,u)&&(s[u]=a[u]);if(r){i=r(a);for(var b=0;b<i.length;b++)e.call(a,i[b])&&(s[i[b]]=a[i[b]])}}return s};\n},{}],\"awqi\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"n8MK\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"awqi\"}],\"IvPb\":[function(require,module,exports) {\n\"use strict\";var e,n,t,r,o;if(\"undefined\"==typeof window||\"function\"!=typeof MessageChannel){var a=null,l=null,i=function(){if(null!==a)try{var e=exports.unstable_now();a(!0,e),a=null}catch(n){throw setTimeout(i,0),n}},u=Date.now();exports.unstable_now=function(){return Date.now()-u},e=function(n){null!==a?setTimeout(e,0,n):(a=n,setTimeout(i,0))},n=function(e,n){l=setTimeout(e,n)},t=function(){clearTimeout(l)},r=function(){return!1},o=exports.unstable_forceFrameRate=function(){}}else{var s=window.performance,c=window.Date,f=window.setTimeout,p=window.clearTimeout;if(\"undefined\"!=typeof console){var b=window.cancelAnimationFrame;\"function\"!=typeof window.requestAnimationFrame&&console.error(\"This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\"),\"function\"!=typeof b&&console.error(\"This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\")}if(\"object\"==typeof s&&\"function\"==typeof s.now)exports.unstable_now=function(){return s.now()};else{var d=c.now();exports.unstable_now=function(){return c.now()-d}}var v=!1,x=null,w=-1,m=5,y=0;r=function(){return exports.unstable_now()>=y},o=function(){},exports.unstable_forceFrameRate=function(e){0>e||125<e?console.error(\"forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported\"):m=0<e?Math.floor(1e3/e):5};var _=new MessageChannel,h=_.port2;_.port1.onmessage=function(){if(null!==x){var e=exports.unstable_now();y=e+m;try{x(!0,e)?h.postMessage(null):(v=!1,x=null)}catch(n){throw h.postMessage(null),n}}else v=!1},e=function(e){x=e,v||(v=!0,h.postMessage(null))},n=function(e,n){w=f(function(){e(exports.unstable_now())},n)},t=function(){p(w),w=-1}}function k(e,n){var t=e.length;e.push(n);e:for(;;){var r=t-1>>>1,o=e[r];if(!(void 0!==o&&0<P(o,n)))break e;e[r]=n,e[t]=o,t=r}}function T(e){return void 0===(e=e[0])?null:e}function g(e){var n=e[0];if(void 0!==n){var t=e.pop();if(t!==n){e[0]=t;e:for(var r=0,o=e.length;r<o;){var a=2*(r+1)-1,l=e[a],i=a+1,u=e[i];if(void 0!==l&&0>P(l,t))void 0!==u&&0>P(u,l)?(e[r]=u,e[i]=t,r=i):(e[r]=l,e[a]=t,r=a);else{if(!(void 0!==u&&0>P(u,t)))break e;e[r]=u,e[i]=t,r=i}}}return n}return null}function P(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}var F=[],I=[],M=1,C=null,A=3,L=!1,q=!1,D=!1;function R(e){for(var n=T(I);null!==n;){if(null===n.callback)g(I);else{if(!(n.startTime<=e))break;g(I),n.sortIndex=n.expirationTime,k(F,n)}n=T(I)}}function j(t){if(D=!1,R(t),!q)if(null!==T(F))q=!0,e(E);else{var r=T(I);null!==r&&n(j,r.startTime-t)}}function E(e,o){q=!1,D&&(D=!1,t()),L=!0;var a=A;try{for(R(o),C=T(F);null!==C&&(!(C.expirationTime>o)||e&&!r());){var l=C.callback;if(null!==l){C.callback=null,A=C.priorityLevel;var i=l(C.expirationTime<=o);o=exports.unstable_now(),\"function\"==typeof i?C.callback=i:C===T(F)&&g(F),R(o)}else g(F);C=T(F)}if(null!==C)var u=!0;else{var s=T(I);null!==s&&n(j,s.startTime-o),u=!1}return u}finally{C=null,A=a,L=!1}}function N(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var B=o;exports.unstable_IdlePriority=5,exports.unstable_ImmediatePriority=1,exports.unstable_LowPriority=4,exports.unstable_NormalPriority=3,exports.unstable_Profiling=null,exports.unstable_UserBlockingPriority=2,exports.unstable_cancelCallback=function(e){e.callback=null},exports.unstable_continueExecution=function(){q||L||(q=!0,e(E))},exports.unstable_getCurrentPriorityLevel=function(){return A},exports.unstable_getFirstCallbackNode=function(){return T(F)},exports.unstable_next=function(e){switch(A){case 1:case 2:case 3:var n=3;break;default:n=A}var t=A;A=n;try{return e()}finally{A=t}},exports.unstable_pauseExecution=function(){},exports.unstable_requestPaint=B,exports.unstable_runWithPriority=function(e,n){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var t=A;A=e;try{return n()}finally{A=t}},exports.unstable_scheduleCallback=function(r,o,a){var l=exports.unstable_now();if(\"object\"==typeof a&&null!==a){var i=a.delay;i=\"number\"==typeof i&&0<i?l+i:l,a=\"number\"==typeof a.timeout?a.timeout:N(r)}else a=N(r),i=l;return r={id:M++,callback:o,priorityLevel:r,startTime:i,expirationTime:a=i+a,sortIndex:-1},i>l?(r.sortIndex=i,k(I,r),null===T(F)&&r===T(I)&&(D?t():D=!0,n(j,i-l))):(r.sortIndex=a,k(F,r),q||L||(q=!0,e(E))),r},exports.unstable_shouldYield=function(){var e=exports.unstable_now();R(e);var n=T(F);return n!==C&&null!==C&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTime<C.expirationTime||r()},exports.unstable_wrapCallback=function(e){var n=A;return function(){var t=A;A=n;try{return e.apply(this,arguments)}finally{A=t}}};\n},{}],\"MDSO\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/scheduler.production.min.js\");\n},{\"./cjs/scheduler.production.min.js\":\"IvPb\"}],\"i17t\":[function(require,module,exports) {\n\"use strict\";var e=require(\"react\"),t=require(\"object-assign\"),n=require(\"scheduler\");function r(e){for(var t=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,n=1;n<arguments.length;n++)t+=\"&args[]=\"+encodeURIComponent(arguments[n]);return\"Minified React error #\"+e+\"; visit \"+t+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}if(!e)throw Error(r(227));function l(e,t,n,r,l,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(s){this.onError(s)}}var i=!1,a=null,o=!1,u=null,c={onError:function(e){i=!0,a=e}};function s(e,t,n,r,o,u,s,f,d){i=!1,a=null,l.apply(c,arguments)}function f(e,t,n,l,c,f,d,p,m){if(s.apply(this,arguments),i){if(!i)throw Error(r(198));var h=a;i=!1,a=null,o||(o=!0,u=h)}}var d=null,p=null,m=null;function h(e,t,n){var r=e.type||\"unknown-event\";e.currentTarget=m(n),f(r,t,void 0,e),e.currentTarget=null}var g=null,v={};function y(){if(g)for(var e in v){var t=v[e],n=g.indexOf(e);if(!(-1<n))throw Error(r(96,e));if(!w[n]){if(!t.extractEvents)throw Error(r(97,e));for(var l in w[n]=t,n=t.eventTypes){var i=void 0,a=n[l],o=t,u=l;if(k.hasOwnProperty(u))throw Error(r(99,u));k[u]=a;var c=a.phasedRegistrationNames;if(c){for(i in c)c.hasOwnProperty(i)&&b(c[i],o,u);i=!0}else a.registrationName?(b(a.registrationName,o,u),i=!0):i=!1;if(!i)throw Error(r(98,l,e))}}}}function b(e,t,n){if(x[e])throw Error(r(100,e));x[e]=t,T[e]=t.eventTypes[n].dependencies}var w=[],k={},x={},T={};function E(e){var t,n=!1;for(t in e)if(e.hasOwnProperty(t)){var l=e[t];if(!v.hasOwnProperty(t)||v[t]!==l){if(v[t])throw Error(r(102,t));v[t]=l,n=!0}}n&&y()}var S=!(\"undefined\"==typeof window||void 0===window.document||void 0===window.document.createElement),C=null,P=null,_=null;function N(e){if(e=p(e)){if(\"function\"!=typeof C)throw Error(r(280));var t=e.stateNode;t&&(t=d(t),C(e.stateNode,e.type,t))}}function z(e){P?_?_.push(e):_=[e]:P=e}function M(){if(P){var e=P,t=_;if(_=P=null,N(e),t)for(e=0;e<t.length;e++)N(t[e])}}function I(e,t){return e(t)}function F(e,t,n,r,l){return e(t,n,r,l)}function O(){}var R=I,D=!1,L=!1;function U(){null===P&&null===_||(O(),M())}function A(e,t,n){if(L)return e(t,n);L=!0;try{return R(e,t,n)}finally{L=!1,U()}}var V=/^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$/,Q=Object.prototype.hasOwnProperty,W={},H={};function j(e){return!!Q.call(H,e)||!Q.call(W,e)&&(V.test(e)?H[e]=!0:(W[e]=!0,!1))}function B(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case\"function\":case\"symbol\":return!0;case\"boolean\":return!r&&(null!==n?!n.acceptsBooleans:\"data-\"!==(e=e.toLowerCase().slice(0,5))&&\"aria-\"!==e);default:return!1}}function K(e,t,n,r){if(null==t||B(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function $(e,t,n,r,l,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i}var q={};\"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style\".split(\" \").forEach(function(e){q[e]=new $(e,0,!1,e,null,!1)}),[[\"acceptCharset\",\"accept-charset\"],[\"className\",\"class\"],[\"htmlFor\",\"for\"],[\"httpEquiv\",\"http-equiv\"]].forEach(function(e){var t=e[0];q[t]=new $(t,1,!1,e[1],null,!1)}),[\"contentEditable\",\"draggable\",\"spellCheck\",\"value\"].forEach(function(e){q[e]=new $(e,2,!1,e.toLowerCase(),null,!1)}),[\"autoReverse\",\"externalResourcesRequired\",\"focusable\",\"preserveAlpha\"].forEach(function(e){q[e]=new $(e,2,!1,e,null,!1)}),\"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope\".split(\" \").forEach(function(e){q[e]=new $(e,3,!1,e.toLowerCase(),null,!1)}),[\"checked\",\"multiple\",\"muted\",\"selected\"].forEach(function(e){q[e]=new $(e,3,!0,e,null,!1)}),[\"capture\",\"download\"].forEach(function(e){q[e]=new $(e,4,!1,e,null,!1)}),[\"cols\",\"rows\",\"size\",\"span\"].forEach(function(e){q[e]=new $(e,6,!1,e,null,!1)}),[\"rowSpan\",\"start\"].forEach(function(e){q[e]=new $(e,5,!1,e.toLowerCase(),null,!1)});var Y=/[\\-:]([a-z])/g;function X(e){return e[1].toUpperCase()}\"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,null,!1)}),\"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/1999/xlink\",!1)}),[\"xml:base\",\"xml:lang\",\"xml:space\"].forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/XML/1998/namespace\",!1)}),[\"tabIndex\",\"crossOrigin\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!1)}),q.xlinkHref=new $(\"xlinkHref\",1,!1,\"xlink:href\",\"http://www.w3.org/1999/xlink\",!0),[\"src\",\"href\",\"action\",\"formAction\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!0)});var G=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function Z(e,t,n,r){var l=q.hasOwnProperty(t)?q[t]:null;(null!==l?0===l.type:!r&&(2<t.length&&(\"o\"===t[0]||\"O\"===t[0])&&(\"n\"===t[1]||\"N\"===t[1])))||(K(t,n,l,r)&&(n=null),r||null===l?j(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,\"\"+n)):l.mustUseProperty?e[l.propertyName]=null===n?3!==l.type&&\"\":n:(t=l.attributeName,r=l.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(l=l.type)||4===l&&!0===n?\"\":\"\"+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}G.hasOwnProperty(\"ReactCurrentDispatcher\")||(G.ReactCurrentDispatcher={current:null}),G.hasOwnProperty(\"ReactCurrentBatchConfig\")||(G.ReactCurrentBatchConfig={suspense:null});var J=/^(.*)[\\\\\\/]/,ee=\"function\"==typeof Symbol&&Symbol.for,te=ee?Symbol.for(\"react.element\"):60103,ne=ee?Symbol.for(\"react.portal\"):60106,re=ee?Symbol.for(\"react.fragment\"):60107,le=ee?Symbol.for(\"react.strict_mode\"):60108,ie=ee?Symbol.for(\"react.profiler\"):60114,ae=ee?Symbol.for(\"react.provider\"):60109,oe=ee?Symbol.for(\"react.context\"):60110,ue=ee?Symbol.for(\"react.concurrent_mode\"):60111,ce=ee?Symbol.for(\"react.forward_ref\"):60112,se=ee?Symbol.for(\"react.suspense\"):60113,fe=ee?Symbol.for(\"react.suspense_list\"):60120,de=ee?Symbol.for(\"react.memo\"):60115,pe=ee?Symbol.for(\"react.lazy\"):60116,me=ee?Symbol.for(\"react.block\"):60121,he=\"function\"==typeof Symbol&&Symbol.iterator;function ge(e){return null===e||\"object\"!=typeof e?null:\"function\"==typeof(e=he&&e[he]||e[\"@@iterator\"])?e:null}function ve(e){if(-1===e._status){e._status=0;var t=e._ctor;t=t(),e._result=t,t.then(function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)},function(t){0===e._status&&(e._status=2,e._result=t)})}}function ye(e){if(null==e)return null;if(\"function\"==typeof e)return e.displayName||e.name||null;if(\"string\"==typeof e)return e;switch(e){case re:return\"Fragment\";case ne:return\"Portal\";case ie:return\"Profiler\";case le:return\"StrictMode\";case se:return\"Suspense\";case fe:return\"SuspenseList\"}if(\"object\"==typeof e)switch(e.$$typeof){case oe:return\"Context.Consumer\";case ae:return\"Context.Provider\";case ce:var t=e.render;return t=t.displayName||t.name||\"\",e.displayName||(\"\"!==t?\"ForwardRef(\"+t+\")\":\"ForwardRef\");case de:return ye(e.type);case me:return ye(e.render);case pe:if(e=1===e._status?e._result:null)return ye(e)}return null}function be(e){var t=\"\";do{e:switch(e.tag){case 3:case 4:case 6:case 7:case 10:case 9:var n=\"\";break e;default:var r=e._debugOwner,l=e._debugSource,i=ye(e.type);n=null,r&&(n=ye(r.type)),r=i,i=\"\",l?i=\" (at \"+l.fileName.replace(J,\"\")+\":\"+l.lineNumber+\")\":n&&(i=\" (created by \"+n+\")\"),n=\"\\n    in \"+(r||\"Unknown\")+i}t+=n,e=e.return}while(e);return t}function we(e){switch(typeof e){case\"boolean\":case\"number\":case\"object\":case\"string\":case\"undefined\":return e;default:return\"\"}}function ke(e){var t=e.type;return(e=e.nodeName)&&\"input\"===e.toLowerCase()&&(\"checkbox\"===t||\"radio\"===t)}function xe(e){var t=ke(e)?\"checked\":\"value\",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=\"\"+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&\"function\"==typeof n.get&&\"function\"==typeof n.set){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(e){r=\"\"+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=\"\"+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Te(e){e._valueTracker||(e._valueTracker=xe(e))}function Ee(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=\"\";return e&&(r=ke(e)?e.checked?\"true\":\"false\":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Se(e,n){var r=n.checked;return t({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:e._wrapperState.initialChecked})}function Ce(e,t){var n=null==t.defaultValue?\"\":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=we(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:\"checkbox\"===t.type||\"radio\"===t.type?null!=t.checked:null!=t.value}}function Pe(e,t){null!=(t=t.checked)&&Z(e,\"checked\",t,!1)}function _e(e,t){Pe(e,t);var n=we(t.value),r=t.type;if(null!=n)\"number\"===r?(0===n&&\"\"===e.value||e.value!=n)&&(e.value=\"\"+n):e.value!==\"\"+n&&(e.value=\"\"+n);else if(\"submit\"===r||\"reset\"===r)return void e.removeAttribute(\"value\");t.hasOwnProperty(\"value\")?ze(e,t.type,n):t.hasOwnProperty(\"defaultValue\")&&ze(e,t.type,we(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Ne(e,t,n){if(t.hasOwnProperty(\"value\")||t.hasOwnProperty(\"defaultValue\")){var r=t.type;if(!(\"submit\"!==r&&\"reset\"!==r||void 0!==t.value&&null!==t.value))return;t=\"\"+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}\"\"!==(n=e.name)&&(e.name=\"\"),e.defaultChecked=!!e._wrapperState.initialChecked,\"\"!==n&&(e.name=n)}function ze(e,t,n){\"number\"===t&&e.ownerDocument.activeElement===e||(null==n?e.defaultValue=\"\"+e._wrapperState.initialValue:e.defaultValue!==\"\"+n&&(e.defaultValue=\"\"+n))}function Me(t){var n=\"\";return e.Children.forEach(t,function(e){null!=e&&(n+=e)}),n}function Ie(e,n){return e=t({children:void 0},n),(n=Me(n.children))&&(e.children=n),e}function Fe(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t[\"$\"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty(\"$\"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=\"\"+we(n),t=null,l=0;l<e.length;l++){if(e[l].value===n)return e[l].selected=!0,void(r&&(e[l].defaultSelected=!0));null!==t||e[l].disabled||(t=e[l])}null!==t&&(t.selected=!0)}}function Oe(e,n){if(null!=n.dangerouslySetInnerHTML)throw Error(r(91));return t({},n,{value:void 0,defaultValue:void 0,children:\"\"+e._wrapperState.initialValue})}function Re(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(r(92));if(Array.isArray(n)){if(!(1>=n.length))throw Error(r(93));n=n[0]}t=n}null==t&&(t=\"\"),n=t}e._wrapperState={initialValue:we(n)}}function De(e,t){var n=we(t.value),r=we(t.defaultValue);null!=n&&((n=\"\"+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=\"\"+r)}function Le(e){var t=e.textContent;t===e._wrapperState.initialValue&&\"\"!==t&&null!==t&&(e.value=t)}var Ue={html:\"http://www.w3.org/1999/xhtml\",mathml:\"http://www.w3.org/1998/Math/MathML\",svg:\"http://www.w3.org/2000/svg\"};function Ae(e){switch(e){case\"svg\":return\"http://www.w3.org/2000/svg\";case\"math\":return\"http://www.w3.org/1998/Math/MathML\";default:return\"http://www.w3.org/1999/xhtml\"}}function Ve(e,t){return null==e||\"http://www.w3.org/1999/xhtml\"===e?Ae(t):\"http://www.w3.org/2000/svg\"===e&&\"foreignObject\"===t?\"http://www.w3.org/1999/xhtml\":e}var Qe,We=function(e){return\"undefined\"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==Ue.svg||\"innerHTML\"in e)e.innerHTML=t;else{for((Qe=Qe||document.createElement(\"div\")).innerHTML=\"<svg>\"+t.valueOf().toString()+\"</svg>\",t=Qe.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function He(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}function je(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[\"Webkit\"+e]=\"webkit\"+t,n[\"Moz\"+e]=\"moz\"+t,n}var Be={animationend:je(\"Animation\",\"AnimationEnd\"),animationiteration:je(\"Animation\",\"AnimationIteration\"),animationstart:je(\"Animation\",\"AnimationStart\"),transitionend:je(\"Transition\",\"TransitionEnd\")},Ke={},$e={};function qe(e){if(Ke[e])return Ke[e];if(!Be[e])return e;var t,n=Be[e];for(t in n)if(n.hasOwnProperty(t)&&t in $e)return Ke[e]=n[t];return e}S&&($e=document.createElement(\"div\").style,\"AnimationEvent\"in window||(delete Be.animationend.animation,delete Be.animationiteration.animation,delete Be.animationstart.animation),\"TransitionEvent\"in window||delete Be.transitionend.transition);var Ye=qe(\"animationend\"),Xe=qe(\"animationiteration\"),Ge=qe(\"animationstart\"),Ze=qe(\"transitionend\"),Je=\"abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting\".split(\" \"),et=new(\"function\"==typeof WeakMap?WeakMap:Map);function tt(e){var t=et.get(e);return void 0===t&&(t=new Map,et.set(e,t)),t}function nt(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!=(1026&(t=e).effectTag)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function rt(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function lt(e){if(nt(e)!==e)throw Error(r(188))}function it(e){var t=e.alternate;if(!t){if(null===(t=nt(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,l=t;;){var i=n.return;if(null===i)break;var a=i.alternate;if(null===a){if(null!==(l=i.return)){n=l;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return lt(i),e;if(a===l)return lt(i),t;a=a.sibling}throw Error(r(188))}if(n.return!==l.return)n=i,l=a;else{for(var o=!1,u=i.child;u;){if(u===n){o=!0,n=i,l=a;break}if(u===l){o=!0,l=i,n=a;break}u=u.sibling}if(!o){for(u=a.child;u;){if(u===n){o=!0,n=a,l=i;break}if(u===l){o=!0,l=a,n=i;break}u=u.sibling}if(!o)throw Error(r(189))}}if(n.alternate!==l)throw Error(r(190))}if(3!==n.tag)throw Error(r(188));return n.stateNode.current===n?e:t}function at(e){if(!(e=it(e)))return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function ot(e,t){if(null==t)throw Error(r(30));return null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function ut(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}var ct=null;function st(e){if(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))for(var r=0;r<t.length&&!e.isPropagationStopped();r++)h(e,t[r],n[r]);else t&&h(e,t,n);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function ft(e){if(null!==e&&(ct=ot(ct,e)),e=ct,ct=null,e){if(ut(e,st),ct)throw Error(r(95));if(o)throw e=u,o=!1,u=null,e}}function dt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}function pt(e){if(!S)return!1;var t=(e=\"on\"+e)in document;return t||((t=document.createElement(\"div\")).setAttribute(e,\"return;\"),t=\"function\"==typeof t[e]),t}var mt=[];function ht(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>mt.length&&mt.push(e)}function gt(e,t,n,r){if(mt.length){var l=mt.pop();return l.topLevelType=e,l.eventSystemFlags=r,l.nativeEvent=t,l.targetInst=n,l}return{topLevelType:e,eventSystemFlags:r,nativeEvent:t,targetInst:n,ancestors:[]}}function vt(e){var t=e.targetInst,n=t;do{if(!n){e.ancestors.push(n);break}var r=n;if(3===r.tag)r=r.stateNode.containerInfo;else{for(;r.return;)r=r.return;r=3!==r.tag?null:r.stateNode.containerInfo}if(!r)break;5!==(t=n.tag)&&6!==t||e.ancestors.push(n),n=Un(r)}while(n);for(n=0;n<e.ancestors.length;n++){t=e.ancestors[n];var l=dt(e.nativeEvent);r=e.topLevelType;var i=e.nativeEvent,a=e.eventSystemFlags;0===n&&(a|=64);for(var o=null,u=0;u<w.length;u++){var c=w[u];c&&(c=c.extractEvents(r,t,i,l,a))&&(o=ot(o,c))}ft(o)}}function yt(e,t,n){if(!n.has(e)){switch(e){case\"scroll\":en(t,\"scroll\",!0);break;case\"focus\":case\"blur\":en(t,\"focus\",!0),en(t,\"blur\",!0),n.set(\"blur\",null),n.set(\"focus\",null);break;case\"cancel\":case\"close\":pt(e)&&en(t,e,!0);break;case\"invalid\":case\"submit\":case\"reset\":break;default:-1===Je.indexOf(e)&&Jt(e,t)}n.set(e,null)}}var bt,wt,kt,xt=!1,Tt=[],Et=null,St=null,Ct=null,Pt=new Map,_t=new Map,Nt=[],zt=\"mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput close cancel copy cut paste click change contextmenu reset submit\".split(\" \"),Mt=\"focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture\".split(\" \");function It(e,t){var n=tt(t);zt.forEach(function(e){yt(e,t,n)}),Mt.forEach(function(e){yt(e,t,n)})}function Ft(e,t,n,r,l){return{blockedOn:e,topLevelType:t,eventSystemFlags:32|n,nativeEvent:l,container:r}}function Ot(e,t){switch(e){case\"focus\":case\"blur\":Et=null;break;case\"dragenter\":case\"dragleave\":St=null;break;case\"mouseover\":case\"mouseout\":Ct=null;break;case\"pointerover\":case\"pointerout\":Pt.delete(t.pointerId);break;case\"gotpointercapture\":case\"lostpointercapture\":_t.delete(t.pointerId)}}function Rt(e,t,n,r,l,i){return null===e||e.nativeEvent!==i?(e=Ft(t,n,r,l,i),null!==t&&(null!==(t=An(t))&&wt(t)),e):(e.eventSystemFlags|=r,e)}function Dt(e,t,n,r,l){switch(t){case\"focus\":return Et=Rt(Et,e,t,n,r,l),!0;case\"dragenter\":return St=Rt(St,e,t,n,r,l),!0;case\"mouseover\":return Ct=Rt(Ct,e,t,n,r,l),!0;case\"pointerover\":var i=l.pointerId;return Pt.set(i,Rt(Pt.get(i)||null,e,t,n,r,l)),!0;case\"gotpointercapture\":return i=l.pointerId,_t.set(i,Rt(_t.get(i)||null,e,t,n,r,l)),!0}return!1}function Lt(e){var t=Un(e.target);if(null!==t){var r=nt(t);if(null!==r)if(13===(t=r.tag)){if(null!==(t=rt(r)))return e.blockedOn=t,void n.unstable_runWithPriority(e.priority,function(){kt(r)})}else if(3===t&&r.stateNode.hydrate)return void(e.blockedOn=3===r.tag?r.stateNode.containerInfo:null)}e.blockedOn=null}function Ut(e){if(null!==e.blockedOn)return!1;var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(null!==t){var n=An(t);return null!==n&&wt(n),e.blockedOn=t,!1}return!0}function At(e,t,n){Ut(e)&&n.delete(t)}function Vt(){for(xt=!1;0<Tt.length;){var e=Tt[0];if(null!==e.blockedOn){null!==(e=An(e.blockedOn))&&bt(e);break}var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);null!==t?e.blockedOn=t:Tt.shift()}null!==Et&&Ut(Et)&&(Et=null),null!==St&&Ut(St)&&(St=null),null!==Ct&&Ut(Ct)&&(Ct=null),Pt.forEach(At),_t.forEach(At)}function Qt(e,t){e.blockedOn===t&&(e.blockedOn=null,xt||(xt=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Vt)))}function Wt(e){function t(t){return Qt(t,e)}if(0<Tt.length){Qt(Tt[0],e);for(var n=1;n<Tt.length;n++){var r=Tt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Et&&Qt(Et,e),null!==St&&Qt(St,e),null!==Ct&&Qt(Ct,e),Pt.forEach(t),_t.forEach(t),n=0;n<Nt.length;n++)(r=Nt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Nt.length&&null===(n=Nt[0]).blockedOn;)Lt(n),null===n.blockedOn&&Nt.shift()}var Ht={},jt=new Map,Bt=new Map,Kt=[\"abort\",\"abort\",Ye,\"animationEnd\",Xe,\"animationIteration\",Ge,\"animationStart\",\"canplay\",\"canPlay\",\"canplaythrough\",\"canPlayThrough\",\"durationchange\",\"durationChange\",\"emptied\",\"emptied\",\"encrypted\",\"encrypted\",\"ended\",\"ended\",\"error\",\"error\",\"gotpointercapture\",\"gotPointerCapture\",\"load\",\"load\",\"loadeddata\",\"loadedData\",\"loadedmetadata\",\"loadedMetadata\",\"loadstart\",\"loadStart\",\"lostpointercapture\",\"lostPointerCapture\",\"playing\",\"playing\",\"progress\",\"progress\",\"seeking\",\"seeking\",\"stalled\",\"stalled\",\"suspend\",\"suspend\",\"timeupdate\",\"timeUpdate\",Ze,\"transitionEnd\",\"waiting\",\"waiting\"];function $t(e,t){for(var n=0;n<e.length;n+=2){var r=e[n],l=e[n+1],i=\"on\"+(l[0].toUpperCase()+l.slice(1));i={phasedRegistrationNames:{bubbled:i,captured:i+\"Capture\"},dependencies:[r],eventPriority:t},Bt.set(r,t),jt.set(r,i),Ht[l]=i}}$t(\"blur blur cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focus focus input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange\".split(\" \"),0),$t(\"drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel\".split(\" \"),1),$t(Kt,2);for(var qt=\"change selectionchange textInput compositionstart compositionend compositionupdate\".split(\" \"),Yt=0;Yt<qt.length;Yt++)Bt.set(qt[Yt],0);var Xt=n.unstable_UserBlockingPriority,Gt=n.unstable_runWithPriority,Zt=!0;function Jt(e,t){en(t,e,!1)}function en(e,t,n){var r=Bt.get(t);switch(void 0===r?2:r){case 0:r=tn.bind(null,t,1,e);break;case 1:r=nn.bind(null,t,1,e);break;default:r=rn.bind(null,t,1,e)}n?e.addEventListener(t,r,!0):e.addEventListener(t,r,!1)}function tn(e,t,n,r){D||O();var l=rn,i=D;D=!0;try{F(l,e,t,n,r)}finally{(D=i)||U()}}function nn(e,t,n,r){Gt(Xt,rn.bind(null,e,t,n,r))}function rn(e,t,n,r){if(Zt)if(0<Tt.length&&-1<zt.indexOf(e))e=Ft(null,e,t,n,r),Tt.push(e);else{var l=ln(e,t,n,r);if(null===l)Ot(e,r);else if(-1<zt.indexOf(e))e=Ft(l,e,t,n,r),Tt.push(e);else if(!Dt(l,e,t,n,r)){Ot(e,r),e=gt(e,r,null,t);try{A(vt,e)}finally{ht(e)}}}}function ln(e,t,n,r){if(null!==(n=Un(n=dt(r)))){var l=nt(n);if(null===l)n=null;else{var i=l.tag;if(13===i){if(null!==(n=rt(l)))return n;n=null}else if(3===i){if(l.stateNode.hydrate)return 3===l.tag?l.stateNode.containerInfo:null;n=null}else l!==n&&(n=null)}}e=gt(e,r,n,t);try{A(vt,e)}finally{ht(e)}return null}var an={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},on=[\"Webkit\",\"ms\",\"Moz\",\"O\"];function un(e,t,n){return null==t||\"boolean\"==typeof t||\"\"===t?\"\":n||\"number\"!=typeof t||0===t||an.hasOwnProperty(e)&&an[e]?(\"\"+t).trim():t+\"px\"}function cn(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf(\"--\"),l=un(n,t[n],r);\"float\"===n&&(n=\"cssFloat\"),r?e.setProperty(n,l):e[n]=l}}Object.keys(an).forEach(function(e){on.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),an[t]=an[e]})});var sn=t({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fn(e,t){if(t){if(sn[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(r(137,e,\"\"));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(r(60));if(!(\"object\"==typeof t.dangerouslySetInnerHTML&&\"__html\"in t.dangerouslySetInnerHTML))throw Error(r(61))}if(null!=t.style&&\"object\"!=typeof t.style)throw Error(r(62,\"\"))}}function dn(e,t){if(-1===e.indexOf(\"-\"))return\"string\"==typeof t.is;switch(e){case\"annotation-xml\":case\"color-profile\":case\"font-face\":case\"font-face-src\":case\"font-face-uri\":case\"font-face-format\":case\"font-face-name\":case\"missing-glyph\":return!1;default:return!0}}var pn=Ue.html;function mn(e,t){var n=tt(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=T[t];for(var r=0;r<t.length;r++)yt(t[r],e,n)}function hn(){}function gn(e){if(void 0===(e=e||(\"undefined\"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function vn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yn(e,t){var n,r=vn(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=vn(r)}}function bn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?bn(e,t.parentNode):\"contains\"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function wn(){for(var e=window,t=gn();t instanceof e.HTMLIFrameElement;){try{var n=\"string\"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=gn((e=t.contentWindow).document)}return t}function kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(\"input\"===t&&(\"text\"===e.type||\"search\"===e.type||\"tel\"===e.type||\"url\"===e.type||\"password\"===e.type)||\"textarea\"===t||\"true\"===e.contentEditable)}var xn=\"$\",Tn=\"/$\",En=\"$?\",Sn=\"$!\",Cn=null,Pn=null;function _n(e,t){switch(e){case\"button\":case\"input\":case\"select\":case\"textarea\":return!!t.autoFocus}return!1}function Nn(e,t){return\"textarea\"===e||\"option\"===e||\"noscript\"===e||\"string\"==typeof t.children||\"number\"==typeof t.children||\"object\"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var zn=\"function\"==typeof setTimeout?setTimeout:void 0,Mn=\"function\"==typeof clearTimeout?clearTimeout:void 0;function In(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break}return e}function Fn(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if(n===xn||n===Sn||n===En){if(0===t)return e;t--}else n===Tn&&t++}e=e.previousSibling}return null}var On=Math.random().toString(36).slice(2),Rn=\"__reactInternalInstance$\"+On,Dn=\"__reactEventHandlers$\"+On,Ln=\"__reactContainere$\"+On;function Un(e){var t=e[Rn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ln]||n[Rn]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fn(e);null!==e;){if(n=e[Rn])return n;e=Fn(e)}return t}n=(e=n).parentNode}return null}function An(e){return!(e=e[Rn]||e[Ln])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Vn(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(r(33))}function Qn(e){return e[Dn]||null}function Wn(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function Hn(e,t){var n=e.stateNode;if(!n)return null;var l=d(n);if(!l)return null;n=l[t];e:switch(t){case\"onClick\":case\"onClickCapture\":case\"onDoubleClick\":case\"onDoubleClickCapture\":case\"onMouseDown\":case\"onMouseDownCapture\":case\"onMouseMove\":case\"onMouseMoveCapture\":case\"onMouseUp\":case\"onMouseUpCapture\":case\"onMouseEnter\":(l=!l.disabled)||(l=!(\"button\"===(e=e.type)||\"input\"===e||\"select\"===e||\"textarea\"===e)),e=!l;break e;default:e=!1}if(e)return null;if(n&&\"function\"!=typeof n)throw Error(r(231,t,typeof n));return n}function jn(e,t,n){(t=Hn(e,n.dispatchConfig.phasedRegistrationNames[t]))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function Bn(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,n=[];t;)n.push(t),t=Wn(t);for(t=n.length;0<t--;)jn(n[t],\"captured\",e);for(t=0;t<n.length;t++)jn(n[t],\"bubbled\",e)}}function Kn(e,t,n){e&&n&&n.dispatchConfig.registrationName&&(t=Hn(e,n.dispatchConfig.registrationName))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function $n(e){e&&e.dispatchConfig.registrationName&&Kn(e._targetInst,null,e)}function qn(e){ut(e,Bn)}var Yn=null,Xn=null,Gn=null;function Zn(){if(Gn)return Gn;var e,t,n=Xn,r=n.length,l=\"value\"in Yn?Yn.value:Yn.textContent,i=l.length;for(e=0;e<r&&n[e]===l[e];e++);var a=r-e;for(t=1;t<=a&&n[r-t]===l[i-t];t++);return Gn=l.slice(e,1<t?1-t:void 0)}function Jn(){return!0}function er(){return!1}function tr(e,t,n,r){for(var l in this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n,e=this.constructor.Interface)e.hasOwnProperty(l)&&((t=e[l])?this[l]=t(n):\"target\"===l?this.target=r:this[l]=n[l]);return this.isDefaultPrevented=(null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue)?Jn:er,this.isPropagationStopped=er,this}function nr(e,t,n,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,t,n,r),l}return new this(e,t,n,r)}function rr(e){if(!(e instanceof this))throw Error(r(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function lr(e){e.eventPool=[],e.getPooled=nr,e.release=rr}t(tr.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():\"unknown\"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Jn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():\"unknown\"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Jn)},persist:function(){this.isPersistent=Jn},isPersistent:er,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=er,this._dispatchInstances=this._dispatchListeners=null}}),tr.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},tr.extend=function(e){function n(){}function r(){return l.apply(this,arguments)}var l=this;n.prototype=l.prototype;var i=new n;return t(i,r.prototype),r.prototype=i,r.prototype.constructor=r,r.Interface=t({},l.Interface,e),r.extend=l.extend,lr(r),r},lr(tr);var ir=tr.extend({data:null}),ar=tr.extend({data:null}),or=[9,13,27,32],ur=S&&\"CompositionEvent\"in window,cr=null;S&&\"documentMode\"in document&&(cr=document.documentMode);var sr=S&&\"TextEvent\"in window&&!cr,fr=S&&(!ur||cr&&8<cr&&11>=cr),dr=String.fromCharCode(32),pr={beforeInput:{phasedRegistrationNames:{bubbled:\"onBeforeInput\",captured:\"onBeforeInputCapture\"},dependencies:[\"compositionend\",\"keypress\",\"textInput\",\"paste\"]},compositionEnd:{phasedRegistrationNames:{bubbled:\"onCompositionEnd\",captured:\"onCompositionEndCapture\"},dependencies:\"blur compositionend keydown keypress keyup mousedown\".split(\" \")},compositionStart:{phasedRegistrationNames:{bubbled:\"onCompositionStart\",captured:\"onCompositionStartCapture\"},dependencies:\"blur compositionstart keydown keypress keyup mousedown\".split(\" \")},compositionUpdate:{phasedRegistrationNames:{bubbled:\"onCompositionUpdate\",captured:\"onCompositionUpdateCapture\"},dependencies:\"blur compositionupdate keydown keypress keyup mousedown\".split(\" \")}},mr=!1;function hr(e,t){switch(e){case\"keyup\":return-1!==or.indexOf(t.keyCode);case\"keydown\":return 229!==t.keyCode;case\"keypress\":case\"mousedown\":case\"blur\":return!0;default:return!1}}function gr(e){return\"object\"==typeof(e=e.detail)&&\"data\"in e?e.data:null}var vr=!1;function yr(e,t){switch(e){case\"compositionend\":return gr(t);case\"keypress\":return 32!==t.which?null:(mr=!0,dr);case\"textInput\":return(e=t.data)===dr&&mr?null:e;default:return null}}function br(e,t){if(vr)return\"compositionend\"===e||!ur&&hr(e,t)?(e=Zn(),Gn=Xn=Yn=null,vr=!1,e):null;switch(e){case\"paste\":return null;case\"keypress\":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case\"compositionend\":return fr&&\"ko\"!==t.locale?null:t.data;default:return null}}var wr={eventTypes:pr,extractEvents:function(e,t,n,r){var l;if(ur)e:{switch(e){case\"compositionstart\":var i=pr.compositionStart;break e;case\"compositionend\":i=pr.compositionEnd;break e;case\"compositionupdate\":i=pr.compositionUpdate;break e}i=void 0}else vr?hr(e,n)&&(i=pr.compositionEnd):\"keydown\"===e&&229===n.keyCode&&(i=pr.compositionStart);return i?(fr&&\"ko\"!==n.locale&&(vr||i!==pr.compositionStart?i===pr.compositionEnd&&vr&&(l=Zn()):(Xn=\"value\"in(Yn=r)?Yn.value:Yn.textContent,vr=!0)),i=ir.getPooled(i,t,n,r),l?i.data=l:null!==(l=gr(n))&&(i.data=l),qn(i),l=i):l=null,(e=sr?yr(e,n):br(e,n))?((t=ar.getPooled(pr.beforeInput,t,n,r)).data=e,qn(t)):t=null,null===l?t:null===t?l:[l,t]}},kr={color:!0,date:!0,datetime:!0,\"datetime-local\":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return\"input\"===t?!!kr[e.type]:\"textarea\"===t}var Tr={change:{phasedRegistrationNames:{bubbled:\"onChange\",captured:\"onChangeCapture\"},dependencies:\"blur change click focus input keydown keyup selectionchange\".split(\" \")}};function Er(e,t,n){return(e=tr.getPooled(Tr.change,e,t,n)).type=\"change\",z(n),qn(e),e}var Sr=null,Cr=null;function Pr(e){ft(e)}function _r(e){if(Ee(Vn(e)))return e}function Nr(e,t){if(\"change\"===e)return t}var zr=!1;function Mr(){Sr&&(Sr.detachEvent(\"onpropertychange\",Ir),Cr=Sr=null)}function Ir(e){if(\"value\"===e.propertyName&&_r(Cr))if(e=Er(Cr,e,dt(e)),D)ft(e);else{D=!0;try{I(Pr,e)}finally{D=!1,U()}}}function Fr(e,t,n){\"focus\"===e?(Mr(),Cr=n,(Sr=t).attachEvent(\"onpropertychange\",Ir)):\"blur\"===e&&Mr()}function Or(e){if(\"selectionchange\"===e||\"keyup\"===e||\"keydown\"===e)return _r(Cr)}function Rr(e,t){if(\"click\"===e)return _r(t)}function Dr(e,t){if(\"input\"===e||\"change\"===e)return _r(t)}S&&(zr=pt(\"input\")&&(!document.documentMode||9<document.documentMode));var Lr={eventTypes:Tr,_isInputEventSupported:zr,extractEvents:function(e,t,n,r){var l=t?Vn(t):window,i=l.nodeName&&l.nodeName.toLowerCase();if(\"select\"===i||\"input\"===i&&\"file\"===l.type)var a=Nr;else if(xr(l))if(zr)a=Dr;else{a=Or;var o=Fr}else(i=l.nodeName)&&\"input\"===i.toLowerCase()&&(\"checkbox\"===l.type||\"radio\"===l.type)&&(a=Rr);if(a&&(a=a(e,t)))return Er(a,n,r);o&&o(e,l,t),\"blur\"===e&&(e=l._wrapperState)&&e.controlled&&\"number\"===l.type&&ze(l,\"number\",l.value)}},Ur=tr.extend({view:null,detail:null}),Ar={Alt:\"altKey\",Control:\"ctrlKey\",Meta:\"metaKey\",Shift:\"shiftKey\"};function Vr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function Qr(){return Vr}var Wr=0,Hr=0,jr=!1,Br=!1,Kr=Ur.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:Qr,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},movementX:function(e){if(\"movementX\"in e)return e.movementX;var t=Wr;return Wr=e.screenX,jr?\"mousemove\"===e.type?e.screenX-t:0:(jr=!0,0)},movementY:function(e){if(\"movementY\"in e)return e.movementY;var t=Hr;return Hr=e.screenY,Br?\"mousemove\"===e.type?e.screenY-t:0:(Br=!0,0)}}),$r=Kr.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),qr={mouseEnter:{registrationName:\"onMouseEnter\",dependencies:[\"mouseout\",\"mouseover\"]},mouseLeave:{registrationName:\"onMouseLeave\",dependencies:[\"mouseout\",\"mouseover\"]},pointerEnter:{registrationName:\"onPointerEnter\",dependencies:[\"pointerout\",\"pointerover\"]},pointerLeave:{registrationName:\"onPointerLeave\",dependencies:[\"pointerout\",\"pointerover\"]}},Yr={eventTypes:qr,extractEvents:function(e,t,n,r,l){var i=\"mouseover\"===e||\"pointerover\"===e,a=\"mouseout\"===e||\"pointerout\"===e;if(i&&0==(32&l)&&(n.relatedTarget||n.fromElement)||!a&&!i)return null;(i=r.window===r?r:(i=r.ownerDocument)?i.defaultView||i.parentWindow:window,a)?(a=t,null!==(t=(t=n.relatedTarget||n.toElement)?Un(t):null)&&(t!==nt(t)||5!==t.tag&&6!==t.tag)&&(t=null)):a=null;if(a===t)return null;if(\"mouseout\"===e||\"mouseover\"===e)var o=Kr,u=qr.mouseLeave,c=qr.mouseEnter,s=\"mouse\";else\"pointerout\"!==e&&\"pointerover\"!==e||(o=$r,u=qr.pointerLeave,c=qr.pointerEnter,s=\"pointer\");if(e=null==a?i:Vn(a),i=null==t?i:Vn(t),(u=o.getPooled(u,a,n,r)).type=s+\"leave\",u.target=e,u.relatedTarget=i,(n=o.getPooled(c,t,n,r)).type=s+\"enter\",n.target=i,n.relatedTarget=e,s=t,(r=a)&&s)e:{for(c=s,a=0,e=o=r;e;e=Wn(e))a++;for(e=0,t=c;t;t=Wn(t))e++;for(;0<a-e;)o=Wn(o),a--;for(;0<e-a;)c=Wn(c),e--;for(;a--;){if(o===c||o===c.alternate)break e;o=Wn(o),c=Wn(c)}o=null}else o=null;for(c=o,o=[];r&&r!==c&&(null===(a=r.alternate)||a!==c);)o.push(r),r=Wn(r);for(r=[];s&&s!==c&&(null===(a=s.alternate)||a!==c);)r.push(s),s=Wn(s);for(s=0;s<o.length;s++)Kn(o[s],\"bubbled\",u);for(s=r.length;0<s--;)Kn(r[s],\"captured\",n);return 0==(64&l)?[u]:[u,n]}};function Xr(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t}var Gr=\"function\"==typeof Object.is?Object.is:Xr,Zr=Object.prototype.hasOwnProperty;function Jr(e,t){if(Gr(e,t))return!0;if(\"object\"!=typeof e||null===e||\"object\"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++)if(!Zr.call(t,n[r])||!Gr(e[n[r]],t[n[r]]))return!1;return!0}var el=S&&\"documentMode\"in document&&11>=document.documentMode,tl={select:{phasedRegistrationNames:{bubbled:\"onSelect\",captured:\"onSelectCapture\"},dependencies:\"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange\".split(\" \")}},nl=null,rl=null,ll=null,il=!1;function al(e,t){var n=t.window===t?t.document:9===t.nodeType?t:t.ownerDocument;return il||null==nl||nl!==gn(n)?null:(\"selectionStart\"in(n=nl)&&kn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},ll&&Jr(ll,n)?null:(ll=n,(e=tr.getPooled(tl.select,rl,e,t)).type=\"select\",e.target=nl,qn(e),e))}var ol={eventTypes:tl,extractEvents:function(e,t,n,r,l,i){if(!(i=!(l=i||(r.window===r?r.document:9===r.nodeType?r:r.ownerDocument)))){e:{l=tt(l),i=T.onSelect;for(var a=0;a<i.length;a++)if(!l.has(i[a])){l=!1;break e}l=!0}i=!l}if(i)return null;switch(l=t?Vn(t):window,e){case\"focus\":(xr(l)||\"true\"===l.contentEditable)&&(nl=l,rl=t,ll=null);break;case\"blur\":ll=rl=nl=null;break;case\"mousedown\":il=!0;break;case\"contextmenu\":case\"mouseup\":case\"dragend\":return il=!1,al(n,r);case\"selectionchange\":if(el)break;case\"keydown\":case\"keyup\":return al(n,r)}return null}},ul=tr.extend({animationName:null,elapsedTime:null,pseudoElement:null}),cl=tr.extend({clipboardData:function(e){return\"clipboardData\"in e?e.clipboardData:window.clipboardData}}),sl=Ur.extend({relatedTarget:null});function fl(e){var t=e.keyCode;return\"charCode\"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}var dl={Esc:\"Escape\",Spacebar:\" \",Left:\"ArrowLeft\",Up:\"ArrowUp\",Right:\"ArrowRight\",Down:\"ArrowDown\",Del:\"Delete\",Win:\"OS\",Menu:\"ContextMenu\",Apps:\"ContextMenu\",Scroll:\"ScrollLock\",MozPrintableKey:\"Unidentified\"},pl={8:\"Backspace\",9:\"Tab\",12:\"Clear\",13:\"Enter\",16:\"Shift\",17:\"Control\",18:\"Alt\",19:\"Pause\",20:\"CapsLock\",27:\"Escape\",32:\" \",33:\"PageUp\",34:\"PageDown\",35:\"End\",36:\"Home\",37:\"ArrowLeft\",38:\"ArrowUp\",39:\"ArrowRight\",40:\"ArrowDown\",45:\"Insert\",46:\"Delete\",112:\"F1\",113:\"F2\",114:\"F3\",115:\"F4\",116:\"F5\",117:\"F6\",118:\"F7\",119:\"F8\",120:\"F9\",121:\"F10\",122:\"F11\",123:\"F12\",144:\"NumLock\",145:\"ScrollLock\",224:\"Meta\"},ml=Ur.extend({key:function(e){if(e.key){var t=dl[e.key]||e.key;if(\"Unidentified\"!==t)return t}return\"keypress\"===e.type?13===(e=fl(e))?\"Enter\":String.fromCharCode(e):\"keydown\"===e.type||\"keyup\"===e.type?pl[e.keyCode]||\"Unidentified\":\"\"},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Qr,charCode:function(e){return\"keypress\"===e.type?fl(e):0},keyCode:function(e){return\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0},which:function(e){return\"keypress\"===e.type?fl(e):\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0}}),hl=Kr.extend({dataTransfer:null}),gl=Ur.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Qr}),vl=tr.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),yl=Kr.extend({deltaX:function(e){return\"deltaX\"in e?e.deltaX:\"wheelDeltaX\"in e?-e.wheelDeltaX:0},deltaY:function(e){return\"deltaY\"in e?e.deltaY:\"wheelDeltaY\"in e?-e.wheelDeltaY:\"wheelDelta\"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),bl={eventTypes:Ht,extractEvents:function(e,t,n,r){var l=jt.get(e);if(!l)return null;switch(e){case\"keypress\":if(0===fl(n))return null;case\"keydown\":case\"keyup\":e=ml;break;case\"blur\":case\"focus\":e=sl;break;case\"click\":if(2===n.button)return null;case\"auxclick\":case\"dblclick\":case\"mousedown\":case\"mousemove\":case\"mouseup\":case\"mouseout\":case\"mouseover\":case\"contextmenu\":e=Kr;break;case\"drag\":case\"dragend\":case\"dragenter\":case\"dragexit\":case\"dragleave\":case\"dragover\":case\"dragstart\":case\"drop\":e=hl;break;case\"touchcancel\":case\"touchend\":case\"touchmove\":case\"touchstart\":e=gl;break;case Ye:case Xe:case Ge:e=ul;break;case Ze:e=vl;break;case\"scroll\":e=Ur;break;case\"wheel\":e=yl;break;case\"copy\":case\"cut\":case\"paste\":e=cl;break;case\"gotpointercapture\":case\"lostpointercapture\":case\"pointercancel\":case\"pointerdown\":case\"pointermove\":case\"pointerout\":case\"pointerover\":case\"pointerup\":e=$r;break;default:e=tr}return qn(t=e.getPooled(l,t,n,r)),t}};if(g)throw Error(r(101));g=Array.prototype.slice.call(\"ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin\".split(\" \")),y();var wl=An;d=Qn,p=wl,m=Vn,E({SimpleEventPlugin:bl,EnterLeaveEventPlugin:Yr,ChangeEventPlugin:Lr,SelectEventPlugin:ol,BeforeInputEventPlugin:wr});var kl=[],xl=-1;function Tl(e){0>xl||(e.current=kl[xl],kl[xl]=null,xl--)}function El(e,t){kl[++xl]=e.current,e.current=t}var Sl={},Cl={current:Sl},Pl={current:!1},_l=Sl;function Nl(e,t){var n=e.type.contextTypes;if(!n)return Sl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,i={};for(l in n)i[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function zl(e){return null!=(e=e.childContextTypes)}function Ml(){Tl(Pl),Tl(Cl)}function Il(e,t,n){if(Cl.current!==Sl)throw Error(r(168));El(Cl,t),El(Pl,n)}function Fl(e,n,l){var i=e.stateNode;if(e=n.childContextTypes,\"function\"!=typeof i.getChildContext)return l;for(var a in i=i.getChildContext())if(!(a in e))throw Error(r(108,ye(n)||\"Unknown\",a));return t({},l,{},i)}function Ol(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Sl,_l=Cl.current,El(Cl,e),El(Pl,Pl.current),!0}function Rl(e,t,n){var l=e.stateNode;if(!l)throw Error(r(169));n?(e=Fl(e,t,_l),l.__reactInternalMemoizedMergedChildContext=e,Tl(Pl),Tl(Cl),El(Cl,e)):Tl(Pl),El(Pl,n)}var Dl=n.unstable_runWithPriority,Ll=n.unstable_scheduleCallback,Ul=n.unstable_cancelCallback,Al=n.unstable_requestPaint,Vl=n.unstable_now,Ql=n.unstable_getCurrentPriorityLevel,Wl=n.unstable_ImmediatePriority,Hl=n.unstable_UserBlockingPriority,jl=n.unstable_NormalPriority,Bl=n.unstable_LowPriority,Kl=n.unstable_IdlePriority,$l={},ql=n.unstable_shouldYield,Yl=void 0!==Al?Al:function(){},Xl=null,Gl=null,Zl=!1,Jl=Vl(),ei=1e4>Jl?Vl:function(){return Vl()-Jl};function ti(){switch(Ql()){case Wl:return 99;case Hl:return 98;case jl:return 97;case Bl:return 96;case Kl:return 95;default:throw Error(r(332))}}function ni(e){switch(e){case 99:return Wl;case 98:return Hl;case 97:return jl;case 96:return Bl;case 95:return Kl;default:throw Error(r(332))}}function ri(e,t){return e=ni(e),Dl(e,t)}function li(e,t,n){return e=ni(e),Ll(e,t,n)}function ii(e){return null===Xl?(Xl=[e],Gl=Ll(Wl,oi)):Xl.push(e),$l}function ai(){if(null!==Gl){var e=Gl;Gl=null,Ul(e)}oi()}function oi(){if(!Zl&&null!==Xl){Zl=!0;var e=0;try{var t=Xl;ri(99,function(){for(;e<t.length;e++){var n=t[e];do{n=n(!0)}while(null!==n)}}),Xl=null}catch(n){throw null!==Xl&&(Xl=Xl.slice(e+1)),Ll(Wl,ai),n}finally{Zl=!1}}}function ui(e,t,n){return 1073741821-(1+((1073741821-e+t/10)/(n/=10)|0))*n}function ci(e,n){if(e&&e.defaultProps)for(var r in n=t({},n),e=e.defaultProps)void 0===n[r]&&(n[r]=e[r]);return n}var si={current:null},fi=null,di=null,pi=null;function mi(){pi=di=fi=null}function hi(e){var t=si.current;Tl(si),e.type._context._currentValue=t}function gi(e,t){for(;null!==e;){var n=e.alternate;if(e.childExpirationTime<t)e.childExpirationTime=t,null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t);else{if(!(null!==n&&n.childExpirationTime<t))break;n.childExpirationTime=t}e=e.return}}function vi(e,t){fi=e,pi=di=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(e.expirationTime>=t&&(ja=!0),e.firstContext=null)}function yi(e,t){if(pi!==e&&!1!==t&&0!==t)if(\"number\"==typeof t&&1073741823!==t||(pi=e,t=1073741823),t={context:e,observedBits:t,next:null},null===di){if(null===fi)throw Error(r(308));di=t,fi.dependencies={expirationTime:0,firstContext:t,responders:null}}else di=di.next=t;return e._currentValue}var bi=!1;function wi(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function ki(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function xi(e,t){return(e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null}).next=e}function Ti(e,t){if(null!==(e=e.updateQueue)){var n=(e=e.shared).pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}}function Ei(e,t){var n=e.alternate;null!==n&&ki(n,e),null===(n=(e=e.updateQueue).baseQueue)?(e.baseQueue=t.next=t,t.next=t):(t.next=n.next,n.next=t)}function Si(e,n,r,l){var i=e.updateQueue;bi=!1;var a=i.baseQueue,o=i.shared.pending;if(null!==o){if(null!==a){var u=a.next;a.next=o.next,o.next=u}a=o,i.shared.pending=null,null!==(u=e.alternate)&&(null!==(u=u.updateQueue)&&(u.baseQueue=o))}if(null!==a){u=a.next;var c=i.baseState,s=0,f=null,d=null,p=null;if(null!==u)for(var m=u;;){if((o=m.expirationTime)<l){var h={expirationTime:m.expirationTime,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null};null===p?(d=p=h,f=c):p=p.next=h,o>s&&(s=o)}else{null!==p&&(p=p.next={expirationTime:1073741823,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null}),Fu(o,m.suspenseConfig);e:{var g=e,v=m;switch(o=n,h=r,v.tag){case 1:if(\"function\"==typeof(g=v.payload)){c=g.call(h,c,o);break e}c=g;break e;case 3:g.effectTag=-4097&g.effectTag|64;case 0:if(null==(o=\"function\"==typeof(g=v.payload)?g.call(h,c,o):g))break e;c=t({},c,o);break e;case 2:bi=!0}}null!==m.callback&&(e.effectTag|=32,null===(o=i.effects)?i.effects=[m]:o.push(m))}if(null===(m=m.next)||m===u){if(null===(o=i.shared.pending))break;m=a.next=o.next,o.next=u,i.baseQueue=a=o,i.shared.pending=null}}null===p?f=c:p.next=d,i.baseState=f,i.baseQueue=p,Ou(s),e.expirationTime=s,e.memoizedState=c}}function Ci(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var l=e[t],i=l.callback;if(null!==i){if(l.callback=null,l=i,i=n,\"function\"!=typeof l)throw Error(r(191,l));l.call(i)}}}var Pi=G.ReactCurrentBatchConfig,_i=(new e.Component).refs;function Ni(e,n,r,l){r=null==(r=r(l,n=e.memoizedState))?n:t({},n,r),e.memoizedState=r,0===e.expirationTime&&(e.updateQueue.baseState=r)}var zi={isMounted:function(e){return!!(e=e._reactInternalFiber)&&nt(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueReplaceState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).tag=1,l.payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var n=bu(),r=Pi.suspense;(r=xi(n=wu(n,e,r),r)).tag=2,null!=t&&(r.callback=t),Ti(e,r),ku(e,n)}};function Mi(e,t,n,r,l,i,a){return\"function\"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,a):!t.prototype||!t.prototype.isPureReactComponent||(!Jr(n,r)||!Jr(l,i))}function Ii(e,t,n){var r=!1,l=Sl,i=t.contextType;return\"object\"==typeof i&&null!==i?i=yi(i):(l=zl(t)?_l:Cl.current,i=(r=null!=(r=t.contextTypes))?Nl(e,l):Sl),t=new t(n,i),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=zi,e.stateNode=t,t._reactInternalFiber=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function Fi(e,t,n,r){e=t.state,\"function\"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),\"function\"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zi.enqueueReplaceState(t,t.state,null)}function Oi(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs=_i,wi(e);var i=t.contextType;\"object\"==typeof i&&null!==i?l.context=yi(i):(i=zl(t)?_l:Cl.current,l.context=Nl(e,i)),Si(e,n,l,r),l.state=e.memoizedState,\"function\"==typeof(i=t.getDerivedStateFromProps)&&(Ni(e,t,i,n),l.state=e.memoizedState),\"function\"==typeof t.getDerivedStateFromProps||\"function\"==typeof l.getSnapshotBeforeUpdate||\"function\"!=typeof l.UNSAFE_componentWillMount&&\"function\"!=typeof l.componentWillMount||(t=l.state,\"function\"==typeof l.componentWillMount&&l.componentWillMount(),\"function\"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),t!==l.state&&zi.enqueueReplaceState(l,l.state,null),Si(e,n,l,r),l.state=e.memoizedState),\"function\"==typeof l.componentDidMount&&(e.effectTag|=4)}var Ri=Array.isArray;function Di(e,t,n){if(null!==(e=n.ref)&&\"function\"!=typeof e&&\"object\"!=typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(r(309));var l=n.stateNode}if(!l)throw Error(r(147,e));var i=\"\"+e;return null!==t&&null!==t.ref&&\"function\"==typeof t.ref&&t.ref._stringRef===i?t.ref:((t=function(e){var t=l.refs;t===_i&&(t=l.refs={}),null===e?delete t[i]:t[i]=e})._stringRef=i,t)}if(\"string\"!=typeof e)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Li(e,t){if(\"textarea\"!==e.type)throw Error(r(31,\"[object Object]\"===Object.prototype.toString.call(t)?\"object with keys {\"+Object.keys(t).join(\", \")+\"}\":t,\"\"))}function Ui(e){function t(t,n){if(e){var r=t.lastEffect;null!==r?(r.nextEffect=n,t.lastEffect=n):t.firstEffect=t.lastEffect=n,n.nextEffect=null,n.effectTag=8}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function l(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=nc(e,t)).index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.effectTag=2,n):r:(t.effectTag=2,n):n}function o(t){return e&&null===t.alternate&&(t.effectTag=2),t}function u(e,t,n,r){return null===t||6!==t.tag?((t=ic(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){return null!==t&&t.elementType===n.type?((r=i(t,n.props)).ref=Di(e,t,n),r.return=e,r):((r=rc(n.type,n.key,n.props,null,e.mode,r)).ref=Di(e,t,n),r.return=e,r)}function s(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=ac(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function f(e,t,n,r,l){return null===t||7!==t.tag?((t=lc(n,e.mode,r,l)).return=e,t):((t=i(t,n)).return=e,t)}function d(e,t,n){if(\"string\"==typeof t||\"number\"==typeof t)return(t=ic(\"\"+t,e.mode,n)).return=e,t;if(\"object\"==typeof t&&null!==t){switch(t.$$typeof){case te:return(n=rc(t.type,t.key,t.props,null,e.mode,n)).ref=Di(e,null,t),n.return=e,n;case ne:return(t=ac(t,e.mode,n)).return=e,t}if(Ri(t)||ge(t))return(t=lc(t,e.mode,n,null)).return=e,t;Li(e,t)}return null}function p(e,t,n,r){var l=null!==t?t.key:null;if(\"string\"==typeof n||\"number\"==typeof n)return null!==l?null:u(e,t,\"\"+n,r);if(\"object\"==typeof n&&null!==n){switch(n.$$typeof){case te:return n.key===l?n.type===re?f(e,t,n.props.children,r,l):c(e,t,n,r):null;case ne:return n.key===l?s(e,t,n,r):null}if(Ri(n)||ge(n))return null!==l?null:f(e,t,n,r,null);Li(e,n)}return null}function m(e,t,n,r,l){if(\"string\"==typeof r||\"number\"==typeof r)return u(t,e=e.get(n)||null,\"\"+r,l);if(\"object\"==typeof r&&null!==r){switch(r.$$typeof){case te:return e=e.get(null===r.key?n:r.key)||null,r.type===re?f(t,e,r.props.children,l,r.key):c(t,e,r,l);case ne:return s(t,e=e.get(null===r.key?n:r.key)||null,r,l)}if(Ri(r)||ge(r))return f(t,e=e.get(n)||null,r,l,null);Li(t,r)}return null}function h(r,i,o,u){for(var c=null,s=null,f=i,h=i=0,g=null;null!==f&&h<o.length;h++){f.index>h?(g=f,f=null):g=f.sibling;var v=p(r,f,o[h],u);if(null===v){null===f&&(f=g);break}e&&f&&null===v.alternate&&t(r,f),i=a(v,i,h),null===s?c=v:s.sibling=v,s=v,f=g}if(h===o.length)return n(r,f),c;if(null===f){for(;h<o.length;h++)null!==(f=d(r,o[h],u))&&(i=a(f,i,h),null===s?c=f:s.sibling=f,s=f);return c}for(f=l(r,f);h<o.length;h++)null!==(g=m(f,r,h,o[h],u))&&(e&&null!==g.alternate&&f.delete(null===g.key?h:g.key),i=a(g,i,h),null===s?c=g:s.sibling=g,s=g);return e&&f.forEach(function(e){return t(r,e)}),c}function g(i,o,u,c){var s=ge(u);if(\"function\"!=typeof s)throw Error(r(150));if(null==(u=s.call(u)))throw Error(r(151));for(var f=s=null,h=o,g=o=0,v=null,y=u.next();null!==h&&!y.done;g++,y=u.next()){h.index>g?(v=h,h=null):v=h.sibling;var b=p(i,h,y.value,c);if(null===b){null===h&&(h=v);break}e&&h&&null===b.alternate&&t(i,h),o=a(b,o,g),null===f?s=b:f.sibling=b,f=b,h=v}if(y.done)return n(i,h),s;if(null===h){for(;!y.done;g++,y=u.next())null!==(y=d(i,y.value,c))&&(o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return s}for(h=l(i,h);!y.done;g++,y=u.next())null!==(y=m(h,i,g,y.value,c))&&(e&&null!==y.alternate&&h.delete(null===y.key?g:y.key),o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return e&&h.forEach(function(e){return t(i,e)}),s}return function(e,l,a,u){var c=\"object\"==typeof a&&null!==a&&a.type===re&&null===a.key;c&&(a=a.props.children);var s=\"object\"==typeof a&&null!==a;if(s)switch(a.$$typeof){case te:e:{for(s=a.key,c=l;null!==c;){if(c.key===s){switch(c.tag){case 7:if(a.type===re){n(e,c.sibling),(l=i(c,a.props.children)).return=e,e=l;break e}break;default:if(c.elementType===a.type){n(e,c.sibling),(l=i(c,a.props)).ref=Di(e,c,a),l.return=e,e=l;break e}}n(e,c);break}t(e,c),c=c.sibling}a.type===re?((l=lc(a.props.children,e.mode,u,a.key)).return=e,e=l):((u=rc(a.type,a.key,a.props,null,e.mode,u)).ref=Di(e,l,a),u.return=e,e=u)}return o(e);case ne:e:{for(c=a.key;null!==l;){if(l.key===c){if(4===l.tag&&l.stateNode.containerInfo===a.containerInfo&&l.stateNode.implementation===a.implementation){n(e,l.sibling),(l=i(l,a.children||[])).return=e,e=l;break e}n(e,l);break}t(e,l),l=l.sibling}(l=ac(a,e.mode,u)).return=e,e=l}return o(e)}if(\"string\"==typeof a||\"number\"==typeof a)return a=\"\"+a,null!==l&&6===l.tag?(n(e,l.sibling),(l=i(l,a)).return=e,e=l):(n(e,l),(l=ic(a,e.mode,u)).return=e,e=l),o(e);if(Ri(a))return h(e,l,a,u);if(ge(a))return g(e,l,a,u);if(s&&Li(e,a),void 0===a&&!c)switch(e.tag){case 1:case 0:throw e=e.type,Error(r(152,e.displayName||e.name||\"Component\"))}return n(e,l)}}var Ai=Ui(!0),Vi=Ui(!1),Qi={},Wi={current:Qi},Hi={current:Qi},ji={current:Qi};function Bi(e){if(e===Qi)throw Error(r(174));return e}function Ki(e,t){switch(El(ji,t),El(Hi,e),El(Wi,Qi),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ve(null,\"\");break;default:t=Ve(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}Tl(Wi),El(Wi,t)}function $i(){Tl(Wi),Tl(Hi),Tl(ji)}function qi(e){Bi(ji.current);var t=Bi(Wi.current),n=Ve(t,e.type);t!==n&&(El(Hi,e),El(Wi,n))}function Yi(e){Hi.current===e&&(Tl(Wi),Tl(Hi))}var Xi={current:0};function Gi(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||n.data===En||n.data===Sn))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(64&t.effectTag))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Zi(e,t){return{responder:e,props:t}}var Ji=G.ReactCurrentDispatcher,ea=G.ReactCurrentBatchConfig,ta=0,na=null,ra=null,la=null,ia=!1;function aa(){throw Error(r(321))}function oa(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Gr(e[n],t[n]))return!1;return!0}function ua(e,t,n,l,i,a){if(ta=a,na=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,Ji.current=null===e||null===e.memoizedState?Ma:Ia,e=n(l,i),t.expirationTime===ta){a=0;do{if(t.expirationTime=0,!(25>a))throw Error(r(301));a+=1,la=ra=null,t.updateQueue=null,Ji.current=Fa,e=n(l,i)}while(t.expirationTime===ta)}if(Ji.current=za,t=null!==ra&&null!==ra.next,ta=0,la=ra=na=null,ia=!1,t)throw Error(r(300));return e}function ca(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===la?na.memoizedState=la=e:la=la.next=e,la}function sa(){if(null===ra){var e=na.alternate;e=null!==e?e.memoizedState:null}else e=ra.next;var t=null===la?na.memoizedState:la.next;if(null!==t)la=t,ra=e;else{if(null===e)throw Error(r(310));e={memoizedState:(ra=e).memoizedState,baseState:ra.baseState,baseQueue:ra.baseQueue,queue:ra.queue,next:null},null===la?na.memoizedState=la=e:la=la.next=e}return la}function fa(e,t){return\"function\"==typeof t?t(e):t}function da(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=ra,i=l.baseQueue,a=n.pending;if(null!==a){if(null!==i){var o=i.next;i.next=a.next,a.next=o}l.baseQueue=i=a,n.pending=null}if(null!==i){i=i.next,l=l.baseState;var u=o=a=null,c=i;do{var s=c.expirationTime;if(s<ta){var f={expirationTime:c.expirationTime,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null};null===u?(o=u=f,a=l):u=u.next=f,s>na.expirationTime&&(na.expirationTime=s,Ou(s))}else null!==u&&(u=u.next={expirationTime:1073741823,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null}),Fu(s,c.suspenseConfig),l=c.eagerReducer===e?c.eagerState:e(l,c.action);c=c.next}while(null!==c&&c!==i);null===u?a=l:u.next=o,Gr(l,t.memoizedState)||(ja=!0),t.memoizedState=l,t.baseState=a,t.baseQueue=u,n.lastRenderedState=l}return[t.memoizedState,n.dispatch]}function pa(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=n.dispatch,i=n.pending,a=t.memoizedState;if(null!==i){n.pending=null;var o=i=i.next;do{a=e(a,o.action),o=o.next}while(o!==i);Gr(a,t.memoizedState)||(ja=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),n.lastRenderedState=a}return[a,l]}function ma(e){var t=ca();return\"function\"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={pending:null,dispatch:null,lastRenderedReducer:fa,lastRenderedState:e}).dispatch=Na.bind(null,na,e),[t.memoizedState,e]}function ha(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=na.updateQueue)?(t={lastEffect:null},na.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ga(){return sa().memoizedState}function va(e,t,n,r){var l=ca();na.effectTag|=e,l.memoizedState=ha(1|t,n,void 0,void 0===r?null:r)}function ya(e,t,n,r){var l=sa();r=void 0===r?null:r;var i=void 0;if(null!==ra){var a=ra.memoizedState;if(i=a.destroy,null!==r&&oa(r,a.deps))return void ha(t,n,i,r)}na.effectTag|=e,l.memoizedState=ha(1|t,n,i,r)}function ba(e,t){return va(516,4,e,t)}function wa(e,t){return ya(516,4,e,t)}function ka(e,t){return ya(4,2,e,t)}function xa(e,t){return\"function\"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ta(e,t,n){return n=null!=n?n.concat([e]):null,ya(4,2,xa.bind(null,t,e),n)}function Ea(){}function Sa(e,t){return ca().memoizedState=[e,void 0===t?null:t],e}function Ca(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Pa(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function _a(e,t,n){var r=ti();ri(98>r?98:r,function(){e(!0)}),ri(97<r?97:r,function(){var r=ea.suspense;ea.suspense=void 0===t?null:t;try{e(!1),n()}finally{ea.suspense=r}})}function Na(e,t,n){var r=bu(),l=Pi.suspense;l={expirationTime:r=wu(r,e,l),suspenseConfig:l,action:n,eagerReducer:null,eagerState:null,next:null};var i=t.pending;if(null===i?l.next=l:(l.next=i.next,i.next=l),t.pending=l,i=e.alternate,e===na||null!==i&&i===na)ia=!0,l.expirationTime=ta,na.expirationTime=ta;else{if(0===e.expirationTime&&(null===i||0===i.expirationTime)&&null!==(i=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=i(a,n);if(l.eagerReducer=i,l.eagerState=o,Gr(o,a))return}catch(u){}ku(e,r)}}var za={readContext:yi,useCallback:aa,useContext:aa,useEffect:aa,useImperativeHandle:aa,useLayoutEffect:aa,useMemo:aa,useReducer:aa,useRef:aa,useState:aa,useDebugValue:aa,useResponder:aa,useDeferredValue:aa,useTransition:aa},Ma={readContext:yi,useCallback:Sa,useContext:yi,useEffect:ba,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,va(4,2,xa.bind(null,t,e),n)},useLayoutEffect:function(e,t){return va(4,2,e,t)},useMemo:function(e,t){var n=ca();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ca();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Na.bind(null,na,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ca().memoizedState=e},useState:ma,useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=ma(e),r=n[0],l=n[1];return ba(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=ma(!1),n=t[0];return t=t[1],[Sa(_a.bind(null,t,e),[t,e]),n]}},Ia={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:da,useRef:ga,useState:function(){return da(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=da(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=da(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Fa={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:pa,useRef:ga,useState:function(){return pa(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=pa(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=pa(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Oa=null,Ra=null,Da=!1;function La(e,t){var n=Ju(5,null,null,0);n.elementType=\"DELETED\",n.type=\"DELETED\",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function Ua(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=\"\"===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);case 13:default:return!1}}function Aa(e){if(Da){var t=Ra;if(t){var n=t;if(!Ua(e,t)){if(!(t=In(n.nextSibling))||!Ua(e,t))return e.effectTag=-1025&e.effectTag|2,Da=!1,void(Oa=e);La(Oa,n)}Oa=e,Ra=In(t.firstChild)}else e.effectTag=-1025&e.effectTag|2,Da=!1,Oa=e}}function Va(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;Oa=e}function Qa(e){if(e!==Oa)return!1;if(!Da)return Va(e),Da=!0,!1;var t=e.type;if(5!==e.tag||\"head\"!==t&&\"body\"!==t&&!Nn(t,e.memoizedProps))for(t=Ra;t;)La(e,t),t=In(t.nextSibling);if(Va(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if(n===Tn){if(0===t){Ra=In(e.nextSibling);break e}t--}else n!==xn&&n!==Sn&&n!==En||t++}e=e.nextSibling}Ra=null}}else Ra=Oa?In(e.stateNode.nextSibling):null;return!0}function Wa(){Ra=Oa=null,Da=!1}var Ha=G.ReactCurrentOwner,ja=!1;function Ba(e,t,n,r){t.child=null===e?Vi(t,null,n,r):Ai(t,e.child,n,r)}function Ka(e,t,n,r,l){n=n.render;var i=t.ref;return vi(t,l),r=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function $a(e,t,n,r,l,i){if(null===e){var a=n.type;return\"function\"!=typeof a||ec(a)||void 0!==a.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=rc(n.type,null,r,null,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,qa(e,t,a,r,l,i))}return a=e.child,l<i&&(l=a.memoizedProps,(n=null!==(n=n.compare)?n:Jr)(l,r)&&e.ref===t.ref)?co(e,t,i):(t.effectTag|=1,(e=nc(a,r)).ref=t.ref,e.return=t,t.child=e)}function qa(e,t,n,r,l,i){return null!==e&&Jr(e.memoizedProps,r)&&e.ref===t.ref&&(ja=!1,l<i)?(t.expirationTime=e.expirationTime,co(e,t,i)):Xa(e,t,n,r,i)}function Ya(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.effectTag|=128)}function Xa(e,t,n,r,l){var i=zl(n)?_l:Cl.current;return i=Nl(t,i),vi(t,l),n=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,n,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function Ga(e,t,n,r,l){if(zl(n)){var i=!0;Ol(t)}else i=!1;if(vi(t,l),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),Ii(t,n,r),Oi(t,n,r,l),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var u=a.context,c=n.contextType;\"object\"==typeof c&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current);var s=n.getDerivedStateFromProps,f=\"function\"==typeof s||\"function\"==typeof a.getSnapshotBeforeUpdate;f||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1;var d=t.memoizedState;a.state=d,Si(t,r,a,l),u=t.memoizedState,o!==r||d!==u||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),u=t.memoizedState),(o=bi||Mi(t,n,o,r,d,u,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillMount&&\"function\"!=typeof a.componentWillMount||(\"function\"==typeof a.componentWillMount&&a.componentWillMount(),\"function\"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),\"function\"==typeof a.componentDidMount&&(t.effectTag|=4)):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=c,r=o):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),r=!1)}else a=t.stateNode,ki(e,t),o=t.memoizedProps,a.props=t.type===t.elementType?o:ci(t.type,o),u=a.context,\"object\"==typeof(c=n.contextType)&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current),(f=\"function\"==typeof(s=n.getDerivedStateFromProps)||\"function\"==typeof a.getSnapshotBeforeUpdate)||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1,u=t.memoizedState,a.state=u,Si(t,r,a,l),d=t.memoizedState,o!==r||u!==d||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),d=t.memoizedState),(s=bi||Mi(t,n,o,r,u,d,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillUpdate&&\"function\"!=typeof a.componentWillUpdate||(\"function\"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,d,c),\"function\"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,d,c)),\"function\"==typeof a.componentDidUpdate&&(t.effectTag|=4),\"function\"==typeof a.getSnapshotBeforeUpdate&&(t.effectTag|=256)):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),t.memoizedProps=r,t.memoizedState=d),a.props=r,a.state=d,a.context=c,r=s):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),r=!1);return Za(e,t,n,r,i,l)}function Za(e,t,n,r,l,i){Ya(e,t);var a=0!=(64&t.effectTag);if(!r&&!a)return l&&Rl(t,n,!1),co(e,t,i);r=t.stateNode,Ha.current=t;var o=a&&\"function\"!=typeof n.getDerivedStateFromError?null:r.render();return t.effectTag|=1,null!==e&&a?(t.child=Ai(t,e.child,null,i),t.child=Ai(t,null,o,i)):Ba(e,t,o,i),t.memoizedState=r.state,l&&Rl(t,n,!0),t.child}function Ja(e){var t=e.stateNode;t.pendingContext?Il(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Il(e,t.context,!1),Ki(e,t.containerInfo)}var eo,to,no,ro,lo={dehydrated:null,retryTime:0};function io(e,t,n){var r,l=t.mode,i=t.pendingProps,a=Xi.current,o=!1;if((r=0!=(64&t.effectTag))||(r=0!=(2&a)&&(null===e||null!==e.memoizedState)),r?(o=!0,t.effectTag&=-65):null!==e&&null===e.memoizedState||void 0===i.fallback||!0===i.unstable_avoidThisFallback||(a|=1),El(Xi,1&a),null===e){if(void 0!==i.fallback&&Aa(t),o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,t.memoizedState=lo,t.child=i,n}return l=i.children,t.memoizedState=null,t.child=Vi(t,null,l,n)}if(null!==e.memoizedState){if(l=(e=e.child).sibling,o){if(i=i.fallback,(n=nc(e,e.pendingProps)).return=t,0==(2&t.mode)&&(o=null!==t.memoizedState?t.child.child:t.child)!==e.child)for(n.child=o;null!==o;)o.return=n,o=o.sibling;return(l=nc(l,i)).return=t,n.sibling=l,n.childExpirationTime=0,t.memoizedState=lo,t.child=n,l}return n=Ai(t,e.child,i.children,n),t.memoizedState=null,t.child=n}if(e=e.child,o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,i.child=e,null!==e&&(e.return=i),0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,n.effectTag|=2,i.childExpirationTime=0,t.memoizedState=lo,t.child=i,n}return t.memoizedState=null,t.child=Ai(t,e,i.children,n)}function ao(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t),gi(e.return,t)}function oo(e,t,n,r,l,i){var a=e.memoizedState;null===a?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailExpiration:0,tailMode:l,lastEffect:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailExpiration=0,a.tailMode=l,a.lastEffect=i)}function uo(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(Ba(e,t,r.children,n),0!=(2&(r=Xi.current)))r=1&r|2,t.effectTag|=64;else{if(null!==e&&0!=(64&e.effectTag))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ao(e,n);else if(19===e.tag)ao(e,n);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(El(Xi,r),0==(2&t.mode))t.memoizedState=null;else switch(l){case\"forwards\":for(n=t.child,l=null;null!==n;)null!==(e=n.alternate)&&null===Gi(e)&&(l=n),n=n.sibling;null===(n=l)?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),oo(t,!1,l,n,i,t.lastEffect);break;case\"backwards\":for(n=null,l=t.child,t.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Gi(e)){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}oo(t,!0,n,null,i,t.lastEffect);break;case\"together\":oo(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function co(e,t,n){null!==e&&(t.dependencies=e.dependencies);var l=t.expirationTime;if(0!==l&&Ou(l),t.childExpirationTime<n)return null;if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=nc(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=nc(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function so(e,t){switch(e.tailMode){case\"hidden\":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case\"collapsed\":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function fo(e,n,l){var i=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return zl(n.type)&&Ml(),null;case 3:return $i(),Tl(Pl),Tl(Cl),(l=n.stateNode).pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||!Qa(n)||(n.effectTag|=4),to(n),null;case 5:Yi(n),l=Bi(ji.current);var a=n.type;if(null!==e&&null!=n.stateNode)no(e,n,a,i,l),e.ref!==n.ref&&(n.effectTag|=128);else{if(!i){if(null===n.stateNode)throw Error(r(166));return null}if(e=Bi(Wi.current),Qa(n)){i=n.stateNode,a=n.type;var o=n.memoizedProps;switch(i[Rn]=n,i[Dn]=o,a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",i);break;case\"video\":case\"audio\":for(e=0;e<Je.length;e++)Jt(Je[e],i);break;case\"source\":Jt(\"error\",i);break;case\"img\":case\"image\":case\"link\":Jt(\"error\",i),Jt(\"load\",i);break;case\"form\":Jt(\"reset\",i),Jt(\"submit\",i);break;case\"details\":Jt(\"toggle\",i);break;case\"input\":Ce(i,o),Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"select\":i._wrapperState={wasMultiple:!!o.multiple},Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"textarea\":Re(i,o),Jt(\"invalid\",i),mn(l,\"onChange\")}for(var u in fn(a,o),e=null,o)if(o.hasOwnProperty(u)){var c=o[u];\"children\"===u?\"string\"==typeof c?i.textContent!==c&&(e=[\"children\",c]):\"number\"==typeof c&&i.textContent!==\"\"+c&&(e=[\"children\",\"\"+c]):x.hasOwnProperty(u)&&null!=c&&mn(l,u)}switch(a){case\"input\":Te(i),Ne(i,o,!0);break;case\"textarea\":Te(i),Le(i);break;case\"select\":case\"option\":break;default:\"function\"==typeof o.onClick&&(i.onclick=hn)}l=e,n.updateQueue=l,null!==l&&(n.effectTag|=4)}else{switch(u=9===l.nodeType?l:l.ownerDocument,e===pn&&(e=Ae(a)),e===pn?\"script\"===a?((e=u.createElement(\"div\")).innerHTML=\"<script><\\/script>\",e=e.removeChild(e.firstChild)):\"string\"==typeof i.is?e=u.createElement(a,{is:i.is}):(e=u.createElement(a),\"select\"===a&&(u=e,i.multiple?u.multiple=!0:i.size&&(u.size=i.size))):e=u.createElementNS(e,a),e[Rn]=n,e[Dn]=i,eo(e,n,!1,!1),n.stateNode=e,u=dn(a,i),a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",e),c=i;break;case\"video\":case\"audio\":for(c=0;c<Je.length;c++)Jt(Je[c],e);c=i;break;case\"source\":Jt(\"error\",e),c=i;break;case\"img\":case\"image\":case\"link\":Jt(\"error\",e),Jt(\"load\",e),c=i;break;case\"form\":Jt(\"reset\",e),Jt(\"submit\",e),c=i;break;case\"details\":Jt(\"toggle\",e),c=i;break;case\"input\":Ce(e,i),c=Se(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"option\":c=Ie(e,i);break;case\"select\":e._wrapperState={wasMultiple:!!i.multiple},c=t({},i,{value:void 0}),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"textarea\":Re(e,i),c=Oe(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;default:c=i}fn(a,c);var s=c;for(o in s)if(s.hasOwnProperty(o)){var f=s[o];\"style\"===o?cn(e,f):\"dangerouslySetInnerHTML\"===o?null!=(f=f?f.__html:void 0)&&We(e,f):\"children\"===o?\"string\"==typeof f?(\"textarea\"!==a||\"\"!==f)&&He(e,f):\"number\"==typeof f&&He(e,\"\"+f):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?null!=f&&mn(l,o):null!=f&&Z(e,o,f,u))}switch(a){case\"input\":Te(e),Ne(e,i,!1);break;case\"textarea\":Te(e),Le(e);break;case\"option\":null!=i.value&&e.setAttribute(\"value\",\"\"+we(i.value));break;case\"select\":e.multiple=!!i.multiple,null!=(l=i.value)?Fe(e,!!i.multiple,l,!1):null!=i.defaultValue&&Fe(e,!!i.multiple,i.defaultValue,!0);break;default:\"function\"==typeof c.onClick&&(e.onclick=hn)}_n(a,i)&&(n.effectTag|=4)}null!==n.ref&&(n.effectTag|=128)}return null;case 6:if(e&&null!=n.stateNode)ro(e,n,e.memoizedProps,i);else{if(\"string\"!=typeof i&&null===n.stateNode)throw Error(r(166));l=Bi(ji.current),Bi(Wi.current),Qa(n)?(l=n.stateNode,i=n.memoizedProps,l[Rn]=n,l.nodeValue!==i&&(n.effectTag|=4)):((l=(9===l.nodeType?l:l.ownerDocument).createTextNode(i))[Rn]=n,n.stateNode=l)}return null;case 13:return Tl(Xi),i=n.memoizedState,0!=(64&n.effectTag)?(n.expirationTime=l,n):(l=null!==i,i=!1,null===e?void 0!==n.memoizedProps.fallback&&Qa(n):(i=null!==(a=e.memoizedState),l||null===a||null!==(a=e.child.sibling)&&(null!==(o=n.firstEffect)?(n.firstEffect=a,a.nextEffect=o):(n.firstEffect=n.lastEffect=a,a.nextEffect=null),a.effectTag=8)),l&&!i&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&Xi.current)?Jo===Ho&&(Jo=Ko):(Jo!==Ho&&Jo!==Ko||(Jo=$o),0!==lu&&null!==Xo&&(cc(Xo,Zo),sc(Xo,lu)))),(l||i)&&(n.effectTag|=4),null);case 4:return $i(),to(n),null;case 10:return hi(n),null;case 17:return zl(n.type)&&Ml(),null;case 19:if(Tl(Xi),null===(i=n.memoizedState))return null;if(a=0!=(64&n.effectTag),null===(o=i.rendering)){if(a)so(i,!1);else if(Jo!==Ho||null!==e&&0!=(64&e.effectTag))for(o=n.child;null!==o;){if(null!==(e=Gi(o))){for(n.effectTag|=64,so(i,!1),null!==(a=e.updateQueue)&&(n.updateQueue=a,n.effectTag|=4),null===i.lastEffect&&(n.firstEffect=null),n.lastEffect=i.lastEffect,i=n.child;null!==i;)o=l,(a=i).effectTag&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,null===(e=a.alternate)?(a.childExpirationTime=0,a.expirationTime=o,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null):(a.childExpirationTime=e.childExpirationTime,a.expirationTime=e.expirationTime,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,o=e.dependencies,a.dependencies=null===o?null:{expirationTime:o.expirationTime,firstContext:o.firstContext,responders:o.responders}),i=i.sibling;return El(Xi,1&Xi.current|2),n.child}o=o.sibling}}else{if(!a)if(null!==(e=Gi(o))){if(n.effectTag|=64,a=!0,null!==(l=e.updateQueue)&&(n.updateQueue=l,n.effectTag|=4),so(i,!0),null===i.tail&&\"hidden\"===i.tailMode&&!o.alternate)return null!==(n=n.lastEffect=i.lastEffect)&&(n.nextEffect=null),null}else 2*ei()-i.renderingStartTime>i.tailExpiration&&1<l&&(n.effectTag|=64,a=!0,so(i,!1),n.expirationTime=n.childExpirationTime=l-1);i.isBackwards?(o.sibling=n.child,n.child=o):(null!==(l=i.last)?l.sibling=o:n.child=o,i.last=o)}return null!==i.tail?(0===i.tailExpiration&&(i.tailExpiration=ei()+500),l=i.tail,i.rendering=l,i.tail=l.sibling,i.lastEffect=n.lastEffect,i.renderingStartTime=ei(),l.sibling=null,n=Xi.current,El(Xi,a?1&n|2:1&n),l):null}throw Error(r(156,n.tag))}function po(e){switch(e.tag){case 1:zl(e.type)&&Ml();var t=e.effectTag;return 4096&t?(e.effectTag=-4097&t|64,e):null;case 3:if($i(),Tl(Pl),Tl(Cl),0!=(64&(t=e.effectTag)))throw Error(r(285));return e.effectTag=-4097&t|64,e;case 5:return Yi(e),null;case 13:return Tl(Xi),4096&(t=e.effectTag)?(e.effectTag=-4097&t|64,e):null;case 19:return Tl(Xi),null;case 4:return $i(),null;case 10:return hi(e),null;default:return null}}function mo(e,t){return{value:e,source:t,stack:be(t)}}eo=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},to=function(){},no=function(e,n,r,l,i){var a=e.memoizedProps;if(a!==l){var o,u,c=n.stateNode;switch(Bi(Wi.current),e=null,r){case\"input\":a=Se(c,a),l=Se(c,l),e=[];break;case\"option\":a=Ie(c,a),l=Ie(c,l),e=[];break;case\"select\":a=t({},a,{value:void 0}),l=t({},l,{value:void 0}),e=[];break;case\"textarea\":a=Oe(c,a),l=Oe(c,l),e=[];break;default:\"function\"!=typeof a.onClick&&\"function\"==typeof l.onClick&&(c.onclick=hn)}for(o in fn(r,l),r=null,a)if(!l.hasOwnProperty(o)&&a.hasOwnProperty(o)&&null!=a[o])if(\"style\"===o)for(u in c=a[o])c.hasOwnProperty(u)&&(r||(r={}),r[u]=\"\");else\"dangerouslySetInnerHTML\"!==o&&\"children\"!==o&&\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?e||(e=[]):(e=e||[]).push(o,null));for(o in l){var s=l[o];if(c=null!=a?a[o]:void 0,l.hasOwnProperty(o)&&s!==c&&(null!=s||null!=c))if(\"style\"===o)if(c){for(u in c)!c.hasOwnProperty(u)||s&&s.hasOwnProperty(u)||(r||(r={}),r[u]=\"\");for(u in s)s.hasOwnProperty(u)&&c[u]!==s[u]&&(r||(r={}),r[u]=s[u])}else r||(e||(e=[]),e.push(o,r)),r=s;else\"dangerouslySetInnerHTML\"===o?(s=s?s.__html:void 0,c=c?c.__html:void 0,null!=s&&c!==s&&(e=e||[]).push(o,s)):\"children\"===o?c===s||\"string\"!=typeof s&&\"number\"!=typeof s||(e=e||[]).push(o,\"\"+s):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&(x.hasOwnProperty(o)?(null!=s&&mn(i,o),e||c===s||(e=[])):(e=e||[]).push(o,s))}r&&(e=e||[]).push(\"style\",r),i=e,(n.updateQueue=i)&&(n.effectTag|=4)}},ro=function(e,t,n,r){n!==r&&(t.effectTag|=4)};var ho=\"function\"==typeof WeakSet?WeakSet:Set;function go(e,t){var n=t.source,r=t.stack;null===r&&null!==n&&(r=be(n)),null!==n&&ye(n.type),t=t.value,null!==e&&1===e.tag&&ye(e.type);try{console.error(t)}catch(l){setTimeout(function(){throw l})}}function vo(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(n){Ku(e,n)}}function yo(e){var t=e.ref;if(null!==t)if(\"function\"==typeof t)try{t(null)}catch(n){Ku(e,n)}else t.current=null}function bo(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&t.effectTag&&null!==e){var n=e.memoizedProps,l=e.memoizedState;t=(e=t.stateNode).getSnapshotBeforeUpdate(t.elementType===t.type?n:ci(t.type,n),l),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(r(163))}function wo(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.destroy;n.destroy=void 0,void 0!==r&&r()}n=n.next}while(n!==t)}}function ko(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xo(e,t,n){switch(n.tag){case 0:case 11:case 15:case 22:return void ko(3,n);case 1:if(e=n.stateNode,4&n.effectTag)if(null===t)e.componentDidMount();else{var l=n.elementType===n.type?t.memoizedProps:ci(n.type,t.memoizedProps);e.componentDidUpdate(l,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}return void(null!==(t=n.updateQueue)&&Ci(n,t,e));case 3:if(null!==(t=n.updateQueue)){if(e=null,null!==n.child)switch(n.child.tag){case 5:e=n.child.stateNode;break;case 1:e=n.child.stateNode}Ci(n,t,e)}return;case 5:return e=n.stateNode,void(null===t&&4&n.effectTag&&_n(n.type,n.memoizedProps)&&e.focus());case 6:case 4:case 12:return;case 13:return void(null===n.memoizedState&&(n=n.alternate,null!==n&&(n=n.memoizedState,null!==n&&(n=n.dehydrated,null!==n&&Wt(n)))));case 19:case 17:case 20:case 21:return}throw Error(r(163))}function To(e,t,n){switch(\"function\"==typeof Xu&&Xu(t),t.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e.next;ri(97<n?97:n,function(){var e=r;do{var n=e.destroy;if(void 0!==n){var l=t;try{n()}catch(i){Ku(l,i)}}e=e.next}while(e!==r)})}break;case 1:yo(t),\"function\"==typeof(n=t.stateNode).componentWillUnmount&&vo(t,n);break;case 5:yo(t);break;case 4:No(e,t,n)}}function Eo(e){var t=e.alternate;e.return=null,e.child=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.alternate=null,e.firstEffect=null,e.lastEffect=null,e.pendingProps=null,e.memoizedProps=null,e.stateNode=null,null!==t&&Eo(t)}function So(e){return 5===e.tag||3===e.tag||4===e.tag}function Co(e){e:{for(var t=e.return;null!==t;){if(So(t)){var n=t;break e}t=t.return}throw Error(r(160))}switch(t=n.stateNode,n.tag){case 5:var l=!1;break;case 3:case 4:t=t.containerInfo,l=!0;break;default:throw Error(r(161))}16&n.effectTag&&(He(t,\"\"),n.effectTag&=-17);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||So(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;5!==n.tag&&6!==n.tag&&18!==n.tag;){if(2&n.effectTag)continue t;if(null===n.child||4===n.tag)continue t;n.child.return=n,n=n.child}if(!(2&n.effectTag)){n=n.stateNode;break e}}l?Po(e,n,t):_o(e,n,t)}function Po(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=hn));else if(4!==r&&null!==(e=e.child))for(Po(e,t,n),e=e.sibling;null!==e;)Po(e,t,n),e=e.sibling}function _o(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(_o(e,t,n),e=e.sibling;null!==e;)_o(e,t,n),e=e.sibling}function No(e,t,n){for(var l,i,a=t,o=!1;;){if(!o){o=a.return;e:for(;;){if(null===o)throw Error(r(160));switch(l=o.stateNode,o.tag){case 5:i=!1;break e;case 3:case 4:l=l.containerInfo,i=!0;break e}o=o.return}o=!0}if(5===a.tag||6===a.tag){e:for(var u=e,c=a,s=n,f=c;;)if(To(u,f,s),null!==f.child&&4!==f.tag)f.child.return=f,f=f.child;else{if(f===c)break e;for(;null===f.sibling;){if(null===f.return||f.return===c)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}i?(u=l,c=a.stateNode,8===u.nodeType?u.parentNode.removeChild(c):u.removeChild(c)):l.removeChild(a.stateNode)}else if(4===a.tag){if(null!==a.child){l=a.stateNode.containerInfo,i=!0,a.child.return=a,a=a.child;continue}}else if(To(e,a,n),null!==a.child){a.child.return=a,a=a.child;continue}if(a===t)break;for(;null===a.sibling;){if(null===a.return||a.return===t)return;4===(a=a.return).tag&&(o=!1)}a.sibling.return=a.return,a=a.sibling}}function zo(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:return void wo(3,t);case 1:return;case 5:var n=t.stateNode;if(null!=n){var l=t.memoizedProps,i=null!==e?e.memoizedProps:l;e=t.type;var a=t.updateQueue;if(t.updateQueue=null,null!==a){for(n[Dn]=l,\"input\"===e&&\"radio\"===l.type&&null!=l.name&&Pe(n,l),dn(e,i),t=dn(e,l),i=0;i<a.length;i+=2){var o=a[i],u=a[i+1];\"style\"===o?cn(n,u):\"dangerouslySetInnerHTML\"===o?We(n,u):\"children\"===o?He(n,u):Z(n,o,u,t)}switch(e){case\"input\":_e(n,l);break;case\"textarea\":De(n,l);break;case\"select\":t=n._wrapperState.wasMultiple,n._wrapperState.wasMultiple=!!l.multiple,null!=(e=l.value)?Fe(n,!!l.multiple,e,!1):t!==!!l.multiple&&(null!=l.defaultValue?Fe(n,!!l.multiple,l.defaultValue,!0):Fe(n,!!l.multiple,l.multiple?[]:\"\",!1))}}}return;case 6:if(null===t.stateNode)throw Error(r(162));return void(t.stateNode.nodeValue=t.memoizedProps);case 3:return void((t=t.stateNode).hydrate&&(t.hydrate=!1,Wt(t.containerInfo)));case 12:return;case 13:if(n=t,null===t.memoizedState?l=!1:(l=!0,n=t.child,au=ei()),null!==n)e:for(e=n;;){if(5===e.tag)a=e.stateNode,l?\"function\"==typeof(a=a.style).setProperty?a.setProperty(\"display\",\"none\",\"important\"):a.display=\"none\":(a=e.stateNode,i=null!=(i=e.memoizedProps.style)&&i.hasOwnProperty(\"display\")?i.display:null,a.style.display=un(\"display\",i));else if(6===e.tag)e.stateNode.nodeValue=l?\"\":e.memoizedProps;else{if(13===e.tag&&null!==e.memoizedState&&null===e.memoizedState.dehydrated){(a=e.child.sibling).return=e,e=a;continue}if(null!==e.child){e.child.return=e,e=e.child;continue}}if(e===n)break;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}return void Mo(t);case 19:return void Mo(t);case 17:return}throw Error(r(163))}function Mo(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new ho),t.forEach(function(t){var r=qu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}var Io=\"function\"==typeof WeakMap?WeakMap:Map;function Fo(e,t,n){(n=xi(n,null)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){cu||(cu=!0,su=r),go(e,t)},n}function Oo(e,t,n){(n=xi(n,null)).tag=3;var r=e.type.getDerivedStateFromError;if(\"function\"==typeof r){var l=t.value;n.payload=function(){return go(e,t),r(l)}}var i=e.stateNode;return null!==i&&\"function\"==typeof i.componentDidCatch&&(n.callback=function(){\"function\"!=typeof r&&(null===fu?fu=new Set([this]):fu.add(this),go(e,t));var n=t.stack;this.componentDidCatch(t.value,{componentStack:null!==n?n:\"\"})}),n}var Ro,Do=Math.ceil,Lo=G.ReactCurrentDispatcher,Uo=G.ReactCurrentOwner,Ao=0,Vo=8,Qo=16,Wo=32,Ho=0,jo=1,Bo=2,Ko=3,$o=4,qo=5,Yo=Ao,Xo=null,Go=null,Zo=0,Jo=Ho,eu=null,tu=1073741823,nu=1073741823,ru=null,lu=0,iu=!1,au=0,ou=500,uu=null,cu=!1,su=null,fu=null,du=!1,pu=null,mu=90,hu=null,gu=0,vu=null,yu=0;function bu(){return(Yo&(Qo|Wo))!==Ao?1073741821-(ei()/10|0):0!==yu?yu:yu=1073741821-(ei()/10|0)}function wu(e,t,n){if(0==(2&(t=t.mode)))return 1073741823;var l=ti();if(0==(4&t))return 99===l?1073741823:1073741822;if((Yo&Qo)!==Ao)return Zo;if(null!==n)e=ui(e,0|n.timeoutMs||5e3,250);else switch(l){case 99:e=1073741823;break;case 98:e=ui(e,150,100);break;case 97:case 96:e=ui(e,5e3,250);break;case 95:e=2;break;default:throw Error(r(326))}return null!==Xo&&e===Zo&&--e,e}function ku(e,t){if(50<gu)throw gu=0,vu=null,Error(r(185));if(null!==(e=xu(e,t))){var n=ti();1073741823===t?(Yo&Vo)!==Ao&&(Yo&(Qo|Wo))===Ao?Cu(e):(Eu(e),Yo===Ao&&ai()):Eu(e),(4&Yo)===Ao||98!==n&&99!==n||(null===hu?hu=new Map([[e,t]]):(void 0===(n=hu.get(e))||n>t)&&hu.set(e,t))}}function xu(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t);var r=e.return,l=null;if(null===r&&3===e.tag)l=e.stateNode;else for(;null!==r;){if(n=r.alternate,r.childExpirationTime<t&&(r.childExpirationTime=t),null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t),null===r.return&&3===r.tag){l=r.stateNode;break}r=r.return}return null!==l&&(Xo===l&&(Ou(t),Jo===$o&&cc(l,Zo)),sc(l,t)),l}function Tu(e){var t=e.lastExpiredTime;if(0!==t)return t;if(!uc(e,t=e.firstPendingTime))return t;var n=e.lastPingedTime;return 2>=(e=n>(e=e.nextKnownPendingLevel)?n:e)&&t!==e?0:e}function Eu(e){if(0!==e.lastExpiredTime)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=ii(Cu.bind(null,e));else{var t=Tu(e),n=e.callbackNode;if(0===t)null!==n&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var r=bu();if(1073741823===t?r=99:1===t||2===t?r=95:r=0>=(r=10*(1073741821-t)-10*(1073741821-r))?99:250>=r?98:5250>=r?97:95,null!==n){var l=e.callbackPriority;if(e.callbackExpirationTime===t&&l>=r)return;n!==$l&&Ul(n)}e.callbackExpirationTime=t,e.callbackPriority=r,t=1073741823===t?ii(Cu.bind(null,e)):li(r,Su.bind(null,e),{timeout:10*(1073741821-t)-ei()}),e.callbackNode=t}}}function Su(e,t){if(yu=0,t)return fc(e,t=bu()),Eu(e),null;var n=Tu(e);if(0!==n){if(t=e.callbackNode,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&n===Zo||zu(e,n),null!==Go){var l=Yo;Yo|=Qo;for(var i=Iu();;)try{Du();break}catch(u){Mu(e,u)}if(mi(),Yo=l,Lo.current=i,Jo===jo)throw t=eu,zu(e,n),cc(e,n),Eu(e),t;if(null===Go)switch(i=e.finishedWork=e.current.alternate,e.finishedExpirationTime=n,l=Jo,Xo=null,l){case Ho:case jo:throw Error(r(345));case Bo:fc(e,2<n?2:n);break;case Ko:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),1073741823===tu&&10<(i=au+ou-ei())){if(iu){var a=e.lastPingedTime;if(0===a||a>=n){e.lastPingedTime=n,zu(e,n);break}}if(0!==(a=Tu(e))&&a!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}e.timeoutHandle=zn(Vu.bind(null,e),i);break}Vu(e);break;case $o:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),iu&&(0===(i=e.lastPingedTime)||i>=n)){e.lastPingedTime=n,zu(e,n);break}if(0!==(i=Tu(e))&&i!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}if(1073741823!==nu?l=10*(1073741821-nu)-ei():1073741823===tu?l=0:(l=10*(1073741821-tu)-5e3,0>(l=(i=ei())-l)&&(l=0),(n=10*(1073741821-n)-i)<(l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Do(l/1960))-l)&&(l=n)),10<l){e.timeoutHandle=zn(Vu.bind(null,e),l);break}Vu(e);break;case qo:if(1073741823!==tu&&null!==ru){a=tu;var o=ru;if(0>=(l=0|o.busyMinDurationMs)?l=0:(i=0|o.busyDelayMs,l=(a=ei()-(10*(1073741821-a)-(0|o.timeoutMs||5e3)))<=i?0:i+l-a),10<l){cc(e,n),e.timeoutHandle=zn(Vu.bind(null,e),l);break}}Vu(e);break;default:throw Error(r(329))}if(Eu(e),e.callbackNode===t)return Su.bind(null,e)}}return null}function Cu(e){var t=e.lastExpiredTime;if(t=0!==t?t:1073741823,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&t===Zo||zu(e,t),null!==Go){var n=Yo;Yo|=Qo;for(var l=Iu();;)try{Ru();break}catch(i){Mu(e,i)}if(mi(),Yo=n,Lo.current=l,Jo===jo)throw n=eu,zu(e,t),cc(e,t),Eu(e),n;if(null!==Go)throw Error(r(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Xo=null,Vu(e),Eu(e)}return null}function Pu(){if(null!==hu){var e=hu;hu=null,e.forEach(function(e,t){fc(t,e),Eu(t)}),ai()}}function _u(e,t){var n=Yo;Yo|=1;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function Nu(e,t){var n=Yo;Yo&=-2,Yo|=Vo;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function zu(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,Mn(n)),null!==Go)for(n=Go.return;null!==n;){var r=n;switch(r.tag){case 1:null!=(r=r.type.childContextTypes)&&Ml();break;case 3:$i(),Tl(Pl),Tl(Cl);break;case 5:Yi(r);break;case 4:$i();break;case 13:case 19:Tl(Xi);break;case 10:hi(r)}n=n.return}Xo=e,Go=nc(e.current,null),Zo=t,Jo=Ho,eu=null,nu=tu=1073741823,ru=null,lu=0,iu=!1}function Mu(e,t){for(;;){try{if(mi(),Ji.current=za,ia)for(var n=na.memoizedState;null!==n;){var r=n.queue;null!==r&&(r.pending=null),n=n.next}if(ta=0,la=ra=na=null,ia=!1,null===Go||null===Go.return)return Jo=jo,eu=t,Go=null;e:{var l=e,i=Go.return,a=Go,o=t;if(t=Zo,a.effectTag|=2048,a.firstEffect=a.lastEffect=null,null!==o&&\"object\"==typeof o&&\"function\"==typeof o.then){var u=o;if(0==(2&a.mode)){var c=a.alternate;c?(a.updateQueue=c.updateQueue,a.memoizedState=c.memoizedState,a.expirationTime=c.expirationTime):(a.updateQueue=null,a.memoizedState=null)}var s=0!=(1&Xi.current),f=i;do{var d;if(d=13===f.tag){var p=f.memoizedState;if(null!==p)d=null!==p.dehydrated;else{var m=f.memoizedProps;d=void 0!==m.fallback&&(!0!==m.unstable_avoidThisFallback||!s)}}if(d){var h=f.updateQueue;if(null===h){var g=new Set;g.add(u),f.updateQueue=g}else h.add(u);if(0==(2&f.mode)){if(f.effectTag|=64,a.effectTag&=-2981,1===a.tag)if(null===a.alternate)a.tag=17;else{var v=xi(1073741823,null);v.tag=2,Ti(a,v)}a.expirationTime=1073741823;break e}o=void 0,a=t;var y=l.pingCache;if(null===y?(y=l.pingCache=new Io,o=new Set,y.set(u,o)):void 0===(o=y.get(u))&&(o=new Set,y.set(u,o)),!o.has(a)){o.add(a);var b=$u.bind(null,l,u,a);u.then(b,b)}f.effectTag|=4096,f.expirationTime=t;break e}f=f.return}while(null!==f);o=Error((ye(a.type)||\"A React component\")+\" suspended while rendering, but no fallback UI was specified.\\n\\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.\"+be(a))}Jo!==qo&&(Jo=Bo),o=mo(o,a),f=i;do{switch(f.tag){case 3:u=o,f.effectTag|=4096,f.expirationTime=t,Ei(f,Fo(f,u,t));break e;case 1:u=o;var w=f.type,k=f.stateNode;if(0==(64&f.effectTag)&&(\"function\"==typeof w.getDerivedStateFromError||null!==k&&\"function\"==typeof k.componentDidCatch&&(null===fu||!fu.has(k)))){f.effectTag|=4096,f.expirationTime=t,Ei(f,Oo(f,u,t));break e}}f=f.return}while(null!==f)}Go=Uu(Go)}catch(x){t=x;continue}break}}function Iu(){var e=Lo.current;return Lo.current=za,null===e?za:e}function Fu(e,t){e<tu&&2<e&&(tu=e),null!==t&&e<nu&&2<e&&(nu=e,ru=t)}function Ou(e){e>lu&&(lu=e)}function Ru(){for(;null!==Go;)Go=Lu(Go)}function Du(){for(;null!==Go&&!ql();)Go=Lu(Go)}function Lu(e){var t=Ro(e.alternate,e,Zo);return e.memoizedProps=e.pendingProps,null===t&&(t=Uu(e)),Uo.current=null,t}function Uu(e){Go=e;do{var t=Go.alternate;if(e=Go.return,0==(2048&Go.effectTag)){if(t=fo(t,Go,Zo),1===Zo||1!==Go.childExpirationTime){for(var n=0,r=Go.child;null!==r;){var l=r.expirationTime,i=r.childExpirationTime;l>n&&(n=l),i>n&&(n=i),r=r.sibling}Go.childExpirationTime=n}if(null!==t)return t;null!==e&&0==(2048&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=Go.firstEffect),null!==Go.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=Go.firstEffect),e.lastEffect=Go.lastEffect),1<Go.effectTag&&(null!==e.lastEffect?e.lastEffect.nextEffect=Go:e.firstEffect=Go,e.lastEffect=Go))}else{if(null!==(t=po(Go)))return t.effectTag&=2047,t;null!==e&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(null!==(t=Go.sibling))return t;Go=e}while(null!==Go);return Jo===Ho&&(Jo=qo),null}function Au(e){var t=e.expirationTime;return t>(e=e.childExpirationTime)?t:e}function Vu(e){var t=ti();return ri(99,Qu.bind(null,e,t)),null}function Qu(e,t){do{Hu()}while(null!==pu);if((Yo&(Qo|Wo))!==Ao)throw Error(r(327));var n=e.finishedWork,l=e.finishedExpirationTime;if(null===n)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var i=Au(n);if(e.firstPendingTime=i,l<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:l<=e.firstSuspendedTime&&(e.firstSuspendedTime=l-1),l<=e.lastPingedTime&&(e.lastPingedTime=0),l<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===Xo&&(Go=Xo=null,Zo=0),1<n.effectTag?null!==n.lastEffect?(n.lastEffect.nextEffect=n,i=n.firstEffect):i=n:i=n.firstEffect,null!==i){var a=Yo;Yo|=Wo,Uo.current=null,Cn=Zt;var o=wn();if(kn(o)){if(\"selectionStart\"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{var c=(u=(u=o.ownerDocument)&&u.defaultView||window).getSelection&&u.getSelection();if(c&&0!==c.rangeCount){u=c.anchorNode;var s=c.anchorOffset,f=c.focusNode;c=c.focusOffset;try{u.nodeType,f.nodeType}catch(C){u=null;break e}var d=0,p=-1,m=-1,h=0,g=0,v=o,y=null;t:for(;;){for(var b;v!==u||0!==s&&3!==v.nodeType||(p=d+s),v!==f||0!==c&&3!==v.nodeType||(m=d+c),3===v.nodeType&&(d+=v.nodeValue.length),null!==(b=v.firstChild);)y=v,v=b;for(;;){if(v===o)break t;if(y===u&&++h===s&&(p=d),y===f&&++g===c&&(m=d),null!==(b=v.nextSibling))break;y=(v=y).parentNode}v=b}u=-1===p||-1===m?null:{start:p,end:m}}else u=null}u=u||{start:0,end:0}}else u=null;Pn={activeElementDetached:null,focusedElem:o,selectionRange:u},Zt=!1,uu=i;do{try{Wu()}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=i;do{try{for(o=e,u=t;null!==uu;){var w=uu.effectTag;if(16&w&&He(uu.stateNode,\"\"),128&w){var k=uu.alternate;if(null!==k){var x=k.ref;null!==x&&(\"function\"==typeof x?x(null):x.current=null)}}switch(1038&w){case 2:Co(uu),uu.effectTag&=-3;break;case 6:Co(uu),uu.effectTag&=-3,zo(uu.alternate,uu);break;case 1024:uu.effectTag&=-1025;break;case 1028:uu.effectTag&=-1025,zo(uu.alternate,uu);break;case 4:zo(uu.alternate,uu);break;case 8:No(o,s=uu,u),Eo(s)}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);if(x=Pn,k=wn(),w=x.focusedElem,u=x.selectionRange,k!==w&&w&&w.ownerDocument&&bn(w.ownerDocument.documentElement,w)){null!==u&&kn(w)&&(k=u.start,void 0===(x=u.end)&&(x=k),\"selectionStart\"in w?(w.selectionStart=k,w.selectionEnd=Math.min(x,w.value.length)):(x=(k=w.ownerDocument||document)&&k.defaultView||window).getSelection&&(x=x.getSelection(),s=w.textContent.length,o=Math.min(u.start,s),u=void 0===u.end?o:Math.min(u.end,s),!x.extend&&o>u&&(s=u,u=o,o=s),s=yn(w,o),f=yn(w,u),s&&f&&(1!==x.rangeCount||x.anchorNode!==s.node||x.anchorOffset!==s.offset||x.focusNode!==f.node||x.focusOffset!==f.offset)&&((k=k.createRange()).setStart(s.node,s.offset),x.removeAllRanges(),o>u?(x.addRange(k),x.extend(f.node,f.offset)):(k.setEnd(f.node,f.offset),x.addRange(k))))),k=[];for(x=w;x=x.parentNode;)1===x.nodeType&&k.push({element:x,left:x.scrollLeft,top:x.scrollTop});for(\"function\"==typeof w.focus&&w.focus(),w=0;w<k.length;w++)(x=k[w]).element.scrollLeft=x.left,x.element.scrollTop=x.top}Zt=!!Cn,Pn=Cn=null,e.current=n,uu=i;do{try{for(w=e;null!==uu;){var T=uu.effectTag;if(36&T&&xo(w,uu.alternate,uu),128&T){k=void 0;var E=uu.ref;if(null!==E){var S=uu.stateNode;switch(uu.tag){case 5:k=S;break;default:k=S}\"function\"==typeof E?E(k):E.current=k}}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=null,Yl(),Yo=a}else e.current=n;if(du)du=!1,pu=e,mu=t;else for(uu=i;null!==uu;)t=uu.nextEffect,uu.nextEffect=null,uu=t;if(0===(t=e.firstPendingTime)&&(fu=null),1073741823===t?e===vu?gu++:(gu=0,vu=e):gu=0,\"function\"==typeof Yu&&Yu(n.stateNode,l),Eu(e),cu)throw cu=!1,e=su,su=null,e;return(Yo&Vo)!==Ao?null:(ai(),null)}function Wu(){for(;null!==uu;){var e=uu.effectTag;0!=(256&e)&&bo(uu.alternate,uu),0==(512&e)||du||(du=!0,li(97,function(){return Hu(),null})),uu=uu.nextEffect}}function Hu(){if(90!==mu){var e=97<mu?97:mu;return mu=90,ri(e,ju)}}function ju(){if(null===pu)return!1;var e=pu;if(pu=null,(Yo&(Qo|Wo))!==Ao)throw Error(r(331));var t=Yo;for(Yo|=Wo,e=e.current.firstEffect;null!==e;){try{var n=e;if(0!=(512&n.effectTag))switch(n.tag){case 0:case 11:case 15:case 22:wo(5,n),ko(5,n)}}catch(l){if(null===e)throw Error(r(330));Ku(e,l)}n=e.nextEffect,e.nextEffect=null,e=n}return Yo=t,ai(),!0}function Bu(e,t,n){Ti(e,t=Fo(e,t=mo(n,t),1073741823)),null!==(e=xu(e,1073741823))&&Eu(e)}function Ku(e,t){if(3===e.tag)Bu(e,e,t);else for(var n=e.return;null!==n;){if(3===n.tag){Bu(n,e,t);break}if(1===n.tag){var r=n.stateNode;if(\"function\"==typeof n.type.getDerivedStateFromError||\"function\"==typeof r.componentDidCatch&&(null===fu||!fu.has(r))){Ti(n,e=Oo(n,e=mo(t,e),1073741823)),null!==(n=xu(n,1073741823))&&Eu(n);break}}n=n.return}}function $u(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),Xo===e&&Zo===n?Jo===$o||Jo===Ko&&1073741823===tu&&ei()-au<ou?zu(e,Zo):iu=!0:uc(e,n)&&(0!==(t=e.lastPingedTime)&&t<n||(e.lastPingedTime=n,Eu(e)))}function qu(e,t){var n=e.stateNode;null!==n&&n.delete(t),0===(t=0)&&(t=wu(t=bu(),e,null)),null!==(e=xu(e,t))&&Eu(e)}Ro=function(e,t,n){var l=t.expirationTime;if(null!==e){var i=t.pendingProps;if(e.memoizedProps!==i||Pl.current)ja=!0;else{if(l<n){switch(ja=!1,t.tag){case 3:Ja(t),Wa();break;case 5:if(qi(t),4&t.mode&&1!==n&&i.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:zl(t.type)&&Ol(t);break;case 4:Ki(t,t.stateNode.containerInfo);break;case 10:l=t.memoizedProps.value,i=t.type._context,El(si,i._currentValue),i._currentValue=l;break;case 13:if(null!==t.memoizedState)return 0!==(l=t.child.childExpirationTime)&&l>=n?io(e,t,n):(El(Xi,1&Xi.current),null!==(t=co(e,t,n))?t.sibling:null);El(Xi,1&Xi.current);break;case 19:if(l=t.childExpirationTime>=n,0!=(64&e.effectTag)){if(l)return uo(e,t,n);t.effectTag|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null),El(Xi,Xi.current),!l)return null}return co(e,t,n)}ja=!1}}else ja=!1;switch(t.expirationTime=0,t.tag){case 2:if(l=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,i=Nl(t,Cl.current),vi(t,n),i=ua(null,t,l,e,i,n),t.effectTag|=1,\"object\"==typeof i&&null!==i&&\"function\"==typeof i.render&&void 0===i.$$typeof){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,zl(l)){var a=!0;Ol(t)}else a=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,wi(t);var o=l.getDerivedStateFromProps;\"function\"==typeof o&&Ni(t,l,o,e),i.updater=zi,t.stateNode=i,i._reactInternalFiber=t,Oi(t,l,e,n),t=Za(null,t,l,!0,a,n)}else t.tag=0,Ba(null,t,i,n),t=t.child;return t;case 16:e:{if(i=t.elementType,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,ve(i),1!==i._status)throw i._result;switch(i=i._result,t.type=i,a=t.tag=tc(i),e=ci(i,e),a){case 0:t=Xa(null,t,i,e,n);break e;case 1:t=Ga(null,t,i,e,n);break e;case 11:t=Ka(null,t,i,e,n);break e;case 14:t=$a(null,t,i,ci(i.type,e),l,n);break e}throw Error(r(306,i,\"\"))}return t;case 0:return l=t.type,i=t.pendingProps,Xa(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 1:return l=t.type,i=t.pendingProps,Ga(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 3:if(Ja(t),l=t.updateQueue,null===e||null===l)throw Error(r(282));if(l=t.pendingProps,i=null!==(i=t.memoizedState)?i.element:null,ki(e,t),Si(t,l,null,n),(l=t.memoizedState.element)===i)Wa(),t=co(e,t,n);else{if((i=t.stateNode.hydrate)&&(Ra=In(t.stateNode.containerInfo.firstChild),Oa=t,i=Da=!0),i)for(n=Vi(t,null,l,n),t.child=n;n;)n.effectTag=-3&n.effectTag|1024,n=n.sibling;else Ba(e,t,l,n),Wa();t=t.child}return t;case 5:return qi(t),null===e&&Aa(t),l=t.type,i=t.pendingProps,a=null!==e?e.memoizedProps:null,o=i.children,Nn(l,i)?o=null:null!==a&&Nn(l,a)&&(t.effectTag|=16),Ya(e,t),4&t.mode&&1!==n&&i.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(Ba(e,t,o,n),t=t.child),t;case 6:return null===e&&Aa(t),null;case 13:return io(e,t,n);case 4:return Ki(t,t.stateNode.containerInfo),l=t.pendingProps,null===e?t.child=Ai(t,null,l,n):Ba(e,t,l,n),t.child;case 11:return l=t.type,i=t.pendingProps,Ka(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 7:return Ba(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ba(e,t,t.pendingProps.children,n),t.child;case 10:e:{l=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value;var u=t.type._context;if(El(si,u._currentValue),u._currentValue=a,null!==o)if(u=o.value,0===(a=Gr(u,a)?0:0|(\"function\"==typeof l._calculateChangedBits?l._calculateChangedBits(u,a):1073741823))){if(o.children===i.children&&!Pl.current){t=co(e,t,n);break e}}else for(null!==(u=t.child)&&(u.return=t);null!==u;){var c=u.dependencies;if(null!==c){o=u.child;for(var s=c.firstContext;null!==s;){if(s.context===l&&0!=(s.observedBits&a)){1===u.tag&&((s=xi(n,null)).tag=2,Ti(u,s)),u.expirationTime<n&&(u.expirationTime=n),null!==(s=u.alternate)&&s.expirationTime<n&&(s.expirationTime=n),gi(u.return,n),c.expirationTime<n&&(c.expirationTime=n);break}s=s.next}}else o=10===u.tag&&u.type===t.type?null:u.child;if(null!==o)o.return=u;else for(o=u;null!==o;){if(o===t){o=null;break}if(null!==(u=o.sibling)){u.return=o.return,o=u;break}o=o.return}u=o}Ba(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,l=(a=t.pendingProps).children,vi(t,n),l=l(i=yi(i,a.unstable_observedBits)),t.effectTag|=1,Ba(e,t,l,n),t.child;case 14:return a=ci(i=t.type,t.pendingProps),$a(e,t,i,a=ci(i.type,a),l,n);case 15:return qa(e,t,t.type,t.pendingProps,l,n);case 17:return l=t.type,i=t.pendingProps,i=t.elementType===l?i:ci(l,i),null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,zl(l)?(e=!0,Ol(t)):e=!1,vi(t,n),Ii(t,l,i),Oi(t,l,i,n),Za(null,t,l,!0,e,n);case 19:return uo(e,t,n)}throw Error(r(156,t.tag))};var Yu=null,Xu=null;function Gu(e){if(\"undefined\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var n=t.inject(e);Yu=function(e){try{t.onCommitFiberRoot(n,e,void 0,64==(64&e.current.effectTag))}catch(r){}},Xu=function(e){try{t.onCommitFiberUnmount(n,e)}catch(r){}}}catch(r){}return!0}function Zu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childExpirationTime=this.expirationTime=0,this.alternate=null}function Ju(e,t,n,r){return new Zu(e,t,n,r)}function ec(e){return!(!(e=e.prototype)||!e.isReactComponent)}function tc(e){if(\"function\"==typeof e)return ec(e)?1:0;if(null!=e){if((e=e.$$typeof)===ce)return 11;if(e===de)return 14}return 2}function nc(e,t){var n=e.alternate;return null===n?((n=Ju(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.effectTag=0,n.nextEffect=null,n.firstEffect=null,n.lastEffect=null),n.childExpirationTime=e.childExpirationTime,n.expirationTime=e.expirationTime,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{expirationTime:t.expirationTime,firstContext:t.firstContext,responders:t.responders},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function rc(e,t,n,l,i,a){var o=2;if(l=e,\"function\"==typeof e)ec(e)&&(o=1);else if(\"string\"==typeof e)o=5;else e:switch(e){case re:return lc(n.children,i,a,t);case ue:o=8,i|=7;break;case le:o=8,i|=1;break;case ie:return(e=Ju(12,n,t,8|i)).elementType=ie,e.type=ie,e.expirationTime=a,e;case se:return(e=Ju(13,n,t,i)).type=se,e.elementType=se,e.expirationTime=a,e;case fe:return(e=Ju(19,n,t,i)).elementType=fe,e.expirationTime=a,e;default:if(\"object\"==typeof e&&null!==e)switch(e.$$typeof){case ae:o=10;break e;case oe:o=9;break e;case ce:o=11;break e;case de:o=14;break e;case pe:o=16,l=null;break e;case me:o=22;break e}throw Error(r(130,null==e?e:typeof e,\"\"))}return(t=Ju(o,n,t,i)).elementType=e,t.type=l,t.expirationTime=a,t}function lc(e,t,n,r){return(e=Ju(7,e,r,t)).expirationTime=n,e}function ic(e,t,n){return(e=Ju(6,e,null,t)).expirationTime=n,e}function ac(e,t,n){return(t=Ju(4,null!==e.children?e.children:[],e.key,t)).expirationTime=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function oc(e,t,n){this.tag=t,this.current=null,this.containerInfo=e,this.pingCache=this.pendingChildren=null,this.finishedExpirationTime=0,this.finishedWork=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=n,this.callbackNode=null,this.callbackPriority=90,this.lastExpiredTime=this.lastPingedTime=this.nextKnownPendingLevel=this.lastSuspendedTime=this.firstSuspendedTime=this.firstPendingTime=0}function uc(e,t){var n=e.firstSuspendedTime;return e=e.lastSuspendedTime,0!==n&&n>=t&&e<=t}function cc(e,t){var n=e.firstSuspendedTime,r=e.lastSuspendedTime;n<t&&(e.firstSuspendedTime=t),(r>t||0===n)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function sc(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var n=e.firstSuspendedTime;0!==n&&(t>=n?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function fc(e,t){var n=e.lastExpiredTime;(0===n||n>t)&&(e.lastExpiredTime=t)}function dc(e,t,n,l){var i=t.current,a=bu(),o=Pi.suspense;a=wu(a,i,o);e:if(n){t:{if(nt(n=n._reactInternalFiber)!==n||1!==n.tag)throw Error(r(170));var u=n;do{switch(u.tag){case 3:u=u.stateNode.context;break t;case 1:if(zl(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break t}}u=u.return}while(null!==u);throw Error(r(171))}if(1===n.tag){var c=n.type;if(zl(c)){n=Fl(n,c,u);break e}}n=u}else n=Sl;return null===t.context?t.context=n:t.pendingContext=n,(t=xi(a,o)).payload={element:e},null!==(l=void 0===l?null:l)&&(t.callback=l),Ti(i,t),ku(i,a),a}function pc(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 5:default:return e.child.stateNode}}function mc(e,t){null!==(e=e.memoizedState)&&null!==e.dehydrated&&e.retryTime<t&&(e.retryTime=t)}function hc(e,t){mc(e,t),(e=e.alternate)&&mc(e,t)}function gc(e,t,n){var r=new oc(e,t,n=null!=n&&!0===n.hydrate),l=Ju(3,null,null,2===t?7:1===t?3:0);r.current=l,l.stateNode=r,wi(l),e[Ln]=r.current,n&&0!==t&&It(e,9===e.nodeType?e:e.ownerDocument),this._internalRoot=r}function vc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||\" react-mount-point-unstable \"!==e.nodeValue))}function yc(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute(\"data-reactroot\"))),!t)for(var n;n=e.lastChild;)e.removeChild(n);return new gc(e,0,t?{hydrate:!0}:void 0)}function bc(e,t,n,r,l){var i=n._reactRootContainer;if(i){var a=i._internalRoot;if(\"function\"==typeof l){var o=l;l=function(){var e=pc(a);o.call(e)}}dc(t,a,e,l)}else{if(i=n._reactRootContainer=yc(n,r),a=i._internalRoot,\"function\"==typeof l){var u=l;l=function(){var e=pc(a);u.call(e)}}Nu(function(){dc(t,a,e,l)})}return pc(a)}function wc(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:ne,key:null==r?null:\"\"+r,children:e,containerInfo:t,implementation:n}}function kc(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!vc(t))throw Error(r(200));return wc(e,t,null,n)}gc.prototype.render=function(e){dc(e,this._internalRoot,null,null)},gc.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;dc(null,e,null,function(){t[Ln]=null})},bt=function(e){if(13===e.tag){var t=ui(bu(),150,100);ku(e,t),hc(e,t)}},wt=function(e){13===e.tag&&(ku(e,3),hc(e,3))},kt=function(e){if(13===e.tag){var t=bu();ku(e,t=wu(t,e,null)),hc(e,t)}},C=function(e,t,n){switch(t){case\"input\":if(_e(e,n),t=n.name,\"radio\"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(\"input[name=\"+JSON.stringify(\"\"+t)+'][type=\"radio\"]'),t=0;t<n.length;t++){var l=n[t];if(l!==e&&l.form===e.form){var i=Qn(l);if(!i)throw Error(r(90));Ee(l),_e(l,i)}}}break;case\"textarea\":De(e,n);break;case\"select\":null!=(t=n.value)&&Fe(e,!!n.multiple,t,!1)}},I=_u,F=function(e,t,n,r,l){var i=Yo;Yo|=4;try{return ri(98,e.bind(null,t,n,r,l))}finally{(Yo=i)===Ao&&ai()}},O=function(){(Yo&(1|Qo|Wo))===Ao&&(Pu(),Hu())},R=function(e,t){var n=Yo;Yo|=2;try{return e(t)}finally{(Yo=n)===Ao&&ai()}};var xc={Events:[An,Vn,Qn,E,k,qn,function(e){ut(e,$n)},z,M,rn,ft,Hu,{current:!1}]};!function(e){var n=e.findFiberByHostInstance;Gu(t({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:G.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=at(e))?null:e.stateNode},findFiberByHostInstance:function(e){return n?n(e):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))}({findFiberByHostInstance:Un,bundleType:0,version:\"16.14.0\",rendererPackageName:\"react-dom\"}),exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xc,exports.createPortal=kc,exports.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternalFiber;if(void 0===t){if(\"function\"==typeof e.render)throw Error(r(188));throw Error(r(268,Object.keys(e)))}return e=null===(e=at(t))?null:e.stateNode},exports.flushSync=function(e,t){if((Yo&(Qo|Wo))!==Ao)throw Error(r(187));var n=Yo;Yo|=1;try{return ri(99,e.bind(null,t))}finally{Yo=n,ai()}},exports.hydrate=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!0,n)},exports.render=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!1,n)},exports.unmountComponentAtNode=function(e){if(!vc(e))throw Error(r(40));return!!e._reactRootContainer&&(Nu(function(){bc(null,null,e,!1,function(){e._reactRootContainer=null,e[Ln]=null})}),!0)},exports.unstable_batchedUpdates=_u,exports.unstable_createPortal=function(e,t){return kc(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},exports.unstable_renderSubtreeIntoContainer=function(e,t,n,l){if(!vc(n))throw Error(r(200));if(null==e||void 0===e._reactInternalFiber)throw Error(r(38));return bc(e,t,n,!1,l)},exports.version=\"16.14.0\";\n},{\"react\":\"n8MK\",\"object-assign\":\"J4Nk\",\"scheduler\":\"MDSO\"}],\"NKHc\":[function(require,module,exports) {\n\"use strict\";function _(){if(\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_)}catch(O){console.error(O)}}}_(),module.exports=require(\"./cjs/react-dom.production.min.js\");\n},{\"./cjs/react-dom.production.min.js\":\"i17t\"}],\"zm2Q\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.customAlphabet=exports.nanoid=void 0;let e=\"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\",t=(e,t)=>()=>{let o=\"\",r=t;for(;r--;)o+=e[Math.random()*e.length|0];return o};exports.customAlphabet=t;let o=(t=21)=>{let o=\"\",r=t;for(;r--;)o+=e[64*Math.random()|0];return o};exports.nanoid=o;\n},{}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"Sn21\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=r,exports.R=void 0;class t{constructor(t){const e=s();this.c=1,this.s0=e(\" \"),this.s1=e(\" \"),this.s2=e(\" \"),this.s0-=e(t),this.s0<0&&(this.s0+=1),this.s1-=e(t),this.s1<0&&(this.s1+=1),this.s2-=e(t),this.s2<0&&(this.s2+=1)}next(){const t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=t-(this.c=Math.trunc(t))}}function s(){let t=4022871197;return function(s){const e=s.toString();for(let r=0;r<e.length;r++){let s=.02519603282416938*(t+=e.charCodeAt(r));s-=t=s>>>0,t=(s*=t)>>>0,t+=4294967296*(s-=t)}return 2.3283064365386963e-10*(t>>>0)}}function e(t,s){return s.c=t.c,s.s0=t.s0,s.s1=t.s1,s.s2=t.s2,s}function r(s,r){const n=new t(s),i=n.next.bind(n);return r&&e(r,n),i.state=(()=>e(n,{})),i}class n{constructor(t){this.state=t||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const t=this.state,s=r(t.prngstate?\"\":t.seed,t.prngstate),e=s();return this.state={...t,prngstate:s.state()},e}api(){const t=this._random.bind(this),s={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},e={};for(const r in s){const n=s[r];e[r]=(s=>void 0===s?Math.floor(t()*n)+1:Array.from({length:s}).map(()=>Math.floor(t()*n)+1))}return{...e,Die:function(s=6,e){return void 0===e?Math.floor(t()*s)+1:Array.from({length:e}).map(()=>Math.floor(t()*s)+1)},Number:()=>t(),Shuffle:s=>{const e=[...s];let r=s.length,n=0;const i=Array.from({length:r});for(;r;){const s=Math.trunc(r*t());i[n++]=e[s],e[s]=e[--r]}return i},_private:this}}}const i={name:\"random\",noClient:({api:t})=>t._private.isUsed(),flush:({api:t})=>t._private.getState(),api:({data:t})=>{return new n(t).api()},setup:({game:t})=>{let{seed:s}=t;return void 0===s&&(s=n.seed()),{seed:s}},playerView:()=>void 0};exports.R=i;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"MZmr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ae,exports.U=ne,exports.a=X,exports.b=Z,exports.c=ee,exports.e=B,exports.i=C,exports.z=exports.y=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.T=exports.S=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=a(require(\"immer\")),t=require(\"./plugin-random-087f861e.js\"),r=a(require(\"lodash.isplainobject\"));function a(e){return e&&e.__esModule?e:{default:e}}const n=\"MAKE_MOVE\";exports.M=n;const s=\"GAME_EVENT\";exports.o=s;const o=\"REDO\";exports.R=o;const i=\"RESET\";exports.l=i;const l=\"SYNC\";exports.j=l;const p=\"UNDO\";exports.h=p;const c=\"UPDATE\";exports.k=c;const d=\"PATCH\";exports.P=d;const u=\"PLUGIN\";exports.d=u;const y=\"STRIP_TRANSIENTS\";exports.p=y;const v=(e,t,r,a)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:a}});exports.B=v;const g=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a}});exports.g=g;const x=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a},automatic:!0}),h=e=>({type:l,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=h;const m=(e,t,r,a)=>({type:d,prevStateID:e,stateID:t,patch:r,deltalog:a,clientOnly:!0});exports.y=m;const f=(e,t)=>({type:c,state:e,deltalog:t,clientOnly:!0});exports.z=f;const P=e=>({type:i,state:e,clientOnly:!0});exports.u=P;const E=(e,t)=>({type:p,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=E;const O=(e,t)=>({type:o,payload:{type:null,args:null,playerID:e,credentials:t}});exports.w=O;const _=(e,t,r,a)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:a}}),M=()=>({type:y});exports.r=M;var N=Object.freeze({__proto__:null,makeMove:v,gameEvent:g,automaticGameEvent:x,sync:h,patch:m,update:f,reset:P,undo:E,redo:O,plugin:_,stripTransients:M});exports.A=N;const T=\"INVALID_MOVE\";exports.n=T;const I={name:\"plugin-immer\",fnWrap:t=>(r,a,...n)=>{let s=!1;const o=(0,e.default)(r,e=>{const r=t(e,a,...n);if(r!==T)return r;s=!0});return s?T:o}};var A,S;exports.G=A,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(A||(exports.G=A={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(S||(S={}));class b{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let a=0;a<this.dispatch.length;a++){const t=this.dispatch[a],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,S.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,S.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case A.TURN_ON_END:case A.PHASE_ON_END:return r(t.error,S.StageEventInOnEnd);case A.PHASE_ON_BEGIN:return r(t.error,S.StageEventInPhaseBegin);case A.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,S.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===A.TURN_ON_END||t.calledFrom===A.PHASE_ON_END)return r(t.error,S.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===A.PHASE_ON_END)return r(t.error,S.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const s=x(t.type,t.args,this.playerID);e=this.flow.processEvent(e,s)}return e}}const D={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,a,...n)=>{const s=a.events;return s&&s._private.updateTurnContext(a,t),r=e(r,a,...n),s&&s._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new b(e.flow,t,r).api()},G={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function U(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,r.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!U(e[t]))return!1;return!0}const R={name:\"plugin-serializable\",fnWrap:e=>(t,r,...a)=>{const n=e(t,r,...a);return n}},k=!0,L=()=>{},w=(...e)=>console.error(...e);function C(e){L(`INFO: ${e}`)}function B(e){w(\"ERROR:\",e)}const j=[I,t.R,G,R],F=[...j,D],H=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[a]:{...n,data:s}}}}),e);exports.f=H;const V=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=V;const $=(e,t,r)=>[...j,...r,D].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=$;const q=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const a=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[a]:{data:n}}}}),e);exports.t=q;const W=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[a]:{...n,api:s}}}}),e);exports.m=W;const z=(e,t)=>([...j,...t.game.plugins,D].reverse().forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}};if(r.flush){const a=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}else if(r.dangerouslyFlushRawState){const s=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[a].data;e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}}),e),K=(e,t)=>[...F,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const a=r.name,n=e.plugins[a];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=K;const Y=(e,t)=>{return[...F,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:a}=r,n=e.plugins[a],s=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!s&&{plugin:a,message:s}}).find(e=>e)||!1},J=(e,t)=>{const r=z(e,t),a=Y(r,t);if(!a)return[r];const{plugin:n,message:s}=a;return B(`${n} plugin declared action invalid:\\n${s}`),[e,a]};exports.q=J;const Q=({G:e,ctx:t,plugins:r={}},{game:a,playerID:n})=>([...F,...a.plugins].forEach(({name:s,playerView:o})=>{if(!o)return;const{data:i}=r[s]||{data:{}},l=o({G:e,ctx:t,game:a,data:i,playerID:n});r={...r,[s]:{data:l}}}),r);function X(e,t=!1){e.moveLimit&&(t&&(e.minMoves=e.moveLimit),e.maxMoves=e.moveLimit,delete e.moveLimit)}function Z(e,t){let r={},a=[],n=null,s={},o={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=oe.NULL),r=e}else{if(X(t),t.next&&(n=t.next),t.revert&&(a=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMinMoves:e._activePlayersMinMoves,_activePlayersMaxMoves:e._activePlayersMaxMoves,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&te(r,s,o,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let a=0;a<e.playOrder.length;a++){const n=e.playOrder[a];n!==e.currentPlayer&&te(r,s,o,n,t.others)}if(void 0!==t.all)for(let a=0;a<e.playOrder.length;a++){te(r,s,o,e.playOrder[a],t.all)}if(t.value)for(const e in t.value)te(r,s,o,e,t.value[e]);if(t.minMoves)for(const e in r)void 0===s[e]&&(s[e]=t.minMoves);if(t.maxMoves)for(const e in r)void 0===o[e]&&(o[e]=t.maxMoves)}0===Object.keys(r).length&&(r=null),0===Object.keys(s).length&&(s=null),0===Object.keys(o).length&&(o=null);const i={};for(const l in r)i[l]=0;return{...e,activePlayers:r,_activePlayersMinMoves:s,_activePlayersMaxMoves:o,_activePlayersNumMoves:i,_prevActivePlayers:a,_nextActivePlayers:n}}function ee(e){let{activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s,_nextActivePlayers:o}=e;if(t&&0===Object.keys(t).length)if(o)e=Z(e,o),({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}=e);else if(s.length>0){const e=s.length-1;({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n}=s[e]),s=s.slice(0,e)}else t=null,r=null,a=null;return{...e,activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}}function te(e,t,r,a,n){\"object\"==typeof n&&n!==oe.NULL||(n={stage:n}),void 0!==n.stage&&(X(n),e[a]=n.stage,n.minMoves&&(t[a]=n.minMoves),n.maxMoves&&(r[a]=n.maxMoves))}function re(e,t){return e[t]+\"\"}function ae(e,t){let{G:r,ctx:a}=e;const{numPlayers:n}=a,s=V(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,s));const l=o.first(r,s),p=typeof l;\"number\"!==p&&B(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=re(i,l);return a=Z(a={...a,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function ne(e,t,r,a){const n=r.order;let{G:s,ctx:o}=e,i=o.playOrderPos,l=!1;if(a&&!0!==a)\"object\"!=typeof a&&B(`invalid argument to endTurn: ${a}`),Object.keys(a).forEach(e=>{switch(e){case\"remove\":t=re(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(a.next),t=a.next;break;default:B(`invalid argument to endTurn: ${e}`)}});else{const r=V(e),a=n.next(s,r),p=typeof a;void 0!==a&&\"number\"!==p&&B(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${a}”.`),void 0===a?l=!0:(i=a,t=re(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.x=Q;const se={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=se;const oe={NULL:null};exports.S=oe;const ie={ALL:{all:oe.NULL},ALL_ONCE:{all:oe.NULL,minMoves:1,maxMoves:1},OTHERS:{others:oe.NULL},OTHERS_ONCE:{others:oe.NULL,minMoves:1,maxMoves:1}};exports.C=ie;\n},{\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)e=o,\"__proto__\"!=(n=this.tokens[r])&&\"constructor\"!=n&&\"prototype\"!=n&&(o=(e||{})[n]);return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"iEGk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=g,exports.I=i,exports.P=s,exports.T=void 0;var e,t,n=require(\"./turn-order-0b7dce3d.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:s,plugins:i}){void 0===e&&(e={}),void 0===s&&(s={}),void 0===i&&(i=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const c={...t};\"\"in c&&(0,n.e)(\"cannot specify phase with empty name\"),c[\"\"]={};const u={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,i);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const B in c){const e=c[B];if(!0===e.start&&(d=B),void 0!==e.moves)for(const t of Object.keys(e.moves))u[B+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={}),(0,n.a)(e.turn,!0);for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){u[B+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?c[e.phase]:c[\"\"]}function g(e){return e}function m(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:s,...i}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const c=[];if(e=o(e,{...i,arg:s,next:c}),o===w)break;const u=G(e);if(u){t.push({fn:w,arg:u,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([g,M,D].includes(o)){const n=b(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...c)}}return e}function x(e,{next:t}){return t.push({fn:h}),e}function h(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.b)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const s=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:s,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:s}=e;if(t&&t.next){if(!(t.next in c))return(0,n.e)(\"invalid phase: \"+t.next),e;s={...s,phase:t.next}}else s={...s,phase:o.wrapped.next(e)||null};return e={...e,ctx:s},a.push({fn:h}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:s}=e;const i=y(s),{endPhase:c,ctx:u}=(0,n.U)(e,a,i.turn,t);return s=u,e={...e,G:o,ctx:s},c?r.push({fn:N,turn:s.turn,phase:s.phase}):r.push({fn:I,currentPlayer:s.currentPlayer}),e}function M(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.S.NULL||(t={stage:t}),\"object\"!=typeof t)return e;(0,n.a)(t);let{ctx:r}=e,{activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,c[a]=0,t.minMoves&&(null===s&&(s={}),s[a]=t.minMoves),t.maxMoves&&(null===i&&(i={}),i[a]=t.maxMoves)),r={...r,activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c},{...e,ctx:r}}function D(e,{arg:t}){return{...e,ctx:(0,n.b)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function b(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.maxMoves&&n>=t.turn.maxMoves)||t.turn.wrapped.endIf(e)}function w(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:s,turn:i}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:s}),null===s)return e;const c=y(e.ctx).wrapped.onEnd(e),u={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:i,phase:s};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:c,ctx:u,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:s,playerID:i}){if(r!==e.ctx.turn)return e;const{currentPlayer:c,numMoves:u,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=u||0;if(!o&&p.turn.minMoves&&v<p.turn.minMoves)return(0,n.i)(`cannot end turn before making ${p.turn.minMoves} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:c});let g={...e.ctx,activePlayers:null};if(t&&t.remove){i=i||c;const t=g.playOrder.filter(e=>e!=i),n=g.playOrderPos>t.length-1?0:g.playOrderPos;if(g={...g,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const m=(0,n.g)(\"endTurn\",t),{_stateID:x}=e,h={action:m,_stateID:x,turn:d,phase:l};s&&(h.automatic=!0);const I=[...e.deltalog||[],h];return{...e,G:f,ctx:g,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:s,_stateID:i}=e,{activePlayers:c,_activePlayersNumMoves:u,_activePlayersMinMoves:l,_activePlayersMaxMoves:d,phase:p,turn:v}=s;const f=null!==c&&o in c,g=y(s);if(!t&&f){const e=g.turn.stages[c[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:M,arg:t,playerID:o}),!f)return e;const m=u[o]||0;if(l&&l[o]&&m<l[o])return(0,n.i)(`cannot end stage before making ${l[o]} moves`),e;delete(c={...c})[o],l&&delete(l={...l})[o],d&&delete(d={...d})[o],s=(0,n.c)({...s,activePlayers:c,_activePlayersMinMoves:l,_activePlayersMaxMoves:d});const x={action:(0,n.g)(\"endStage\",t),_stateID:i,turn:v,phase:p};r&&(x.automatic=!0);const h=[...e.deltalog||[],x];return{...e,ctx:s,deltalog:h}}function S(t,a,r){const o=y(t),s=o.turn.stages,{activePlayers:i}=t;if(i&&void 0!==i[r]&&i[r]!==n.S.NULL&&void 0!==s[i[r]]&&void 0!==s[i[r]].moves){const e=s[i[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const U={endStage:function(e,t){return m(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return m(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return m(e,[{fn:w,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return m(e,[{fn:D,arg:n}])}},T=[];return!1!==s.endTurn&&T.push(\"endTurn\"),!1!==s.pass&&T.push(\"pass\"),!1!==s.endPhase&&T.push(\"endPhase\"),!1!==s.setPhase&&T.push(\"setPhase\"),!1!==s.endGame&&T.push(\"endGame\"),!1!==s.setActivePlayers&&T.push(\"setActivePlayers\"),!1!==s.endStage&&T.push(\"endStage\"),!1!==s.setStage&&T.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>m(e,[{fn:x}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:U,eventNames:Object.keys(U),enabledEventNames:T,moveMap:u,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{currentPlayer:r,activePlayers:o,_activePlayersMaxMoves:s}=e.ctx,i=S(e.ctx,a,n),c=!i||\"function\"==typeof i||!0!==i.noLimit;let{numMoves:u,_activePlayersNumMoves:l}=e.ctx;c&&(n===r&&u++,o&&l[n]++),e={...e,ctx:{...e.ctx,numMoves:u,_activePlayersNumMoves:l}},s&&l[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const d=y(e.ctx).turn.wrapped.onMove({...e,ctx:{...e.ctx,playerID:n}});return m(e={...e,G:d},[{fn:g}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof U[n]?e:U[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function s(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(i(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),s={...(0,n.E)(a),playerID:r.playerID};let i=[];return void 0!==r.args&&(i=Array.isArray(r.args)?r.args:[r.args]),t(a.G,s,...i)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function i(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const c=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,u=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,s]=(0,n.q)(e,r);return s?[o,f(a,t.PluginActionInvalid,s)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.p:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.r)()),{...r,transients:t}):r}}};function g({game:r,isClient:o}){return r=s(r),(s=null,i)=>{let[y]=v(s);switch(i.type){case n.p:return y;case n.o:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed event: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:!1,playerID:i.payload.playerID});let e,a=r.flow.processEvent(y,i);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:i}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,i.payload.type,i.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:o,playerID:i.payload.playerID});const s=r.processMove(y,i.payload);if(s===n.n)return(0,n.e)(`invalid move: ${i.payload.type} args: ${i.payload.args}`),f(y,t.InvalidMove);const u={...y,G:s};if(o&&(0,n.N)(u,{game:r}))return y;if(y=u,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,i,a),y=r.flow.processMove(y,i.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:i}),{...y,_stateID:y._stateID+1})}case n.l:case n.k:case n.j:return i.state;case n.h:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:s,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(c(i)&&i.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!u(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,i),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...s]}}case n.R:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const s=a[0];return c(i)&&i.payload.playerID!==s.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,i),{...y,G:s.G,ctx:s.ctx,plugins:s.plugins,_stateID:o+1,_undo:[...e,s],_redo:a.slice(1)})}case n.d:return(0,n.f)(y,i,{game:r});case n.P:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,i.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(i.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"lU15\":[function(require,module,exports) {\nvar global = arguments[3];\nvar process = require(\"process\");\nvar e=arguments[3],t=require(\"process\");!function(e,n){\"use strict\";if(!e.setImmediate){var a,s,o,c,i,r=1,f={},u=!1,l=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,\"[object process]\"==={}.toString.call(e.process)?a=function(e){t.nextTick(function(){m(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(\"\",\"*\"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},a=function(e){o.port2.postMessage(e)}):l&&\"onreadystatechange\"in l.createElement(\"script\")?(s=l.documentElement,a=function(e){var t=l.createElement(\"script\");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):a=function(e){setTimeout(m,0,e)}:(c=\"setImmediate$\"+Math.random()+\"$\",i=function(t){t.source===e&&\"string\"==typeof t.data&&0===t.data.indexOf(c)&&m(+t.data.slice(c.length))},e.addEventListener?e.addEventListener(\"message\",i,!1):e.attachEvent(\"onmessage\",i),a=function(t){e.postMessage(c+t,\"*\")}),d.setImmediate=function(e){\"function\"!=typeof e&&(e=new Function(\"\"+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var s={callback:e,args:t};return f[r]=s,a(r),r++},d.clearImmediate=g}function g(e){delete f[e]}function m(e){if(u)setTimeout(m,0,e);else{var t=f[e];if(t){u=!0;try{!function(e){var t=e.callback,a=e.args;switch(a.length){case 0:t();break;case 1:t(a[0]);break;case 2:t(a[0],a[1]);break;case 3:t(a[0],a[1],a[2]);break;default:t.apply(n,a)}}(t)}finally{g(e),u=!1}}}}}(\"undefined\"==typeof self?void 0===e?this:e:self);\n},{\"process\":\"pBGv\"}],\"pO2S\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=o,exports.a=c,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./plugin-random-087f861e.js\"),r=require(\"./reducer-07c7b307.js\");require(\"setimmediate\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:r}){this._opts[t]={range:e,value:r}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,r,a){return this.enumerateFn(e,r,a).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.B)(e.move,e.args,a):\"event\"in e?(0,t.g)(e.event,e.args,a):void 0)}random(t){let r;if(void 0!==this.seed){const t=this.prngstate?\"\":this.seed,a=(0,e.a)(t,this.prngstate);r=a(),this.prngstate=a.state()}else r=Math.random();if(t){if(Array.isArray(t)){return t[Math.floor(r*t.length)]}return Math.floor(r*t)}return r}}exports.B=a;const s=25;class i extends a{constructor({enumerate:t,seed:e,objectives:a,game:s,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:e}),void 0===a&&(a=(()=>({}))),this.objectives=a,this.iterationCallback=o||(()=>{}),this.reducer=(0,r.C)({game:s}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:r,playerID:a}){const{G:s,ctx:i}=t;let n=[],o=[];if(void 0!==a)n=this.enumerate(s,i,a),o=this.objectives(s,i,a);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(s,i,c)),o.push(this.objectives(s,i,c));else n=this.enumerate(s,i,i.currentPlayer),o=this.objectives(s,i,i.currentPlayer);return{state:t,parent:r,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,r=0;for(const a of t.children){const s=a.visits+Number.EPSILON,i=a.value/s+Math.sqrt(2*Math.log(t.visits)/s);(null==e||i>r)&&(r=i,e=a)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const r=this.random(e.length),a=e[r];t.actions.splice(r,1);const s=this.reducer(t.state,a),i=this.createNode({state:s,parentAction:a,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let r=0;r<e&&void 0===t.ctx.gameover;r++){const{G:e,ctx:r}=t;let a=r.currentPlayer;r.activePlayers&&(a=Object.keys(r.activePlayers)[0]);const s=this.enumerate(e,r,a),i=this.objectives(e,r,a),n=Object.keys(i).reduce((t,a)=>{const s=i[a];return s.checker(e,r)?t+s.weight:t},0);if(n>0)return{score:n};if(!s||0===s.length)return;const o=this.random(s.length);t=this.reducer(t,s[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const r=this.createNode({state:t,playerID:e});let a=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(a=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of r.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:r}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<a;t++){const t=this.select(r),e=this.expand(t),a=this.playout(e);this.backpropagate(e,a),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:a,metadata:r})};if(this.iterationCounter=0,this.getOpt(\"async\")){const r=()=>{this.iterationCounter<a?(e(),setImmediate(r)):t(i())};r()}else{for(;this.iterationCounter<a;)e();t(i())}})}}exports.M=i;class n extends a{play({G:t,ctx:e},r){const a=this.enumerate(t,e,r);return Promise.resolve({action:this.random(a)})}}async function o(t,e){const r=t.store.getState();let a=r.ctx.currentPlayer;r.ctx.activePlayers&&(a=Object.keys(r.ctx.activePlayers)[0]);const{action:s,metadata:i}=await e.play(r,a);if(s){const e={...s,payload:{...s.payload,metadata:i}};return t.store.dispatch(e),e}}async function c({game:t,bots:e,state:s,depth:i}){void 0===i&&(i=1e4);const n=(0,r.C)({game:t});let o=null,c=0;for(;void 0===s.ctx.gameover&&c<i;){let t=s.ctx.currentPlayer;s.ctx.activePlayers&&(t=Object.keys(s.ctx.activePlayers)[0]);const r=e instanceof a?e:e[t],i=await r.play(s,t);if(!i.action)break;o=i.metadata,s=n(s,i.action),c++}return{state:s,metadata:o}}exports.R=n;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./plugin-random-087f861e.js\":\"Sn21\",\"./reducer-07c7b307.js\":\"iEGk\",\"setimmediate\":\"lU15\"}],\"uvSB\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\"),n=require(\"flatted\"),r=require(\"./ai-3099ce9a.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function W(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function X(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const Y=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);Y.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(Y.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Y.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=X(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(X(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function We(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Xe(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function Ye(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},Ye)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1xg9v5h\",\".menu.svelte-1xg9v5h{display:flex;margin-top:43px;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;margin-right:-500px;transform-origin:bottom right;transform:rotate(-90deg) translate(0, -500px)}.menu-item.svelte-1xg9v5h{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1xg9v5h:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1xg9v5h:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1xg9v5h{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1xg9v5h:hover,.menu-item.svelte-1xg9v5h:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1xg9v5h\"),W(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&W(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1xg9v5h\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),W(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&W(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),W(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&W(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&W(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&W(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Wt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Xt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Yt,Xt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),W(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&W(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&W(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&W(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Wt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Wn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Xn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),W(t,\"current\",e[7]==e[0].currentPlayer),W(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&W(t,\"current\",e[7]==e[0].currentPlayer),6&o&&W(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Yn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Xn(Wn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Wn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Xn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Yn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){if(t&&(\"object\"==typeof t||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return pr(e)}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t,{ToggleVisibility:c}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager),\"ToggleVisibility\"in e&&n(3,c=e.ToggleVisibility)}),[s,r,i,c]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2,ToggleVisibility:3},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Wr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Xr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Yr,Xr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),W(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&W(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Wr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),W(t,\"clickable\",e[1].length>0),W(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&W(t,\"clickable\",e[1].length>0),1&l&&W(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),W(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&W(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[6]=t[n][0],r[7]=t[n][1],r[8]=t,r[9]=n,r}function Bl(e){let t,n,r,l;function o(){e[5].call(t,e[6])}return{c(){G(t=M(\"input\"),\"id\",n=e[3](e[6])),G(t,\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(n,a){q(n,t,a),t.checked=e[1][e[6]],r||(l=[R(t,\"change\",o),R(t,\"change\",e[2])],r=!0)},p(r,l){e=r,1&l&&n!==(n=e[3](e[6]))&&G(t,\"id\",n),3&l&&(t.checked=e[1][e[6]])},d(e){e&&I(t),r=!1,c(l)}}}function Rl(e){let t,n,r,l,o,a,s,i,u,d=e[1][e[6]]+\"\";function f(){e[4].call(l,e[6])}return{c(){t=M(\"span\"),n=N(d),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"id\",o=e[3](e[6])),G(l,\"type\",\"range\"),G(l,\"min\",a=e[7].range.min),G(l,\"max\",s=e[7].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[6]]),i||(u=[R(l,\"change\",f),R(l,\"input\",f),R(l,\"change\",e[2])],i=!0)},p(t,r){e=t,3&r&&d!==(d=e[1][e[6]]+\"\")&&F(n,d),1&r&&o!==(o=e[3](e[6]))&&G(l,\"id\",o),1&r&&a!==(a=e[7].range.min)&&G(l,\"min\",a),1&r&&s!==(s=e[7].range.max)&&G(l,\"max\",s),3&r&&H(l,e[1][e[6]])},d(e){e&&I(t),e&&I(r),e&&I(l),i=!1,c(u)}}}function Kl(e){let t,n,r,l,o,a,s=e[6]+\"\";function i(e,t){return e[7].range?Rl:\"boolean\"==typeof e[7].value?Bl:void 0}let c=i(e),u=c&&c(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),o=V(),u&&u.c(),a=V(),G(n,\"for\",l=e[3](e[6])),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),u&&u.m(t,null),A(t,a)},p(e,o){1&o&&s!==(s=e[6]+\"\")&&F(r,s),1&o&&l!==(l=e[3](e[6]))&&G(n,\"for\",l),c===(c=i(e))&&u?u.p(e,o):(u&&u.d(1),(u=c&&c(e))&&(u.c(),u.m(t,a)))},d(e){e&&I(t),u&&u.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(15&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},e=>\"ai-option-\"+e,function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Xl(Hl(e,E,c));let z=j&&Yl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[17].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[17]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Xl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Yl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Xl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Yl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"for\",\"ai-option-debug\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"id\",\"ai-option-debug\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[18]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Wl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t,{ToggleVisibility:a}=t;const{secondaryPane:s}=de(\"secondaryPane\"),i={MCTS:r.M,Random:r.R};let c=!1,u=null,d=0,f=null;const p=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,d=e),n(2,u=e/t),f=r,c&&f&&s.set({component:jl,metadata:f})};let m,g,v,$;function y(){l.overrideGameState(null),s.set(null),n(1,c=!1)}return l.game.ai&&(m=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})).setOpt(\"async\",!0),ie(y),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager),\"ToggleVisibility\"in e&&n(16,a=e.ToggleVisibility)}),[l,c,u,d,g,v,$,m,i,function(){c&&f?s.set({component:jl,metadata:f}):s.set(null)},function(){const e=i[g];n(7,m=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})),m.setOpt(\"async\",!0),n(5,v=null),f=null,s.set(null),n(3,d=0)},async function(){n(5,v=null),f=null,n(3,d=0);const e=await(0,r.S)(l,m);e&&(n(5,v=e.payload.type),n(6,$=e.payload.args))},function(e=1e4,t=100){return n(5,v=null),f=null,n(3,d=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,m);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,v=null),f=null,n(3,d=0),y()},function(e){27==e.keyCode&&y()},o,a,function(){g=U(this),n(4,g),n(8,i)},function(){c=this.checked,n(1,c)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15,ToggleVisibility:16},Fl)}}function oo(e){z(e,\"svelte-8ymctk\",\".debug-panel.svelte-8ymctk.svelte-8ymctk{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-8ymctk.svelte-8ymctk{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-8ymctk.svelte-8ymctk{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-8ymctk.svelte-8ymctk:hover,.visibility-toggle.svelte-8ymctk.svelte-8ymctk:focus{background:#eee}.opener.svelte-8ymctk.svelte-8ymctk{right:10px}.closer.svelte-8ymctk.svelte-8ymctk{left:-326px}@keyframes svelte-8ymctk-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-8ymctk.svelte-8ymctk{display:flex;height:100%;animation:svelte-8ymctk-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-8ymctk .icon.svelte-8ymctk{animation-direction:reverse}.pane.svelte-8ymctk.svelte-8ymctk{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-8ymctk.svelte-8ymctk{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-8ymctk button,.debug-panel.svelte-8ymctk select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-8ymctk select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-8ymctk section{margin-bottom:20px}.debug-panel.svelte-8ymctk .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u=e[10]&&io(e);(r=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var d=e[6][e[2]].component;function f(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}d&&(a=new d(f(e)));let p=e[5]&&co(e);return{c(){t=M(\"div\"),u&&u.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"div\"),a&&Be(a.$$.fragment),s=V(),p&&p.c(),G(o,\"class\",\"pane svelte-8ymctk\"),G(o,\"role\",\"region\"),G(o,\"aria-label\",e[2]),G(o,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-8ymctk\")},m(i,d){q(i,t,d),u&&u.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),a&&Re(a,o,null),e[16](o),A(t,s),p&&p.m(t,null),c=!0},p(n,l){(e=n)[10]&&u.p(e,l);const s={};4&l&&(s.pane=e[2]),r.$set(s);const i={};if(16&l&&(i.client=e[4]),1&l&&(i.clientManager=e[0]),d!==(d=e[6][e[2]].component)){if(a){_e();const e=a;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}d?(Be((a=new d(f(e))).$$.fragment),Ce(a.$$.fragment,1),Re(a,o,null)):a=null}else d&&a.$set(i);(!c||4&l)&&G(o,\"aria-label\",e[2]),e[5]?p?(p.p(e,l),32&l&&Ce(p,1)):((p=co(e)).c(),Ce(p,1),p.m(t,null)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se())},i(n){c||(Ce(u),Ce(r.$$.fragment,n),a&&Ce(a.$$.fragment,n),Ce(p),be(()=>{i||(i=De(t,We,{x:400,...e[12]},!0)),i.run(1)}),c=!0)},o(n){qe(u),qe(r.$$.fragment,n),a&&qe(a.$$.fragment,n),qe(p),i||(i=De(t,We,{x:400,...e[12]},!1)),i.run(0),c=!1},d(n){n&&I(t),u&&u.d(),Ke(r),a&&Ke(a),e[16](null),p&&p.d(),n&&i&&i.end()}}}function so(e){let t,n,r=e[10]&&uo(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,t){e[10]&&r.p(e,t)},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function io(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle closer svelte-8ymctk\"),G(t,\"title\",\"Hide Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function co(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-8ymctk\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function uo(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-8ymctk\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function fo(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-8ymctk\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[11]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function po(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(15,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,h=!h)}const y=o.client.debugOpt;let h=!y||!y.collapseOnLoad;const b=!y||!y.hideToggleButton;const x={duration:150,easing:Ze},[w,k]=Xe(x);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{32768&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,h,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,b,function(e){\".\"!=e.key?h&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},x,w,k,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class mo extends Le{constructor(e){super(),Je(this,e,po,fo,d,{clientManager:0},oo)}}exports.D=mo;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"flatted\":\"O5av\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"Wibm\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.t)(n,{game:r}),n=(0,e.m)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.q)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\"}],\"zA0v\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class t{constructor({transportDataCallback:t,gameName:a,playerID:s,matchID:e,credentials:n,numPlayers:i}){this.connectionStatusCallback=(()=>{}),this.isConnected=!1,this.transportDataCallback=t,this.gameName=a||\"default\",this.playerID=s||null,this.matchID=e||\"default\",this.credentials=n,this.numPlayers=i||2}subscribeToConnectionStatus(t){this.connectionStatusCallback=t}setConnectionStatus(t){this.isConnected=t,this.connectionStatusCallback()}notifyClient(t){this.transportDataCallback(t)}}exports.T=t;\n},{}],\"FkTq\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid/non-secure\"),e=require(\"./Debug-fd09b8bc.js\"),s=require(\"redux\"),i=require(\"./turn-order-0b7dce3d.js\"),r=require(\"./reducer-07c7b307.js\"),a=require(\"./initialize-9ac1bbf5.js\"),n=require(\"./transport-ce07b771.js\");class h extends n.T{connect(){}disconnect(){}sendAction(){}sendChatMessage(){}requestSync(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const c=t=>new h(t);class l{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const u=new l;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const c of e)h[c]=((...e)=>{const h=i.A[t](c,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:l,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g||\"default\",this.credentials=d,this.multiplayer=l,this.debugOpt=n,this.manager=u,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==l}),this.initialState=null,l||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.u)(this.initialState))}),this.undo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.w)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.p||this.transport.sendAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.o:case i.h:case i.R:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.l:this.log=[];break;case i.P:case i.k:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.j:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),l||(l=c),this.transport=l({transportDataCallback:t=>this.receiveTransportData(t),gameKey:e,game:this.game,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.sendChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})})}receiveMatchData(t){this.matchData=t,this.notifySubscribers()}receiveChatMessage(t){this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()}receiveTransportData(t){const[e]=t.args;if(e===this.matchID)switch(t.type){case\"sync\":{const[,e]=t.args,s=(0,i.s)(e);this.receiveMatchData(e.filteredMetadata),this.store.dispatch(s);break}case\"update\":{const[,e,s]=t.args,r=this.store.getState();if(e._stateID>=r._stateID){const t=(0,i.z)(e,s);this.store.dispatch(t)}break}case\"patch\":{const[,e,s,r,a]=t.args,n=this.store.getState()._stateID;if(e!==n)break;const h=(0,i.y)(e,s,r,a);this.store.dispatch(h),this.store.getState()._stateID===n&&this.transport.requestSync();break}case\"matchData\":{const[,e]=t.args;this.receiveMatchData(e);break}case\"chat\":{const[,e]=t.args;this.receiveChatMessage(e);break}}}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribeToConnectionStatus(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.x)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\"}],\"mOPV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const e=(e,t)=>{if(!e||\"string\"!=typeof e)throw new Error(`Expected ${t} string, got \"${e}\".`)},t=t=>e(t,\"game name\"),s=t=>e(t,\"match ID\"),r=(e,t)=>{if(!e)throw new Error(`Expected body, got “${e}”.`);for(const s in t){const r=t[s],a=Array.isArray(r)?r:[r],n=e[s];if(!a.includes(typeof n)){const e=a.join(\"|\");throw new TypeError(`Expected body.${s} to be of type ${e}, got “${n}”.`)}}};class a extends Error{constructor(e,t){super(e),this.details=t}}exports.a=a;class n{constructor({server:e=\"\"}={}){this.server=e.replace(/\\/$/,\"\")}async request(e,t){const s=await fetch(this.server+e,t);if(!s.ok){let e;try{e=await s.clone().json()}catch{try{e=await s.text()}catch(r){e=r.message}}throw new a(`HTTP status ${s.status}`,e)}return s.json()}async post(e,t){let s={method:\"post\",body:JSON.stringify(t.body),headers:{\"Content-Type\":\"application/json\"}};return t.init&&(s={...s,...t.init,headers:{...s.headers,...t.init.headers}}),this.request(e,s)}async listGames(e){return this.request(\"/games\",e)}async listMatches(e,s,r){t(e);let a=\"\";if(s){const e=[],{isGameover:t,updatedBefore:r,updatedAfter:n}=s;void 0!==t&&e.push(`isGameover=${t}`),r&&e.push(`updatedBefore=${r}`),n&&e.push(`updatedAfter=${n}`),e.length>0&&(a=\"?\"+e.join(\"&\"))}return this.request(`/games/${e}${a}`,r)}async getMatch(e,r,a){return t(e),s(r),this.request(`/games/${e}/${r}`,a)}async createMatch(e,s,a){return t(e),r(s,{numPlayers:\"number\"}),this.post(`/games/${e}/create`,{body:s,init:a})}async joinMatch(e,a,n,i){return t(e),s(a),r(n,{playerID:[\"string\",\"undefined\"],playerName:\"string\"}),this.post(`/games/${e}/${a}/join`,{body:n,init:i})}async leaveMatch(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/leave`,{body:n,init:i})}async updatePlayer(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/update`,{body:n,init:i})}async playAgain(e,a,n,i){return t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${e}/${a}/playAgain`,{body:n,init:i})}}exports.L=n;\n},{}],\"L8uO\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"SAdv\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"L8uO\"}],\"PB2Y\":[function(require,module,exports) {\n\"use strict\";var _=\"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED\";module.exports=_;\n},{}],\"cTRg\":[function(require,module,exports) {\n\"use strict\";var e=require(\"./lib/ReactPropTypesSecret\");function r(){}function t(){}t.resetWarningCache=r,module.exports=function(){function n(r,t,n,o,a,p){if(p!==e){var c=new Error(\"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types\");throw c.name=\"Invariant Violation\",c}}function o(){return n}n.isRequired=n;var a={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:o,element:n,elementType:n,instanceOf:o,node:n,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:t,resetWarningCache:r};return a.PropTypes=a,a};\n},{\"./lib/ReactPropTypesSecret\":\"PB2Y\"}],\"yu5W\":[function(require,module,exports) {\nvar r,e;module.exports=require(\"./factoryWithThrowingShims\")();\n},{\"./factoryWithThrowingShims\":\"cTRg\"}],\"KAZ5\":[function(require,module,exports) {\n\"use strict\";exports.parse=n,exports.serialize=o;var e=decodeURIComponent,t=encodeURIComponent,r=/; */,i=/^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;function n(t,i){if(\"string\"!=typeof t)throw new TypeError(\"argument str must be a string\");for(var n={},o=i||{},s=t.split(r),p=o.decode||e,f=0;f<s.length;f++){var u=s[f],m=u.indexOf(\"=\");if(!(m<0)){var c=u.substr(0,m).trim(),l=u.substr(++m,u.length).trim();'\"'==l[0]&&(l=l.slice(1,-1)),null==n[c]&&(n[c]=a(l,p))}}return n}function o(e,r,n){var o=n||{},a=o.encode||t;if(\"function\"!=typeof a)throw new TypeError(\"option encode is invalid\");if(!i.test(e))throw new TypeError(\"argument name is invalid\");var s=a(r);if(s&&!i.test(s))throw new TypeError(\"argument val is invalid\");var p=e+\"=\"+s;if(null!=o.maxAge){var f=o.maxAge-0;if(isNaN(f))throw new Error(\"maxAge should be a Number\");p+=\"; Max-Age=\"+Math.floor(f)}if(o.domain){if(!i.test(o.domain))throw new TypeError(\"option domain is invalid\");p+=\"; Domain=\"+o.domain}if(o.path){if(!i.test(o.path))throw new TypeError(\"option path is invalid\");p+=\"; Path=\"+o.path}if(o.expires){if(\"function\"!=typeof o.expires.toUTCString)throw new TypeError(\"option expires is invalid\");p+=\"; Expires=\"+o.expires.toUTCString()}if(o.httpOnly&&(p+=\"; HttpOnly\"),o.secure&&(p+=\"; Secure\"),o.sameSite)switch(\"string\"==typeof o.sameSite?o.sameSite.toLowerCase():o.sameSite){case!0:p+=\"; SameSite=Strict\";break;case\"lax\":p+=\"; SameSite=Lax\";break;case\"strict\":p+=\"; SameSite=Strict\";break;default:throw new TypeError(\"option sameSite is invalid\")}return p}function a(e,t){try{return t(e)}catch(r){return e}}\n},{}],\"kpSY\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");Object.defineProperty(exports,\"__esModule\",{value:!0});var o=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e};exports.load=f,exports.loadAll=l,exports.select=p,exports.save=y,exports.remove=v,exports.setRawCookie=k,exports.plugToRequest=m;var t=require(\"cookie\"),r=u(t),n=require(\"object-assign\"),i=u(n);function u(e){return e&&e.__esModule?e:{default:e}}var c=\"undefined\"==typeof document||void 0!==e&&e.env&&!1,a={},s=void 0;function d(){return s&&!s.headersSent}function f(e,o){var t=c?a:r.default.parse(document.cookie),n=t&&t[e];if(void 0===o&&(o=!n||\"{\"!==n[0]&&\"[\"!==n[0]),!o)try{n=JSON.parse(n)}catch(i){}return n}function l(e){var o=c?a:r.default.parse(document.cookie);if(void 0===e&&(e=!o||\"{\"!==o[0]&&\"[\"!==o[0]),!e)try{o=JSON.parse(o)}catch(t){}return o}function p(e){var o=c?a:r.default.parse(document.cookie);return o?e?Object.keys(o).reduce(function(t,r){if(!e.test(r))return t;var n={};return n[r]=o[r],(0,i.default)({},t,n)},{}):o:{}}function y(e,t,n){a[e]=t,\"object\"===(void 0===t?\"undefined\":o(t))&&(a[e]=JSON.stringify(t)),c||(document.cookie=r.default.serialize(e,a[e],n)),d()&&s.cookie&&s.cookie(e,t,n)}function v(e,o){delete a[e],o=void 0===o?{}:\"string\"==typeof o?{path:o}:(0,i.default)({},o),\"undefined\"!=typeof document&&(o.expires=new Date(1970,1,1,0,0,1),o.maxAge=0,document.cookie=r.default.serialize(e,\"\",o)),d()&&s.clearCookie&&s.clearCookie(e,o)}function k(e){a=e?r.default.parse(e):{}}function m(e,o){return e.cookie?a=e.cookie:e.cookies?a=e.cookies:e.headers&&e.headers.cookie?k(e.headers.cookie):a={},s=o,function(){s=null,a={}}}exports.default={setRawCookie:k,load:f,loadAll:l,select:p,save:y,remove:v,plugToRequest:m};\n},{\"cookie\":\"KAZ5\",\"object-assign\":\"J4Nk\",\"process\":\"pBGv\"}],\"pSNY\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=a,exports.c=exports.S=exports.A=void 0;var e,t=require(\"./initialize-9ac1bbf5.js\");function a(t){return t.type()===e.SYNC}!function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class s{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=s;class n{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=n;const o=({game:e,unlisted:t,setupData:a,numPlayers:s})=>{const n={gameName:e.name,unlisted:!!t,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==a&&(n.setupData=a);for(let o=0;o<s;o++)n.players[o]={id:o};return n},r=({game:e,numPlayers:a,setupData:s,unlisted:n})=>{a&&\"number\"==typeof a||(a=2);const r=e.validateSetupData&&e.validateSetupData(s,a);return void 0!==r?{setupDataError:r}:{metadata:o({game:e,numPlayers:a,setupData:s,unlisted:n}),initialState:(0,t.I)({game:e,numPlayers:a,setupData:s})}};exports.c=r;\n},{\"./initialize-9ac1bbf5.js\":\"Wibm\"}],\"gTRl\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./reducer-07c7b307.js\"),r=require(\"./util-b1699aa1.js\");const s=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),i=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class o{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(s,o,n,c){if(!s||!s.payload)return{error:\"missing action or action payload\"};let l;if((0,r.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(n,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:c,credentials:s.payload.credentials,metadata:l})))return{error:\"unauthorized action\"}}const d=i(s),h=n;let u;if((0,r.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${c}]`+` - action[${d.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),y=(0,t.createStore)(p,u,g);if(d.type==a.h||d.type==a.R){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===c;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[c]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${c}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,c))return void(0,a.e)(`player not active - playerID=[${c}]`+` - action[${d.payload.type}]`);const m=d.type==a.M?this.game.flow.getMove(u.ctx,d.payload.type,c):null;if(d.type==a.M&&!m)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${c}]`+` - action[${d.payload.type}]`);if(u._stateID!==o&&!(m&&(0,e.I)(m)&&m.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${o}], expected=[${u._stateID}]`+` - playerID=[${c}] - action[${d.payload.type}]`);const I=y.getState();y.dispatch(d),u=y.getState(),this.subscribeCallback({state:u,action:d,matchID:n}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[n,o,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[n,u]});const{deltalog:f,...P}=u;let A;if(!l||void 0!==l.gameover&&null!==l.gameover||(A={...l,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,r.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,i=2){const o=t,n={state:!0,metadata:!0,log:!0,initialState:!0},c=(0,r.i)(this.storageAPI)?this.storageAPI.fetch(o,n):await this.storageAPI.fetch(o,n);let{state:l,initialState:d,log:h,metadata:u}=c;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:u})))return{error:\"unauthorized\"}}if(void 0===l){const a=(0,r.c)({game:this.game,unlisted:!0,numPlayers:i,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};d=l=a.initialState,u=a.metadata,this.subscribeCallback({state:l,matchID:t}),(0,r.i)(this.storageAPI)?this.storageAPI.createMatch(o,{initialState:d,metadata:u}):await this.storageAPI.createMatch(o,{initialState:d,metadata:u})}const p={state:l,log:h,filteredMetadata:u?s(u):void 0,initialState:d};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,p]})}async onConnectionChange(t,e,i,o){const n=t;if(null==e)return;let c;if((0,r.i)(this.storageAPI)?({metadata:c}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:c}=await this.storageAPI.fetch(n,{metadata:!0})),void 0===c)return(0,a.e)(`metadata not found for matchID=[${n}]`),{error:\"metadata not found\"};if(void 0===c.players[e])return(0,a.e)(`Player not in the match, matchID=[${n}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:i,metadata:c})))return{error:\"unauthorized\"}}c.players[e].isConnected=o;const l=s(c);this.transportAPI.sendAll({type:\"matchData\",args:[t,l]}),(0,r.i)(this.storageAPI)?this.storageAPI.setMetadata(n,c):await this.storageAPI.setMetadata(n,c)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=o;\n},{\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./util-b1699aa1.js\":\"pSNY\"}],\"AbzV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.g=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"rfc6902\");const r=(t,r,a)=>({...a,G:t.playerView(a.G,a.ctx,r),plugins:(0,e.x)(a,{playerID:r,game:t}),deltalog:void 0,_undo:[],_redo:[]}),a=e=>(a,s)=>{switch(s.type){case\"patch\":{const[c,n,l,u]=s.args,d=o(u.deltalog,a),p=r(e,a,u),i=u._stateID,g=r(e,a,l);return{type:\"patch\",args:[c,n,i,(0,t.createPatch)(g,p),d]}}case\"update\":{const[t,c]=s.args,n=o(c.deltalog,a);return{type:\"update\",args:[t,r(e,a,c),n]}}case\"sync\":{const[t,c]=s.args,n=r(e,a,c.state),l=o(c.log,a);return{type:\"sync\",args:[t,{...c,state:n,log:l}]}}default:return s}};function o(e,t){return void 0===e?e:e.map(e=>{if(null!==t&&+t==+e.action.payload.playerID)return e;if(!0!==e.redact)return e;const r={...e.action.payload,args:null},a={...e,action:{...e.action,payload:r}},{redact:o,...s}=a;return s})}exports.g=a;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"UzxM\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=p,exports.S=g;var t=require(\"./transport-ce07b771.js\"),e=require(\"./util-b1699aa1.js\"),s=require(\"./master-be1abdd0.js\"),i=require(\"./filter-player-view-c30cdfbf.js\"),a=n(require(\"socket.io-client\"));function n(t){return t&&t.__esModule?t:{default:t}}class r extends e.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class c extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends r{constructor(t=\"bgio\"){super();const e=e=>new c(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}function h(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class l extends s.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const n={},c={};if(t&&t.ai&&e)for(const i in e){const s=e[i];c[i]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const l=({playerID:t,...e})=>{const s=n[t];void 0!==s&&s(u(t,e))},u=(0,i.g)(t),d={send:l,sendAll:t=>{for(const e in n)l({playerID:e,...t})}};super(t,a?new o(s):new r,d),this.connect=((t,e)=>{n[t]=e}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const i=h(t,c);null!==i&&setTimeout(async()=>{const e=await c[i].play(t,i);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class u extends t.T{constructor({master:t,...e}){super(e),this.master=t}sendChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}sendAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}requestSync(){this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}connect(){this.setConnectionStatus(!0),this.master.connect(this.playerID,t=>this.notifyClient(t)),this.requestSync()}disconnect(){this.setConnectionStatus(!1)}updateMatchID(t){this.matchID=t,this.connect()}updatePlayerID(t){this.playerID=t,this.connect()}updateCredentials(t){this.credentials=t,this.connect()}}const d=new Map;function p({bots:t,persist:e,storageKey:s}={}){return i=>{const{gameKey:a,game:n}=i;let r;const c=d.get(a);return c&&c.bots===t&&c.storageKey===s&&c.persist===e&&(r=c.master),r||(r=new l({game:n,bots:t,persist:e,storageKey:s}),d.set(a,{master:r,bots:t,persist:e,storageKey:s})),new u({master:r,...i})}}const m=a.default;class y extends t.T{constructor({socket:t,socketOpts:e,server:s,...i}){super(i),this.server=s,this.socket=t,this.socketOpts=e}sendAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}sendChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=m(t+this.gameName,this.socketOpts)}else this.socket=m(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(t,e,s,i,a)=>{this.notifyClient({type:\"patch\",args:[t,e,s,i,a]})}),this.socket.on(\"update\",(t,e,s)=>{this.notifyClient({type:\"update\",args:[t,e,s]})}),this.socket.on(\"sync\",(t,e)=>{this.notifyClient({type:\"sync\",args:[t,e]})}),this.socket.on(\"matchData\",(t,e)=>{this.notifyClient({type:\"matchData\",args:[t,e]})}),this.socket.on(\"chat\",(t,e)=>{this.notifyClient({type:\"chat\",args:[t,e]})}),this.socket.on(\"connect\",()=>{this.requestSync(),this.setConnectionStatus(!0)}),this.socket.on(\"disconnect\",()=>{this.setConnectionStatus(!1)})}disconnect(){this.socket.close(),this.socket=null,this.setConnectionStatus(!1)}requestSync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}updateMatchID(t){this.matchID=t,this.requestSync()}updatePlayerID(t){this.playerID=t,this.requestSync()}updateCredentials(t){this.credentials=t,this.requestSync()}}function g({server:t,socketOpts:e}={}){return s=>new y({server:t,socketOpts:e,...s})}\n},{\"./transport-ce07b771.js\":\"zA0v\",\"./util-b1699aa1.js\":\"pSNY\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"PUvW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Client=o,exports.Lobby=void 0,require(\"nanoid/non-secure\"),require(\"./Debug-fd09b8bc.js\"),require(\"redux\"),require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"./initialize-9ac1bbf5.js\"),require(\"./transport-ce07b771.js\");var e=require(\"./client-fa36c03a.js\");require(\"flatted\"),require(\"setimmediate\");var t=require(\"./ai-3099ce9a.js\"),a=require(\"./client-5f57c3f2.js\"),s=c(require(\"react\")),r=c(require(\"prop-types\")),n=c(require(\"react-cookies\"));require(\"./util-b1699aa1.js\");var i,l=require(\"./socketio-e4fb268a.js\");function c(e){return e&&e.__esModule?e:{default:e}}function o(t){var a;const{game:n,numPlayers:i,board:l,multiplayer:c,enhancer:o}=t;let{loading:h,debug:m}=t;if(void 0===h){h=(()=>s.default.createElement(\"div\",{className:\"bgio-loading\"},\"connecting...\"))}return(a=class extends s.default.Component{constructor(t){super(t),void 0===m&&(m=t.debug),this.client=(0,e.C)({game:n,debug:m,numPlayers:i,multiplayer:c,matchID:t.matchID,playerID:t.playerID,credentials:t.credentials,enhancer:o})}componentDidMount(){this.unsubscribe=this.client.subscribe(()=>this.forceUpdate()),this.client.start()}componentWillUnmount(){this.client.stop(),this.unsubscribe()}componentDidUpdate(e){this.props.matchID!=e.matchID&&this.client.updateMatchID(this.props.matchID),this.props.playerID!=e.playerID&&this.client.updatePlayerID(this.props.playerID),this.props.credentials!=e.credentials&&this.client.updateCredentials(this.props.credentials)}render(){const e=this.client.getState();if(null===e)return s.default.createElement(h);let t=null;return l&&(t=s.default.createElement(l,{...e,...this.props,isMultiplayer:!!c,moves:this.client.moves,events:this.client.events,matchID:this.client.matchID,playerID:this.client.playerID,reset:this.client.reset,undo:this.client.undo,redo:this.client.redo,log:this.client.log,matchData:this.client.matchData,sendChatMessage:this.client.sendChatMessage,chatMessages:this.client.chatMessages})),s.default.createElement(\"div\",{className:\"bgio-client\"},t)}}).propTypes={matchID:r.default.string,playerID:r.default.string,credentials:r.default.string,debug:r.default.any},a.defaultProps={matchID:\"default\",playerID:null,credentials:null,debug:!0},a}require(\"./master-be1abdd0.js\"),require(\"./filter-player-view-c30cdfbf.js\"),require(\"socket.io-client\");class h{constructor({server:e,gameComponents:t,playerName:s,playerCredentials:r}){this.client=new a.L({server:e}),this.gameComponents=t,this.playerName=s||\"Visitor\",this.playerCredentials=r,this.matches=[]}async refresh(){try{this.matches=[];const t=await this.client.listGames();for(const e of t){if(!this._getGameComponents(e))continue;const{matches:t}=await this.client.listMatches(e);this.matches.push(...t)}}catch(e){throw new Error(\"failed to retrieve list of matches (\"+e+\")\")}}_getMatchInstance(e){for(const t of this.matches)if(t.matchID===e)return t}_getGameComponents(e){for(const t of this.gameComponents)if(t.game.name===e)return t}_findPlayer(e){for(const t of this.matches)if(t.players.some(t=>t.name===e))return t}async join(e,t,a){try{let r=this._findPlayer(this.playerName);if(r)throw new Error(\"player has already joined \"+r.matchID);if(!(r=this._getMatchInstance(t)))throw new Error(\"game instance \"+t+\" not found\");const n=await this.client.joinMatch(e,t,{playerID:a,playerName:this.playerName});r.players[Number.parseInt(a)].name=this.playerName,this.playerCredentials=n.playerCredentials}catch(s){throw new Error(\"failed to join match \"+t+\" (\"+s+\")\")}}async leave(e,t){try{const s=this._getMatchInstance(t);if(!s)throw new Error(\"match instance not found\");for(const a of s.players)if(a.name===this.playerName)return await this.client.leaveMatch(e,t,{playerID:a.id.toString(),credentials:this.playerCredentials}),delete a.name,void delete this.playerCredentials;throw new Error(\"player not found in match\")}catch(a){throw new Error(\"failed to leave match \"+t+\" (\"+a+\")\")}}async disconnect(){const e=this._findPlayer(this.playerName);e&&await this.leave(e.gameName,e.matchID),this.matches=[],this.playerName=\"Visitor\"}async create(e,t){try{const s=this._getGameComponents(e);if(!s)throw new Error(\"game not found\");if(t<s.game.minPlayers||t>s.game.maxPlayers)throw new Error(\"invalid number of players \"+t);await this.client.createMatch(e,{numPlayers:t})}catch(a){throw new Error(\"failed to create match for \"+e+\" (\"+a+\")\")}}}function m(e){return new h(e)}class u extends s.default.Component{constructor(){super(...arguments),this.state={playerName:this.props.playerName,nameErrorMsg:\"\"},this.onClickEnter=(()=>{\"\"!==this.state.playerName&&this.props.onEnter(this.state.playerName)}),this.onKeyPress=(e=>{\"Enter\"===e.key&&this.onClickEnter()}),this.onChangePlayerName=(e=>{const t=e.target.value.trim();this.setState({playerName:t,nameErrorMsg:t.length>0?\"\":\"empty player name\"})})}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"p\",{className:\"phase-title\"},\"Choose a player name:\"),s.default.createElement(\"input\",{type:\"text\",value:this.state.playerName,onChange:this.onChangePlayerName,onKeyPress:this.onKeyPress}),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{className:\"buttons\",onClick:this.onClickEnter},\"Enter\")),s.default.createElement(\"br\",null),s.default.createElement(\"span\",{className:\"error-msg\"},this.state.nameErrorMsg,s.default.createElement(\"br\",null)))}}u.defaultProps={playerName:\"\"};class p extends s.default.Component{constructor(){super(...arguments),this._createSeat=(e=>e.name||\"[free]\"),this._createButtonJoin=((e,t)=>s.default.createElement(\"button\",{key:\"button-join-\"+e.matchID,onClick:()=>this.props.onClickJoin(e.gameName,e.matchID,\"\"+t)},\"Join\")),this._createButtonLeave=(e=>s.default.createElement(\"button\",{key:\"button-leave-\"+e.matchID,onClick:()=>this.props.onClickLeave(e.gameName,e.matchID)},\"Leave\")),this._createButtonPlay=((e,t)=>s.default.createElement(\"button\",{key:\"button-play-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,playerID:\"\"+t,numPlayers:e.players.length})},\"Play\")),this._createButtonSpectate=(e=>s.default.createElement(\"button\",{key:\"button-spectate-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,numPlayers:e.players.length})},\"Spectate\")),this._createInstanceButtons=(e=>{const t=e.players.find(e=>e.name===this.props.playerName),a=e.players.find(e=>!e.name);return t&&a?this._createButtonLeave(e):a?this._createButtonJoin(e,a.id):t?s.default.createElement(\"div\",null,[this._createButtonPlay(e,t.id),this._createButtonLeave(e)]):this._createButtonSpectate(e)})}render(){const e=this.props.match;let t=\"OPEN\";return e.players.some(e=>!e.name)||(t=\"RUNNING\"),s.default.createElement(\"tr\",{key:\"line-\"+e.matchID},s.default.createElement(\"td\",{key:\"cell-name-\"+e.matchID},e.gameName),s.default.createElement(\"td\",{key:\"cell-status-\"+e.matchID},t),s.default.createElement(\"td\",{key:\"cell-seats-\"+e.matchID},e.players.map(e=>this._createSeat(e)).join(\", \")),s.default.createElement(\"td\",{key:\"cell-buttons-\"+e.matchID},this._createInstanceButtons(e)))}}class d extends s.default.Component{constructor(e){super(e),this.state={selectedGame:0,numPlayers:2},this._createGameNameOption=((e,t)=>s.default.createElement(\"option\",{key:\"name-option-\"+t,value:t},e.game.name)),this._createNumPlayersOption=(e=>s.default.createElement(\"option\",{key:\"num-option-\"+e,value:e},e)),this._createNumPlayersRange=(e=>Array.from({length:e.maxPlayers+1}).map((e,t)=>t).slice(e.minPlayers)),this.onChangeNumPlayers=(e=>{this.setState({numPlayers:Number.parseInt(e.target.value)})}),this.onChangeSelectedGame=(e=>{const t=Number.parseInt(e.target.value);this.setState({selectedGame:t,numPlayers:this.props.games[t].game.minPlayers})}),this.onClickCreate=(()=>{this.props.createMatch(this.props.games[this.state.selectedGame].game.name,this.state.numPlayers)});for(const t of e.games){const e=t.game;e.minPlayers||(e.minPlayers=1),e.maxPlayers||(e.maxPlayers=4),console.assert(e.maxPlayers>=e.minPlayers)}this.state={selectedGame:0,numPlayers:e.games[0].game.minPlayers}}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"select\",{value:this.state.selectedGame,onChange:e=>this.onChangeSelectedGame(e)},this.props.games.map((e,t)=>this._createGameNameOption(e,t))),s.default.createElement(\"span\",null,\"Players:\"),s.default.createElement(\"select\",{value:this.state.numPlayers,onChange:this.onChangeNumPlayers},this._createNumPlayersRange(this.props.games[this.state.selectedGame].game).map(e=>this._createNumPlayersOption(e))),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{onClick:this.onClickCreate},\"Create\")))}}!function(e){e.ENTER=\"enter\",e.PLAY=\"play\",e.LIST=\"list\"}(i||(i={}));class y extends s.default.Component{constructor(e){super(e),this.state={phase:i.ENTER,playerName:\"Visitor\",runningMatch:null,errorMsg:\"\",credentialStore:{}},this._createConnection=(e=>{const t=this.state.playerName;this.connection=m({server:e.lobbyServer,gameComponents:e.gameComponents,playerName:t,playerCredentials:this.state.credentialStore[t]})}),this._updateCredentials=((e,t)=>{this.setState(a=>{const s=Object.assign({},a.credentialStore);return s[e]=t,{credentialStore:s}})}),this._updateConnection=(async()=>{await this.connection.refresh(),this.forceUpdate()}),this._enterLobby=(e=>{this._startRefreshInterval(),this.setState({playerName:e,phase:i.LIST})}),this._exitLobby=(async()=>{this._clearRefreshInterval(),await this.connection.disconnect(),this.setState({phase:i.ENTER,errorMsg:\"\"})}),this._createMatch=(async(e,t)=>{try{await this.connection.create(e,t),await this.connection.refresh(),this.setState({})}catch(a){this.setState({errorMsg:a.message})}}),this._joinMatch=(async(e,t,a)=>{try{await this.connection.join(e,t,a),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(s){this.setState({errorMsg:s.message})}}),this._leaveMatch=(async(e,t)=>{try{await this.connection.leave(e,t),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(a){this.setState({errorMsg:a.message})}}),this._startMatch=((e,a)=>{const s=this.connection._getGameComponents(e);if(!s)return void this.setState({errorMsg:\"game \"+e+\" not supported\"});let r=void 0;if(a.numPlayers>1&&(r=this.props.gameServer?(0,l.S)({server:this.props.gameServer}):(0,l.S)()),1==a.numPlayers){const e=s.game.maxPlayers,a={};for(let s=1;s<e;s++)a[s+\"\"]=t.M;r=(0,l.L)({bots:a})}const n={app:this.props.clientFactory({game:s.game,board:s.board,debug:this.props.debug,multiplayer:r}),matchID:a.matchID,playerID:a.numPlayers>1?a.playerID:\"0\",credentials:this.connection.playerCredentials};this._clearRefreshInterval(),this.setState({phase:i.PLAY,runningMatch:n})}),this._exitMatch=(()=>{this._startRefreshInterval(),this.setState({phase:i.LIST,runningMatch:null})}),this._getPhaseVisibility=(e=>this.state.phase!==e?\"hidden\":\"phase\"),this.renderMatches=((e,t)=>e.map(e=>{const{matchID:a,gameName:r,players:n}=e;return s.default.createElement(p,{key:\"instance-\"+a,match:{matchID:a,gameName:r,players:Object.values(n)},playerName:t,onClickJoin:this._joinMatch,onClickLeave:this._leaveMatch,onClickPlay:this._startMatch})})),this._createConnection(this.props)}componentDidMount(){const e=n.default.load(\"lobbyState\")||{};e.phase&&e.phase===i.PLAY&&(e.phase=i.LIST),e.phase&&e.phase!==i.ENTER&&this._startRefreshInterval(),this.setState({phase:e.phase||i.ENTER,playerName:e.playerName||\"Visitor\",credentialStore:e.credentialStore||{}})}componentDidUpdate(e,t){const a=this.state.playerName,s=this.state.credentialStore[a];if(t.phase!==this.state.phase||t.credentialStore[a]!==s||t.playerName!==a){this._createConnection(this.props),this._updateConnection();const e={phase:this.state.phase,playerName:a,credentialStore:this.state.credentialStore};n.default.save(\"lobbyState\",e,{path:\"/\"})}e.refreshInterval!==this.props.refreshInterval&&this._startRefreshInterval()}componentWillUnmount(){this._clearRefreshInterval()}_startRefreshInterval(){this._clearRefreshInterval(),this._currentInterval=setInterval(this._updateConnection,this.props.refreshInterval)}_clearRefreshInterval(){clearInterval(this._currentInterval)}render(){const{gameComponents:e,renderer:t}=this.props,{errorMsg:a,playerName:r,phase:n,runningMatch:l}=this.state;return t?t({errorMsg:a,gameComponents:e,matches:this.connection.matches,phase:n,playerName:r,runningMatch:l,handleEnterLobby:this._enterLobby,handleExitLobby:this._exitLobby,handleCreateMatch:this._createMatch,handleJoinMatch:this._joinMatch,handleLeaveMatch:this._leaveMatch,handleExitMatch:this._exitMatch,handleRefreshMatches:this._updateConnection,handleStartMatch:this._startMatch}):s.default.createElement(\"div\",{id:\"lobby-view\",style:{padding:50}},s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.ENTER)},s.default.createElement(u,{key:r,playerName:r,onEnter:this._enterLobby})),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.LIST)},s.default.createElement(\"p\",null,\"Welcome, \",r),s.default.createElement(\"div\",{className:\"phase-title\",id:\"match-creation\"},s.default.createElement(\"span\",null,\"Create a match:\"),s.default.createElement(d,{games:e,createMatch:this._createMatch})),s.default.createElement(\"p\",{className:\"phase-title\"},\"Join a match:\"),s.default.createElement(\"div\",{id:\"instances\"},s.default.createElement(\"table\",null,s.default.createElement(\"tbody\",null,this.renderMatches(this.connection.matches,r))),s.default.createElement(\"span\",{className:\"error-msg\"},a,s.default.createElement(\"br\",null))),s.default.createElement(\"p\",{className:\"phase-title\"},\"Matches that become empty are automatically deleted.\")),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.PLAY)},l&&s.default.createElement(l.app,{matchID:l.matchID,playerID:l.playerID,credentials:l.credentials}),s.default.createElement(\"div\",{className:\"buttons\",id:\"match-exit\"},s.default.createElement(\"button\",{onClick:this._exitMatch},\"Exit match\"))),s.default.createElement(\"div\",{className:\"buttons\",id:\"lobby-exit\"},s.default.createElement(\"button\",{onClick:this._exitLobby},\"Exit lobby\")))}}exports.Lobby=y,y.propTypes={gameComponents:r.default.array.isRequired,lobbyServer:r.default.string,gameServer:r.default.string,debug:r.default.bool,clientFactory:r.default.func,refreshInterval:r.default.number},y.defaultProps={debug:!1,clientFactory:o,refreshInterval:2e3};\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\",\"./client-fa36c03a.js\":\"FkTq\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\",\"./client-5f57c3f2.js\":\"mOPV\",\"react\":\"SAdv\",\"prop-types\":\"yu5W\",\"react-cookies\":\"kpSY\",\"./util-b1699aa1.js\":\"pSNY\",\"./socketio-e4fb268a.js\":\"UzxM\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"Prnk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Debug\",{enumerable:!0,get:function(){return e.D}});var e=require(\"./Debug-fd09b8bc.js\");require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"flatted\"),require(\"setimmediate\"),require(\"./ai-3099ce9a.js\");\n},{\"./Debug-fd09b8bc.js\":\"uvSB\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"WrEP\":[function(require,module,exports) {\n\"use strict\";var e=t(require(\"react\")),r=t(require(\"react-dom\")),l=require(\"boardgame.io/react\"),u=require(\"boardgame.io/debug\");function t(e){return e&&e.__esModule?e:{default:e}}var a={setup:()=>({cells:Array(9).fill(null)}),moves:{clickCell(e,r,l){e.cells[l]=r.currentPlayer}}},c=(0,l.Client)({game:a,debug:{impl:u.Debug}});r.default.render(e.default.createElement(c,null),document.getElementById(\"app\"));\n},{\"react\":\"n8MK\",\"react-dom\":\"NKHc\",\"boardgame.io/react\":\"PUvW\",\"boardgame.io/debug\":\"Prnk\"}]},{},[\"WrEP\"], null)"
  },
  {
    "path": "docs/documentation/snippets/example-2/index.html",
    "content": "<!DOCTYPE html><html><head><style>body{padding:20px}.msg{position:absolute;bottom:0;left:20px;color:#aaa;font-size:12px;margin-bottom:20px}</style></head><body> <div class=\"msg\">interactive (not an image)</div> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/example-2.e4675089.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/example-2.e4675089.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"J4Nk\":[function(require,module,exports) {\n\"use strict\";var r=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(r){if(null==r)throw new TypeError(\"Object.assign cannot be called with null or undefined\");return Object(r)}function o(){try{if(!Object.assign)return!1;var r=new String(\"abc\");if(r[5]=\"de\",\"5\"===Object.getOwnPropertyNames(r)[0])return!1;for(var t={},e=0;e<10;e++)t[\"_\"+String.fromCharCode(e)]=e;if(\"0123456789\"!==Object.getOwnPropertyNames(t).map(function(r){return t[r]}).join(\"\"))return!1;var n={};return\"abcdefghijklmnopqrst\".split(\"\").forEach(function(r){n[r]=r}),\"abcdefghijklmnopqrst\"===Object.keys(Object.assign({},n)).join(\"\")}catch(o){return!1}}module.exports=o()?Object.assign:function(o,c){for(var a,i,s=n(o),f=1;f<arguments.length;f++){for(var u in a=Object(arguments[f]))t.call(a,u)&&(s[u]=a[u]);if(r){i=r(a);for(var b=0;b<i.length;b++)e.call(a,i[b])&&(s[i[b]]=a[i[b]])}}return s};\n},{}],\"awqi\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"n8MK\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"awqi\"}],\"IvPb\":[function(require,module,exports) {\n\"use strict\";var e,n,t,r,o;if(\"undefined\"==typeof window||\"function\"!=typeof MessageChannel){var a=null,l=null,i=function(){if(null!==a)try{var e=exports.unstable_now();a(!0,e),a=null}catch(n){throw setTimeout(i,0),n}},u=Date.now();exports.unstable_now=function(){return Date.now()-u},e=function(n){null!==a?setTimeout(e,0,n):(a=n,setTimeout(i,0))},n=function(e,n){l=setTimeout(e,n)},t=function(){clearTimeout(l)},r=function(){return!1},o=exports.unstable_forceFrameRate=function(){}}else{var s=window.performance,c=window.Date,f=window.setTimeout,p=window.clearTimeout;if(\"undefined\"!=typeof console){var b=window.cancelAnimationFrame;\"function\"!=typeof window.requestAnimationFrame&&console.error(\"This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\"),\"function\"!=typeof b&&console.error(\"This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\")}if(\"object\"==typeof s&&\"function\"==typeof s.now)exports.unstable_now=function(){return s.now()};else{var d=c.now();exports.unstable_now=function(){return c.now()-d}}var v=!1,x=null,w=-1,m=5,y=0;r=function(){return exports.unstable_now()>=y},o=function(){},exports.unstable_forceFrameRate=function(e){0>e||125<e?console.error(\"forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported\"):m=0<e?Math.floor(1e3/e):5};var _=new MessageChannel,h=_.port2;_.port1.onmessage=function(){if(null!==x){var e=exports.unstable_now();y=e+m;try{x(!0,e)?h.postMessage(null):(v=!1,x=null)}catch(n){throw h.postMessage(null),n}}else v=!1},e=function(e){x=e,v||(v=!0,h.postMessage(null))},n=function(e,n){w=f(function(){e(exports.unstable_now())},n)},t=function(){p(w),w=-1}}function k(e,n){var t=e.length;e.push(n);e:for(;;){var r=t-1>>>1,o=e[r];if(!(void 0!==o&&0<P(o,n)))break e;e[r]=n,e[t]=o,t=r}}function T(e){return void 0===(e=e[0])?null:e}function g(e){var n=e[0];if(void 0!==n){var t=e.pop();if(t!==n){e[0]=t;e:for(var r=0,o=e.length;r<o;){var a=2*(r+1)-1,l=e[a],i=a+1,u=e[i];if(void 0!==l&&0>P(l,t))void 0!==u&&0>P(u,l)?(e[r]=u,e[i]=t,r=i):(e[r]=l,e[a]=t,r=a);else{if(!(void 0!==u&&0>P(u,t)))break e;e[r]=u,e[i]=t,r=i}}}return n}return null}function P(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}var F=[],I=[],M=1,C=null,A=3,L=!1,q=!1,D=!1;function R(e){for(var n=T(I);null!==n;){if(null===n.callback)g(I);else{if(!(n.startTime<=e))break;g(I),n.sortIndex=n.expirationTime,k(F,n)}n=T(I)}}function j(t){if(D=!1,R(t),!q)if(null!==T(F))q=!0,e(E);else{var r=T(I);null!==r&&n(j,r.startTime-t)}}function E(e,o){q=!1,D&&(D=!1,t()),L=!0;var a=A;try{for(R(o),C=T(F);null!==C&&(!(C.expirationTime>o)||e&&!r());){var l=C.callback;if(null!==l){C.callback=null,A=C.priorityLevel;var i=l(C.expirationTime<=o);o=exports.unstable_now(),\"function\"==typeof i?C.callback=i:C===T(F)&&g(F),R(o)}else g(F);C=T(F)}if(null!==C)var u=!0;else{var s=T(I);null!==s&&n(j,s.startTime-o),u=!1}return u}finally{C=null,A=a,L=!1}}function N(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var B=o;exports.unstable_IdlePriority=5,exports.unstable_ImmediatePriority=1,exports.unstable_LowPriority=4,exports.unstable_NormalPriority=3,exports.unstable_Profiling=null,exports.unstable_UserBlockingPriority=2,exports.unstable_cancelCallback=function(e){e.callback=null},exports.unstable_continueExecution=function(){q||L||(q=!0,e(E))},exports.unstable_getCurrentPriorityLevel=function(){return A},exports.unstable_getFirstCallbackNode=function(){return T(F)},exports.unstable_next=function(e){switch(A){case 1:case 2:case 3:var n=3;break;default:n=A}var t=A;A=n;try{return e()}finally{A=t}},exports.unstable_pauseExecution=function(){},exports.unstable_requestPaint=B,exports.unstable_runWithPriority=function(e,n){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var t=A;A=e;try{return n()}finally{A=t}},exports.unstable_scheduleCallback=function(r,o,a){var l=exports.unstable_now();if(\"object\"==typeof a&&null!==a){var i=a.delay;i=\"number\"==typeof i&&0<i?l+i:l,a=\"number\"==typeof a.timeout?a.timeout:N(r)}else a=N(r),i=l;return r={id:M++,callback:o,priorityLevel:r,startTime:i,expirationTime:a=i+a,sortIndex:-1},i>l?(r.sortIndex=i,k(I,r),null===T(F)&&r===T(I)&&(D?t():D=!0,n(j,i-l))):(r.sortIndex=a,k(F,r),q||L||(q=!0,e(E))),r},exports.unstable_shouldYield=function(){var e=exports.unstable_now();R(e);var n=T(F);return n!==C&&null!==C&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTime<C.expirationTime||r()},exports.unstable_wrapCallback=function(e){var n=A;return function(){var t=A;A=n;try{return e.apply(this,arguments)}finally{A=t}}};\n},{}],\"MDSO\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/scheduler.production.min.js\");\n},{\"./cjs/scheduler.production.min.js\":\"IvPb\"}],\"i17t\":[function(require,module,exports) {\n\"use strict\";var e=require(\"react\"),t=require(\"object-assign\"),n=require(\"scheduler\");function r(e){for(var t=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,n=1;n<arguments.length;n++)t+=\"&args[]=\"+encodeURIComponent(arguments[n]);return\"Minified React error #\"+e+\"; visit \"+t+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}if(!e)throw Error(r(227));function l(e,t,n,r,l,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(s){this.onError(s)}}var i=!1,a=null,o=!1,u=null,c={onError:function(e){i=!0,a=e}};function s(e,t,n,r,o,u,s,f,d){i=!1,a=null,l.apply(c,arguments)}function f(e,t,n,l,c,f,d,p,m){if(s.apply(this,arguments),i){if(!i)throw Error(r(198));var h=a;i=!1,a=null,o||(o=!0,u=h)}}var d=null,p=null,m=null;function h(e,t,n){var r=e.type||\"unknown-event\";e.currentTarget=m(n),f(r,t,void 0,e),e.currentTarget=null}var g=null,v={};function y(){if(g)for(var e in v){var t=v[e],n=g.indexOf(e);if(!(-1<n))throw Error(r(96,e));if(!w[n]){if(!t.extractEvents)throw Error(r(97,e));for(var l in w[n]=t,n=t.eventTypes){var i=void 0,a=n[l],o=t,u=l;if(k.hasOwnProperty(u))throw Error(r(99,u));k[u]=a;var c=a.phasedRegistrationNames;if(c){for(i in c)c.hasOwnProperty(i)&&b(c[i],o,u);i=!0}else a.registrationName?(b(a.registrationName,o,u),i=!0):i=!1;if(!i)throw Error(r(98,l,e))}}}}function b(e,t,n){if(x[e])throw Error(r(100,e));x[e]=t,T[e]=t.eventTypes[n].dependencies}var w=[],k={},x={},T={};function E(e){var t,n=!1;for(t in e)if(e.hasOwnProperty(t)){var l=e[t];if(!v.hasOwnProperty(t)||v[t]!==l){if(v[t])throw Error(r(102,t));v[t]=l,n=!0}}n&&y()}var S=!(\"undefined\"==typeof window||void 0===window.document||void 0===window.document.createElement),C=null,P=null,_=null;function N(e){if(e=p(e)){if(\"function\"!=typeof C)throw Error(r(280));var t=e.stateNode;t&&(t=d(t),C(e.stateNode,e.type,t))}}function z(e){P?_?_.push(e):_=[e]:P=e}function M(){if(P){var e=P,t=_;if(_=P=null,N(e),t)for(e=0;e<t.length;e++)N(t[e])}}function I(e,t){return e(t)}function F(e,t,n,r,l){return e(t,n,r,l)}function O(){}var R=I,D=!1,L=!1;function U(){null===P&&null===_||(O(),M())}function A(e,t,n){if(L)return e(t,n);L=!0;try{return R(e,t,n)}finally{L=!1,U()}}var V=/^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$/,Q=Object.prototype.hasOwnProperty,W={},H={};function j(e){return!!Q.call(H,e)||!Q.call(W,e)&&(V.test(e)?H[e]=!0:(W[e]=!0,!1))}function B(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case\"function\":case\"symbol\":return!0;case\"boolean\":return!r&&(null!==n?!n.acceptsBooleans:\"data-\"!==(e=e.toLowerCase().slice(0,5))&&\"aria-\"!==e);default:return!1}}function K(e,t,n,r){if(null==t||B(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function $(e,t,n,r,l,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i}var q={};\"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style\".split(\" \").forEach(function(e){q[e]=new $(e,0,!1,e,null,!1)}),[[\"acceptCharset\",\"accept-charset\"],[\"className\",\"class\"],[\"htmlFor\",\"for\"],[\"httpEquiv\",\"http-equiv\"]].forEach(function(e){var t=e[0];q[t]=new $(t,1,!1,e[1],null,!1)}),[\"contentEditable\",\"draggable\",\"spellCheck\",\"value\"].forEach(function(e){q[e]=new $(e,2,!1,e.toLowerCase(),null,!1)}),[\"autoReverse\",\"externalResourcesRequired\",\"focusable\",\"preserveAlpha\"].forEach(function(e){q[e]=new $(e,2,!1,e,null,!1)}),\"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope\".split(\" \").forEach(function(e){q[e]=new $(e,3,!1,e.toLowerCase(),null,!1)}),[\"checked\",\"multiple\",\"muted\",\"selected\"].forEach(function(e){q[e]=new $(e,3,!0,e,null,!1)}),[\"capture\",\"download\"].forEach(function(e){q[e]=new $(e,4,!1,e,null,!1)}),[\"cols\",\"rows\",\"size\",\"span\"].forEach(function(e){q[e]=new $(e,6,!1,e,null,!1)}),[\"rowSpan\",\"start\"].forEach(function(e){q[e]=new $(e,5,!1,e.toLowerCase(),null,!1)});var Y=/[\\-:]([a-z])/g;function X(e){return e[1].toUpperCase()}\"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,null,!1)}),\"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/1999/xlink\",!1)}),[\"xml:base\",\"xml:lang\",\"xml:space\"].forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/XML/1998/namespace\",!1)}),[\"tabIndex\",\"crossOrigin\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!1)}),q.xlinkHref=new $(\"xlinkHref\",1,!1,\"xlink:href\",\"http://www.w3.org/1999/xlink\",!0),[\"src\",\"href\",\"action\",\"formAction\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!0)});var G=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function Z(e,t,n,r){var l=q.hasOwnProperty(t)?q[t]:null;(null!==l?0===l.type:!r&&(2<t.length&&(\"o\"===t[0]||\"O\"===t[0])&&(\"n\"===t[1]||\"N\"===t[1])))||(K(t,n,l,r)&&(n=null),r||null===l?j(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,\"\"+n)):l.mustUseProperty?e[l.propertyName]=null===n?3!==l.type&&\"\":n:(t=l.attributeName,r=l.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(l=l.type)||4===l&&!0===n?\"\":\"\"+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}G.hasOwnProperty(\"ReactCurrentDispatcher\")||(G.ReactCurrentDispatcher={current:null}),G.hasOwnProperty(\"ReactCurrentBatchConfig\")||(G.ReactCurrentBatchConfig={suspense:null});var J=/^(.*)[\\\\\\/]/,ee=\"function\"==typeof Symbol&&Symbol.for,te=ee?Symbol.for(\"react.element\"):60103,ne=ee?Symbol.for(\"react.portal\"):60106,re=ee?Symbol.for(\"react.fragment\"):60107,le=ee?Symbol.for(\"react.strict_mode\"):60108,ie=ee?Symbol.for(\"react.profiler\"):60114,ae=ee?Symbol.for(\"react.provider\"):60109,oe=ee?Symbol.for(\"react.context\"):60110,ue=ee?Symbol.for(\"react.concurrent_mode\"):60111,ce=ee?Symbol.for(\"react.forward_ref\"):60112,se=ee?Symbol.for(\"react.suspense\"):60113,fe=ee?Symbol.for(\"react.suspense_list\"):60120,de=ee?Symbol.for(\"react.memo\"):60115,pe=ee?Symbol.for(\"react.lazy\"):60116,me=ee?Symbol.for(\"react.block\"):60121,he=\"function\"==typeof Symbol&&Symbol.iterator;function ge(e){return null===e||\"object\"!=typeof e?null:\"function\"==typeof(e=he&&e[he]||e[\"@@iterator\"])?e:null}function ve(e){if(-1===e._status){e._status=0;var t=e._ctor;t=t(),e._result=t,t.then(function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)},function(t){0===e._status&&(e._status=2,e._result=t)})}}function ye(e){if(null==e)return null;if(\"function\"==typeof e)return e.displayName||e.name||null;if(\"string\"==typeof e)return e;switch(e){case re:return\"Fragment\";case ne:return\"Portal\";case ie:return\"Profiler\";case le:return\"StrictMode\";case se:return\"Suspense\";case fe:return\"SuspenseList\"}if(\"object\"==typeof e)switch(e.$$typeof){case oe:return\"Context.Consumer\";case ae:return\"Context.Provider\";case ce:var t=e.render;return t=t.displayName||t.name||\"\",e.displayName||(\"\"!==t?\"ForwardRef(\"+t+\")\":\"ForwardRef\");case de:return ye(e.type);case me:return ye(e.render);case pe:if(e=1===e._status?e._result:null)return ye(e)}return null}function be(e){var t=\"\";do{e:switch(e.tag){case 3:case 4:case 6:case 7:case 10:case 9:var n=\"\";break e;default:var r=e._debugOwner,l=e._debugSource,i=ye(e.type);n=null,r&&(n=ye(r.type)),r=i,i=\"\",l?i=\" (at \"+l.fileName.replace(J,\"\")+\":\"+l.lineNumber+\")\":n&&(i=\" (created by \"+n+\")\"),n=\"\\n    in \"+(r||\"Unknown\")+i}t+=n,e=e.return}while(e);return t}function we(e){switch(typeof e){case\"boolean\":case\"number\":case\"object\":case\"string\":case\"undefined\":return e;default:return\"\"}}function ke(e){var t=e.type;return(e=e.nodeName)&&\"input\"===e.toLowerCase()&&(\"checkbox\"===t||\"radio\"===t)}function xe(e){var t=ke(e)?\"checked\":\"value\",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=\"\"+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&\"function\"==typeof n.get&&\"function\"==typeof n.set){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(e){r=\"\"+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=\"\"+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Te(e){e._valueTracker||(e._valueTracker=xe(e))}function Ee(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=\"\";return e&&(r=ke(e)?e.checked?\"true\":\"false\":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Se(e,n){var r=n.checked;return t({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:e._wrapperState.initialChecked})}function Ce(e,t){var n=null==t.defaultValue?\"\":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=we(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:\"checkbox\"===t.type||\"radio\"===t.type?null!=t.checked:null!=t.value}}function Pe(e,t){null!=(t=t.checked)&&Z(e,\"checked\",t,!1)}function _e(e,t){Pe(e,t);var n=we(t.value),r=t.type;if(null!=n)\"number\"===r?(0===n&&\"\"===e.value||e.value!=n)&&(e.value=\"\"+n):e.value!==\"\"+n&&(e.value=\"\"+n);else if(\"submit\"===r||\"reset\"===r)return void e.removeAttribute(\"value\");t.hasOwnProperty(\"value\")?ze(e,t.type,n):t.hasOwnProperty(\"defaultValue\")&&ze(e,t.type,we(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Ne(e,t,n){if(t.hasOwnProperty(\"value\")||t.hasOwnProperty(\"defaultValue\")){var r=t.type;if(!(\"submit\"!==r&&\"reset\"!==r||void 0!==t.value&&null!==t.value))return;t=\"\"+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}\"\"!==(n=e.name)&&(e.name=\"\"),e.defaultChecked=!!e._wrapperState.initialChecked,\"\"!==n&&(e.name=n)}function ze(e,t,n){\"number\"===t&&e.ownerDocument.activeElement===e||(null==n?e.defaultValue=\"\"+e._wrapperState.initialValue:e.defaultValue!==\"\"+n&&(e.defaultValue=\"\"+n))}function Me(t){var n=\"\";return e.Children.forEach(t,function(e){null!=e&&(n+=e)}),n}function Ie(e,n){return e=t({children:void 0},n),(n=Me(n.children))&&(e.children=n),e}function Fe(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t[\"$\"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty(\"$\"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=\"\"+we(n),t=null,l=0;l<e.length;l++){if(e[l].value===n)return e[l].selected=!0,void(r&&(e[l].defaultSelected=!0));null!==t||e[l].disabled||(t=e[l])}null!==t&&(t.selected=!0)}}function Oe(e,n){if(null!=n.dangerouslySetInnerHTML)throw Error(r(91));return t({},n,{value:void 0,defaultValue:void 0,children:\"\"+e._wrapperState.initialValue})}function Re(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(r(92));if(Array.isArray(n)){if(!(1>=n.length))throw Error(r(93));n=n[0]}t=n}null==t&&(t=\"\"),n=t}e._wrapperState={initialValue:we(n)}}function De(e,t){var n=we(t.value),r=we(t.defaultValue);null!=n&&((n=\"\"+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=\"\"+r)}function Le(e){var t=e.textContent;t===e._wrapperState.initialValue&&\"\"!==t&&null!==t&&(e.value=t)}var Ue={html:\"http://www.w3.org/1999/xhtml\",mathml:\"http://www.w3.org/1998/Math/MathML\",svg:\"http://www.w3.org/2000/svg\"};function Ae(e){switch(e){case\"svg\":return\"http://www.w3.org/2000/svg\";case\"math\":return\"http://www.w3.org/1998/Math/MathML\";default:return\"http://www.w3.org/1999/xhtml\"}}function Ve(e,t){return null==e||\"http://www.w3.org/1999/xhtml\"===e?Ae(t):\"http://www.w3.org/2000/svg\"===e&&\"foreignObject\"===t?\"http://www.w3.org/1999/xhtml\":e}var Qe,We=function(e){return\"undefined\"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==Ue.svg||\"innerHTML\"in e)e.innerHTML=t;else{for((Qe=Qe||document.createElement(\"div\")).innerHTML=\"<svg>\"+t.valueOf().toString()+\"</svg>\",t=Qe.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function He(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}function je(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[\"Webkit\"+e]=\"webkit\"+t,n[\"Moz\"+e]=\"moz\"+t,n}var Be={animationend:je(\"Animation\",\"AnimationEnd\"),animationiteration:je(\"Animation\",\"AnimationIteration\"),animationstart:je(\"Animation\",\"AnimationStart\"),transitionend:je(\"Transition\",\"TransitionEnd\")},Ke={},$e={};function qe(e){if(Ke[e])return Ke[e];if(!Be[e])return e;var t,n=Be[e];for(t in n)if(n.hasOwnProperty(t)&&t in $e)return Ke[e]=n[t];return e}S&&($e=document.createElement(\"div\").style,\"AnimationEvent\"in window||(delete Be.animationend.animation,delete Be.animationiteration.animation,delete Be.animationstart.animation),\"TransitionEvent\"in window||delete Be.transitionend.transition);var Ye=qe(\"animationend\"),Xe=qe(\"animationiteration\"),Ge=qe(\"animationstart\"),Ze=qe(\"transitionend\"),Je=\"abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting\".split(\" \"),et=new(\"function\"==typeof WeakMap?WeakMap:Map);function tt(e){var t=et.get(e);return void 0===t&&(t=new Map,et.set(e,t)),t}function nt(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!=(1026&(t=e).effectTag)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function rt(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function lt(e){if(nt(e)!==e)throw Error(r(188))}function it(e){var t=e.alternate;if(!t){if(null===(t=nt(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,l=t;;){var i=n.return;if(null===i)break;var a=i.alternate;if(null===a){if(null!==(l=i.return)){n=l;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return lt(i),e;if(a===l)return lt(i),t;a=a.sibling}throw Error(r(188))}if(n.return!==l.return)n=i,l=a;else{for(var o=!1,u=i.child;u;){if(u===n){o=!0,n=i,l=a;break}if(u===l){o=!0,l=i,n=a;break}u=u.sibling}if(!o){for(u=a.child;u;){if(u===n){o=!0,n=a,l=i;break}if(u===l){o=!0,l=a,n=i;break}u=u.sibling}if(!o)throw Error(r(189))}}if(n.alternate!==l)throw Error(r(190))}if(3!==n.tag)throw Error(r(188));return n.stateNode.current===n?e:t}function at(e){if(!(e=it(e)))return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function ot(e,t){if(null==t)throw Error(r(30));return null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function ut(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}var ct=null;function st(e){if(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))for(var r=0;r<t.length&&!e.isPropagationStopped();r++)h(e,t[r],n[r]);else t&&h(e,t,n);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function ft(e){if(null!==e&&(ct=ot(ct,e)),e=ct,ct=null,e){if(ut(e,st),ct)throw Error(r(95));if(o)throw e=u,o=!1,u=null,e}}function dt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}function pt(e){if(!S)return!1;var t=(e=\"on\"+e)in document;return t||((t=document.createElement(\"div\")).setAttribute(e,\"return;\"),t=\"function\"==typeof t[e]),t}var mt=[];function ht(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>mt.length&&mt.push(e)}function gt(e,t,n,r){if(mt.length){var l=mt.pop();return l.topLevelType=e,l.eventSystemFlags=r,l.nativeEvent=t,l.targetInst=n,l}return{topLevelType:e,eventSystemFlags:r,nativeEvent:t,targetInst:n,ancestors:[]}}function vt(e){var t=e.targetInst,n=t;do{if(!n){e.ancestors.push(n);break}var r=n;if(3===r.tag)r=r.stateNode.containerInfo;else{for(;r.return;)r=r.return;r=3!==r.tag?null:r.stateNode.containerInfo}if(!r)break;5!==(t=n.tag)&&6!==t||e.ancestors.push(n),n=Un(r)}while(n);for(n=0;n<e.ancestors.length;n++){t=e.ancestors[n];var l=dt(e.nativeEvent);r=e.topLevelType;var i=e.nativeEvent,a=e.eventSystemFlags;0===n&&(a|=64);for(var o=null,u=0;u<w.length;u++){var c=w[u];c&&(c=c.extractEvents(r,t,i,l,a))&&(o=ot(o,c))}ft(o)}}function yt(e,t,n){if(!n.has(e)){switch(e){case\"scroll\":en(t,\"scroll\",!0);break;case\"focus\":case\"blur\":en(t,\"focus\",!0),en(t,\"blur\",!0),n.set(\"blur\",null),n.set(\"focus\",null);break;case\"cancel\":case\"close\":pt(e)&&en(t,e,!0);break;case\"invalid\":case\"submit\":case\"reset\":break;default:-1===Je.indexOf(e)&&Jt(e,t)}n.set(e,null)}}var bt,wt,kt,xt=!1,Tt=[],Et=null,St=null,Ct=null,Pt=new Map,_t=new Map,Nt=[],zt=\"mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput close cancel copy cut paste click change contextmenu reset submit\".split(\" \"),Mt=\"focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture\".split(\" \");function It(e,t){var n=tt(t);zt.forEach(function(e){yt(e,t,n)}),Mt.forEach(function(e){yt(e,t,n)})}function Ft(e,t,n,r,l){return{blockedOn:e,topLevelType:t,eventSystemFlags:32|n,nativeEvent:l,container:r}}function Ot(e,t){switch(e){case\"focus\":case\"blur\":Et=null;break;case\"dragenter\":case\"dragleave\":St=null;break;case\"mouseover\":case\"mouseout\":Ct=null;break;case\"pointerover\":case\"pointerout\":Pt.delete(t.pointerId);break;case\"gotpointercapture\":case\"lostpointercapture\":_t.delete(t.pointerId)}}function Rt(e,t,n,r,l,i){return null===e||e.nativeEvent!==i?(e=Ft(t,n,r,l,i),null!==t&&(null!==(t=An(t))&&wt(t)),e):(e.eventSystemFlags|=r,e)}function Dt(e,t,n,r,l){switch(t){case\"focus\":return Et=Rt(Et,e,t,n,r,l),!0;case\"dragenter\":return St=Rt(St,e,t,n,r,l),!0;case\"mouseover\":return Ct=Rt(Ct,e,t,n,r,l),!0;case\"pointerover\":var i=l.pointerId;return Pt.set(i,Rt(Pt.get(i)||null,e,t,n,r,l)),!0;case\"gotpointercapture\":return i=l.pointerId,_t.set(i,Rt(_t.get(i)||null,e,t,n,r,l)),!0}return!1}function Lt(e){var t=Un(e.target);if(null!==t){var r=nt(t);if(null!==r)if(13===(t=r.tag)){if(null!==(t=rt(r)))return e.blockedOn=t,void n.unstable_runWithPriority(e.priority,function(){kt(r)})}else if(3===t&&r.stateNode.hydrate)return void(e.blockedOn=3===r.tag?r.stateNode.containerInfo:null)}e.blockedOn=null}function Ut(e){if(null!==e.blockedOn)return!1;var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(null!==t){var n=An(t);return null!==n&&wt(n),e.blockedOn=t,!1}return!0}function At(e,t,n){Ut(e)&&n.delete(t)}function Vt(){for(xt=!1;0<Tt.length;){var e=Tt[0];if(null!==e.blockedOn){null!==(e=An(e.blockedOn))&&bt(e);break}var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);null!==t?e.blockedOn=t:Tt.shift()}null!==Et&&Ut(Et)&&(Et=null),null!==St&&Ut(St)&&(St=null),null!==Ct&&Ut(Ct)&&(Ct=null),Pt.forEach(At),_t.forEach(At)}function Qt(e,t){e.blockedOn===t&&(e.blockedOn=null,xt||(xt=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Vt)))}function Wt(e){function t(t){return Qt(t,e)}if(0<Tt.length){Qt(Tt[0],e);for(var n=1;n<Tt.length;n++){var r=Tt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Et&&Qt(Et,e),null!==St&&Qt(St,e),null!==Ct&&Qt(Ct,e),Pt.forEach(t),_t.forEach(t),n=0;n<Nt.length;n++)(r=Nt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Nt.length&&null===(n=Nt[0]).blockedOn;)Lt(n),null===n.blockedOn&&Nt.shift()}var Ht={},jt=new Map,Bt=new Map,Kt=[\"abort\",\"abort\",Ye,\"animationEnd\",Xe,\"animationIteration\",Ge,\"animationStart\",\"canplay\",\"canPlay\",\"canplaythrough\",\"canPlayThrough\",\"durationchange\",\"durationChange\",\"emptied\",\"emptied\",\"encrypted\",\"encrypted\",\"ended\",\"ended\",\"error\",\"error\",\"gotpointercapture\",\"gotPointerCapture\",\"load\",\"load\",\"loadeddata\",\"loadedData\",\"loadedmetadata\",\"loadedMetadata\",\"loadstart\",\"loadStart\",\"lostpointercapture\",\"lostPointerCapture\",\"playing\",\"playing\",\"progress\",\"progress\",\"seeking\",\"seeking\",\"stalled\",\"stalled\",\"suspend\",\"suspend\",\"timeupdate\",\"timeUpdate\",Ze,\"transitionEnd\",\"waiting\",\"waiting\"];function $t(e,t){for(var n=0;n<e.length;n+=2){var r=e[n],l=e[n+1],i=\"on\"+(l[0].toUpperCase()+l.slice(1));i={phasedRegistrationNames:{bubbled:i,captured:i+\"Capture\"},dependencies:[r],eventPriority:t},Bt.set(r,t),jt.set(r,i),Ht[l]=i}}$t(\"blur blur cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focus focus input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange\".split(\" \"),0),$t(\"drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel\".split(\" \"),1),$t(Kt,2);for(var qt=\"change selectionchange textInput compositionstart compositionend compositionupdate\".split(\" \"),Yt=0;Yt<qt.length;Yt++)Bt.set(qt[Yt],0);var Xt=n.unstable_UserBlockingPriority,Gt=n.unstable_runWithPriority,Zt=!0;function Jt(e,t){en(t,e,!1)}function en(e,t,n){var r=Bt.get(t);switch(void 0===r?2:r){case 0:r=tn.bind(null,t,1,e);break;case 1:r=nn.bind(null,t,1,e);break;default:r=rn.bind(null,t,1,e)}n?e.addEventListener(t,r,!0):e.addEventListener(t,r,!1)}function tn(e,t,n,r){D||O();var l=rn,i=D;D=!0;try{F(l,e,t,n,r)}finally{(D=i)||U()}}function nn(e,t,n,r){Gt(Xt,rn.bind(null,e,t,n,r))}function rn(e,t,n,r){if(Zt)if(0<Tt.length&&-1<zt.indexOf(e))e=Ft(null,e,t,n,r),Tt.push(e);else{var l=ln(e,t,n,r);if(null===l)Ot(e,r);else if(-1<zt.indexOf(e))e=Ft(l,e,t,n,r),Tt.push(e);else if(!Dt(l,e,t,n,r)){Ot(e,r),e=gt(e,r,null,t);try{A(vt,e)}finally{ht(e)}}}}function ln(e,t,n,r){if(null!==(n=Un(n=dt(r)))){var l=nt(n);if(null===l)n=null;else{var i=l.tag;if(13===i){if(null!==(n=rt(l)))return n;n=null}else if(3===i){if(l.stateNode.hydrate)return 3===l.tag?l.stateNode.containerInfo:null;n=null}else l!==n&&(n=null)}}e=gt(e,r,n,t);try{A(vt,e)}finally{ht(e)}return null}var an={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},on=[\"Webkit\",\"ms\",\"Moz\",\"O\"];function un(e,t,n){return null==t||\"boolean\"==typeof t||\"\"===t?\"\":n||\"number\"!=typeof t||0===t||an.hasOwnProperty(e)&&an[e]?(\"\"+t).trim():t+\"px\"}function cn(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf(\"--\"),l=un(n,t[n],r);\"float\"===n&&(n=\"cssFloat\"),r?e.setProperty(n,l):e[n]=l}}Object.keys(an).forEach(function(e){on.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),an[t]=an[e]})});var sn=t({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fn(e,t){if(t){if(sn[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(r(137,e,\"\"));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(r(60));if(!(\"object\"==typeof t.dangerouslySetInnerHTML&&\"__html\"in t.dangerouslySetInnerHTML))throw Error(r(61))}if(null!=t.style&&\"object\"!=typeof t.style)throw Error(r(62,\"\"))}}function dn(e,t){if(-1===e.indexOf(\"-\"))return\"string\"==typeof t.is;switch(e){case\"annotation-xml\":case\"color-profile\":case\"font-face\":case\"font-face-src\":case\"font-face-uri\":case\"font-face-format\":case\"font-face-name\":case\"missing-glyph\":return!1;default:return!0}}var pn=Ue.html;function mn(e,t){var n=tt(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=T[t];for(var r=0;r<t.length;r++)yt(t[r],e,n)}function hn(){}function gn(e){if(void 0===(e=e||(\"undefined\"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function vn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yn(e,t){var n,r=vn(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=vn(r)}}function bn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?bn(e,t.parentNode):\"contains\"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function wn(){for(var e=window,t=gn();t instanceof e.HTMLIFrameElement;){try{var n=\"string\"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=gn((e=t.contentWindow).document)}return t}function kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(\"input\"===t&&(\"text\"===e.type||\"search\"===e.type||\"tel\"===e.type||\"url\"===e.type||\"password\"===e.type)||\"textarea\"===t||\"true\"===e.contentEditable)}var xn=\"$\",Tn=\"/$\",En=\"$?\",Sn=\"$!\",Cn=null,Pn=null;function _n(e,t){switch(e){case\"button\":case\"input\":case\"select\":case\"textarea\":return!!t.autoFocus}return!1}function Nn(e,t){return\"textarea\"===e||\"option\"===e||\"noscript\"===e||\"string\"==typeof t.children||\"number\"==typeof t.children||\"object\"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var zn=\"function\"==typeof setTimeout?setTimeout:void 0,Mn=\"function\"==typeof clearTimeout?clearTimeout:void 0;function In(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break}return e}function Fn(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if(n===xn||n===Sn||n===En){if(0===t)return e;t--}else n===Tn&&t++}e=e.previousSibling}return null}var On=Math.random().toString(36).slice(2),Rn=\"__reactInternalInstance$\"+On,Dn=\"__reactEventHandlers$\"+On,Ln=\"__reactContainere$\"+On;function Un(e){var t=e[Rn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ln]||n[Rn]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fn(e);null!==e;){if(n=e[Rn])return n;e=Fn(e)}return t}n=(e=n).parentNode}return null}function An(e){return!(e=e[Rn]||e[Ln])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Vn(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(r(33))}function Qn(e){return e[Dn]||null}function Wn(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function Hn(e,t){var n=e.stateNode;if(!n)return null;var l=d(n);if(!l)return null;n=l[t];e:switch(t){case\"onClick\":case\"onClickCapture\":case\"onDoubleClick\":case\"onDoubleClickCapture\":case\"onMouseDown\":case\"onMouseDownCapture\":case\"onMouseMove\":case\"onMouseMoveCapture\":case\"onMouseUp\":case\"onMouseUpCapture\":case\"onMouseEnter\":(l=!l.disabled)||(l=!(\"button\"===(e=e.type)||\"input\"===e||\"select\"===e||\"textarea\"===e)),e=!l;break e;default:e=!1}if(e)return null;if(n&&\"function\"!=typeof n)throw Error(r(231,t,typeof n));return n}function jn(e,t,n){(t=Hn(e,n.dispatchConfig.phasedRegistrationNames[t]))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function Bn(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,n=[];t;)n.push(t),t=Wn(t);for(t=n.length;0<t--;)jn(n[t],\"captured\",e);for(t=0;t<n.length;t++)jn(n[t],\"bubbled\",e)}}function Kn(e,t,n){e&&n&&n.dispatchConfig.registrationName&&(t=Hn(e,n.dispatchConfig.registrationName))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function $n(e){e&&e.dispatchConfig.registrationName&&Kn(e._targetInst,null,e)}function qn(e){ut(e,Bn)}var Yn=null,Xn=null,Gn=null;function Zn(){if(Gn)return Gn;var e,t,n=Xn,r=n.length,l=\"value\"in Yn?Yn.value:Yn.textContent,i=l.length;for(e=0;e<r&&n[e]===l[e];e++);var a=r-e;for(t=1;t<=a&&n[r-t]===l[i-t];t++);return Gn=l.slice(e,1<t?1-t:void 0)}function Jn(){return!0}function er(){return!1}function tr(e,t,n,r){for(var l in this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n,e=this.constructor.Interface)e.hasOwnProperty(l)&&((t=e[l])?this[l]=t(n):\"target\"===l?this.target=r:this[l]=n[l]);return this.isDefaultPrevented=(null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue)?Jn:er,this.isPropagationStopped=er,this}function nr(e,t,n,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,t,n,r),l}return new this(e,t,n,r)}function rr(e){if(!(e instanceof this))throw Error(r(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function lr(e){e.eventPool=[],e.getPooled=nr,e.release=rr}t(tr.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():\"unknown\"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Jn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():\"unknown\"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Jn)},persist:function(){this.isPersistent=Jn},isPersistent:er,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=er,this._dispatchInstances=this._dispatchListeners=null}}),tr.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},tr.extend=function(e){function n(){}function r(){return l.apply(this,arguments)}var l=this;n.prototype=l.prototype;var i=new n;return t(i,r.prototype),r.prototype=i,r.prototype.constructor=r,r.Interface=t({},l.Interface,e),r.extend=l.extend,lr(r),r},lr(tr);var ir=tr.extend({data:null}),ar=tr.extend({data:null}),or=[9,13,27,32],ur=S&&\"CompositionEvent\"in window,cr=null;S&&\"documentMode\"in document&&(cr=document.documentMode);var sr=S&&\"TextEvent\"in window&&!cr,fr=S&&(!ur||cr&&8<cr&&11>=cr),dr=String.fromCharCode(32),pr={beforeInput:{phasedRegistrationNames:{bubbled:\"onBeforeInput\",captured:\"onBeforeInputCapture\"},dependencies:[\"compositionend\",\"keypress\",\"textInput\",\"paste\"]},compositionEnd:{phasedRegistrationNames:{bubbled:\"onCompositionEnd\",captured:\"onCompositionEndCapture\"},dependencies:\"blur compositionend keydown keypress keyup mousedown\".split(\" \")},compositionStart:{phasedRegistrationNames:{bubbled:\"onCompositionStart\",captured:\"onCompositionStartCapture\"},dependencies:\"blur compositionstart keydown keypress keyup mousedown\".split(\" \")},compositionUpdate:{phasedRegistrationNames:{bubbled:\"onCompositionUpdate\",captured:\"onCompositionUpdateCapture\"},dependencies:\"blur compositionupdate keydown keypress keyup mousedown\".split(\" \")}},mr=!1;function hr(e,t){switch(e){case\"keyup\":return-1!==or.indexOf(t.keyCode);case\"keydown\":return 229!==t.keyCode;case\"keypress\":case\"mousedown\":case\"blur\":return!0;default:return!1}}function gr(e){return\"object\"==typeof(e=e.detail)&&\"data\"in e?e.data:null}var vr=!1;function yr(e,t){switch(e){case\"compositionend\":return gr(t);case\"keypress\":return 32!==t.which?null:(mr=!0,dr);case\"textInput\":return(e=t.data)===dr&&mr?null:e;default:return null}}function br(e,t){if(vr)return\"compositionend\"===e||!ur&&hr(e,t)?(e=Zn(),Gn=Xn=Yn=null,vr=!1,e):null;switch(e){case\"paste\":return null;case\"keypress\":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case\"compositionend\":return fr&&\"ko\"!==t.locale?null:t.data;default:return null}}var wr={eventTypes:pr,extractEvents:function(e,t,n,r){var l;if(ur)e:{switch(e){case\"compositionstart\":var i=pr.compositionStart;break e;case\"compositionend\":i=pr.compositionEnd;break e;case\"compositionupdate\":i=pr.compositionUpdate;break e}i=void 0}else vr?hr(e,n)&&(i=pr.compositionEnd):\"keydown\"===e&&229===n.keyCode&&(i=pr.compositionStart);return i?(fr&&\"ko\"!==n.locale&&(vr||i!==pr.compositionStart?i===pr.compositionEnd&&vr&&(l=Zn()):(Xn=\"value\"in(Yn=r)?Yn.value:Yn.textContent,vr=!0)),i=ir.getPooled(i,t,n,r),l?i.data=l:null!==(l=gr(n))&&(i.data=l),qn(i),l=i):l=null,(e=sr?yr(e,n):br(e,n))?((t=ar.getPooled(pr.beforeInput,t,n,r)).data=e,qn(t)):t=null,null===l?t:null===t?l:[l,t]}},kr={color:!0,date:!0,datetime:!0,\"datetime-local\":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return\"input\"===t?!!kr[e.type]:\"textarea\"===t}var Tr={change:{phasedRegistrationNames:{bubbled:\"onChange\",captured:\"onChangeCapture\"},dependencies:\"blur change click focus input keydown keyup selectionchange\".split(\" \")}};function Er(e,t,n){return(e=tr.getPooled(Tr.change,e,t,n)).type=\"change\",z(n),qn(e),e}var Sr=null,Cr=null;function Pr(e){ft(e)}function _r(e){if(Ee(Vn(e)))return e}function Nr(e,t){if(\"change\"===e)return t}var zr=!1;function Mr(){Sr&&(Sr.detachEvent(\"onpropertychange\",Ir),Cr=Sr=null)}function Ir(e){if(\"value\"===e.propertyName&&_r(Cr))if(e=Er(Cr,e,dt(e)),D)ft(e);else{D=!0;try{I(Pr,e)}finally{D=!1,U()}}}function Fr(e,t,n){\"focus\"===e?(Mr(),Cr=n,(Sr=t).attachEvent(\"onpropertychange\",Ir)):\"blur\"===e&&Mr()}function Or(e){if(\"selectionchange\"===e||\"keyup\"===e||\"keydown\"===e)return _r(Cr)}function Rr(e,t){if(\"click\"===e)return _r(t)}function Dr(e,t){if(\"input\"===e||\"change\"===e)return _r(t)}S&&(zr=pt(\"input\")&&(!document.documentMode||9<document.documentMode));var Lr={eventTypes:Tr,_isInputEventSupported:zr,extractEvents:function(e,t,n,r){var l=t?Vn(t):window,i=l.nodeName&&l.nodeName.toLowerCase();if(\"select\"===i||\"input\"===i&&\"file\"===l.type)var a=Nr;else if(xr(l))if(zr)a=Dr;else{a=Or;var o=Fr}else(i=l.nodeName)&&\"input\"===i.toLowerCase()&&(\"checkbox\"===l.type||\"radio\"===l.type)&&(a=Rr);if(a&&(a=a(e,t)))return Er(a,n,r);o&&o(e,l,t),\"blur\"===e&&(e=l._wrapperState)&&e.controlled&&\"number\"===l.type&&ze(l,\"number\",l.value)}},Ur=tr.extend({view:null,detail:null}),Ar={Alt:\"altKey\",Control:\"ctrlKey\",Meta:\"metaKey\",Shift:\"shiftKey\"};function Vr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function Qr(){return Vr}var Wr=0,Hr=0,jr=!1,Br=!1,Kr=Ur.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:Qr,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},movementX:function(e){if(\"movementX\"in e)return e.movementX;var t=Wr;return Wr=e.screenX,jr?\"mousemove\"===e.type?e.screenX-t:0:(jr=!0,0)},movementY:function(e){if(\"movementY\"in e)return e.movementY;var t=Hr;return Hr=e.screenY,Br?\"mousemove\"===e.type?e.screenY-t:0:(Br=!0,0)}}),$r=Kr.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),qr={mouseEnter:{registrationName:\"onMouseEnter\",dependencies:[\"mouseout\",\"mouseover\"]},mouseLeave:{registrationName:\"onMouseLeave\",dependencies:[\"mouseout\",\"mouseover\"]},pointerEnter:{registrationName:\"onPointerEnter\",dependencies:[\"pointerout\",\"pointerover\"]},pointerLeave:{registrationName:\"onPointerLeave\",dependencies:[\"pointerout\",\"pointerover\"]}},Yr={eventTypes:qr,extractEvents:function(e,t,n,r,l){var i=\"mouseover\"===e||\"pointerover\"===e,a=\"mouseout\"===e||\"pointerout\"===e;if(i&&0==(32&l)&&(n.relatedTarget||n.fromElement)||!a&&!i)return null;(i=r.window===r?r:(i=r.ownerDocument)?i.defaultView||i.parentWindow:window,a)?(a=t,null!==(t=(t=n.relatedTarget||n.toElement)?Un(t):null)&&(t!==nt(t)||5!==t.tag&&6!==t.tag)&&(t=null)):a=null;if(a===t)return null;if(\"mouseout\"===e||\"mouseover\"===e)var o=Kr,u=qr.mouseLeave,c=qr.mouseEnter,s=\"mouse\";else\"pointerout\"!==e&&\"pointerover\"!==e||(o=$r,u=qr.pointerLeave,c=qr.pointerEnter,s=\"pointer\");if(e=null==a?i:Vn(a),i=null==t?i:Vn(t),(u=o.getPooled(u,a,n,r)).type=s+\"leave\",u.target=e,u.relatedTarget=i,(n=o.getPooled(c,t,n,r)).type=s+\"enter\",n.target=i,n.relatedTarget=e,s=t,(r=a)&&s)e:{for(c=s,a=0,e=o=r;e;e=Wn(e))a++;for(e=0,t=c;t;t=Wn(t))e++;for(;0<a-e;)o=Wn(o),a--;for(;0<e-a;)c=Wn(c),e--;for(;a--;){if(o===c||o===c.alternate)break e;o=Wn(o),c=Wn(c)}o=null}else o=null;for(c=o,o=[];r&&r!==c&&(null===(a=r.alternate)||a!==c);)o.push(r),r=Wn(r);for(r=[];s&&s!==c&&(null===(a=s.alternate)||a!==c);)r.push(s),s=Wn(s);for(s=0;s<o.length;s++)Kn(o[s],\"bubbled\",u);for(s=r.length;0<s--;)Kn(r[s],\"captured\",n);return 0==(64&l)?[u]:[u,n]}};function Xr(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t}var Gr=\"function\"==typeof Object.is?Object.is:Xr,Zr=Object.prototype.hasOwnProperty;function Jr(e,t){if(Gr(e,t))return!0;if(\"object\"!=typeof e||null===e||\"object\"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++)if(!Zr.call(t,n[r])||!Gr(e[n[r]],t[n[r]]))return!1;return!0}var el=S&&\"documentMode\"in document&&11>=document.documentMode,tl={select:{phasedRegistrationNames:{bubbled:\"onSelect\",captured:\"onSelectCapture\"},dependencies:\"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange\".split(\" \")}},nl=null,rl=null,ll=null,il=!1;function al(e,t){var n=t.window===t?t.document:9===t.nodeType?t:t.ownerDocument;return il||null==nl||nl!==gn(n)?null:(\"selectionStart\"in(n=nl)&&kn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},ll&&Jr(ll,n)?null:(ll=n,(e=tr.getPooled(tl.select,rl,e,t)).type=\"select\",e.target=nl,qn(e),e))}var ol={eventTypes:tl,extractEvents:function(e,t,n,r,l,i){if(!(i=!(l=i||(r.window===r?r.document:9===r.nodeType?r:r.ownerDocument)))){e:{l=tt(l),i=T.onSelect;for(var a=0;a<i.length;a++)if(!l.has(i[a])){l=!1;break e}l=!0}i=!l}if(i)return null;switch(l=t?Vn(t):window,e){case\"focus\":(xr(l)||\"true\"===l.contentEditable)&&(nl=l,rl=t,ll=null);break;case\"blur\":ll=rl=nl=null;break;case\"mousedown\":il=!0;break;case\"contextmenu\":case\"mouseup\":case\"dragend\":return il=!1,al(n,r);case\"selectionchange\":if(el)break;case\"keydown\":case\"keyup\":return al(n,r)}return null}},ul=tr.extend({animationName:null,elapsedTime:null,pseudoElement:null}),cl=tr.extend({clipboardData:function(e){return\"clipboardData\"in e?e.clipboardData:window.clipboardData}}),sl=Ur.extend({relatedTarget:null});function fl(e){var t=e.keyCode;return\"charCode\"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}var dl={Esc:\"Escape\",Spacebar:\" \",Left:\"ArrowLeft\",Up:\"ArrowUp\",Right:\"ArrowRight\",Down:\"ArrowDown\",Del:\"Delete\",Win:\"OS\",Menu:\"ContextMenu\",Apps:\"ContextMenu\",Scroll:\"ScrollLock\",MozPrintableKey:\"Unidentified\"},pl={8:\"Backspace\",9:\"Tab\",12:\"Clear\",13:\"Enter\",16:\"Shift\",17:\"Control\",18:\"Alt\",19:\"Pause\",20:\"CapsLock\",27:\"Escape\",32:\" \",33:\"PageUp\",34:\"PageDown\",35:\"End\",36:\"Home\",37:\"ArrowLeft\",38:\"ArrowUp\",39:\"ArrowRight\",40:\"ArrowDown\",45:\"Insert\",46:\"Delete\",112:\"F1\",113:\"F2\",114:\"F3\",115:\"F4\",116:\"F5\",117:\"F6\",118:\"F7\",119:\"F8\",120:\"F9\",121:\"F10\",122:\"F11\",123:\"F12\",144:\"NumLock\",145:\"ScrollLock\",224:\"Meta\"},ml=Ur.extend({key:function(e){if(e.key){var t=dl[e.key]||e.key;if(\"Unidentified\"!==t)return t}return\"keypress\"===e.type?13===(e=fl(e))?\"Enter\":String.fromCharCode(e):\"keydown\"===e.type||\"keyup\"===e.type?pl[e.keyCode]||\"Unidentified\":\"\"},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Qr,charCode:function(e){return\"keypress\"===e.type?fl(e):0},keyCode:function(e){return\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0},which:function(e){return\"keypress\"===e.type?fl(e):\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0}}),hl=Kr.extend({dataTransfer:null}),gl=Ur.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Qr}),vl=tr.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),yl=Kr.extend({deltaX:function(e){return\"deltaX\"in e?e.deltaX:\"wheelDeltaX\"in e?-e.wheelDeltaX:0},deltaY:function(e){return\"deltaY\"in e?e.deltaY:\"wheelDeltaY\"in e?-e.wheelDeltaY:\"wheelDelta\"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),bl={eventTypes:Ht,extractEvents:function(e,t,n,r){var l=jt.get(e);if(!l)return null;switch(e){case\"keypress\":if(0===fl(n))return null;case\"keydown\":case\"keyup\":e=ml;break;case\"blur\":case\"focus\":e=sl;break;case\"click\":if(2===n.button)return null;case\"auxclick\":case\"dblclick\":case\"mousedown\":case\"mousemove\":case\"mouseup\":case\"mouseout\":case\"mouseover\":case\"contextmenu\":e=Kr;break;case\"drag\":case\"dragend\":case\"dragenter\":case\"dragexit\":case\"dragleave\":case\"dragover\":case\"dragstart\":case\"drop\":e=hl;break;case\"touchcancel\":case\"touchend\":case\"touchmove\":case\"touchstart\":e=gl;break;case Ye:case Xe:case Ge:e=ul;break;case Ze:e=vl;break;case\"scroll\":e=Ur;break;case\"wheel\":e=yl;break;case\"copy\":case\"cut\":case\"paste\":e=cl;break;case\"gotpointercapture\":case\"lostpointercapture\":case\"pointercancel\":case\"pointerdown\":case\"pointermove\":case\"pointerout\":case\"pointerover\":case\"pointerup\":e=$r;break;default:e=tr}return qn(t=e.getPooled(l,t,n,r)),t}};if(g)throw Error(r(101));g=Array.prototype.slice.call(\"ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin\".split(\" \")),y();var wl=An;d=Qn,p=wl,m=Vn,E({SimpleEventPlugin:bl,EnterLeaveEventPlugin:Yr,ChangeEventPlugin:Lr,SelectEventPlugin:ol,BeforeInputEventPlugin:wr});var kl=[],xl=-1;function Tl(e){0>xl||(e.current=kl[xl],kl[xl]=null,xl--)}function El(e,t){kl[++xl]=e.current,e.current=t}var Sl={},Cl={current:Sl},Pl={current:!1},_l=Sl;function Nl(e,t){var n=e.type.contextTypes;if(!n)return Sl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,i={};for(l in n)i[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function zl(e){return null!=(e=e.childContextTypes)}function Ml(){Tl(Pl),Tl(Cl)}function Il(e,t,n){if(Cl.current!==Sl)throw Error(r(168));El(Cl,t),El(Pl,n)}function Fl(e,n,l){var i=e.stateNode;if(e=n.childContextTypes,\"function\"!=typeof i.getChildContext)return l;for(var a in i=i.getChildContext())if(!(a in e))throw Error(r(108,ye(n)||\"Unknown\",a));return t({},l,{},i)}function Ol(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Sl,_l=Cl.current,El(Cl,e),El(Pl,Pl.current),!0}function Rl(e,t,n){var l=e.stateNode;if(!l)throw Error(r(169));n?(e=Fl(e,t,_l),l.__reactInternalMemoizedMergedChildContext=e,Tl(Pl),Tl(Cl),El(Cl,e)):Tl(Pl),El(Pl,n)}var Dl=n.unstable_runWithPriority,Ll=n.unstable_scheduleCallback,Ul=n.unstable_cancelCallback,Al=n.unstable_requestPaint,Vl=n.unstable_now,Ql=n.unstable_getCurrentPriorityLevel,Wl=n.unstable_ImmediatePriority,Hl=n.unstable_UserBlockingPriority,jl=n.unstable_NormalPriority,Bl=n.unstable_LowPriority,Kl=n.unstable_IdlePriority,$l={},ql=n.unstable_shouldYield,Yl=void 0!==Al?Al:function(){},Xl=null,Gl=null,Zl=!1,Jl=Vl(),ei=1e4>Jl?Vl:function(){return Vl()-Jl};function ti(){switch(Ql()){case Wl:return 99;case Hl:return 98;case jl:return 97;case Bl:return 96;case Kl:return 95;default:throw Error(r(332))}}function ni(e){switch(e){case 99:return Wl;case 98:return Hl;case 97:return jl;case 96:return Bl;case 95:return Kl;default:throw Error(r(332))}}function ri(e,t){return e=ni(e),Dl(e,t)}function li(e,t,n){return e=ni(e),Ll(e,t,n)}function ii(e){return null===Xl?(Xl=[e],Gl=Ll(Wl,oi)):Xl.push(e),$l}function ai(){if(null!==Gl){var e=Gl;Gl=null,Ul(e)}oi()}function oi(){if(!Zl&&null!==Xl){Zl=!0;var e=0;try{var t=Xl;ri(99,function(){for(;e<t.length;e++){var n=t[e];do{n=n(!0)}while(null!==n)}}),Xl=null}catch(n){throw null!==Xl&&(Xl=Xl.slice(e+1)),Ll(Wl,ai),n}finally{Zl=!1}}}function ui(e,t,n){return 1073741821-(1+((1073741821-e+t/10)/(n/=10)|0))*n}function ci(e,n){if(e&&e.defaultProps)for(var r in n=t({},n),e=e.defaultProps)void 0===n[r]&&(n[r]=e[r]);return n}var si={current:null},fi=null,di=null,pi=null;function mi(){pi=di=fi=null}function hi(e){var t=si.current;Tl(si),e.type._context._currentValue=t}function gi(e,t){for(;null!==e;){var n=e.alternate;if(e.childExpirationTime<t)e.childExpirationTime=t,null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t);else{if(!(null!==n&&n.childExpirationTime<t))break;n.childExpirationTime=t}e=e.return}}function vi(e,t){fi=e,pi=di=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(e.expirationTime>=t&&(ja=!0),e.firstContext=null)}function yi(e,t){if(pi!==e&&!1!==t&&0!==t)if(\"number\"==typeof t&&1073741823!==t||(pi=e,t=1073741823),t={context:e,observedBits:t,next:null},null===di){if(null===fi)throw Error(r(308));di=t,fi.dependencies={expirationTime:0,firstContext:t,responders:null}}else di=di.next=t;return e._currentValue}var bi=!1;function wi(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function ki(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function xi(e,t){return(e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null}).next=e}function Ti(e,t){if(null!==(e=e.updateQueue)){var n=(e=e.shared).pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}}function Ei(e,t){var n=e.alternate;null!==n&&ki(n,e),null===(n=(e=e.updateQueue).baseQueue)?(e.baseQueue=t.next=t,t.next=t):(t.next=n.next,n.next=t)}function Si(e,n,r,l){var i=e.updateQueue;bi=!1;var a=i.baseQueue,o=i.shared.pending;if(null!==o){if(null!==a){var u=a.next;a.next=o.next,o.next=u}a=o,i.shared.pending=null,null!==(u=e.alternate)&&(null!==(u=u.updateQueue)&&(u.baseQueue=o))}if(null!==a){u=a.next;var c=i.baseState,s=0,f=null,d=null,p=null;if(null!==u)for(var m=u;;){if((o=m.expirationTime)<l){var h={expirationTime:m.expirationTime,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null};null===p?(d=p=h,f=c):p=p.next=h,o>s&&(s=o)}else{null!==p&&(p=p.next={expirationTime:1073741823,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null}),Fu(o,m.suspenseConfig);e:{var g=e,v=m;switch(o=n,h=r,v.tag){case 1:if(\"function\"==typeof(g=v.payload)){c=g.call(h,c,o);break e}c=g;break e;case 3:g.effectTag=-4097&g.effectTag|64;case 0:if(null==(o=\"function\"==typeof(g=v.payload)?g.call(h,c,o):g))break e;c=t({},c,o);break e;case 2:bi=!0}}null!==m.callback&&(e.effectTag|=32,null===(o=i.effects)?i.effects=[m]:o.push(m))}if(null===(m=m.next)||m===u){if(null===(o=i.shared.pending))break;m=a.next=o.next,o.next=u,i.baseQueue=a=o,i.shared.pending=null}}null===p?f=c:p.next=d,i.baseState=f,i.baseQueue=p,Ou(s),e.expirationTime=s,e.memoizedState=c}}function Ci(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var l=e[t],i=l.callback;if(null!==i){if(l.callback=null,l=i,i=n,\"function\"!=typeof l)throw Error(r(191,l));l.call(i)}}}var Pi=G.ReactCurrentBatchConfig,_i=(new e.Component).refs;function Ni(e,n,r,l){r=null==(r=r(l,n=e.memoizedState))?n:t({},n,r),e.memoizedState=r,0===e.expirationTime&&(e.updateQueue.baseState=r)}var zi={isMounted:function(e){return!!(e=e._reactInternalFiber)&&nt(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueReplaceState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).tag=1,l.payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var n=bu(),r=Pi.suspense;(r=xi(n=wu(n,e,r),r)).tag=2,null!=t&&(r.callback=t),Ti(e,r),ku(e,n)}};function Mi(e,t,n,r,l,i,a){return\"function\"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,a):!t.prototype||!t.prototype.isPureReactComponent||(!Jr(n,r)||!Jr(l,i))}function Ii(e,t,n){var r=!1,l=Sl,i=t.contextType;return\"object\"==typeof i&&null!==i?i=yi(i):(l=zl(t)?_l:Cl.current,i=(r=null!=(r=t.contextTypes))?Nl(e,l):Sl),t=new t(n,i),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=zi,e.stateNode=t,t._reactInternalFiber=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function Fi(e,t,n,r){e=t.state,\"function\"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),\"function\"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zi.enqueueReplaceState(t,t.state,null)}function Oi(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs=_i,wi(e);var i=t.contextType;\"object\"==typeof i&&null!==i?l.context=yi(i):(i=zl(t)?_l:Cl.current,l.context=Nl(e,i)),Si(e,n,l,r),l.state=e.memoizedState,\"function\"==typeof(i=t.getDerivedStateFromProps)&&(Ni(e,t,i,n),l.state=e.memoizedState),\"function\"==typeof t.getDerivedStateFromProps||\"function\"==typeof l.getSnapshotBeforeUpdate||\"function\"!=typeof l.UNSAFE_componentWillMount&&\"function\"!=typeof l.componentWillMount||(t=l.state,\"function\"==typeof l.componentWillMount&&l.componentWillMount(),\"function\"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),t!==l.state&&zi.enqueueReplaceState(l,l.state,null),Si(e,n,l,r),l.state=e.memoizedState),\"function\"==typeof l.componentDidMount&&(e.effectTag|=4)}var Ri=Array.isArray;function Di(e,t,n){if(null!==(e=n.ref)&&\"function\"!=typeof e&&\"object\"!=typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(r(309));var l=n.stateNode}if(!l)throw Error(r(147,e));var i=\"\"+e;return null!==t&&null!==t.ref&&\"function\"==typeof t.ref&&t.ref._stringRef===i?t.ref:((t=function(e){var t=l.refs;t===_i&&(t=l.refs={}),null===e?delete t[i]:t[i]=e})._stringRef=i,t)}if(\"string\"!=typeof e)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Li(e,t){if(\"textarea\"!==e.type)throw Error(r(31,\"[object Object]\"===Object.prototype.toString.call(t)?\"object with keys {\"+Object.keys(t).join(\", \")+\"}\":t,\"\"))}function Ui(e){function t(t,n){if(e){var r=t.lastEffect;null!==r?(r.nextEffect=n,t.lastEffect=n):t.firstEffect=t.lastEffect=n,n.nextEffect=null,n.effectTag=8}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function l(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=nc(e,t)).index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.effectTag=2,n):r:(t.effectTag=2,n):n}function o(t){return e&&null===t.alternate&&(t.effectTag=2),t}function u(e,t,n,r){return null===t||6!==t.tag?((t=ic(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){return null!==t&&t.elementType===n.type?((r=i(t,n.props)).ref=Di(e,t,n),r.return=e,r):((r=rc(n.type,n.key,n.props,null,e.mode,r)).ref=Di(e,t,n),r.return=e,r)}function s(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=ac(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function f(e,t,n,r,l){return null===t||7!==t.tag?((t=lc(n,e.mode,r,l)).return=e,t):((t=i(t,n)).return=e,t)}function d(e,t,n){if(\"string\"==typeof t||\"number\"==typeof t)return(t=ic(\"\"+t,e.mode,n)).return=e,t;if(\"object\"==typeof t&&null!==t){switch(t.$$typeof){case te:return(n=rc(t.type,t.key,t.props,null,e.mode,n)).ref=Di(e,null,t),n.return=e,n;case ne:return(t=ac(t,e.mode,n)).return=e,t}if(Ri(t)||ge(t))return(t=lc(t,e.mode,n,null)).return=e,t;Li(e,t)}return null}function p(e,t,n,r){var l=null!==t?t.key:null;if(\"string\"==typeof n||\"number\"==typeof n)return null!==l?null:u(e,t,\"\"+n,r);if(\"object\"==typeof n&&null!==n){switch(n.$$typeof){case te:return n.key===l?n.type===re?f(e,t,n.props.children,r,l):c(e,t,n,r):null;case ne:return n.key===l?s(e,t,n,r):null}if(Ri(n)||ge(n))return null!==l?null:f(e,t,n,r,null);Li(e,n)}return null}function m(e,t,n,r,l){if(\"string\"==typeof r||\"number\"==typeof r)return u(t,e=e.get(n)||null,\"\"+r,l);if(\"object\"==typeof r&&null!==r){switch(r.$$typeof){case te:return e=e.get(null===r.key?n:r.key)||null,r.type===re?f(t,e,r.props.children,l,r.key):c(t,e,r,l);case ne:return s(t,e=e.get(null===r.key?n:r.key)||null,r,l)}if(Ri(r)||ge(r))return f(t,e=e.get(n)||null,r,l,null);Li(t,r)}return null}function h(r,i,o,u){for(var c=null,s=null,f=i,h=i=0,g=null;null!==f&&h<o.length;h++){f.index>h?(g=f,f=null):g=f.sibling;var v=p(r,f,o[h],u);if(null===v){null===f&&(f=g);break}e&&f&&null===v.alternate&&t(r,f),i=a(v,i,h),null===s?c=v:s.sibling=v,s=v,f=g}if(h===o.length)return n(r,f),c;if(null===f){for(;h<o.length;h++)null!==(f=d(r,o[h],u))&&(i=a(f,i,h),null===s?c=f:s.sibling=f,s=f);return c}for(f=l(r,f);h<o.length;h++)null!==(g=m(f,r,h,o[h],u))&&(e&&null!==g.alternate&&f.delete(null===g.key?h:g.key),i=a(g,i,h),null===s?c=g:s.sibling=g,s=g);return e&&f.forEach(function(e){return t(r,e)}),c}function g(i,o,u,c){var s=ge(u);if(\"function\"!=typeof s)throw Error(r(150));if(null==(u=s.call(u)))throw Error(r(151));for(var f=s=null,h=o,g=o=0,v=null,y=u.next();null!==h&&!y.done;g++,y=u.next()){h.index>g?(v=h,h=null):v=h.sibling;var b=p(i,h,y.value,c);if(null===b){null===h&&(h=v);break}e&&h&&null===b.alternate&&t(i,h),o=a(b,o,g),null===f?s=b:f.sibling=b,f=b,h=v}if(y.done)return n(i,h),s;if(null===h){for(;!y.done;g++,y=u.next())null!==(y=d(i,y.value,c))&&(o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return s}for(h=l(i,h);!y.done;g++,y=u.next())null!==(y=m(h,i,g,y.value,c))&&(e&&null!==y.alternate&&h.delete(null===y.key?g:y.key),o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return e&&h.forEach(function(e){return t(i,e)}),s}return function(e,l,a,u){var c=\"object\"==typeof a&&null!==a&&a.type===re&&null===a.key;c&&(a=a.props.children);var s=\"object\"==typeof a&&null!==a;if(s)switch(a.$$typeof){case te:e:{for(s=a.key,c=l;null!==c;){if(c.key===s){switch(c.tag){case 7:if(a.type===re){n(e,c.sibling),(l=i(c,a.props.children)).return=e,e=l;break e}break;default:if(c.elementType===a.type){n(e,c.sibling),(l=i(c,a.props)).ref=Di(e,c,a),l.return=e,e=l;break e}}n(e,c);break}t(e,c),c=c.sibling}a.type===re?((l=lc(a.props.children,e.mode,u,a.key)).return=e,e=l):((u=rc(a.type,a.key,a.props,null,e.mode,u)).ref=Di(e,l,a),u.return=e,e=u)}return o(e);case ne:e:{for(c=a.key;null!==l;){if(l.key===c){if(4===l.tag&&l.stateNode.containerInfo===a.containerInfo&&l.stateNode.implementation===a.implementation){n(e,l.sibling),(l=i(l,a.children||[])).return=e,e=l;break e}n(e,l);break}t(e,l),l=l.sibling}(l=ac(a,e.mode,u)).return=e,e=l}return o(e)}if(\"string\"==typeof a||\"number\"==typeof a)return a=\"\"+a,null!==l&&6===l.tag?(n(e,l.sibling),(l=i(l,a)).return=e,e=l):(n(e,l),(l=ic(a,e.mode,u)).return=e,e=l),o(e);if(Ri(a))return h(e,l,a,u);if(ge(a))return g(e,l,a,u);if(s&&Li(e,a),void 0===a&&!c)switch(e.tag){case 1:case 0:throw e=e.type,Error(r(152,e.displayName||e.name||\"Component\"))}return n(e,l)}}var Ai=Ui(!0),Vi=Ui(!1),Qi={},Wi={current:Qi},Hi={current:Qi},ji={current:Qi};function Bi(e){if(e===Qi)throw Error(r(174));return e}function Ki(e,t){switch(El(ji,t),El(Hi,e),El(Wi,Qi),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ve(null,\"\");break;default:t=Ve(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}Tl(Wi),El(Wi,t)}function $i(){Tl(Wi),Tl(Hi),Tl(ji)}function qi(e){Bi(ji.current);var t=Bi(Wi.current),n=Ve(t,e.type);t!==n&&(El(Hi,e),El(Wi,n))}function Yi(e){Hi.current===e&&(Tl(Wi),Tl(Hi))}var Xi={current:0};function Gi(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||n.data===En||n.data===Sn))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(64&t.effectTag))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Zi(e,t){return{responder:e,props:t}}var Ji=G.ReactCurrentDispatcher,ea=G.ReactCurrentBatchConfig,ta=0,na=null,ra=null,la=null,ia=!1;function aa(){throw Error(r(321))}function oa(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Gr(e[n],t[n]))return!1;return!0}function ua(e,t,n,l,i,a){if(ta=a,na=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,Ji.current=null===e||null===e.memoizedState?Ma:Ia,e=n(l,i),t.expirationTime===ta){a=0;do{if(t.expirationTime=0,!(25>a))throw Error(r(301));a+=1,la=ra=null,t.updateQueue=null,Ji.current=Fa,e=n(l,i)}while(t.expirationTime===ta)}if(Ji.current=za,t=null!==ra&&null!==ra.next,ta=0,la=ra=na=null,ia=!1,t)throw Error(r(300));return e}function ca(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===la?na.memoizedState=la=e:la=la.next=e,la}function sa(){if(null===ra){var e=na.alternate;e=null!==e?e.memoizedState:null}else e=ra.next;var t=null===la?na.memoizedState:la.next;if(null!==t)la=t,ra=e;else{if(null===e)throw Error(r(310));e={memoizedState:(ra=e).memoizedState,baseState:ra.baseState,baseQueue:ra.baseQueue,queue:ra.queue,next:null},null===la?na.memoizedState=la=e:la=la.next=e}return la}function fa(e,t){return\"function\"==typeof t?t(e):t}function da(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=ra,i=l.baseQueue,a=n.pending;if(null!==a){if(null!==i){var o=i.next;i.next=a.next,a.next=o}l.baseQueue=i=a,n.pending=null}if(null!==i){i=i.next,l=l.baseState;var u=o=a=null,c=i;do{var s=c.expirationTime;if(s<ta){var f={expirationTime:c.expirationTime,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null};null===u?(o=u=f,a=l):u=u.next=f,s>na.expirationTime&&(na.expirationTime=s,Ou(s))}else null!==u&&(u=u.next={expirationTime:1073741823,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null}),Fu(s,c.suspenseConfig),l=c.eagerReducer===e?c.eagerState:e(l,c.action);c=c.next}while(null!==c&&c!==i);null===u?a=l:u.next=o,Gr(l,t.memoizedState)||(ja=!0),t.memoizedState=l,t.baseState=a,t.baseQueue=u,n.lastRenderedState=l}return[t.memoizedState,n.dispatch]}function pa(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=n.dispatch,i=n.pending,a=t.memoizedState;if(null!==i){n.pending=null;var o=i=i.next;do{a=e(a,o.action),o=o.next}while(o!==i);Gr(a,t.memoizedState)||(ja=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),n.lastRenderedState=a}return[a,l]}function ma(e){var t=ca();return\"function\"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={pending:null,dispatch:null,lastRenderedReducer:fa,lastRenderedState:e}).dispatch=Na.bind(null,na,e),[t.memoizedState,e]}function ha(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=na.updateQueue)?(t={lastEffect:null},na.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ga(){return sa().memoizedState}function va(e,t,n,r){var l=ca();na.effectTag|=e,l.memoizedState=ha(1|t,n,void 0,void 0===r?null:r)}function ya(e,t,n,r){var l=sa();r=void 0===r?null:r;var i=void 0;if(null!==ra){var a=ra.memoizedState;if(i=a.destroy,null!==r&&oa(r,a.deps))return void ha(t,n,i,r)}na.effectTag|=e,l.memoizedState=ha(1|t,n,i,r)}function ba(e,t){return va(516,4,e,t)}function wa(e,t){return ya(516,4,e,t)}function ka(e,t){return ya(4,2,e,t)}function xa(e,t){return\"function\"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ta(e,t,n){return n=null!=n?n.concat([e]):null,ya(4,2,xa.bind(null,t,e),n)}function Ea(){}function Sa(e,t){return ca().memoizedState=[e,void 0===t?null:t],e}function Ca(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Pa(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function _a(e,t,n){var r=ti();ri(98>r?98:r,function(){e(!0)}),ri(97<r?97:r,function(){var r=ea.suspense;ea.suspense=void 0===t?null:t;try{e(!1),n()}finally{ea.suspense=r}})}function Na(e,t,n){var r=bu(),l=Pi.suspense;l={expirationTime:r=wu(r,e,l),suspenseConfig:l,action:n,eagerReducer:null,eagerState:null,next:null};var i=t.pending;if(null===i?l.next=l:(l.next=i.next,i.next=l),t.pending=l,i=e.alternate,e===na||null!==i&&i===na)ia=!0,l.expirationTime=ta,na.expirationTime=ta;else{if(0===e.expirationTime&&(null===i||0===i.expirationTime)&&null!==(i=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=i(a,n);if(l.eagerReducer=i,l.eagerState=o,Gr(o,a))return}catch(u){}ku(e,r)}}var za={readContext:yi,useCallback:aa,useContext:aa,useEffect:aa,useImperativeHandle:aa,useLayoutEffect:aa,useMemo:aa,useReducer:aa,useRef:aa,useState:aa,useDebugValue:aa,useResponder:aa,useDeferredValue:aa,useTransition:aa},Ma={readContext:yi,useCallback:Sa,useContext:yi,useEffect:ba,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,va(4,2,xa.bind(null,t,e),n)},useLayoutEffect:function(e,t){return va(4,2,e,t)},useMemo:function(e,t){var n=ca();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ca();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Na.bind(null,na,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ca().memoizedState=e},useState:ma,useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=ma(e),r=n[0],l=n[1];return ba(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=ma(!1),n=t[0];return t=t[1],[Sa(_a.bind(null,t,e),[t,e]),n]}},Ia={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:da,useRef:ga,useState:function(){return da(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=da(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=da(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Fa={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:pa,useRef:ga,useState:function(){return pa(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=pa(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=pa(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Oa=null,Ra=null,Da=!1;function La(e,t){var n=Ju(5,null,null,0);n.elementType=\"DELETED\",n.type=\"DELETED\",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function Ua(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=\"\"===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);case 13:default:return!1}}function Aa(e){if(Da){var t=Ra;if(t){var n=t;if(!Ua(e,t)){if(!(t=In(n.nextSibling))||!Ua(e,t))return e.effectTag=-1025&e.effectTag|2,Da=!1,void(Oa=e);La(Oa,n)}Oa=e,Ra=In(t.firstChild)}else e.effectTag=-1025&e.effectTag|2,Da=!1,Oa=e}}function Va(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;Oa=e}function Qa(e){if(e!==Oa)return!1;if(!Da)return Va(e),Da=!0,!1;var t=e.type;if(5!==e.tag||\"head\"!==t&&\"body\"!==t&&!Nn(t,e.memoizedProps))for(t=Ra;t;)La(e,t),t=In(t.nextSibling);if(Va(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if(n===Tn){if(0===t){Ra=In(e.nextSibling);break e}t--}else n!==xn&&n!==Sn&&n!==En||t++}e=e.nextSibling}Ra=null}}else Ra=Oa?In(e.stateNode.nextSibling):null;return!0}function Wa(){Ra=Oa=null,Da=!1}var Ha=G.ReactCurrentOwner,ja=!1;function Ba(e,t,n,r){t.child=null===e?Vi(t,null,n,r):Ai(t,e.child,n,r)}function Ka(e,t,n,r,l){n=n.render;var i=t.ref;return vi(t,l),r=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function $a(e,t,n,r,l,i){if(null===e){var a=n.type;return\"function\"!=typeof a||ec(a)||void 0!==a.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=rc(n.type,null,r,null,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,qa(e,t,a,r,l,i))}return a=e.child,l<i&&(l=a.memoizedProps,(n=null!==(n=n.compare)?n:Jr)(l,r)&&e.ref===t.ref)?co(e,t,i):(t.effectTag|=1,(e=nc(a,r)).ref=t.ref,e.return=t,t.child=e)}function qa(e,t,n,r,l,i){return null!==e&&Jr(e.memoizedProps,r)&&e.ref===t.ref&&(ja=!1,l<i)?(t.expirationTime=e.expirationTime,co(e,t,i)):Xa(e,t,n,r,i)}function Ya(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.effectTag|=128)}function Xa(e,t,n,r,l){var i=zl(n)?_l:Cl.current;return i=Nl(t,i),vi(t,l),n=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,n,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function Ga(e,t,n,r,l){if(zl(n)){var i=!0;Ol(t)}else i=!1;if(vi(t,l),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),Ii(t,n,r),Oi(t,n,r,l),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var u=a.context,c=n.contextType;\"object\"==typeof c&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current);var s=n.getDerivedStateFromProps,f=\"function\"==typeof s||\"function\"==typeof a.getSnapshotBeforeUpdate;f||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1;var d=t.memoizedState;a.state=d,Si(t,r,a,l),u=t.memoizedState,o!==r||d!==u||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),u=t.memoizedState),(o=bi||Mi(t,n,o,r,d,u,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillMount&&\"function\"!=typeof a.componentWillMount||(\"function\"==typeof a.componentWillMount&&a.componentWillMount(),\"function\"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),\"function\"==typeof a.componentDidMount&&(t.effectTag|=4)):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=c,r=o):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),r=!1)}else a=t.stateNode,ki(e,t),o=t.memoizedProps,a.props=t.type===t.elementType?o:ci(t.type,o),u=a.context,\"object\"==typeof(c=n.contextType)&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current),(f=\"function\"==typeof(s=n.getDerivedStateFromProps)||\"function\"==typeof a.getSnapshotBeforeUpdate)||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1,u=t.memoizedState,a.state=u,Si(t,r,a,l),d=t.memoizedState,o!==r||u!==d||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),d=t.memoizedState),(s=bi||Mi(t,n,o,r,u,d,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillUpdate&&\"function\"!=typeof a.componentWillUpdate||(\"function\"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,d,c),\"function\"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,d,c)),\"function\"==typeof a.componentDidUpdate&&(t.effectTag|=4),\"function\"==typeof a.getSnapshotBeforeUpdate&&(t.effectTag|=256)):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),t.memoizedProps=r,t.memoizedState=d),a.props=r,a.state=d,a.context=c,r=s):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),r=!1);return Za(e,t,n,r,i,l)}function Za(e,t,n,r,l,i){Ya(e,t);var a=0!=(64&t.effectTag);if(!r&&!a)return l&&Rl(t,n,!1),co(e,t,i);r=t.stateNode,Ha.current=t;var o=a&&\"function\"!=typeof n.getDerivedStateFromError?null:r.render();return t.effectTag|=1,null!==e&&a?(t.child=Ai(t,e.child,null,i),t.child=Ai(t,null,o,i)):Ba(e,t,o,i),t.memoizedState=r.state,l&&Rl(t,n,!0),t.child}function Ja(e){var t=e.stateNode;t.pendingContext?Il(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Il(e,t.context,!1),Ki(e,t.containerInfo)}var eo,to,no,ro,lo={dehydrated:null,retryTime:0};function io(e,t,n){var r,l=t.mode,i=t.pendingProps,a=Xi.current,o=!1;if((r=0!=(64&t.effectTag))||(r=0!=(2&a)&&(null===e||null!==e.memoizedState)),r?(o=!0,t.effectTag&=-65):null!==e&&null===e.memoizedState||void 0===i.fallback||!0===i.unstable_avoidThisFallback||(a|=1),El(Xi,1&a),null===e){if(void 0!==i.fallback&&Aa(t),o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,t.memoizedState=lo,t.child=i,n}return l=i.children,t.memoizedState=null,t.child=Vi(t,null,l,n)}if(null!==e.memoizedState){if(l=(e=e.child).sibling,o){if(i=i.fallback,(n=nc(e,e.pendingProps)).return=t,0==(2&t.mode)&&(o=null!==t.memoizedState?t.child.child:t.child)!==e.child)for(n.child=o;null!==o;)o.return=n,o=o.sibling;return(l=nc(l,i)).return=t,n.sibling=l,n.childExpirationTime=0,t.memoizedState=lo,t.child=n,l}return n=Ai(t,e.child,i.children,n),t.memoizedState=null,t.child=n}if(e=e.child,o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,i.child=e,null!==e&&(e.return=i),0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,n.effectTag|=2,i.childExpirationTime=0,t.memoizedState=lo,t.child=i,n}return t.memoizedState=null,t.child=Ai(t,e,i.children,n)}function ao(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t),gi(e.return,t)}function oo(e,t,n,r,l,i){var a=e.memoizedState;null===a?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailExpiration:0,tailMode:l,lastEffect:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailExpiration=0,a.tailMode=l,a.lastEffect=i)}function uo(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(Ba(e,t,r.children,n),0!=(2&(r=Xi.current)))r=1&r|2,t.effectTag|=64;else{if(null!==e&&0!=(64&e.effectTag))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ao(e,n);else if(19===e.tag)ao(e,n);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(El(Xi,r),0==(2&t.mode))t.memoizedState=null;else switch(l){case\"forwards\":for(n=t.child,l=null;null!==n;)null!==(e=n.alternate)&&null===Gi(e)&&(l=n),n=n.sibling;null===(n=l)?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),oo(t,!1,l,n,i,t.lastEffect);break;case\"backwards\":for(n=null,l=t.child,t.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Gi(e)){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}oo(t,!0,n,null,i,t.lastEffect);break;case\"together\":oo(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function co(e,t,n){null!==e&&(t.dependencies=e.dependencies);var l=t.expirationTime;if(0!==l&&Ou(l),t.childExpirationTime<n)return null;if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=nc(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=nc(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function so(e,t){switch(e.tailMode){case\"hidden\":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case\"collapsed\":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function fo(e,n,l){var i=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return zl(n.type)&&Ml(),null;case 3:return $i(),Tl(Pl),Tl(Cl),(l=n.stateNode).pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||!Qa(n)||(n.effectTag|=4),to(n),null;case 5:Yi(n),l=Bi(ji.current);var a=n.type;if(null!==e&&null!=n.stateNode)no(e,n,a,i,l),e.ref!==n.ref&&(n.effectTag|=128);else{if(!i){if(null===n.stateNode)throw Error(r(166));return null}if(e=Bi(Wi.current),Qa(n)){i=n.stateNode,a=n.type;var o=n.memoizedProps;switch(i[Rn]=n,i[Dn]=o,a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",i);break;case\"video\":case\"audio\":for(e=0;e<Je.length;e++)Jt(Je[e],i);break;case\"source\":Jt(\"error\",i);break;case\"img\":case\"image\":case\"link\":Jt(\"error\",i),Jt(\"load\",i);break;case\"form\":Jt(\"reset\",i),Jt(\"submit\",i);break;case\"details\":Jt(\"toggle\",i);break;case\"input\":Ce(i,o),Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"select\":i._wrapperState={wasMultiple:!!o.multiple},Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"textarea\":Re(i,o),Jt(\"invalid\",i),mn(l,\"onChange\")}for(var u in fn(a,o),e=null,o)if(o.hasOwnProperty(u)){var c=o[u];\"children\"===u?\"string\"==typeof c?i.textContent!==c&&(e=[\"children\",c]):\"number\"==typeof c&&i.textContent!==\"\"+c&&(e=[\"children\",\"\"+c]):x.hasOwnProperty(u)&&null!=c&&mn(l,u)}switch(a){case\"input\":Te(i),Ne(i,o,!0);break;case\"textarea\":Te(i),Le(i);break;case\"select\":case\"option\":break;default:\"function\"==typeof o.onClick&&(i.onclick=hn)}l=e,n.updateQueue=l,null!==l&&(n.effectTag|=4)}else{switch(u=9===l.nodeType?l:l.ownerDocument,e===pn&&(e=Ae(a)),e===pn?\"script\"===a?((e=u.createElement(\"div\")).innerHTML=\"<script><\\/script>\",e=e.removeChild(e.firstChild)):\"string\"==typeof i.is?e=u.createElement(a,{is:i.is}):(e=u.createElement(a),\"select\"===a&&(u=e,i.multiple?u.multiple=!0:i.size&&(u.size=i.size))):e=u.createElementNS(e,a),e[Rn]=n,e[Dn]=i,eo(e,n,!1,!1),n.stateNode=e,u=dn(a,i),a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",e),c=i;break;case\"video\":case\"audio\":for(c=0;c<Je.length;c++)Jt(Je[c],e);c=i;break;case\"source\":Jt(\"error\",e),c=i;break;case\"img\":case\"image\":case\"link\":Jt(\"error\",e),Jt(\"load\",e),c=i;break;case\"form\":Jt(\"reset\",e),Jt(\"submit\",e),c=i;break;case\"details\":Jt(\"toggle\",e),c=i;break;case\"input\":Ce(e,i),c=Se(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"option\":c=Ie(e,i);break;case\"select\":e._wrapperState={wasMultiple:!!i.multiple},c=t({},i,{value:void 0}),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"textarea\":Re(e,i),c=Oe(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;default:c=i}fn(a,c);var s=c;for(o in s)if(s.hasOwnProperty(o)){var f=s[o];\"style\"===o?cn(e,f):\"dangerouslySetInnerHTML\"===o?null!=(f=f?f.__html:void 0)&&We(e,f):\"children\"===o?\"string\"==typeof f?(\"textarea\"!==a||\"\"!==f)&&He(e,f):\"number\"==typeof f&&He(e,\"\"+f):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?null!=f&&mn(l,o):null!=f&&Z(e,o,f,u))}switch(a){case\"input\":Te(e),Ne(e,i,!1);break;case\"textarea\":Te(e),Le(e);break;case\"option\":null!=i.value&&e.setAttribute(\"value\",\"\"+we(i.value));break;case\"select\":e.multiple=!!i.multiple,null!=(l=i.value)?Fe(e,!!i.multiple,l,!1):null!=i.defaultValue&&Fe(e,!!i.multiple,i.defaultValue,!0);break;default:\"function\"==typeof c.onClick&&(e.onclick=hn)}_n(a,i)&&(n.effectTag|=4)}null!==n.ref&&(n.effectTag|=128)}return null;case 6:if(e&&null!=n.stateNode)ro(e,n,e.memoizedProps,i);else{if(\"string\"!=typeof i&&null===n.stateNode)throw Error(r(166));l=Bi(ji.current),Bi(Wi.current),Qa(n)?(l=n.stateNode,i=n.memoizedProps,l[Rn]=n,l.nodeValue!==i&&(n.effectTag|=4)):((l=(9===l.nodeType?l:l.ownerDocument).createTextNode(i))[Rn]=n,n.stateNode=l)}return null;case 13:return Tl(Xi),i=n.memoizedState,0!=(64&n.effectTag)?(n.expirationTime=l,n):(l=null!==i,i=!1,null===e?void 0!==n.memoizedProps.fallback&&Qa(n):(i=null!==(a=e.memoizedState),l||null===a||null!==(a=e.child.sibling)&&(null!==(o=n.firstEffect)?(n.firstEffect=a,a.nextEffect=o):(n.firstEffect=n.lastEffect=a,a.nextEffect=null),a.effectTag=8)),l&&!i&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&Xi.current)?Jo===Ho&&(Jo=Ko):(Jo!==Ho&&Jo!==Ko||(Jo=$o),0!==lu&&null!==Xo&&(cc(Xo,Zo),sc(Xo,lu)))),(l||i)&&(n.effectTag|=4),null);case 4:return $i(),to(n),null;case 10:return hi(n),null;case 17:return zl(n.type)&&Ml(),null;case 19:if(Tl(Xi),null===(i=n.memoizedState))return null;if(a=0!=(64&n.effectTag),null===(o=i.rendering)){if(a)so(i,!1);else if(Jo!==Ho||null!==e&&0!=(64&e.effectTag))for(o=n.child;null!==o;){if(null!==(e=Gi(o))){for(n.effectTag|=64,so(i,!1),null!==(a=e.updateQueue)&&(n.updateQueue=a,n.effectTag|=4),null===i.lastEffect&&(n.firstEffect=null),n.lastEffect=i.lastEffect,i=n.child;null!==i;)o=l,(a=i).effectTag&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,null===(e=a.alternate)?(a.childExpirationTime=0,a.expirationTime=o,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null):(a.childExpirationTime=e.childExpirationTime,a.expirationTime=e.expirationTime,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,o=e.dependencies,a.dependencies=null===o?null:{expirationTime:o.expirationTime,firstContext:o.firstContext,responders:o.responders}),i=i.sibling;return El(Xi,1&Xi.current|2),n.child}o=o.sibling}}else{if(!a)if(null!==(e=Gi(o))){if(n.effectTag|=64,a=!0,null!==(l=e.updateQueue)&&(n.updateQueue=l,n.effectTag|=4),so(i,!0),null===i.tail&&\"hidden\"===i.tailMode&&!o.alternate)return null!==(n=n.lastEffect=i.lastEffect)&&(n.nextEffect=null),null}else 2*ei()-i.renderingStartTime>i.tailExpiration&&1<l&&(n.effectTag|=64,a=!0,so(i,!1),n.expirationTime=n.childExpirationTime=l-1);i.isBackwards?(o.sibling=n.child,n.child=o):(null!==(l=i.last)?l.sibling=o:n.child=o,i.last=o)}return null!==i.tail?(0===i.tailExpiration&&(i.tailExpiration=ei()+500),l=i.tail,i.rendering=l,i.tail=l.sibling,i.lastEffect=n.lastEffect,i.renderingStartTime=ei(),l.sibling=null,n=Xi.current,El(Xi,a?1&n|2:1&n),l):null}throw Error(r(156,n.tag))}function po(e){switch(e.tag){case 1:zl(e.type)&&Ml();var t=e.effectTag;return 4096&t?(e.effectTag=-4097&t|64,e):null;case 3:if($i(),Tl(Pl),Tl(Cl),0!=(64&(t=e.effectTag)))throw Error(r(285));return e.effectTag=-4097&t|64,e;case 5:return Yi(e),null;case 13:return Tl(Xi),4096&(t=e.effectTag)?(e.effectTag=-4097&t|64,e):null;case 19:return Tl(Xi),null;case 4:return $i(),null;case 10:return hi(e),null;default:return null}}function mo(e,t){return{value:e,source:t,stack:be(t)}}eo=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},to=function(){},no=function(e,n,r,l,i){var a=e.memoizedProps;if(a!==l){var o,u,c=n.stateNode;switch(Bi(Wi.current),e=null,r){case\"input\":a=Se(c,a),l=Se(c,l),e=[];break;case\"option\":a=Ie(c,a),l=Ie(c,l),e=[];break;case\"select\":a=t({},a,{value:void 0}),l=t({},l,{value:void 0}),e=[];break;case\"textarea\":a=Oe(c,a),l=Oe(c,l),e=[];break;default:\"function\"!=typeof a.onClick&&\"function\"==typeof l.onClick&&(c.onclick=hn)}for(o in fn(r,l),r=null,a)if(!l.hasOwnProperty(o)&&a.hasOwnProperty(o)&&null!=a[o])if(\"style\"===o)for(u in c=a[o])c.hasOwnProperty(u)&&(r||(r={}),r[u]=\"\");else\"dangerouslySetInnerHTML\"!==o&&\"children\"!==o&&\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?e||(e=[]):(e=e||[]).push(o,null));for(o in l){var s=l[o];if(c=null!=a?a[o]:void 0,l.hasOwnProperty(o)&&s!==c&&(null!=s||null!=c))if(\"style\"===o)if(c){for(u in c)!c.hasOwnProperty(u)||s&&s.hasOwnProperty(u)||(r||(r={}),r[u]=\"\");for(u in s)s.hasOwnProperty(u)&&c[u]!==s[u]&&(r||(r={}),r[u]=s[u])}else r||(e||(e=[]),e.push(o,r)),r=s;else\"dangerouslySetInnerHTML\"===o?(s=s?s.__html:void 0,c=c?c.__html:void 0,null!=s&&c!==s&&(e=e||[]).push(o,s)):\"children\"===o?c===s||\"string\"!=typeof s&&\"number\"!=typeof s||(e=e||[]).push(o,\"\"+s):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&(x.hasOwnProperty(o)?(null!=s&&mn(i,o),e||c===s||(e=[])):(e=e||[]).push(o,s))}r&&(e=e||[]).push(\"style\",r),i=e,(n.updateQueue=i)&&(n.effectTag|=4)}},ro=function(e,t,n,r){n!==r&&(t.effectTag|=4)};var ho=\"function\"==typeof WeakSet?WeakSet:Set;function go(e,t){var n=t.source,r=t.stack;null===r&&null!==n&&(r=be(n)),null!==n&&ye(n.type),t=t.value,null!==e&&1===e.tag&&ye(e.type);try{console.error(t)}catch(l){setTimeout(function(){throw l})}}function vo(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(n){Ku(e,n)}}function yo(e){var t=e.ref;if(null!==t)if(\"function\"==typeof t)try{t(null)}catch(n){Ku(e,n)}else t.current=null}function bo(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&t.effectTag&&null!==e){var n=e.memoizedProps,l=e.memoizedState;t=(e=t.stateNode).getSnapshotBeforeUpdate(t.elementType===t.type?n:ci(t.type,n),l),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(r(163))}function wo(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.destroy;n.destroy=void 0,void 0!==r&&r()}n=n.next}while(n!==t)}}function ko(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xo(e,t,n){switch(n.tag){case 0:case 11:case 15:case 22:return void ko(3,n);case 1:if(e=n.stateNode,4&n.effectTag)if(null===t)e.componentDidMount();else{var l=n.elementType===n.type?t.memoizedProps:ci(n.type,t.memoizedProps);e.componentDidUpdate(l,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}return void(null!==(t=n.updateQueue)&&Ci(n,t,e));case 3:if(null!==(t=n.updateQueue)){if(e=null,null!==n.child)switch(n.child.tag){case 5:e=n.child.stateNode;break;case 1:e=n.child.stateNode}Ci(n,t,e)}return;case 5:return e=n.stateNode,void(null===t&&4&n.effectTag&&_n(n.type,n.memoizedProps)&&e.focus());case 6:case 4:case 12:return;case 13:return void(null===n.memoizedState&&(n=n.alternate,null!==n&&(n=n.memoizedState,null!==n&&(n=n.dehydrated,null!==n&&Wt(n)))));case 19:case 17:case 20:case 21:return}throw Error(r(163))}function To(e,t,n){switch(\"function\"==typeof Xu&&Xu(t),t.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e.next;ri(97<n?97:n,function(){var e=r;do{var n=e.destroy;if(void 0!==n){var l=t;try{n()}catch(i){Ku(l,i)}}e=e.next}while(e!==r)})}break;case 1:yo(t),\"function\"==typeof(n=t.stateNode).componentWillUnmount&&vo(t,n);break;case 5:yo(t);break;case 4:No(e,t,n)}}function Eo(e){var t=e.alternate;e.return=null,e.child=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.alternate=null,e.firstEffect=null,e.lastEffect=null,e.pendingProps=null,e.memoizedProps=null,e.stateNode=null,null!==t&&Eo(t)}function So(e){return 5===e.tag||3===e.tag||4===e.tag}function Co(e){e:{for(var t=e.return;null!==t;){if(So(t)){var n=t;break e}t=t.return}throw Error(r(160))}switch(t=n.stateNode,n.tag){case 5:var l=!1;break;case 3:case 4:t=t.containerInfo,l=!0;break;default:throw Error(r(161))}16&n.effectTag&&(He(t,\"\"),n.effectTag&=-17);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||So(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;5!==n.tag&&6!==n.tag&&18!==n.tag;){if(2&n.effectTag)continue t;if(null===n.child||4===n.tag)continue t;n.child.return=n,n=n.child}if(!(2&n.effectTag)){n=n.stateNode;break e}}l?Po(e,n,t):_o(e,n,t)}function Po(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=hn));else if(4!==r&&null!==(e=e.child))for(Po(e,t,n),e=e.sibling;null!==e;)Po(e,t,n),e=e.sibling}function _o(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(_o(e,t,n),e=e.sibling;null!==e;)_o(e,t,n),e=e.sibling}function No(e,t,n){for(var l,i,a=t,o=!1;;){if(!o){o=a.return;e:for(;;){if(null===o)throw Error(r(160));switch(l=o.stateNode,o.tag){case 5:i=!1;break e;case 3:case 4:l=l.containerInfo,i=!0;break e}o=o.return}o=!0}if(5===a.tag||6===a.tag){e:for(var u=e,c=a,s=n,f=c;;)if(To(u,f,s),null!==f.child&&4!==f.tag)f.child.return=f,f=f.child;else{if(f===c)break e;for(;null===f.sibling;){if(null===f.return||f.return===c)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}i?(u=l,c=a.stateNode,8===u.nodeType?u.parentNode.removeChild(c):u.removeChild(c)):l.removeChild(a.stateNode)}else if(4===a.tag){if(null!==a.child){l=a.stateNode.containerInfo,i=!0,a.child.return=a,a=a.child;continue}}else if(To(e,a,n),null!==a.child){a.child.return=a,a=a.child;continue}if(a===t)break;for(;null===a.sibling;){if(null===a.return||a.return===t)return;4===(a=a.return).tag&&(o=!1)}a.sibling.return=a.return,a=a.sibling}}function zo(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:return void wo(3,t);case 1:return;case 5:var n=t.stateNode;if(null!=n){var l=t.memoizedProps,i=null!==e?e.memoizedProps:l;e=t.type;var a=t.updateQueue;if(t.updateQueue=null,null!==a){for(n[Dn]=l,\"input\"===e&&\"radio\"===l.type&&null!=l.name&&Pe(n,l),dn(e,i),t=dn(e,l),i=0;i<a.length;i+=2){var o=a[i],u=a[i+1];\"style\"===o?cn(n,u):\"dangerouslySetInnerHTML\"===o?We(n,u):\"children\"===o?He(n,u):Z(n,o,u,t)}switch(e){case\"input\":_e(n,l);break;case\"textarea\":De(n,l);break;case\"select\":t=n._wrapperState.wasMultiple,n._wrapperState.wasMultiple=!!l.multiple,null!=(e=l.value)?Fe(n,!!l.multiple,e,!1):t!==!!l.multiple&&(null!=l.defaultValue?Fe(n,!!l.multiple,l.defaultValue,!0):Fe(n,!!l.multiple,l.multiple?[]:\"\",!1))}}}return;case 6:if(null===t.stateNode)throw Error(r(162));return void(t.stateNode.nodeValue=t.memoizedProps);case 3:return void((t=t.stateNode).hydrate&&(t.hydrate=!1,Wt(t.containerInfo)));case 12:return;case 13:if(n=t,null===t.memoizedState?l=!1:(l=!0,n=t.child,au=ei()),null!==n)e:for(e=n;;){if(5===e.tag)a=e.stateNode,l?\"function\"==typeof(a=a.style).setProperty?a.setProperty(\"display\",\"none\",\"important\"):a.display=\"none\":(a=e.stateNode,i=null!=(i=e.memoizedProps.style)&&i.hasOwnProperty(\"display\")?i.display:null,a.style.display=un(\"display\",i));else if(6===e.tag)e.stateNode.nodeValue=l?\"\":e.memoizedProps;else{if(13===e.tag&&null!==e.memoizedState&&null===e.memoizedState.dehydrated){(a=e.child.sibling).return=e,e=a;continue}if(null!==e.child){e.child.return=e,e=e.child;continue}}if(e===n)break;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}return void Mo(t);case 19:return void Mo(t);case 17:return}throw Error(r(163))}function Mo(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new ho),t.forEach(function(t){var r=qu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}var Io=\"function\"==typeof WeakMap?WeakMap:Map;function Fo(e,t,n){(n=xi(n,null)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){cu||(cu=!0,su=r),go(e,t)},n}function Oo(e,t,n){(n=xi(n,null)).tag=3;var r=e.type.getDerivedStateFromError;if(\"function\"==typeof r){var l=t.value;n.payload=function(){return go(e,t),r(l)}}var i=e.stateNode;return null!==i&&\"function\"==typeof i.componentDidCatch&&(n.callback=function(){\"function\"!=typeof r&&(null===fu?fu=new Set([this]):fu.add(this),go(e,t));var n=t.stack;this.componentDidCatch(t.value,{componentStack:null!==n?n:\"\"})}),n}var Ro,Do=Math.ceil,Lo=G.ReactCurrentDispatcher,Uo=G.ReactCurrentOwner,Ao=0,Vo=8,Qo=16,Wo=32,Ho=0,jo=1,Bo=2,Ko=3,$o=4,qo=5,Yo=Ao,Xo=null,Go=null,Zo=0,Jo=Ho,eu=null,tu=1073741823,nu=1073741823,ru=null,lu=0,iu=!1,au=0,ou=500,uu=null,cu=!1,su=null,fu=null,du=!1,pu=null,mu=90,hu=null,gu=0,vu=null,yu=0;function bu(){return(Yo&(Qo|Wo))!==Ao?1073741821-(ei()/10|0):0!==yu?yu:yu=1073741821-(ei()/10|0)}function wu(e,t,n){if(0==(2&(t=t.mode)))return 1073741823;var l=ti();if(0==(4&t))return 99===l?1073741823:1073741822;if((Yo&Qo)!==Ao)return Zo;if(null!==n)e=ui(e,0|n.timeoutMs||5e3,250);else switch(l){case 99:e=1073741823;break;case 98:e=ui(e,150,100);break;case 97:case 96:e=ui(e,5e3,250);break;case 95:e=2;break;default:throw Error(r(326))}return null!==Xo&&e===Zo&&--e,e}function ku(e,t){if(50<gu)throw gu=0,vu=null,Error(r(185));if(null!==(e=xu(e,t))){var n=ti();1073741823===t?(Yo&Vo)!==Ao&&(Yo&(Qo|Wo))===Ao?Cu(e):(Eu(e),Yo===Ao&&ai()):Eu(e),(4&Yo)===Ao||98!==n&&99!==n||(null===hu?hu=new Map([[e,t]]):(void 0===(n=hu.get(e))||n>t)&&hu.set(e,t))}}function xu(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t);var r=e.return,l=null;if(null===r&&3===e.tag)l=e.stateNode;else for(;null!==r;){if(n=r.alternate,r.childExpirationTime<t&&(r.childExpirationTime=t),null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t),null===r.return&&3===r.tag){l=r.stateNode;break}r=r.return}return null!==l&&(Xo===l&&(Ou(t),Jo===$o&&cc(l,Zo)),sc(l,t)),l}function Tu(e){var t=e.lastExpiredTime;if(0!==t)return t;if(!uc(e,t=e.firstPendingTime))return t;var n=e.lastPingedTime;return 2>=(e=n>(e=e.nextKnownPendingLevel)?n:e)&&t!==e?0:e}function Eu(e){if(0!==e.lastExpiredTime)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=ii(Cu.bind(null,e));else{var t=Tu(e),n=e.callbackNode;if(0===t)null!==n&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var r=bu();if(1073741823===t?r=99:1===t||2===t?r=95:r=0>=(r=10*(1073741821-t)-10*(1073741821-r))?99:250>=r?98:5250>=r?97:95,null!==n){var l=e.callbackPriority;if(e.callbackExpirationTime===t&&l>=r)return;n!==$l&&Ul(n)}e.callbackExpirationTime=t,e.callbackPriority=r,t=1073741823===t?ii(Cu.bind(null,e)):li(r,Su.bind(null,e),{timeout:10*(1073741821-t)-ei()}),e.callbackNode=t}}}function Su(e,t){if(yu=0,t)return fc(e,t=bu()),Eu(e),null;var n=Tu(e);if(0!==n){if(t=e.callbackNode,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&n===Zo||zu(e,n),null!==Go){var l=Yo;Yo|=Qo;for(var i=Iu();;)try{Du();break}catch(u){Mu(e,u)}if(mi(),Yo=l,Lo.current=i,Jo===jo)throw t=eu,zu(e,n),cc(e,n),Eu(e),t;if(null===Go)switch(i=e.finishedWork=e.current.alternate,e.finishedExpirationTime=n,l=Jo,Xo=null,l){case Ho:case jo:throw Error(r(345));case Bo:fc(e,2<n?2:n);break;case Ko:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),1073741823===tu&&10<(i=au+ou-ei())){if(iu){var a=e.lastPingedTime;if(0===a||a>=n){e.lastPingedTime=n,zu(e,n);break}}if(0!==(a=Tu(e))&&a!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}e.timeoutHandle=zn(Vu.bind(null,e),i);break}Vu(e);break;case $o:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),iu&&(0===(i=e.lastPingedTime)||i>=n)){e.lastPingedTime=n,zu(e,n);break}if(0!==(i=Tu(e))&&i!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}if(1073741823!==nu?l=10*(1073741821-nu)-ei():1073741823===tu?l=0:(l=10*(1073741821-tu)-5e3,0>(l=(i=ei())-l)&&(l=0),(n=10*(1073741821-n)-i)<(l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Do(l/1960))-l)&&(l=n)),10<l){e.timeoutHandle=zn(Vu.bind(null,e),l);break}Vu(e);break;case qo:if(1073741823!==tu&&null!==ru){a=tu;var o=ru;if(0>=(l=0|o.busyMinDurationMs)?l=0:(i=0|o.busyDelayMs,l=(a=ei()-(10*(1073741821-a)-(0|o.timeoutMs||5e3)))<=i?0:i+l-a),10<l){cc(e,n),e.timeoutHandle=zn(Vu.bind(null,e),l);break}}Vu(e);break;default:throw Error(r(329))}if(Eu(e),e.callbackNode===t)return Su.bind(null,e)}}return null}function Cu(e){var t=e.lastExpiredTime;if(t=0!==t?t:1073741823,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&t===Zo||zu(e,t),null!==Go){var n=Yo;Yo|=Qo;for(var l=Iu();;)try{Ru();break}catch(i){Mu(e,i)}if(mi(),Yo=n,Lo.current=l,Jo===jo)throw n=eu,zu(e,t),cc(e,t),Eu(e),n;if(null!==Go)throw Error(r(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Xo=null,Vu(e),Eu(e)}return null}function Pu(){if(null!==hu){var e=hu;hu=null,e.forEach(function(e,t){fc(t,e),Eu(t)}),ai()}}function _u(e,t){var n=Yo;Yo|=1;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function Nu(e,t){var n=Yo;Yo&=-2,Yo|=Vo;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function zu(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,Mn(n)),null!==Go)for(n=Go.return;null!==n;){var r=n;switch(r.tag){case 1:null!=(r=r.type.childContextTypes)&&Ml();break;case 3:$i(),Tl(Pl),Tl(Cl);break;case 5:Yi(r);break;case 4:$i();break;case 13:case 19:Tl(Xi);break;case 10:hi(r)}n=n.return}Xo=e,Go=nc(e.current,null),Zo=t,Jo=Ho,eu=null,nu=tu=1073741823,ru=null,lu=0,iu=!1}function Mu(e,t){for(;;){try{if(mi(),Ji.current=za,ia)for(var n=na.memoizedState;null!==n;){var r=n.queue;null!==r&&(r.pending=null),n=n.next}if(ta=0,la=ra=na=null,ia=!1,null===Go||null===Go.return)return Jo=jo,eu=t,Go=null;e:{var l=e,i=Go.return,a=Go,o=t;if(t=Zo,a.effectTag|=2048,a.firstEffect=a.lastEffect=null,null!==o&&\"object\"==typeof o&&\"function\"==typeof o.then){var u=o;if(0==(2&a.mode)){var c=a.alternate;c?(a.updateQueue=c.updateQueue,a.memoizedState=c.memoizedState,a.expirationTime=c.expirationTime):(a.updateQueue=null,a.memoizedState=null)}var s=0!=(1&Xi.current),f=i;do{var d;if(d=13===f.tag){var p=f.memoizedState;if(null!==p)d=null!==p.dehydrated;else{var m=f.memoizedProps;d=void 0!==m.fallback&&(!0!==m.unstable_avoidThisFallback||!s)}}if(d){var h=f.updateQueue;if(null===h){var g=new Set;g.add(u),f.updateQueue=g}else h.add(u);if(0==(2&f.mode)){if(f.effectTag|=64,a.effectTag&=-2981,1===a.tag)if(null===a.alternate)a.tag=17;else{var v=xi(1073741823,null);v.tag=2,Ti(a,v)}a.expirationTime=1073741823;break e}o=void 0,a=t;var y=l.pingCache;if(null===y?(y=l.pingCache=new Io,o=new Set,y.set(u,o)):void 0===(o=y.get(u))&&(o=new Set,y.set(u,o)),!o.has(a)){o.add(a);var b=$u.bind(null,l,u,a);u.then(b,b)}f.effectTag|=4096,f.expirationTime=t;break e}f=f.return}while(null!==f);o=Error((ye(a.type)||\"A React component\")+\" suspended while rendering, but no fallback UI was specified.\\n\\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.\"+be(a))}Jo!==qo&&(Jo=Bo),o=mo(o,a),f=i;do{switch(f.tag){case 3:u=o,f.effectTag|=4096,f.expirationTime=t,Ei(f,Fo(f,u,t));break e;case 1:u=o;var w=f.type,k=f.stateNode;if(0==(64&f.effectTag)&&(\"function\"==typeof w.getDerivedStateFromError||null!==k&&\"function\"==typeof k.componentDidCatch&&(null===fu||!fu.has(k)))){f.effectTag|=4096,f.expirationTime=t,Ei(f,Oo(f,u,t));break e}}f=f.return}while(null!==f)}Go=Uu(Go)}catch(x){t=x;continue}break}}function Iu(){var e=Lo.current;return Lo.current=za,null===e?za:e}function Fu(e,t){e<tu&&2<e&&(tu=e),null!==t&&e<nu&&2<e&&(nu=e,ru=t)}function Ou(e){e>lu&&(lu=e)}function Ru(){for(;null!==Go;)Go=Lu(Go)}function Du(){for(;null!==Go&&!ql();)Go=Lu(Go)}function Lu(e){var t=Ro(e.alternate,e,Zo);return e.memoizedProps=e.pendingProps,null===t&&(t=Uu(e)),Uo.current=null,t}function Uu(e){Go=e;do{var t=Go.alternate;if(e=Go.return,0==(2048&Go.effectTag)){if(t=fo(t,Go,Zo),1===Zo||1!==Go.childExpirationTime){for(var n=0,r=Go.child;null!==r;){var l=r.expirationTime,i=r.childExpirationTime;l>n&&(n=l),i>n&&(n=i),r=r.sibling}Go.childExpirationTime=n}if(null!==t)return t;null!==e&&0==(2048&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=Go.firstEffect),null!==Go.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=Go.firstEffect),e.lastEffect=Go.lastEffect),1<Go.effectTag&&(null!==e.lastEffect?e.lastEffect.nextEffect=Go:e.firstEffect=Go,e.lastEffect=Go))}else{if(null!==(t=po(Go)))return t.effectTag&=2047,t;null!==e&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(null!==(t=Go.sibling))return t;Go=e}while(null!==Go);return Jo===Ho&&(Jo=qo),null}function Au(e){var t=e.expirationTime;return t>(e=e.childExpirationTime)?t:e}function Vu(e){var t=ti();return ri(99,Qu.bind(null,e,t)),null}function Qu(e,t){do{Hu()}while(null!==pu);if((Yo&(Qo|Wo))!==Ao)throw Error(r(327));var n=e.finishedWork,l=e.finishedExpirationTime;if(null===n)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var i=Au(n);if(e.firstPendingTime=i,l<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:l<=e.firstSuspendedTime&&(e.firstSuspendedTime=l-1),l<=e.lastPingedTime&&(e.lastPingedTime=0),l<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===Xo&&(Go=Xo=null,Zo=0),1<n.effectTag?null!==n.lastEffect?(n.lastEffect.nextEffect=n,i=n.firstEffect):i=n:i=n.firstEffect,null!==i){var a=Yo;Yo|=Wo,Uo.current=null,Cn=Zt;var o=wn();if(kn(o)){if(\"selectionStart\"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{var c=(u=(u=o.ownerDocument)&&u.defaultView||window).getSelection&&u.getSelection();if(c&&0!==c.rangeCount){u=c.anchorNode;var s=c.anchorOffset,f=c.focusNode;c=c.focusOffset;try{u.nodeType,f.nodeType}catch(C){u=null;break e}var d=0,p=-1,m=-1,h=0,g=0,v=o,y=null;t:for(;;){for(var b;v!==u||0!==s&&3!==v.nodeType||(p=d+s),v!==f||0!==c&&3!==v.nodeType||(m=d+c),3===v.nodeType&&(d+=v.nodeValue.length),null!==(b=v.firstChild);)y=v,v=b;for(;;){if(v===o)break t;if(y===u&&++h===s&&(p=d),y===f&&++g===c&&(m=d),null!==(b=v.nextSibling))break;y=(v=y).parentNode}v=b}u=-1===p||-1===m?null:{start:p,end:m}}else u=null}u=u||{start:0,end:0}}else u=null;Pn={activeElementDetached:null,focusedElem:o,selectionRange:u},Zt=!1,uu=i;do{try{Wu()}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=i;do{try{for(o=e,u=t;null!==uu;){var w=uu.effectTag;if(16&w&&He(uu.stateNode,\"\"),128&w){var k=uu.alternate;if(null!==k){var x=k.ref;null!==x&&(\"function\"==typeof x?x(null):x.current=null)}}switch(1038&w){case 2:Co(uu),uu.effectTag&=-3;break;case 6:Co(uu),uu.effectTag&=-3,zo(uu.alternate,uu);break;case 1024:uu.effectTag&=-1025;break;case 1028:uu.effectTag&=-1025,zo(uu.alternate,uu);break;case 4:zo(uu.alternate,uu);break;case 8:No(o,s=uu,u),Eo(s)}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);if(x=Pn,k=wn(),w=x.focusedElem,u=x.selectionRange,k!==w&&w&&w.ownerDocument&&bn(w.ownerDocument.documentElement,w)){null!==u&&kn(w)&&(k=u.start,void 0===(x=u.end)&&(x=k),\"selectionStart\"in w?(w.selectionStart=k,w.selectionEnd=Math.min(x,w.value.length)):(x=(k=w.ownerDocument||document)&&k.defaultView||window).getSelection&&(x=x.getSelection(),s=w.textContent.length,o=Math.min(u.start,s),u=void 0===u.end?o:Math.min(u.end,s),!x.extend&&o>u&&(s=u,u=o,o=s),s=yn(w,o),f=yn(w,u),s&&f&&(1!==x.rangeCount||x.anchorNode!==s.node||x.anchorOffset!==s.offset||x.focusNode!==f.node||x.focusOffset!==f.offset)&&((k=k.createRange()).setStart(s.node,s.offset),x.removeAllRanges(),o>u?(x.addRange(k),x.extend(f.node,f.offset)):(k.setEnd(f.node,f.offset),x.addRange(k))))),k=[];for(x=w;x=x.parentNode;)1===x.nodeType&&k.push({element:x,left:x.scrollLeft,top:x.scrollTop});for(\"function\"==typeof w.focus&&w.focus(),w=0;w<k.length;w++)(x=k[w]).element.scrollLeft=x.left,x.element.scrollTop=x.top}Zt=!!Cn,Pn=Cn=null,e.current=n,uu=i;do{try{for(w=e;null!==uu;){var T=uu.effectTag;if(36&T&&xo(w,uu.alternate,uu),128&T){k=void 0;var E=uu.ref;if(null!==E){var S=uu.stateNode;switch(uu.tag){case 5:k=S;break;default:k=S}\"function\"==typeof E?E(k):E.current=k}}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=null,Yl(),Yo=a}else e.current=n;if(du)du=!1,pu=e,mu=t;else for(uu=i;null!==uu;)t=uu.nextEffect,uu.nextEffect=null,uu=t;if(0===(t=e.firstPendingTime)&&(fu=null),1073741823===t?e===vu?gu++:(gu=0,vu=e):gu=0,\"function\"==typeof Yu&&Yu(n.stateNode,l),Eu(e),cu)throw cu=!1,e=su,su=null,e;return(Yo&Vo)!==Ao?null:(ai(),null)}function Wu(){for(;null!==uu;){var e=uu.effectTag;0!=(256&e)&&bo(uu.alternate,uu),0==(512&e)||du||(du=!0,li(97,function(){return Hu(),null})),uu=uu.nextEffect}}function Hu(){if(90!==mu){var e=97<mu?97:mu;return mu=90,ri(e,ju)}}function ju(){if(null===pu)return!1;var e=pu;if(pu=null,(Yo&(Qo|Wo))!==Ao)throw Error(r(331));var t=Yo;for(Yo|=Wo,e=e.current.firstEffect;null!==e;){try{var n=e;if(0!=(512&n.effectTag))switch(n.tag){case 0:case 11:case 15:case 22:wo(5,n),ko(5,n)}}catch(l){if(null===e)throw Error(r(330));Ku(e,l)}n=e.nextEffect,e.nextEffect=null,e=n}return Yo=t,ai(),!0}function Bu(e,t,n){Ti(e,t=Fo(e,t=mo(n,t),1073741823)),null!==(e=xu(e,1073741823))&&Eu(e)}function Ku(e,t){if(3===e.tag)Bu(e,e,t);else for(var n=e.return;null!==n;){if(3===n.tag){Bu(n,e,t);break}if(1===n.tag){var r=n.stateNode;if(\"function\"==typeof n.type.getDerivedStateFromError||\"function\"==typeof r.componentDidCatch&&(null===fu||!fu.has(r))){Ti(n,e=Oo(n,e=mo(t,e),1073741823)),null!==(n=xu(n,1073741823))&&Eu(n);break}}n=n.return}}function $u(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),Xo===e&&Zo===n?Jo===$o||Jo===Ko&&1073741823===tu&&ei()-au<ou?zu(e,Zo):iu=!0:uc(e,n)&&(0!==(t=e.lastPingedTime)&&t<n||(e.lastPingedTime=n,Eu(e)))}function qu(e,t){var n=e.stateNode;null!==n&&n.delete(t),0===(t=0)&&(t=wu(t=bu(),e,null)),null!==(e=xu(e,t))&&Eu(e)}Ro=function(e,t,n){var l=t.expirationTime;if(null!==e){var i=t.pendingProps;if(e.memoizedProps!==i||Pl.current)ja=!0;else{if(l<n){switch(ja=!1,t.tag){case 3:Ja(t),Wa();break;case 5:if(qi(t),4&t.mode&&1!==n&&i.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:zl(t.type)&&Ol(t);break;case 4:Ki(t,t.stateNode.containerInfo);break;case 10:l=t.memoizedProps.value,i=t.type._context,El(si,i._currentValue),i._currentValue=l;break;case 13:if(null!==t.memoizedState)return 0!==(l=t.child.childExpirationTime)&&l>=n?io(e,t,n):(El(Xi,1&Xi.current),null!==(t=co(e,t,n))?t.sibling:null);El(Xi,1&Xi.current);break;case 19:if(l=t.childExpirationTime>=n,0!=(64&e.effectTag)){if(l)return uo(e,t,n);t.effectTag|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null),El(Xi,Xi.current),!l)return null}return co(e,t,n)}ja=!1}}else ja=!1;switch(t.expirationTime=0,t.tag){case 2:if(l=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,i=Nl(t,Cl.current),vi(t,n),i=ua(null,t,l,e,i,n),t.effectTag|=1,\"object\"==typeof i&&null!==i&&\"function\"==typeof i.render&&void 0===i.$$typeof){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,zl(l)){var a=!0;Ol(t)}else a=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,wi(t);var o=l.getDerivedStateFromProps;\"function\"==typeof o&&Ni(t,l,o,e),i.updater=zi,t.stateNode=i,i._reactInternalFiber=t,Oi(t,l,e,n),t=Za(null,t,l,!0,a,n)}else t.tag=0,Ba(null,t,i,n),t=t.child;return t;case 16:e:{if(i=t.elementType,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,ve(i),1!==i._status)throw i._result;switch(i=i._result,t.type=i,a=t.tag=tc(i),e=ci(i,e),a){case 0:t=Xa(null,t,i,e,n);break e;case 1:t=Ga(null,t,i,e,n);break e;case 11:t=Ka(null,t,i,e,n);break e;case 14:t=$a(null,t,i,ci(i.type,e),l,n);break e}throw Error(r(306,i,\"\"))}return t;case 0:return l=t.type,i=t.pendingProps,Xa(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 1:return l=t.type,i=t.pendingProps,Ga(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 3:if(Ja(t),l=t.updateQueue,null===e||null===l)throw Error(r(282));if(l=t.pendingProps,i=null!==(i=t.memoizedState)?i.element:null,ki(e,t),Si(t,l,null,n),(l=t.memoizedState.element)===i)Wa(),t=co(e,t,n);else{if((i=t.stateNode.hydrate)&&(Ra=In(t.stateNode.containerInfo.firstChild),Oa=t,i=Da=!0),i)for(n=Vi(t,null,l,n),t.child=n;n;)n.effectTag=-3&n.effectTag|1024,n=n.sibling;else Ba(e,t,l,n),Wa();t=t.child}return t;case 5:return qi(t),null===e&&Aa(t),l=t.type,i=t.pendingProps,a=null!==e?e.memoizedProps:null,o=i.children,Nn(l,i)?o=null:null!==a&&Nn(l,a)&&(t.effectTag|=16),Ya(e,t),4&t.mode&&1!==n&&i.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(Ba(e,t,o,n),t=t.child),t;case 6:return null===e&&Aa(t),null;case 13:return io(e,t,n);case 4:return Ki(t,t.stateNode.containerInfo),l=t.pendingProps,null===e?t.child=Ai(t,null,l,n):Ba(e,t,l,n),t.child;case 11:return l=t.type,i=t.pendingProps,Ka(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 7:return Ba(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ba(e,t,t.pendingProps.children,n),t.child;case 10:e:{l=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value;var u=t.type._context;if(El(si,u._currentValue),u._currentValue=a,null!==o)if(u=o.value,0===(a=Gr(u,a)?0:0|(\"function\"==typeof l._calculateChangedBits?l._calculateChangedBits(u,a):1073741823))){if(o.children===i.children&&!Pl.current){t=co(e,t,n);break e}}else for(null!==(u=t.child)&&(u.return=t);null!==u;){var c=u.dependencies;if(null!==c){o=u.child;for(var s=c.firstContext;null!==s;){if(s.context===l&&0!=(s.observedBits&a)){1===u.tag&&((s=xi(n,null)).tag=2,Ti(u,s)),u.expirationTime<n&&(u.expirationTime=n),null!==(s=u.alternate)&&s.expirationTime<n&&(s.expirationTime=n),gi(u.return,n),c.expirationTime<n&&(c.expirationTime=n);break}s=s.next}}else o=10===u.tag&&u.type===t.type?null:u.child;if(null!==o)o.return=u;else for(o=u;null!==o;){if(o===t){o=null;break}if(null!==(u=o.sibling)){u.return=o.return,o=u;break}o=o.return}u=o}Ba(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,l=(a=t.pendingProps).children,vi(t,n),l=l(i=yi(i,a.unstable_observedBits)),t.effectTag|=1,Ba(e,t,l,n),t.child;case 14:return a=ci(i=t.type,t.pendingProps),$a(e,t,i,a=ci(i.type,a),l,n);case 15:return qa(e,t,t.type,t.pendingProps,l,n);case 17:return l=t.type,i=t.pendingProps,i=t.elementType===l?i:ci(l,i),null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,zl(l)?(e=!0,Ol(t)):e=!1,vi(t,n),Ii(t,l,i),Oi(t,l,i,n),Za(null,t,l,!0,e,n);case 19:return uo(e,t,n)}throw Error(r(156,t.tag))};var Yu=null,Xu=null;function Gu(e){if(\"undefined\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var n=t.inject(e);Yu=function(e){try{t.onCommitFiberRoot(n,e,void 0,64==(64&e.current.effectTag))}catch(r){}},Xu=function(e){try{t.onCommitFiberUnmount(n,e)}catch(r){}}}catch(r){}return!0}function Zu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childExpirationTime=this.expirationTime=0,this.alternate=null}function Ju(e,t,n,r){return new Zu(e,t,n,r)}function ec(e){return!(!(e=e.prototype)||!e.isReactComponent)}function tc(e){if(\"function\"==typeof e)return ec(e)?1:0;if(null!=e){if((e=e.$$typeof)===ce)return 11;if(e===de)return 14}return 2}function nc(e,t){var n=e.alternate;return null===n?((n=Ju(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.effectTag=0,n.nextEffect=null,n.firstEffect=null,n.lastEffect=null),n.childExpirationTime=e.childExpirationTime,n.expirationTime=e.expirationTime,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{expirationTime:t.expirationTime,firstContext:t.firstContext,responders:t.responders},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function rc(e,t,n,l,i,a){var o=2;if(l=e,\"function\"==typeof e)ec(e)&&(o=1);else if(\"string\"==typeof e)o=5;else e:switch(e){case re:return lc(n.children,i,a,t);case ue:o=8,i|=7;break;case le:o=8,i|=1;break;case ie:return(e=Ju(12,n,t,8|i)).elementType=ie,e.type=ie,e.expirationTime=a,e;case se:return(e=Ju(13,n,t,i)).type=se,e.elementType=se,e.expirationTime=a,e;case fe:return(e=Ju(19,n,t,i)).elementType=fe,e.expirationTime=a,e;default:if(\"object\"==typeof e&&null!==e)switch(e.$$typeof){case ae:o=10;break e;case oe:o=9;break e;case ce:o=11;break e;case de:o=14;break e;case pe:o=16,l=null;break e;case me:o=22;break e}throw Error(r(130,null==e?e:typeof e,\"\"))}return(t=Ju(o,n,t,i)).elementType=e,t.type=l,t.expirationTime=a,t}function lc(e,t,n,r){return(e=Ju(7,e,r,t)).expirationTime=n,e}function ic(e,t,n){return(e=Ju(6,e,null,t)).expirationTime=n,e}function ac(e,t,n){return(t=Ju(4,null!==e.children?e.children:[],e.key,t)).expirationTime=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function oc(e,t,n){this.tag=t,this.current=null,this.containerInfo=e,this.pingCache=this.pendingChildren=null,this.finishedExpirationTime=0,this.finishedWork=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=n,this.callbackNode=null,this.callbackPriority=90,this.lastExpiredTime=this.lastPingedTime=this.nextKnownPendingLevel=this.lastSuspendedTime=this.firstSuspendedTime=this.firstPendingTime=0}function uc(e,t){var n=e.firstSuspendedTime;return e=e.lastSuspendedTime,0!==n&&n>=t&&e<=t}function cc(e,t){var n=e.firstSuspendedTime,r=e.lastSuspendedTime;n<t&&(e.firstSuspendedTime=t),(r>t||0===n)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function sc(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var n=e.firstSuspendedTime;0!==n&&(t>=n?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function fc(e,t){var n=e.lastExpiredTime;(0===n||n>t)&&(e.lastExpiredTime=t)}function dc(e,t,n,l){var i=t.current,a=bu(),o=Pi.suspense;a=wu(a,i,o);e:if(n){t:{if(nt(n=n._reactInternalFiber)!==n||1!==n.tag)throw Error(r(170));var u=n;do{switch(u.tag){case 3:u=u.stateNode.context;break t;case 1:if(zl(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break t}}u=u.return}while(null!==u);throw Error(r(171))}if(1===n.tag){var c=n.type;if(zl(c)){n=Fl(n,c,u);break e}}n=u}else n=Sl;return null===t.context?t.context=n:t.pendingContext=n,(t=xi(a,o)).payload={element:e},null!==(l=void 0===l?null:l)&&(t.callback=l),Ti(i,t),ku(i,a),a}function pc(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 5:default:return e.child.stateNode}}function mc(e,t){null!==(e=e.memoizedState)&&null!==e.dehydrated&&e.retryTime<t&&(e.retryTime=t)}function hc(e,t){mc(e,t),(e=e.alternate)&&mc(e,t)}function gc(e,t,n){var r=new oc(e,t,n=null!=n&&!0===n.hydrate),l=Ju(3,null,null,2===t?7:1===t?3:0);r.current=l,l.stateNode=r,wi(l),e[Ln]=r.current,n&&0!==t&&It(e,9===e.nodeType?e:e.ownerDocument),this._internalRoot=r}function vc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||\" react-mount-point-unstable \"!==e.nodeValue))}function yc(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute(\"data-reactroot\"))),!t)for(var n;n=e.lastChild;)e.removeChild(n);return new gc(e,0,t?{hydrate:!0}:void 0)}function bc(e,t,n,r,l){var i=n._reactRootContainer;if(i){var a=i._internalRoot;if(\"function\"==typeof l){var o=l;l=function(){var e=pc(a);o.call(e)}}dc(t,a,e,l)}else{if(i=n._reactRootContainer=yc(n,r),a=i._internalRoot,\"function\"==typeof l){var u=l;l=function(){var e=pc(a);u.call(e)}}Nu(function(){dc(t,a,e,l)})}return pc(a)}function wc(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:ne,key:null==r?null:\"\"+r,children:e,containerInfo:t,implementation:n}}function kc(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!vc(t))throw Error(r(200));return wc(e,t,null,n)}gc.prototype.render=function(e){dc(e,this._internalRoot,null,null)},gc.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;dc(null,e,null,function(){t[Ln]=null})},bt=function(e){if(13===e.tag){var t=ui(bu(),150,100);ku(e,t),hc(e,t)}},wt=function(e){13===e.tag&&(ku(e,3),hc(e,3))},kt=function(e){if(13===e.tag){var t=bu();ku(e,t=wu(t,e,null)),hc(e,t)}},C=function(e,t,n){switch(t){case\"input\":if(_e(e,n),t=n.name,\"radio\"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(\"input[name=\"+JSON.stringify(\"\"+t)+'][type=\"radio\"]'),t=0;t<n.length;t++){var l=n[t];if(l!==e&&l.form===e.form){var i=Qn(l);if(!i)throw Error(r(90));Ee(l),_e(l,i)}}}break;case\"textarea\":De(e,n);break;case\"select\":null!=(t=n.value)&&Fe(e,!!n.multiple,t,!1)}},I=_u,F=function(e,t,n,r,l){var i=Yo;Yo|=4;try{return ri(98,e.bind(null,t,n,r,l))}finally{(Yo=i)===Ao&&ai()}},O=function(){(Yo&(1|Qo|Wo))===Ao&&(Pu(),Hu())},R=function(e,t){var n=Yo;Yo|=2;try{return e(t)}finally{(Yo=n)===Ao&&ai()}};var xc={Events:[An,Vn,Qn,E,k,qn,function(e){ut(e,$n)},z,M,rn,ft,Hu,{current:!1}]};!function(e){var n=e.findFiberByHostInstance;Gu(t({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:G.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=at(e))?null:e.stateNode},findFiberByHostInstance:function(e){return n?n(e):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))}({findFiberByHostInstance:Un,bundleType:0,version:\"16.14.0\",rendererPackageName:\"react-dom\"}),exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xc,exports.createPortal=kc,exports.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternalFiber;if(void 0===t){if(\"function\"==typeof e.render)throw Error(r(188));throw Error(r(268,Object.keys(e)))}return e=null===(e=at(t))?null:e.stateNode},exports.flushSync=function(e,t){if((Yo&(Qo|Wo))!==Ao)throw Error(r(187));var n=Yo;Yo|=1;try{return ri(99,e.bind(null,t))}finally{Yo=n,ai()}},exports.hydrate=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!0,n)},exports.render=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!1,n)},exports.unmountComponentAtNode=function(e){if(!vc(e))throw Error(r(40));return!!e._reactRootContainer&&(Nu(function(){bc(null,null,e,!1,function(){e._reactRootContainer=null,e[Ln]=null})}),!0)},exports.unstable_batchedUpdates=_u,exports.unstable_createPortal=function(e,t){return kc(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},exports.unstable_renderSubtreeIntoContainer=function(e,t,n,l){if(!vc(n))throw Error(r(200));if(null==e||void 0===e._reactInternalFiber)throw Error(r(38));return bc(e,t,n,!1,l)},exports.version=\"16.14.0\";\n},{\"react\":\"n8MK\",\"object-assign\":\"J4Nk\",\"scheduler\":\"MDSO\"}],\"NKHc\":[function(require,module,exports) {\n\"use strict\";function _(){if(\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_)}catch(O){console.error(O)}}}_(),module.exports=require(\"./cjs/react-dom.production.min.js\");\n},{\"./cjs/react-dom.production.min.js\":\"i17t\"}],\"zm2Q\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.customAlphabet=exports.nanoid=void 0;let e=\"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\",t=(e,t)=>()=>{let o=\"\",r=t;for(;r--;)o+=e[Math.random()*e.length|0];return o};exports.customAlphabet=t;let o=(t=21)=>{let o=\"\",r=t;for(;r--;)o+=e[64*Math.random()|0];return o};exports.nanoid=o;\n},{}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"Sn21\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=r,exports.R=void 0;class t{constructor(t){const e=s();this.c=1,this.s0=e(\" \"),this.s1=e(\" \"),this.s2=e(\" \"),this.s0-=e(t),this.s0<0&&(this.s0+=1),this.s1-=e(t),this.s1<0&&(this.s1+=1),this.s2-=e(t),this.s2<0&&(this.s2+=1)}next(){const t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=t-(this.c=Math.trunc(t))}}function s(){let t=4022871197;return function(s){const e=s.toString();for(let r=0;r<e.length;r++){let s=.02519603282416938*(t+=e.charCodeAt(r));s-=t=s>>>0,t=(s*=t)>>>0,t+=4294967296*(s-=t)}return 2.3283064365386963e-10*(t>>>0)}}function e(t,s){return s.c=t.c,s.s0=t.s0,s.s1=t.s1,s.s2=t.s2,s}function r(s,r){const n=new t(s),i=n.next.bind(n);return r&&e(r,n),i.state=(()=>e(n,{})),i}class n{constructor(t){this.state=t||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const t=this.state,s=r(t.prngstate?\"\":t.seed,t.prngstate),e=s();return this.state={...t,prngstate:s.state()},e}api(){const t=this._random.bind(this),s={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},e={};for(const r in s){const n=s[r];e[r]=(s=>void 0===s?Math.floor(t()*n)+1:Array.from({length:s}).map(()=>Math.floor(t()*n)+1))}return{...e,Die:function(s=6,e){return void 0===e?Math.floor(t()*s)+1:Array.from({length:e}).map(()=>Math.floor(t()*s)+1)},Number:()=>t(),Shuffle:s=>{const e=[...s];let r=s.length,n=0;const i=Array.from({length:r});for(;r;){const s=Math.trunc(r*t());i[n++]=e[s],e[s]=e[--r]}return i},_private:this}}}const i={name:\"random\",noClient:({api:t})=>t._private.isUsed(),flush:({api:t})=>t._private.getState(),api:({data:t})=>{return new n(t).api()},setup:({game:t})=>{let{seed:s}=t;return void 0===s&&(s=n.seed()),{seed:s}},playerView:()=>void 0};exports.R=i;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"MZmr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ae,exports.U=ne,exports.a=X,exports.b=Z,exports.c=ee,exports.e=B,exports.i=C,exports.z=exports.y=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.T=exports.S=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=a(require(\"immer\")),t=require(\"./plugin-random-087f861e.js\"),r=a(require(\"lodash.isplainobject\"));function a(e){return e&&e.__esModule?e:{default:e}}const n=\"MAKE_MOVE\";exports.M=n;const s=\"GAME_EVENT\";exports.o=s;const o=\"REDO\";exports.R=o;const i=\"RESET\";exports.l=i;const l=\"SYNC\";exports.j=l;const p=\"UNDO\";exports.h=p;const c=\"UPDATE\";exports.k=c;const d=\"PATCH\";exports.P=d;const u=\"PLUGIN\";exports.d=u;const y=\"STRIP_TRANSIENTS\";exports.p=y;const v=(e,t,r,a)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:a}});exports.B=v;const g=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a}});exports.g=g;const x=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a},automatic:!0}),h=e=>({type:l,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=h;const m=(e,t,r,a)=>({type:d,prevStateID:e,stateID:t,patch:r,deltalog:a,clientOnly:!0});exports.y=m;const f=(e,t)=>({type:c,state:e,deltalog:t,clientOnly:!0});exports.z=f;const P=e=>({type:i,state:e,clientOnly:!0});exports.u=P;const E=(e,t)=>({type:p,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=E;const O=(e,t)=>({type:o,payload:{type:null,args:null,playerID:e,credentials:t}});exports.w=O;const _=(e,t,r,a)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:a}}),M=()=>({type:y});exports.r=M;var N=Object.freeze({__proto__:null,makeMove:v,gameEvent:g,automaticGameEvent:x,sync:h,patch:m,update:f,reset:P,undo:E,redo:O,plugin:_,stripTransients:M});exports.A=N;const T=\"INVALID_MOVE\";exports.n=T;const I={name:\"plugin-immer\",fnWrap:t=>(r,a,...n)=>{let s=!1;const o=(0,e.default)(r,e=>{const r=t(e,a,...n);if(r!==T)return r;s=!0});return s?T:o}};var A,S;exports.G=A,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(A||(exports.G=A={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(S||(S={}));class b{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let a=0;a<this.dispatch.length;a++){const t=this.dispatch[a],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,S.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,S.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case A.TURN_ON_END:case A.PHASE_ON_END:return r(t.error,S.StageEventInOnEnd);case A.PHASE_ON_BEGIN:return r(t.error,S.StageEventInPhaseBegin);case A.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,S.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===A.TURN_ON_END||t.calledFrom===A.PHASE_ON_END)return r(t.error,S.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===A.PHASE_ON_END)return r(t.error,S.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const s=x(t.type,t.args,this.playerID);e=this.flow.processEvent(e,s)}return e}}const D={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,a,...n)=>{const s=a.events;return s&&s._private.updateTurnContext(a,t),r=e(r,a,...n),s&&s._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new b(e.flow,t,r).api()},G={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function U(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,r.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!U(e[t]))return!1;return!0}const R={name:\"plugin-serializable\",fnWrap:e=>(t,r,...a)=>{const n=e(t,r,...a);return n}},k=!0,L=()=>{},w=(...e)=>console.error(...e);function C(e){L(`INFO: ${e}`)}function B(e){w(\"ERROR:\",e)}const j=[I,t.R,G,R],F=[...j,D],H=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[a]:{...n,data:s}}}}),e);exports.f=H;const V=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=V;const $=(e,t,r)=>[...j,...r,D].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=$;const q=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const a=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[a]:{data:n}}}}),e);exports.t=q;const W=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[a]:{...n,api:s}}}}),e);exports.m=W;const z=(e,t)=>([...j,...t.game.plugins,D].reverse().forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}};if(r.flush){const a=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}else if(r.dangerouslyFlushRawState){const s=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[a].data;e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}}),e),K=(e,t)=>[...F,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const a=r.name,n=e.plugins[a];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=K;const Y=(e,t)=>{return[...F,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:a}=r,n=e.plugins[a],s=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!s&&{plugin:a,message:s}}).find(e=>e)||!1},J=(e,t)=>{const r=z(e,t),a=Y(r,t);if(!a)return[r];const{plugin:n,message:s}=a;return B(`${n} plugin declared action invalid:\\n${s}`),[e,a]};exports.q=J;const Q=({G:e,ctx:t,plugins:r={}},{game:a,playerID:n})=>([...F,...a.plugins].forEach(({name:s,playerView:o})=>{if(!o)return;const{data:i}=r[s]||{data:{}},l=o({G:e,ctx:t,game:a,data:i,playerID:n});r={...r,[s]:{data:l}}}),r);function X(e,t=!1){e.moveLimit&&(t&&(e.minMoves=e.moveLimit),e.maxMoves=e.moveLimit,delete e.moveLimit)}function Z(e,t){let r={},a=[],n=null,s={},o={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=oe.NULL),r=e}else{if(X(t),t.next&&(n=t.next),t.revert&&(a=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMinMoves:e._activePlayersMinMoves,_activePlayersMaxMoves:e._activePlayersMaxMoves,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&te(r,s,o,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let a=0;a<e.playOrder.length;a++){const n=e.playOrder[a];n!==e.currentPlayer&&te(r,s,o,n,t.others)}if(void 0!==t.all)for(let a=0;a<e.playOrder.length;a++){te(r,s,o,e.playOrder[a],t.all)}if(t.value)for(const e in t.value)te(r,s,o,e,t.value[e]);if(t.minMoves)for(const e in r)void 0===s[e]&&(s[e]=t.minMoves);if(t.maxMoves)for(const e in r)void 0===o[e]&&(o[e]=t.maxMoves)}0===Object.keys(r).length&&(r=null),0===Object.keys(s).length&&(s=null),0===Object.keys(o).length&&(o=null);const i={};for(const l in r)i[l]=0;return{...e,activePlayers:r,_activePlayersMinMoves:s,_activePlayersMaxMoves:o,_activePlayersNumMoves:i,_prevActivePlayers:a,_nextActivePlayers:n}}function ee(e){let{activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s,_nextActivePlayers:o}=e;if(t&&0===Object.keys(t).length)if(o)e=Z(e,o),({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}=e);else if(s.length>0){const e=s.length-1;({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n}=s[e]),s=s.slice(0,e)}else t=null,r=null,a=null;return{...e,activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}}function te(e,t,r,a,n){\"object\"==typeof n&&n!==oe.NULL||(n={stage:n}),void 0!==n.stage&&(X(n),e[a]=n.stage,n.minMoves&&(t[a]=n.minMoves),n.maxMoves&&(r[a]=n.maxMoves))}function re(e,t){return e[t]+\"\"}function ae(e,t){let{G:r,ctx:a}=e;const{numPlayers:n}=a,s=V(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,s));const l=o.first(r,s),p=typeof l;\"number\"!==p&&B(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=re(i,l);return a=Z(a={...a,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function ne(e,t,r,a){const n=r.order;let{G:s,ctx:o}=e,i=o.playOrderPos,l=!1;if(a&&!0!==a)\"object\"!=typeof a&&B(`invalid argument to endTurn: ${a}`),Object.keys(a).forEach(e=>{switch(e){case\"remove\":t=re(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(a.next),t=a.next;break;default:B(`invalid argument to endTurn: ${e}`)}});else{const r=V(e),a=n.next(s,r),p=typeof a;void 0!==a&&\"number\"!==p&&B(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${a}”.`),void 0===a?l=!0:(i=a,t=re(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.x=Q;const se={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=se;const oe={NULL:null};exports.S=oe;const ie={ALL:{all:oe.NULL},ALL_ONCE:{all:oe.NULL,minMoves:1,maxMoves:1},OTHERS:{others:oe.NULL},OTHERS_ONCE:{others:oe.NULL,minMoves:1,maxMoves:1}};exports.C=ie;\n},{\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)e=o,\"__proto__\"!=(n=this.tokens[r])&&\"constructor\"!=n&&\"prototype\"!=n&&(o=(e||{})[n]);return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"iEGk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=g,exports.I=i,exports.P=s,exports.T=void 0;var e,t,n=require(\"./turn-order-0b7dce3d.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:s,plugins:i}){void 0===e&&(e={}),void 0===s&&(s={}),void 0===i&&(i=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const c={...t};\"\"in c&&(0,n.e)(\"cannot specify phase with empty name\"),c[\"\"]={};const u={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,i);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const B in c){const e=c[B];if(!0===e.start&&(d=B),void 0!==e.moves)for(const t of Object.keys(e.moves))u[B+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={}),(0,n.a)(e.turn,!0);for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){u[B+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?c[e.phase]:c[\"\"]}function g(e){return e}function m(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:s,...i}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const c=[];if(e=o(e,{...i,arg:s,next:c}),o===w)break;const u=G(e);if(u){t.push({fn:w,arg:u,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([g,M,D].includes(o)){const n=b(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...c)}}return e}function x(e,{next:t}){return t.push({fn:h}),e}function h(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.b)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const s=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:s,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:s}=e;if(t&&t.next){if(!(t.next in c))return(0,n.e)(\"invalid phase: \"+t.next),e;s={...s,phase:t.next}}else s={...s,phase:o.wrapped.next(e)||null};return e={...e,ctx:s},a.push({fn:h}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:s}=e;const i=y(s),{endPhase:c,ctx:u}=(0,n.U)(e,a,i.turn,t);return s=u,e={...e,G:o,ctx:s},c?r.push({fn:N,turn:s.turn,phase:s.phase}):r.push({fn:I,currentPlayer:s.currentPlayer}),e}function M(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.S.NULL||(t={stage:t}),\"object\"!=typeof t)return e;(0,n.a)(t);let{ctx:r}=e,{activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,c[a]=0,t.minMoves&&(null===s&&(s={}),s[a]=t.minMoves),t.maxMoves&&(null===i&&(i={}),i[a]=t.maxMoves)),r={...r,activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c},{...e,ctx:r}}function D(e,{arg:t}){return{...e,ctx:(0,n.b)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function b(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.maxMoves&&n>=t.turn.maxMoves)||t.turn.wrapped.endIf(e)}function w(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:s,turn:i}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:s}),null===s)return e;const c=y(e.ctx).wrapped.onEnd(e),u={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:i,phase:s};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:c,ctx:u,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:s,playerID:i}){if(r!==e.ctx.turn)return e;const{currentPlayer:c,numMoves:u,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=u||0;if(!o&&p.turn.minMoves&&v<p.turn.minMoves)return(0,n.i)(`cannot end turn before making ${p.turn.minMoves} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:c});let g={...e.ctx,activePlayers:null};if(t&&t.remove){i=i||c;const t=g.playOrder.filter(e=>e!=i),n=g.playOrderPos>t.length-1?0:g.playOrderPos;if(g={...g,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const m=(0,n.g)(\"endTurn\",t),{_stateID:x}=e,h={action:m,_stateID:x,turn:d,phase:l};s&&(h.automatic=!0);const I=[...e.deltalog||[],h];return{...e,G:f,ctx:g,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:s,_stateID:i}=e,{activePlayers:c,_activePlayersNumMoves:u,_activePlayersMinMoves:l,_activePlayersMaxMoves:d,phase:p,turn:v}=s;const f=null!==c&&o in c,g=y(s);if(!t&&f){const e=g.turn.stages[c[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:M,arg:t,playerID:o}),!f)return e;const m=u[o]||0;if(l&&l[o]&&m<l[o])return(0,n.i)(`cannot end stage before making ${l[o]} moves`),e;delete(c={...c})[o],l&&delete(l={...l})[o],d&&delete(d={...d})[o],s=(0,n.c)({...s,activePlayers:c,_activePlayersMinMoves:l,_activePlayersMaxMoves:d});const x={action:(0,n.g)(\"endStage\",t),_stateID:i,turn:v,phase:p};r&&(x.automatic=!0);const h=[...e.deltalog||[],x];return{...e,ctx:s,deltalog:h}}function S(t,a,r){const o=y(t),s=o.turn.stages,{activePlayers:i}=t;if(i&&void 0!==i[r]&&i[r]!==n.S.NULL&&void 0!==s[i[r]]&&void 0!==s[i[r]].moves){const e=s[i[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const U={endStage:function(e,t){return m(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return m(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return m(e,[{fn:w,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return m(e,[{fn:D,arg:n}])}},T=[];return!1!==s.endTurn&&T.push(\"endTurn\"),!1!==s.pass&&T.push(\"pass\"),!1!==s.endPhase&&T.push(\"endPhase\"),!1!==s.setPhase&&T.push(\"setPhase\"),!1!==s.endGame&&T.push(\"endGame\"),!1!==s.setActivePlayers&&T.push(\"setActivePlayers\"),!1!==s.endStage&&T.push(\"endStage\"),!1!==s.setStage&&T.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>m(e,[{fn:x}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:U,eventNames:Object.keys(U),enabledEventNames:T,moveMap:u,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{currentPlayer:r,activePlayers:o,_activePlayersMaxMoves:s}=e.ctx,i=S(e.ctx,a,n),c=!i||\"function\"==typeof i||!0!==i.noLimit;let{numMoves:u,_activePlayersNumMoves:l}=e.ctx;c&&(n===r&&u++,o&&l[n]++),e={...e,ctx:{...e.ctx,numMoves:u,_activePlayersNumMoves:l}},s&&l[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const d=y(e.ctx).turn.wrapped.onMove({...e,ctx:{...e.ctx,playerID:n}});return m(e={...e,G:d},[{fn:g}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof U[n]?e:U[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function s(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(i(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),s={...(0,n.E)(a),playerID:r.playerID};let i=[];return void 0!==r.args&&(i=Array.isArray(r.args)?r.args:[r.args]),t(a.G,s,...i)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function i(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const c=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,u=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,s]=(0,n.q)(e,r);return s?[o,f(a,t.PluginActionInvalid,s)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.p:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.r)()),{...r,transients:t}):r}}};function g({game:r,isClient:o}){return r=s(r),(s=null,i)=>{let[y]=v(s);switch(i.type){case n.p:return y;case n.o:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed event: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:!1,playerID:i.payload.playerID});let e,a=r.flow.processEvent(y,i);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:i}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,i.payload.type,i.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:o,playerID:i.payload.playerID});const s=r.processMove(y,i.payload);if(s===n.n)return(0,n.e)(`invalid move: ${i.payload.type} args: ${i.payload.args}`),f(y,t.InvalidMove);const u={...y,G:s};if(o&&(0,n.N)(u,{game:r}))return y;if(y=u,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,i,a),y=r.flow.processMove(y,i.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:i}),{...y,_stateID:y._stateID+1})}case n.l:case n.k:case n.j:return i.state;case n.h:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:s,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(c(i)&&i.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!u(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,i),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...s]}}case n.R:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const s=a[0];return c(i)&&i.payload.playerID!==s.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,i),{...y,G:s.G,ctx:s.ctx,plugins:s.plugins,_stateID:o+1,_undo:[...e,s],_redo:a.slice(1)})}case n.d:return(0,n.f)(y,i,{game:r});case n.P:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,i.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(i.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"lU15\":[function(require,module,exports) {\nvar global = arguments[3];\nvar process = require(\"process\");\nvar e=arguments[3],t=require(\"process\");!function(e,n){\"use strict\";if(!e.setImmediate){var a,s,o,c,i,r=1,f={},u=!1,l=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,\"[object process]\"==={}.toString.call(e.process)?a=function(e){t.nextTick(function(){m(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(\"\",\"*\"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},a=function(e){o.port2.postMessage(e)}):l&&\"onreadystatechange\"in l.createElement(\"script\")?(s=l.documentElement,a=function(e){var t=l.createElement(\"script\");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):a=function(e){setTimeout(m,0,e)}:(c=\"setImmediate$\"+Math.random()+\"$\",i=function(t){t.source===e&&\"string\"==typeof t.data&&0===t.data.indexOf(c)&&m(+t.data.slice(c.length))},e.addEventListener?e.addEventListener(\"message\",i,!1):e.attachEvent(\"onmessage\",i),a=function(t){e.postMessage(c+t,\"*\")}),d.setImmediate=function(e){\"function\"!=typeof e&&(e=new Function(\"\"+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var s={callback:e,args:t};return f[r]=s,a(r),r++},d.clearImmediate=g}function g(e){delete f[e]}function m(e){if(u)setTimeout(m,0,e);else{var t=f[e];if(t){u=!0;try{!function(e){var t=e.callback,a=e.args;switch(a.length){case 0:t();break;case 1:t(a[0]);break;case 2:t(a[0],a[1]);break;case 3:t(a[0],a[1],a[2]);break;default:t.apply(n,a)}}(t)}finally{g(e),u=!1}}}}}(\"undefined\"==typeof self?void 0===e?this:e:self);\n},{\"process\":\"pBGv\"}],\"pO2S\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=o,exports.a=c,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./plugin-random-087f861e.js\"),r=require(\"./reducer-07c7b307.js\");require(\"setimmediate\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:r}){this._opts[t]={range:e,value:r}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,r,a){return this.enumerateFn(e,r,a).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.B)(e.move,e.args,a):\"event\"in e?(0,t.g)(e.event,e.args,a):void 0)}random(t){let r;if(void 0!==this.seed){const t=this.prngstate?\"\":this.seed,a=(0,e.a)(t,this.prngstate);r=a(),this.prngstate=a.state()}else r=Math.random();if(t){if(Array.isArray(t)){return t[Math.floor(r*t.length)]}return Math.floor(r*t)}return r}}exports.B=a;const s=25;class i extends a{constructor({enumerate:t,seed:e,objectives:a,game:s,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:e}),void 0===a&&(a=(()=>({}))),this.objectives=a,this.iterationCallback=o||(()=>{}),this.reducer=(0,r.C)({game:s}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:r,playerID:a}){const{G:s,ctx:i}=t;let n=[],o=[];if(void 0!==a)n=this.enumerate(s,i,a),o=this.objectives(s,i,a);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(s,i,c)),o.push(this.objectives(s,i,c));else n=this.enumerate(s,i,i.currentPlayer),o=this.objectives(s,i,i.currentPlayer);return{state:t,parent:r,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,r=0;for(const a of t.children){const s=a.visits+Number.EPSILON,i=a.value/s+Math.sqrt(2*Math.log(t.visits)/s);(null==e||i>r)&&(r=i,e=a)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const r=this.random(e.length),a=e[r];t.actions.splice(r,1);const s=this.reducer(t.state,a),i=this.createNode({state:s,parentAction:a,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let r=0;r<e&&void 0===t.ctx.gameover;r++){const{G:e,ctx:r}=t;let a=r.currentPlayer;r.activePlayers&&(a=Object.keys(r.activePlayers)[0]);const s=this.enumerate(e,r,a),i=this.objectives(e,r,a),n=Object.keys(i).reduce((t,a)=>{const s=i[a];return s.checker(e,r)?t+s.weight:t},0);if(n>0)return{score:n};if(!s||0===s.length)return;const o=this.random(s.length);t=this.reducer(t,s[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const r=this.createNode({state:t,playerID:e});let a=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(a=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of r.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:r}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<a;t++){const t=this.select(r),e=this.expand(t),a=this.playout(e);this.backpropagate(e,a),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:a,metadata:r})};if(this.iterationCounter=0,this.getOpt(\"async\")){const r=()=>{this.iterationCounter<a?(e(),setImmediate(r)):t(i())};r()}else{for(;this.iterationCounter<a;)e();t(i())}})}}exports.M=i;class n extends a{play({G:t,ctx:e},r){const a=this.enumerate(t,e,r);return Promise.resolve({action:this.random(a)})}}async function o(t,e){const r=t.store.getState();let a=r.ctx.currentPlayer;r.ctx.activePlayers&&(a=Object.keys(r.ctx.activePlayers)[0]);const{action:s,metadata:i}=await e.play(r,a);if(s){const e={...s,payload:{...s.payload,metadata:i}};return t.store.dispatch(e),e}}async function c({game:t,bots:e,state:s,depth:i}){void 0===i&&(i=1e4);const n=(0,r.C)({game:t});let o=null,c=0;for(;void 0===s.ctx.gameover&&c<i;){let t=s.ctx.currentPlayer;s.ctx.activePlayers&&(t=Object.keys(s.ctx.activePlayers)[0]);const r=e instanceof a?e:e[t],i=await r.play(s,t);if(!i.action)break;o=i.metadata,s=n(s,i.action),c++}return{state:s,metadata:o}}exports.R=n;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./plugin-random-087f861e.js\":\"Sn21\",\"./reducer-07c7b307.js\":\"iEGk\",\"setimmediate\":\"lU15\"}],\"uvSB\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\"),n=require(\"flatted\"),r=require(\"./ai-3099ce9a.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function W(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function X(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const Y=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);Y.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(Y.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Y.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=X(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(X(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function We(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Xe(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function Ye(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},Ye)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1xg9v5h\",\".menu.svelte-1xg9v5h{display:flex;margin-top:43px;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;margin-right:-500px;transform-origin:bottom right;transform:rotate(-90deg) translate(0, -500px)}.menu-item.svelte-1xg9v5h{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1xg9v5h:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1xg9v5h:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1xg9v5h{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1xg9v5h:hover,.menu-item.svelte-1xg9v5h:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1xg9v5h\"),W(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&W(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1xg9v5h\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),W(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&W(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),W(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&W(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&W(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&W(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Wt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Xt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Yt,Xt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),W(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&W(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&W(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&W(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Wt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Wn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Xn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),W(t,\"current\",e[7]==e[0].currentPlayer),W(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&W(t,\"current\",e[7]==e[0].currentPlayer),6&o&&W(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Yn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Xn(Wn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Wn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Xn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Yn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){if(t&&(\"object\"==typeof t||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return pr(e)}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t,{ToggleVisibility:c}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager),\"ToggleVisibility\"in e&&n(3,c=e.ToggleVisibility)}),[s,r,i,c]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2,ToggleVisibility:3},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Wr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Xr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Yr,Xr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),W(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&W(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Wr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),W(t,\"clickable\",e[1].length>0),W(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&W(t,\"clickable\",e[1].length>0),1&l&&W(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),W(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&W(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[6]=t[n][0],r[7]=t[n][1],r[8]=t,r[9]=n,r}function Bl(e){let t,n,r,l;function o(){e[5].call(t,e[6])}return{c(){G(t=M(\"input\"),\"id\",n=e[3](e[6])),G(t,\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(n,a){q(n,t,a),t.checked=e[1][e[6]],r||(l=[R(t,\"change\",o),R(t,\"change\",e[2])],r=!0)},p(r,l){e=r,1&l&&n!==(n=e[3](e[6]))&&G(t,\"id\",n),3&l&&(t.checked=e[1][e[6]])},d(e){e&&I(t),r=!1,c(l)}}}function Rl(e){let t,n,r,l,o,a,s,i,u,d=e[1][e[6]]+\"\";function f(){e[4].call(l,e[6])}return{c(){t=M(\"span\"),n=N(d),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"id\",o=e[3](e[6])),G(l,\"type\",\"range\"),G(l,\"min\",a=e[7].range.min),G(l,\"max\",s=e[7].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[6]]),i||(u=[R(l,\"change\",f),R(l,\"input\",f),R(l,\"change\",e[2])],i=!0)},p(t,r){e=t,3&r&&d!==(d=e[1][e[6]]+\"\")&&F(n,d),1&r&&o!==(o=e[3](e[6]))&&G(l,\"id\",o),1&r&&a!==(a=e[7].range.min)&&G(l,\"min\",a),1&r&&s!==(s=e[7].range.max)&&G(l,\"max\",s),3&r&&H(l,e[1][e[6]])},d(e){e&&I(t),e&&I(r),e&&I(l),i=!1,c(u)}}}function Kl(e){let t,n,r,l,o,a,s=e[6]+\"\";function i(e,t){return e[7].range?Rl:\"boolean\"==typeof e[7].value?Bl:void 0}let c=i(e),u=c&&c(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),o=V(),u&&u.c(),a=V(),G(n,\"for\",l=e[3](e[6])),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),u&&u.m(t,null),A(t,a)},p(e,o){1&o&&s!==(s=e[6]+\"\")&&F(r,s),1&o&&l!==(l=e[3](e[6]))&&G(n,\"for\",l),c===(c=i(e))&&u?u.p(e,o):(u&&u.d(1),(u=c&&c(e))&&(u.c(),u.m(t,a)))},d(e){e&&I(t),u&&u.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(15&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},e=>\"ai-option-\"+e,function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Xl(Hl(e,E,c));let z=j&&Yl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[17].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[17]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Xl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Yl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Xl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Yl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"for\",\"ai-option-debug\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"id\",\"ai-option-debug\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[18]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Wl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t,{ToggleVisibility:a}=t;const{secondaryPane:s}=de(\"secondaryPane\"),i={MCTS:r.M,Random:r.R};let c=!1,u=null,d=0,f=null;const p=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,d=e),n(2,u=e/t),f=r,c&&f&&s.set({component:jl,metadata:f})};let m,g,v,$;function y(){l.overrideGameState(null),s.set(null),n(1,c=!1)}return l.game.ai&&(m=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})).setOpt(\"async\",!0),ie(y),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager),\"ToggleVisibility\"in e&&n(16,a=e.ToggleVisibility)}),[l,c,u,d,g,v,$,m,i,function(){c&&f?s.set({component:jl,metadata:f}):s.set(null)},function(){const e=i[g];n(7,m=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})),m.setOpt(\"async\",!0),n(5,v=null),f=null,s.set(null),n(3,d=0)},async function(){n(5,v=null),f=null,n(3,d=0);const e=await(0,r.S)(l,m);e&&(n(5,v=e.payload.type),n(6,$=e.payload.args))},function(e=1e4,t=100){return n(5,v=null),f=null,n(3,d=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,m);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,v=null),f=null,n(3,d=0),y()},function(e){27==e.keyCode&&y()},o,a,function(){g=U(this),n(4,g),n(8,i)},function(){c=this.checked,n(1,c)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15,ToggleVisibility:16},Fl)}}function oo(e){z(e,\"svelte-8ymctk\",\".debug-panel.svelte-8ymctk.svelte-8ymctk{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-8ymctk.svelte-8ymctk{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-8ymctk.svelte-8ymctk{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-8ymctk.svelte-8ymctk:hover,.visibility-toggle.svelte-8ymctk.svelte-8ymctk:focus{background:#eee}.opener.svelte-8ymctk.svelte-8ymctk{right:10px}.closer.svelte-8ymctk.svelte-8ymctk{left:-326px}@keyframes svelte-8ymctk-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-8ymctk.svelte-8ymctk{display:flex;height:100%;animation:svelte-8ymctk-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-8ymctk .icon.svelte-8ymctk{animation-direction:reverse}.pane.svelte-8ymctk.svelte-8ymctk{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-8ymctk.svelte-8ymctk{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-8ymctk button,.debug-panel.svelte-8ymctk select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-8ymctk select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-8ymctk section{margin-bottom:20px}.debug-panel.svelte-8ymctk .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u=e[10]&&io(e);(r=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var d=e[6][e[2]].component;function f(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}d&&(a=new d(f(e)));let p=e[5]&&co(e);return{c(){t=M(\"div\"),u&&u.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"div\"),a&&Be(a.$$.fragment),s=V(),p&&p.c(),G(o,\"class\",\"pane svelte-8ymctk\"),G(o,\"role\",\"region\"),G(o,\"aria-label\",e[2]),G(o,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-8ymctk\")},m(i,d){q(i,t,d),u&&u.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),a&&Re(a,o,null),e[16](o),A(t,s),p&&p.m(t,null),c=!0},p(n,l){(e=n)[10]&&u.p(e,l);const s={};4&l&&(s.pane=e[2]),r.$set(s);const i={};if(16&l&&(i.client=e[4]),1&l&&(i.clientManager=e[0]),d!==(d=e[6][e[2]].component)){if(a){_e();const e=a;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}d?(Be((a=new d(f(e))).$$.fragment),Ce(a.$$.fragment,1),Re(a,o,null)):a=null}else d&&a.$set(i);(!c||4&l)&&G(o,\"aria-label\",e[2]),e[5]?p?(p.p(e,l),32&l&&Ce(p,1)):((p=co(e)).c(),Ce(p,1),p.m(t,null)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se())},i(n){c||(Ce(u),Ce(r.$$.fragment,n),a&&Ce(a.$$.fragment,n),Ce(p),be(()=>{i||(i=De(t,We,{x:400,...e[12]},!0)),i.run(1)}),c=!0)},o(n){qe(u),qe(r.$$.fragment,n),a&&qe(a.$$.fragment,n),qe(p),i||(i=De(t,We,{x:400,...e[12]},!1)),i.run(0),c=!1},d(n){n&&I(t),u&&u.d(),Ke(r),a&&Ke(a),e[16](null),p&&p.d(),n&&i&&i.end()}}}function so(e){let t,n,r=e[10]&&uo(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,t){e[10]&&r.p(e,t)},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function io(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle closer svelte-8ymctk\"),G(t,\"title\",\"Hide Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function co(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-8ymctk\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function uo(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-8ymctk\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function fo(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-8ymctk\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[11]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function po(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(15,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,h=!h)}const y=o.client.debugOpt;let h=!y||!y.collapseOnLoad;const b=!y||!y.hideToggleButton;const x={duration:150,easing:Ze},[w,k]=Xe(x);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{32768&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,h,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,b,function(e){\".\"!=e.key?h&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},x,w,k,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class mo extends Le{constructor(e){super(),Je(this,e,po,fo,d,{clientManager:0},oo)}}exports.D=mo;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"flatted\":\"O5av\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"Wibm\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.t)(n,{game:r}),n=(0,e.m)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.q)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\"}],\"zA0v\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class t{constructor({transportDataCallback:t,gameName:a,playerID:s,matchID:e,credentials:n,numPlayers:i}){this.connectionStatusCallback=(()=>{}),this.isConnected=!1,this.transportDataCallback=t,this.gameName=a||\"default\",this.playerID=s||null,this.matchID=e||\"default\",this.credentials=n,this.numPlayers=i||2}subscribeToConnectionStatus(t){this.connectionStatusCallback=t}setConnectionStatus(t){this.isConnected=t,this.connectionStatusCallback()}notifyClient(t){this.transportDataCallback(t)}}exports.T=t;\n},{}],\"FkTq\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid/non-secure\"),e=require(\"./Debug-fd09b8bc.js\"),s=require(\"redux\"),i=require(\"./turn-order-0b7dce3d.js\"),r=require(\"./reducer-07c7b307.js\"),a=require(\"./initialize-9ac1bbf5.js\"),n=require(\"./transport-ce07b771.js\");class h extends n.T{connect(){}disconnect(){}sendAction(){}sendChatMessage(){}requestSync(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const c=t=>new h(t);class l{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const u=new l;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const c of e)h[c]=((...e)=>{const h=i.A[t](c,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:l,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g||\"default\",this.credentials=d,this.multiplayer=l,this.debugOpt=n,this.manager=u,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==l}),this.initialState=null,l||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.u)(this.initialState))}),this.undo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.w)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.p||this.transport.sendAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.o:case i.h:case i.R:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.l:this.log=[];break;case i.P:case i.k:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.j:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),l||(l=c),this.transport=l({transportDataCallback:t=>this.receiveTransportData(t),gameKey:e,game:this.game,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.sendChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})})}receiveMatchData(t){this.matchData=t,this.notifySubscribers()}receiveChatMessage(t){this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()}receiveTransportData(t){const[e]=t.args;if(e===this.matchID)switch(t.type){case\"sync\":{const[,e]=t.args,s=(0,i.s)(e);this.receiveMatchData(e.filteredMetadata),this.store.dispatch(s);break}case\"update\":{const[,e,s]=t.args,r=this.store.getState();if(e._stateID>=r._stateID){const t=(0,i.z)(e,s);this.store.dispatch(t)}break}case\"patch\":{const[,e,s,r,a]=t.args,n=this.store.getState()._stateID;if(e!==n)break;const h=(0,i.y)(e,s,r,a);this.store.dispatch(h),this.store.getState()._stateID===n&&this.transport.requestSync();break}case\"matchData\":{const[,e]=t.args;this.receiveMatchData(e);break}case\"chat\":{const[,e]=t.args;this.receiveChatMessage(e);break}}}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribeToConnectionStatus(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.x)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\"}],\"mOPV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const e=(e,t)=>{if(!e||\"string\"!=typeof e)throw new Error(`Expected ${t} string, got \"${e}\".`)},t=t=>e(t,\"game name\"),s=t=>e(t,\"match ID\"),r=(e,t)=>{if(!e)throw new Error(`Expected body, got “${e}”.`);for(const s in t){const r=t[s],a=Array.isArray(r)?r:[r],n=e[s];if(!a.includes(typeof n)){const e=a.join(\"|\");throw new TypeError(`Expected body.${s} to be of type ${e}, got “${n}”.`)}}};class a extends Error{constructor(e,t){super(e),this.details=t}}exports.a=a;class n{constructor({server:e=\"\"}={}){this.server=e.replace(/\\/$/,\"\")}async request(e,t){const s=await fetch(this.server+e,t);if(!s.ok){let e;try{e=await s.clone().json()}catch{try{e=await s.text()}catch(r){e=r.message}}throw new a(`HTTP status ${s.status}`,e)}return s.json()}async post(e,t){let s={method:\"post\",body:JSON.stringify(t.body),headers:{\"Content-Type\":\"application/json\"}};return t.init&&(s={...s,...t.init,headers:{...s.headers,...t.init.headers}}),this.request(e,s)}async listGames(e){return this.request(\"/games\",e)}async listMatches(e,s,r){t(e);let a=\"\";if(s){const e=[],{isGameover:t,updatedBefore:r,updatedAfter:n}=s;void 0!==t&&e.push(`isGameover=${t}`),r&&e.push(`updatedBefore=${r}`),n&&e.push(`updatedAfter=${n}`),e.length>0&&(a=\"?\"+e.join(\"&\"))}return this.request(`/games/${e}${a}`,r)}async getMatch(e,r,a){return t(e),s(r),this.request(`/games/${e}/${r}`,a)}async createMatch(e,s,a){return t(e),r(s,{numPlayers:\"number\"}),this.post(`/games/${e}/create`,{body:s,init:a})}async joinMatch(e,a,n,i){return t(e),s(a),r(n,{playerID:[\"string\",\"undefined\"],playerName:\"string\"}),this.post(`/games/${e}/${a}/join`,{body:n,init:i})}async leaveMatch(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/leave`,{body:n,init:i})}async updatePlayer(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/update`,{body:n,init:i})}async playAgain(e,a,n,i){return t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${e}/${a}/playAgain`,{body:n,init:i})}}exports.L=n;\n},{}],\"L8uO\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"SAdv\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"L8uO\"}],\"PB2Y\":[function(require,module,exports) {\n\"use strict\";var _=\"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED\";module.exports=_;\n},{}],\"cTRg\":[function(require,module,exports) {\n\"use strict\";var e=require(\"./lib/ReactPropTypesSecret\");function r(){}function t(){}t.resetWarningCache=r,module.exports=function(){function n(r,t,n,o,a,p){if(p!==e){var c=new Error(\"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types\");throw c.name=\"Invariant Violation\",c}}function o(){return n}n.isRequired=n;var a={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:o,element:n,elementType:n,instanceOf:o,node:n,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:t,resetWarningCache:r};return a.PropTypes=a,a};\n},{\"./lib/ReactPropTypesSecret\":\"PB2Y\"}],\"yu5W\":[function(require,module,exports) {\nvar r,e;module.exports=require(\"./factoryWithThrowingShims\")();\n},{\"./factoryWithThrowingShims\":\"cTRg\"}],\"KAZ5\":[function(require,module,exports) {\n\"use strict\";exports.parse=n,exports.serialize=o;var e=decodeURIComponent,t=encodeURIComponent,r=/; */,i=/^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;function n(t,i){if(\"string\"!=typeof t)throw new TypeError(\"argument str must be a string\");for(var n={},o=i||{},s=t.split(r),p=o.decode||e,f=0;f<s.length;f++){var u=s[f],m=u.indexOf(\"=\");if(!(m<0)){var c=u.substr(0,m).trim(),l=u.substr(++m,u.length).trim();'\"'==l[0]&&(l=l.slice(1,-1)),null==n[c]&&(n[c]=a(l,p))}}return n}function o(e,r,n){var o=n||{},a=o.encode||t;if(\"function\"!=typeof a)throw new TypeError(\"option encode is invalid\");if(!i.test(e))throw new TypeError(\"argument name is invalid\");var s=a(r);if(s&&!i.test(s))throw new TypeError(\"argument val is invalid\");var p=e+\"=\"+s;if(null!=o.maxAge){var f=o.maxAge-0;if(isNaN(f))throw new Error(\"maxAge should be a Number\");p+=\"; Max-Age=\"+Math.floor(f)}if(o.domain){if(!i.test(o.domain))throw new TypeError(\"option domain is invalid\");p+=\"; Domain=\"+o.domain}if(o.path){if(!i.test(o.path))throw new TypeError(\"option path is invalid\");p+=\"; Path=\"+o.path}if(o.expires){if(\"function\"!=typeof o.expires.toUTCString)throw new TypeError(\"option expires is invalid\");p+=\"; Expires=\"+o.expires.toUTCString()}if(o.httpOnly&&(p+=\"; HttpOnly\"),o.secure&&(p+=\"; Secure\"),o.sameSite)switch(\"string\"==typeof o.sameSite?o.sameSite.toLowerCase():o.sameSite){case!0:p+=\"; SameSite=Strict\";break;case\"lax\":p+=\"; SameSite=Lax\";break;case\"strict\":p+=\"; SameSite=Strict\";break;default:throw new TypeError(\"option sameSite is invalid\")}return p}function a(e,t){try{return t(e)}catch(r){return e}}\n},{}],\"kpSY\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");Object.defineProperty(exports,\"__esModule\",{value:!0});var o=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e};exports.load=f,exports.loadAll=l,exports.select=p,exports.save=y,exports.remove=v,exports.setRawCookie=k,exports.plugToRequest=m;var t=require(\"cookie\"),r=u(t),n=require(\"object-assign\"),i=u(n);function u(e){return e&&e.__esModule?e:{default:e}}var c=\"undefined\"==typeof document||void 0!==e&&e.env&&!1,a={},s=void 0;function d(){return s&&!s.headersSent}function f(e,o){var t=c?a:r.default.parse(document.cookie),n=t&&t[e];if(void 0===o&&(o=!n||\"{\"!==n[0]&&\"[\"!==n[0]),!o)try{n=JSON.parse(n)}catch(i){}return n}function l(e){var o=c?a:r.default.parse(document.cookie);if(void 0===e&&(e=!o||\"{\"!==o[0]&&\"[\"!==o[0]),!e)try{o=JSON.parse(o)}catch(t){}return o}function p(e){var o=c?a:r.default.parse(document.cookie);return o?e?Object.keys(o).reduce(function(t,r){if(!e.test(r))return t;var n={};return n[r]=o[r],(0,i.default)({},t,n)},{}):o:{}}function y(e,t,n){a[e]=t,\"object\"===(void 0===t?\"undefined\":o(t))&&(a[e]=JSON.stringify(t)),c||(document.cookie=r.default.serialize(e,a[e],n)),d()&&s.cookie&&s.cookie(e,t,n)}function v(e,o){delete a[e],o=void 0===o?{}:\"string\"==typeof o?{path:o}:(0,i.default)({},o),\"undefined\"!=typeof document&&(o.expires=new Date(1970,1,1,0,0,1),o.maxAge=0,document.cookie=r.default.serialize(e,\"\",o)),d()&&s.clearCookie&&s.clearCookie(e,o)}function k(e){a=e?r.default.parse(e):{}}function m(e,o){return e.cookie?a=e.cookie:e.cookies?a=e.cookies:e.headers&&e.headers.cookie?k(e.headers.cookie):a={},s=o,function(){s=null,a={}}}exports.default={setRawCookie:k,load:f,loadAll:l,select:p,save:y,remove:v,plugToRequest:m};\n},{\"cookie\":\"KAZ5\",\"object-assign\":\"J4Nk\",\"process\":\"pBGv\"}],\"pSNY\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=a,exports.c=exports.S=exports.A=void 0;var e,t=require(\"./initialize-9ac1bbf5.js\");function a(t){return t.type()===e.SYNC}!function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class s{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=s;class n{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=n;const o=({game:e,unlisted:t,setupData:a,numPlayers:s})=>{const n={gameName:e.name,unlisted:!!t,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==a&&(n.setupData=a);for(let o=0;o<s;o++)n.players[o]={id:o};return n},r=({game:e,numPlayers:a,setupData:s,unlisted:n})=>{a&&\"number\"==typeof a||(a=2);const r=e.validateSetupData&&e.validateSetupData(s,a);return void 0!==r?{setupDataError:r}:{metadata:o({game:e,numPlayers:a,setupData:s,unlisted:n}),initialState:(0,t.I)({game:e,numPlayers:a,setupData:s})}};exports.c=r;\n},{\"./initialize-9ac1bbf5.js\":\"Wibm\"}],\"gTRl\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./reducer-07c7b307.js\"),r=require(\"./util-b1699aa1.js\");const s=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),i=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class o{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(s,o,n,c){if(!s||!s.payload)return{error:\"missing action or action payload\"};let l;if((0,r.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(n,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:c,credentials:s.payload.credentials,metadata:l})))return{error:\"unauthorized action\"}}const d=i(s),h=n;let u;if((0,r.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${c}]`+` - action[${d.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),y=(0,t.createStore)(p,u,g);if(d.type==a.h||d.type==a.R){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===c;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[c]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${c}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,c))return void(0,a.e)(`player not active - playerID=[${c}]`+` - action[${d.payload.type}]`);const m=d.type==a.M?this.game.flow.getMove(u.ctx,d.payload.type,c):null;if(d.type==a.M&&!m)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${c}]`+` - action[${d.payload.type}]`);if(u._stateID!==o&&!(m&&(0,e.I)(m)&&m.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${o}], expected=[${u._stateID}]`+` - playerID=[${c}] - action[${d.payload.type}]`);const I=y.getState();y.dispatch(d),u=y.getState(),this.subscribeCallback({state:u,action:d,matchID:n}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[n,o,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[n,u]});const{deltalog:f,...P}=u;let A;if(!l||void 0!==l.gameover&&null!==l.gameover||(A={...l,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,r.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,i=2){const o=t,n={state:!0,metadata:!0,log:!0,initialState:!0},c=(0,r.i)(this.storageAPI)?this.storageAPI.fetch(o,n):await this.storageAPI.fetch(o,n);let{state:l,initialState:d,log:h,metadata:u}=c;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:u})))return{error:\"unauthorized\"}}if(void 0===l){const a=(0,r.c)({game:this.game,unlisted:!0,numPlayers:i,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};d=l=a.initialState,u=a.metadata,this.subscribeCallback({state:l,matchID:t}),(0,r.i)(this.storageAPI)?this.storageAPI.createMatch(o,{initialState:d,metadata:u}):await this.storageAPI.createMatch(o,{initialState:d,metadata:u})}const p={state:l,log:h,filteredMetadata:u?s(u):void 0,initialState:d};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,p]})}async onConnectionChange(t,e,i,o){const n=t;if(null==e)return;let c;if((0,r.i)(this.storageAPI)?({metadata:c}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:c}=await this.storageAPI.fetch(n,{metadata:!0})),void 0===c)return(0,a.e)(`metadata not found for matchID=[${n}]`),{error:\"metadata not found\"};if(void 0===c.players[e])return(0,a.e)(`Player not in the match, matchID=[${n}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:i,metadata:c})))return{error:\"unauthorized\"}}c.players[e].isConnected=o;const l=s(c);this.transportAPI.sendAll({type:\"matchData\",args:[t,l]}),(0,r.i)(this.storageAPI)?this.storageAPI.setMetadata(n,c):await this.storageAPI.setMetadata(n,c)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=o;\n},{\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./util-b1699aa1.js\":\"pSNY\"}],\"AbzV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.g=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"rfc6902\");const r=(t,r,a)=>({...a,G:t.playerView(a.G,a.ctx,r),plugins:(0,e.x)(a,{playerID:r,game:t}),deltalog:void 0,_undo:[],_redo:[]}),a=e=>(a,s)=>{switch(s.type){case\"patch\":{const[c,n,l,u]=s.args,d=o(u.deltalog,a),p=r(e,a,u),i=u._stateID,g=r(e,a,l);return{type:\"patch\",args:[c,n,i,(0,t.createPatch)(g,p),d]}}case\"update\":{const[t,c]=s.args,n=o(c.deltalog,a);return{type:\"update\",args:[t,r(e,a,c),n]}}case\"sync\":{const[t,c]=s.args,n=r(e,a,c.state),l=o(c.log,a);return{type:\"sync\",args:[t,{...c,state:n,log:l}]}}default:return s}};function o(e,t){return void 0===e?e:e.map(e=>{if(null!==t&&+t==+e.action.payload.playerID)return e;if(!0!==e.redact)return e;const r={...e.action.payload,args:null},a={...e,action:{...e.action,payload:r}},{redact:o,...s}=a;return s})}exports.g=a;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"UzxM\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=p,exports.S=g;var t=require(\"./transport-ce07b771.js\"),e=require(\"./util-b1699aa1.js\"),s=require(\"./master-be1abdd0.js\"),i=require(\"./filter-player-view-c30cdfbf.js\"),a=n(require(\"socket.io-client\"));function n(t){return t&&t.__esModule?t:{default:t}}class r extends e.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class c extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends r{constructor(t=\"bgio\"){super();const e=e=>new c(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}function h(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class l extends s.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const n={},c={};if(t&&t.ai&&e)for(const i in e){const s=e[i];c[i]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const l=({playerID:t,...e})=>{const s=n[t];void 0!==s&&s(u(t,e))},u=(0,i.g)(t),d={send:l,sendAll:t=>{for(const e in n)l({playerID:e,...t})}};super(t,a?new o(s):new r,d),this.connect=((t,e)=>{n[t]=e}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const i=h(t,c);null!==i&&setTimeout(async()=>{const e=await c[i].play(t,i);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class u extends t.T{constructor({master:t,...e}){super(e),this.master=t}sendChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}sendAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}requestSync(){this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}connect(){this.setConnectionStatus(!0),this.master.connect(this.playerID,t=>this.notifyClient(t)),this.requestSync()}disconnect(){this.setConnectionStatus(!1)}updateMatchID(t){this.matchID=t,this.connect()}updatePlayerID(t){this.playerID=t,this.connect()}updateCredentials(t){this.credentials=t,this.connect()}}const d=new Map;function p({bots:t,persist:e,storageKey:s}={}){return i=>{const{gameKey:a,game:n}=i;let r;const c=d.get(a);return c&&c.bots===t&&c.storageKey===s&&c.persist===e&&(r=c.master),r||(r=new l({game:n,bots:t,persist:e,storageKey:s}),d.set(a,{master:r,bots:t,persist:e,storageKey:s})),new u({master:r,...i})}}const m=a.default;class y extends t.T{constructor({socket:t,socketOpts:e,server:s,...i}){super(i),this.server=s,this.socket=t,this.socketOpts=e}sendAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}sendChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=m(t+this.gameName,this.socketOpts)}else this.socket=m(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(t,e,s,i,a)=>{this.notifyClient({type:\"patch\",args:[t,e,s,i,a]})}),this.socket.on(\"update\",(t,e,s)=>{this.notifyClient({type:\"update\",args:[t,e,s]})}),this.socket.on(\"sync\",(t,e)=>{this.notifyClient({type:\"sync\",args:[t,e]})}),this.socket.on(\"matchData\",(t,e)=>{this.notifyClient({type:\"matchData\",args:[t,e]})}),this.socket.on(\"chat\",(t,e)=>{this.notifyClient({type:\"chat\",args:[t,e]})}),this.socket.on(\"connect\",()=>{this.requestSync(),this.setConnectionStatus(!0)}),this.socket.on(\"disconnect\",()=>{this.setConnectionStatus(!1)})}disconnect(){this.socket.close(),this.socket=null,this.setConnectionStatus(!1)}requestSync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}updateMatchID(t){this.matchID=t,this.requestSync()}updatePlayerID(t){this.playerID=t,this.requestSync()}updateCredentials(t){this.credentials=t,this.requestSync()}}function g({server:t,socketOpts:e}={}){return s=>new y({server:t,socketOpts:e,...s})}\n},{\"./transport-ce07b771.js\":\"zA0v\",\"./util-b1699aa1.js\":\"pSNY\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"PUvW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Client=o,exports.Lobby=void 0,require(\"nanoid/non-secure\"),require(\"./Debug-fd09b8bc.js\"),require(\"redux\"),require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"./initialize-9ac1bbf5.js\"),require(\"./transport-ce07b771.js\");var e=require(\"./client-fa36c03a.js\");require(\"flatted\"),require(\"setimmediate\");var t=require(\"./ai-3099ce9a.js\"),a=require(\"./client-5f57c3f2.js\"),s=c(require(\"react\")),r=c(require(\"prop-types\")),n=c(require(\"react-cookies\"));require(\"./util-b1699aa1.js\");var i,l=require(\"./socketio-e4fb268a.js\");function c(e){return e&&e.__esModule?e:{default:e}}function o(t){var a;const{game:n,numPlayers:i,board:l,multiplayer:c,enhancer:o}=t;let{loading:h,debug:m}=t;if(void 0===h){h=(()=>s.default.createElement(\"div\",{className:\"bgio-loading\"},\"connecting...\"))}return(a=class extends s.default.Component{constructor(t){super(t),void 0===m&&(m=t.debug),this.client=(0,e.C)({game:n,debug:m,numPlayers:i,multiplayer:c,matchID:t.matchID,playerID:t.playerID,credentials:t.credentials,enhancer:o})}componentDidMount(){this.unsubscribe=this.client.subscribe(()=>this.forceUpdate()),this.client.start()}componentWillUnmount(){this.client.stop(),this.unsubscribe()}componentDidUpdate(e){this.props.matchID!=e.matchID&&this.client.updateMatchID(this.props.matchID),this.props.playerID!=e.playerID&&this.client.updatePlayerID(this.props.playerID),this.props.credentials!=e.credentials&&this.client.updateCredentials(this.props.credentials)}render(){const e=this.client.getState();if(null===e)return s.default.createElement(h);let t=null;return l&&(t=s.default.createElement(l,{...e,...this.props,isMultiplayer:!!c,moves:this.client.moves,events:this.client.events,matchID:this.client.matchID,playerID:this.client.playerID,reset:this.client.reset,undo:this.client.undo,redo:this.client.redo,log:this.client.log,matchData:this.client.matchData,sendChatMessage:this.client.sendChatMessage,chatMessages:this.client.chatMessages})),s.default.createElement(\"div\",{className:\"bgio-client\"},t)}}).propTypes={matchID:r.default.string,playerID:r.default.string,credentials:r.default.string,debug:r.default.any},a.defaultProps={matchID:\"default\",playerID:null,credentials:null,debug:!0},a}require(\"./master-be1abdd0.js\"),require(\"./filter-player-view-c30cdfbf.js\"),require(\"socket.io-client\");class h{constructor({server:e,gameComponents:t,playerName:s,playerCredentials:r}){this.client=new a.L({server:e}),this.gameComponents=t,this.playerName=s||\"Visitor\",this.playerCredentials=r,this.matches=[]}async refresh(){try{this.matches=[];const t=await this.client.listGames();for(const e of t){if(!this._getGameComponents(e))continue;const{matches:t}=await this.client.listMatches(e);this.matches.push(...t)}}catch(e){throw new Error(\"failed to retrieve list of matches (\"+e+\")\")}}_getMatchInstance(e){for(const t of this.matches)if(t.matchID===e)return t}_getGameComponents(e){for(const t of this.gameComponents)if(t.game.name===e)return t}_findPlayer(e){for(const t of this.matches)if(t.players.some(t=>t.name===e))return t}async join(e,t,a){try{let r=this._findPlayer(this.playerName);if(r)throw new Error(\"player has already joined \"+r.matchID);if(!(r=this._getMatchInstance(t)))throw new Error(\"game instance \"+t+\" not found\");const n=await this.client.joinMatch(e,t,{playerID:a,playerName:this.playerName});r.players[Number.parseInt(a)].name=this.playerName,this.playerCredentials=n.playerCredentials}catch(s){throw new Error(\"failed to join match \"+t+\" (\"+s+\")\")}}async leave(e,t){try{const s=this._getMatchInstance(t);if(!s)throw new Error(\"match instance not found\");for(const a of s.players)if(a.name===this.playerName)return await this.client.leaveMatch(e,t,{playerID:a.id.toString(),credentials:this.playerCredentials}),delete a.name,void delete this.playerCredentials;throw new Error(\"player not found in match\")}catch(a){throw new Error(\"failed to leave match \"+t+\" (\"+a+\")\")}}async disconnect(){const e=this._findPlayer(this.playerName);e&&await this.leave(e.gameName,e.matchID),this.matches=[],this.playerName=\"Visitor\"}async create(e,t){try{const s=this._getGameComponents(e);if(!s)throw new Error(\"game not found\");if(t<s.game.minPlayers||t>s.game.maxPlayers)throw new Error(\"invalid number of players \"+t);await this.client.createMatch(e,{numPlayers:t})}catch(a){throw new Error(\"failed to create match for \"+e+\" (\"+a+\")\")}}}function m(e){return new h(e)}class u extends s.default.Component{constructor(){super(...arguments),this.state={playerName:this.props.playerName,nameErrorMsg:\"\"},this.onClickEnter=(()=>{\"\"!==this.state.playerName&&this.props.onEnter(this.state.playerName)}),this.onKeyPress=(e=>{\"Enter\"===e.key&&this.onClickEnter()}),this.onChangePlayerName=(e=>{const t=e.target.value.trim();this.setState({playerName:t,nameErrorMsg:t.length>0?\"\":\"empty player name\"})})}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"p\",{className:\"phase-title\"},\"Choose a player name:\"),s.default.createElement(\"input\",{type:\"text\",value:this.state.playerName,onChange:this.onChangePlayerName,onKeyPress:this.onKeyPress}),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{className:\"buttons\",onClick:this.onClickEnter},\"Enter\")),s.default.createElement(\"br\",null),s.default.createElement(\"span\",{className:\"error-msg\"},this.state.nameErrorMsg,s.default.createElement(\"br\",null)))}}u.defaultProps={playerName:\"\"};class p extends s.default.Component{constructor(){super(...arguments),this._createSeat=(e=>e.name||\"[free]\"),this._createButtonJoin=((e,t)=>s.default.createElement(\"button\",{key:\"button-join-\"+e.matchID,onClick:()=>this.props.onClickJoin(e.gameName,e.matchID,\"\"+t)},\"Join\")),this._createButtonLeave=(e=>s.default.createElement(\"button\",{key:\"button-leave-\"+e.matchID,onClick:()=>this.props.onClickLeave(e.gameName,e.matchID)},\"Leave\")),this._createButtonPlay=((e,t)=>s.default.createElement(\"button\",{key:\"button-play-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,playerID:\"\"+t,numPlayers:e.players.length})},\"Play\")),this._createButtonSpectate=(e=>s.default.createElement(\"button\",{key:\"button-spectate-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,numPlayers:e.players.length})},\"Spectate\")),this._createInstanceButtons=(e=>{const t=e.players.find(e=>e.name===this.props.playerName),a=e.players.find(e=>!e.name);return t&&a?this._createButtonLeave(e):a?this._createButtonJoin(e,a.id):t?s.default.createElement(\"div\",null,[this._createButtonPlay(e,t.id),this._createButtonLeave(e)]):this._createButtonSpectate(e)})}render(){const e=this.props.match;let t=\"OPEN\";return e.players.some(e=>!e.name)||(t=\"RUNNING\"),s.default.createElement(\"tr\",{key:\"line-\"+e.matchID},s.default.createElement(\"td\",{key:\"cell-name-\"+e.matchID},e.gameName),s.default.createElement(\"td\",{key:\"cell-status-\"+e.matchID},t),s.default.createElement(\"td\",{key:\"cell-seats-\"+e.matchID},e.players.map(e=>this._createSeat(e)).join(\", \")),s.default.createElement(\"td\",{key:\"cell-buttons-\"+e.matchID},this._createInstanceButtons(e)))}}class d extends s.default.Component{constructor(e){super(e),this.state={selectedGame:0,numPlayers:2},this._createGameNameOption=((e,t)=>s.default.createElement(\"option\",{key:\"name-option-\"+t,value:t},e.game.name)),this._createNumPlayersOption=(e=>s.default.createElement(\"option\",{key:\"num-option-\"+e,value:e},e)),this._createNumPlayersRange=(e=>Array.from({length:e.maxPlayers+1}).map((e,t)=>t).slice(e.minPlayers)),this.onChangeNumPlayers=(e=>{this.setState({numPlayers:Number.parseInt(e.target.value)})}),this.onChangeSelectedGame=(e=>{const t=Number.parseInt(e.target.value);this.setState({selectedGame:t,numPlayers:this.props.games[t].game.minPlayers})}),this.onClickCreate=(()=>{this.props.createMatch(this.props.games[this.state.selectedGame].game.name,this.state.numPlayers)});for(const t of e.games){const e=t.game;e.minPlayers||(e.minPlayers=1),e.maxPlayers||(e.maxPlayers=4),console.assert(e.maxPlayers>=e.minPlayers)}this.state={selectedGame:0,numPlayers:e.games[0].game.minPlayers}}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"select\",{value:this.state.selectedGame,onChange:e=>this.onChangeSelectedGame(e)},this.props.games.map((e,t)=>this._createGameNameOption(e,t))),s.default.createElement(\"span\",null,\"Players:\"),s.default.createElement(\"select\",{value:this.state.numPlayers,onChange:this.onChangeNumPlayers},this._createNumPlayersRange(this.props.games[this.state.selectedGame].game).map(e=>this._createNumPlayersOption(e))),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{onClick:this.onClickCreate},\"Create\")))}}!function(e){e.ENTER=\"enter\",e.PLAY=\"play\",e.LIST=\"list\"}(i||(i={}));class y extends s.default.Component{constructor(e){super(e),this.state={phase:i.ENTER,playerName:\"Visitor\",runningMatch:null,errorMsg:\"\",credentialStore:{}},this._createConnection=(e=>{const t=this.state.playerName;this.connection=m({server:e.lobbyServer,gameComponents:e.gameComponents,playerName:t,playerCredentials:this.state.credentialStore[t]})}),this._updateCredentials=((e,t)=>{this.setState(a=>{const s=Object.assign({},a.credentialStore);return s[e]=t,{credentialStore:s}})}),this._updateConnection=(async()=>{await this.connection.refresh(),this.forceUpdate()}),this._enterLobby=(e=>{this._startRefreshInterval(),this.setState({playerName:e,phase:i.LIST})}),this._exitLobby=(async()=>{this._clearRefreshInterval(),await this.connection.disconnect(),this.setState({phase:i.ENTER,errorMsg:\"\"})}),this._createMatch=(async(e,t)=>{try{await this.connection.create(e,t),await this.connection.refresh(),this.setState({})}catch(a){this.setState({errorMsg:a.message})}}),this._joinMatch=(async(e,t,a)=>{try{await this.connection.join(e,t,a),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(s){this.setState({errorMsg:s.message})}}),this._leaveMatch=(async(e,t)=>{try{await this.connection.leave(e,t),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(a){this.setState({errorMsg:a.message})}}),this._startMatch=((e,a)=>{const s=this.connection._getGameComponents(e);if(!s)return void this.setState({errorMsg:\"game \"+e+\" not supported\"});let r=void 0;if(a.numPlayers>1&&(r=this.props.gameServer?(0,l.S)({server:this.props.gameServer}):(0,l.S)()),1==a.numPlayers){const e=s.game.maxPlayers,a={};for(let s=1;s<e;s++)a[s+\"\"]=t.M;r=(0,l.L)({bots:a})}const n={app:this.props.clientFactory({game:s.game,board:s.board,debug:this.props.debug,multiplayer:r}),matchID:a.matchID,playerID:a.numPlayers>1?a.playerID:\"0\",credentials:this.connection.playerCredentials};this._clearRefreshInterval(),this.setState({phase:i.PLAY,runningMatch:n})}),this._exitMatch=(()=>{this._startRefreshInterval(),this.setState({phase:i.LIST,runningMatch:null})}),this._getPhaseVisibility=(e=>this.state.phase!==e?\"hidden\":\"phase\"),this.renderMatches=((e,t)=>e.map(e=>{const{matchID:a,gameName:r,players:n}=e;return s.default.createElement(p,{key:\"instance-\"+a,match:{matchID:a,gameName:r,players:Object.values(n)},playerName:t,onClickJoin:this._joinMatch,onClickLeave:this._leaveMatch,onClickPlay:this._startMatch})})),this._createConnection(this.props)}componentDidMount(){const e=n.default.load(\"lobbyState\")||{};e.phase&&e.phase===i.PLAY&&(e.phase=i.LIST),e.phase&&e.phase!==i.ENTER&&this._startRefreshInterval(),this.setState({phase:e.phase||i.ENTER,playerName:e.playerName||\"Visitor\",credentialStore:e.credentialStore||{}})}componentDidUpdate(e,t){const a=this.state.playerName,s=this.state.credentialStore[a];if(t.phase!==this.state.phase||t.credentialStore[a]!==s||t.playerName!==a){this._createConnection(this.props),this._updateConnection();const e={phase:this.state.phase,playerName:a,credentialStore:this.state.credentialStore};n.default.save(\"lobbyState\",e,{path:\"/\"})}e.refreshInterval!==this.props.refreshInterval&&this._startRefreshInterval()}componentWillUnmount(){this._clearRefreshInterval()}_startRefreshInterval(){this._clearRefreshInterval(),this._currentInterval=setInterval(this._updateConnection,this.props.refreshInterval)}_clearRefreshInterval(){clearInterval(this._currentInterval)}render(){const{gameComponents:e,renderer:t}=this.props,{errorMsg:a,playerName:r,phase:n,runningMatch:l}=this.state;return t?t({errorMsg:a,gameComponents:e,matches:this.connection.matches,phase:n,playerName:r,runningMatch:l,handleEnterLobby:this._enterLobby,handleExitLobby:this._exitLobby,handleCreateMatch:this._createMatch,handleJoinMatch:this._joinMatch,handleLeaveMatch:this._leaveMatch,handleExitMatch:this._exitMatch,handleRefreshMatches:this._updateConnection,handleStartMatch:this._startMatch}):s.default.createElement(\"div\",{id:\"lobby-view\",style:{padding:50}},s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.ENTER)},s.default.createElement(u,{key:r,playerName:r,onEnter:this._enterLobby})),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.LIST)},s.default.createElement(\"p\",null,\"Welcome, \",r),s.default.createElement(\"div\",{className:\"phase-title\",id:\"match-creation\"},s.default.createElement(\"span\",null,\"Create a match:\"),s.default.createElement(d,{games:e,createMatch:this._createMatch})),s.default.createElement(\"p\",{className:\"phase-title\"},\"Join a match:\"),s.default.createElement(\"div\",{id:\"instances\"},s.default.createElement(\"table\",null,s.default.createElement(\"tbody\",null,this.renderMatches(this.connection.matches,r))),s.default.createElement(\"span\",{className:\"error-msg\"},a,s.default.createElement(\"br\",null))),s.default.createElement(\"p\",{className:\"phase-title\"},\"Matches that become empty are automatically deleted.\")),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.PLAY)},l&&s.default.createElement(l.app,{matchID:l.matchID,playerID:l.playerID,credentials:l.credentials}),s.default.createElement(\"div\",{className:\"buttons\",id:\"match-exit\"},s.default.createElement(\"button\",{onClick:this._exitMatch},\"Exit match\"))),s.default.createElement(\"div\",{className:\"buttons\",id:\"lobby-exit\"},s.default.createElement(\"button\",{onClick:this._exitLobby},\"Exit lobby\")))}}exports.Lobby=y,y.propTypes={gameComponents:r.default.array.isRequired,lobbyServer:r.default.string,gameServer:r.default.string,debug:r.default.bool,clientFactory:r.default.func,refreshInterval:r.default.number},y.defaultProps={debug:!1,clientFactory:o,refreshInterval:2e3};\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\",\"./client-fa36c03a.js\":\"FkTq\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\",\"./client-5f57c3f2.js\":\"mOPV\",\"react\":\"SAdv\",\"prop-types\":\"yu5W\",\"react-cookies\":\"kpSY\",\"./util-b1699aa1.js\":\"pSNY\",\"./socketio-e4fb268a.js\":\"UzxM\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"Prnk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Debug\",{enumerable:!0,get:function(){return e.D}});var e=require(\"./Debug-fd09b8bc.js\");require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"flatted\"),require(\"setimmediate\"),require(\"./ai-3099ce9a.js\");\n},{\"./Debug-fd09b8bc.js\":\"uvSB\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"CnBY\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"ActivePlayers\",{enumerable:!0,get:function(){return e.C}}),Object.defineProperty(exports,\"GameMethod\",{enumerable:!0,get:function(){return e.G}}),Object.defineProperty(exports,\"INVALID_MOVE\",{enumerable:!0,get:function(){return e.n}}),Object.defineProperty(exports,\"Stage\",{enumerable:!0,get:function(){return e.S}}),Object.defineProperty(exports,\"TurnOrder\",{enumerable:!0,get:function(){return e.T}}),exports.PlayerView=void 0;var e=require(\"./turn-order-0b7dce3d.js\");require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\");const r={STRIP_SECRETS:(e,r,t)=>{const n={...e};return void 0!==n.secret&&delete n.secret,n.players&&(n.players=t?{[t]:n.players[t]}:{}),n}};exports.PlayerView=r;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\"}],\"xwiN\":[function(require,module,exports) {\n\"use strict\";var e=a(require(\"react\")),t=a(require(\"react-dom\")),l=require(\"boardgame.io/react\"),r=require(\"boardgame.io/debug\"),n=require(\"boardgame.io/core\");function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].map(t=>{const l=t.map(t=>e[t]);return l.every(e=>null!==e&&e===l[0])}).some(e=>!0===e)}const o={setup:()=>({cells:Array(9).fill(null)}),moves:{clickCell(e,t,l){if(null!==e.cells[l])return n.INVALID_MOVE;e.cells[l]=t.currentPlayer}},turn:{minMoves:1,maxMoves:1},endIf:(e,t)=>i(e.cells)?{winner:t.currentPlayer}:0==e.cells.filter(e=>null===e).length?{draw:!0}:void 0};function u({ctx:t,G:l,moves:r}){const n=e=>r.clickCell(e);let a=\"\";t.gameover&&(a=void 0!==t.gameover.winner?e.default.createElement(\"div\",{id:\"winner\"},\"Winner: \",t.gameover.winner):e.default.createElement(\"div\",{id:\"winner\"},\"Draw!\"));const i={border:\"1px solid #555\",width:\"50px\",height:\"50px\",lineHeight:\"50px\",textAlign:\"center\",fontFamily:\"monospace\",fontSize:\"20px\",fontWeight:\"bold\",padding:\"0\",boxSizing:\"border-box\"};let o=[];for(let u=0;u<3;u++){let t=[];for(let r=0;r<3;r++){const a=3*u+r;t.push(e.default.createElement(\"td\",{key:a},l.cells[a]?e.default.createElement(\"div\",{style:i},l.cells[a]):e.default.createElement(\"button\",{style:i,onClick:()=>n(a)})))}o.push(e.default.createElement(\"tr\",{key:u},t))}return e.default.createElement(\"div\",null,e.default.createElement(\"table\",{id:\"board\"},e.default.createElement(\"tbody\",null,o)),a)}var d=(0,l.Client)({board:u,game:o,debug:{impl:r.Debug}});t.default.render(e.default.createElement(d,null),document.getElementById(\"app\"));\n},{\"react\":\"n8MK\",\"react-dom\":\"NKHc\",\"boardgame.io/react\":\"PUvW\",\"boardgame.io/debug\":\"Prnk\",\"boardgame.io/core\":\"CnBY\"}]},{},[\"xwiN\"], null)"
  },
  {
    "path": "docs/documentation/snippets/example-3/index.html",
    "content": "<!DOCTYPE html><html><head><style>body{padding:20px}.msg{position:absolute;bottom:0;left:20px;color:#aaa;font-size:12px;margin-bottom:20px}</style></head><body> <div class=\"msg\">interactive (not an image)</div> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/example-3.1fa4f5db.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/example-3.1fa4f5db.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"J4Nk\":[function(require,module,exports) {\n\"use strict\";var r=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(r){if(null==r)throw new TypeError(\"Object.assign cannot be called with null or undefined\");return Object(r)}function o(){try{if(!Object.assign)return!1;var r=new String(\"abc\");if(r[5]=\"de\",\"5\"===Object.getOwnPropertyNames(r)[0])return!1;for(var t={},e=0;e<10;e++)t[\"_\"+String.fromCharCode(e)]=e;if(\"0123456789\"!==Object.getOwnPropertyNames(t).map(function(r){return t[r]}).join(\"\"))return!1;var n={};return\"abcdefghijklmnopqrst\".split(\"\").forEach(function(r){n[r]=r}),\"abcdefghijklmnopqrst\"===Object.keys(Object.assign({},n)).join(\"\")}catch(o){return!1}}module.exports=o()?Object.assign:function(o,c){for(var a,i,s=n(o),f=1;f<arguments.length;f++){for(var u in a=Object(arguments[f]))t.call(a,u)&&(s[u]=a[u]);if(r){i=r(a);for(var b=0;b<i.length;b++)e.call(a,i[b])&&(s[i[b]]=a[i[b]])}}return s};\n},{}],\"awqi\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"n8MK\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"awqi\"}],\"IvPb\":[function(require,module,exports) {\n\"use strict\";var e,n,t,r,o;if(\"undefined\"==typeof window||\"function\"!=typeof MessageChannel){var a=null,l=null,i=function(){if(null!==a)try{var e=exports.unstable_now();a(!0,e),a=null}catch(n){throw setTimeout(i,0),n}},u=Date.now();exports.unstable_now=function(){return Date.now()-u},e=function(n){null!==a?setTimeout(e,0,n):(a=n,setTimeout(i,0))},n=function(e,n){l=setTimeout(e,n)},t=function(){clearTimeout(l)},r=function(){return!1},o=exports.unstable_forceFrameRate=function(){}}else{var s=window.performance,c=window.Date,f=window.setTimeout,p=window.clearTimeout;if(\"undefined\"!=typeof console){var b=window.cancelAnimationFrame;\"function\"!=typeof window.requestAnimationFrame&&console.error(\"This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\"),\"function\"!=typeof b&&console.error(\"This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\")}if(\"object\"==typeof s&&\"function\"==typeof s.now)exports.unstable_now=function(){return s.now()};else{var d=c.now();exports.unstable_now=function(){return c.now()-d}}var v=!1,x=null,w=-1,m=5,y=0;r=function(){return exports.unstable_now()>=y},o=function(){},exports.unstable_forceFrameRate=function(e){0>e||125<e?console.error(\"forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported\"):m=0<e?Math.floor(1e3/e):5};var _=new MessageChannel,h=_.port2;_.port1.onmessage=function(){if(null!==x){var e=exports.unstable_now();y=e+m;try{x(!0,e)?h.postMessage(null):(v=!1,x=null)}catch(n){throw h.postMessage(null),n}}else v=!1},e=function(e){x=e,v||(v=!0,h.postMessage(null))},n=function(e,n){w=f(function(){e(exports.unstable_now())},n)},t=function(){p(w),w=-1}}function k(e,n){var t=e.length;e.push(n);e:for(;;){var r=t-1>>>1,o=e[r];if(!(void 0!==o&&0<P(o,n)))break e;e[r]=n,e[t]=o,t=r}}function T(e){return void 0===(e=e[0])?null:e}function g(e){var n=e[0];if(void 0!==n){var t=e.pop();if(t!==n){e[0]=t;e:for(var r=0,o=e.length;r<o;){var a=2*(r+1)-1,l=e[a],i=a+1,u=e[i];if(void 0!==l&&0>P(l,t))void 0!==u&&0>P(u,l)?(e[r]=u,e[i]=t,r=i):(e[r]=l,e[a]=t,r=a);else{if(!(void 0!==u&&0>P(u,t)))break e;e[r]=u,e[i]=t,r=i}}}return n}return null}function P(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}var F=[],I=[],M=1,C=null,A=3,L=!1,q=!1,D=!1;function R(e){for(var n=T(I);null!==n;){if(null===n.callback)g(I);else{if(!(n.startTime<=e))break;g(I),n.sortIndex=n.expirationTime,k(F,n)}n=T(I)}}function j(t){if(D=!1,R(t),!q)if(null!==T(F))q=!0,e(E);else{var r=T(I);null!==r&&n(j,r.startTime-t)}}function E(e,o){q=!1,D&&(D=!1,t()),L=!0;var a=A;try{for(R(o),C=T(F);null!==C&&(!(C.expirationTime>o)||e&&!r());){var l=C.callback;if(null!==l){C.callback=null,A=C.priorityLevel;var i=l(C.expirationTime<=o);o=exports.unstable_now(),\"function\"==typeof i?C.callback=i:C===T(F)&&g(F),R(o)}else g(F);C=T(F)}if(null!==C)var u=!0;else{var s=T(I);null!==s&&n(j,s.startTime-o),u=!1}return u}finally{C=null,A=a,L=!1}}function N(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var B=o;exports.unstable_IdlePriority=5,exports.unstable_ImmediatePriority=1,exports.unstable_LowPriority=4,exports.unstable_NormalPriority=3,exports.unstable_Profiling=null,exports.unstable_UserBlockingPriority=2,exports.unstable_cancelCallback=function(e){e.callback=null},exports.unstable_continueExecution=function(){q||L||(q=!0,e(E))},exports.unstable_getCurrentPriorityLevel=function(){return A},exports.unstable_getFirstCallbackNode=function(){return T(F)},exports.unstable_next=function(e){switch(A){case 1:case 2:case 3:var n=3;break;default:n=A}var t=A;A=n;try{return e()}finally{A=t}},exports.unstable_pauseExecution=function(){},exports.unstable_requestPaint=B,exports.unstable_runWithPriority=function(e,n){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var t=A;A=e;try{return n()}finally{A=t}},exports.unstable_scheduleCallback=function(r,o,a){var l=exports.unstable_now();if(\"object\"==typeof a&&null!==a){var i=a.delay;i=\"number\"==typeof i&&0<i?l+i:l,a=\"number\"==typeof a.timeout?a.timeout:N(r)}else a=N(r),i=l;return r={id:M++,callback:o,priorityLevel:r,startTime:i,expirationTime:a=i+a,sortIndex:-1},i>l?(r.sortIndex=i,k(I,r),null===T(F)&&r===T(I)&&(D?t():D=!0,n(j,i-l))):(r.sortIndex=a,k(F,r),q||L||(q=!0,e(E))),r},exports.unstable_shouldYield=function(){var e=exports.unstable_now();R(e);var n=T(F);return n!==C&&null!==C&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTime<C.expirationTime||r()},exports.unstable_wrapCallback=function(e){var n=A;return function(){var t=A;A=n;try{return e.apply(this,arguments)}finally{A=t}}};\n},{}],\"MDSO\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/scheduler.production.min.js\");\n},{\"./cjs/scheduler.production.min.js\":\"IvPb\"}],\"i17t\":[function(require,module,exports) {\n\"use strict\";var e=require(\"react\"),t=require(\"object-assign\"),n=require(\"scheduler\");function r(e){for(var t=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,n=1;n<arguments.length;n++)t+=\"&args[]=\"+encodeURIComponent(arguments[n]);return\"Minified React error #\"+e+\"; visit \"+t+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}if(!e)throw Error(r(227));function l(e,t,n,r,l,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(s){this.onError(s)}}var i=!1,a=null,o=!1,u=null,c={onError:function(e){i=!0,a=e}};function s(e,t,n,r,o,u,s,f,d){i=!1,a=null,l.apply(c,arguments)}function f(e,t,n,l,c,f,d,p,m){if(s.apply(this,arguments),i){if(!i)throw Error(r(198));var h=a;i=!1,a=null,o||(o=!0,u=h)}}var d=null,p=null,m=null;function h(e,t,n){var r=e.type||\"unknown-event\";e.currentTarget=m(n),f(r,t,void 0,e),e.currentTarget=null}var g=null,v={};function y(){if(g)for(var e in v){var t=v[e],n=g.indexOf(e);if(!(-1<n))throw Error(r(96,e));if(!w[n]){if(!t.extractEvents)throw Error(r(97,e));for(var l in w[n]=t,n=t.eventTypes){var i=void 0,a=n[l],o=t,u=l;if(k.hasOwnProperty(u))throw Error(r(99,u));k[u]=a;var c=a.phasedRegistrationNames;if(c){for(i in c)c.hasOwnProperty(i)&&b(c[i],o,u);i=!0}else a.registrationName?(b(a.registrationName,o,u),i=!0):i=!1;if(!i)throw Error(r(98,l,e))}}}}function b(e,t,n){if(x[e])throw Error(r(100,e));x[e]=t,T[e]=t.eventTypes[n].dependencies}var w=[],k={},x={},T={};function E(e){var t,n=!1;for(t in e)if(e.hasOwnProperty(t)){var l=e[t];if(!v.hasOwnProperty(t)||v[t]!==l){if(v[t])throw Error(r(102,t));v[t]=l,n=!0}}n&&y()}var S=!(\"undefined\"==typeof window||void 0===window.document||void 0===window.document.createElement),C=null,P=null,_=null;function N(e){if(e=p(e)){if(\"function\"!=typeof C)throw Error(r(280));var t=e.stateNode;t&&(t=d(t),C(e.stateNode,e.type,t))}}function z(e){P?_?_.push(e):_=[e]:P=e}function M(){if(P){var e=P,t=_;if(_=P=null,N(e),t)for(e=0;e<t.length;e++)N(t[e])}}function I(e,t){return e(t)}function F(e,t,n,r,l){return e(t,n,r,l)}function O(){}var R=I,D=!1,L=!1;function U(){null===P&&null===_||(O(),M())}function A(e,t,n){if(L)return e(t,n);L=!0;try{return R(e,t,n)}finally{L=!1,U()}}var V=/^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$/,Q=Object.prototype.hasOwnProperty,W={},H={};function j(e){return!!Q.call(H,e)||!Q.call(W,e)&&(V.test(e)?H[e]=!0:(W[e]=!0,!1))}function B(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case\"function\":case\"symbol\":return!0;case\"boolean\":return!r&&(null!==n?!n.acceptsBooleans:\"data-\"!==(e=e.toLowerCase().slice(0,5))&&\"aria-\"!==e);default:return!1}}function K(e,t,n,r){if(null==t||B(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function $(e,t,n,r,l,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i}var q={};\"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style\".split(\" \").forEach(function(e){q[e]=new $(e,0,!1,e,null,!1)}),[[\"acceptCharset\",\"accept-charset\"],[\"className\",\"class\"],[\"htmlFor\",\"for\"],[\"httpEquiv\",\"http-equiv\"]].forEach(function(e){var t=e[0];q[t]=new $(t,1,!1,e[1],null,!1)}),[\"contentEditable\",\"draggable\",\"spellCheck\",\"value\"].forEach(function(e){q[e]=new $(e,2,!1,e.toLowerCase(),null,!1)}),[\"autoReverse\",\"externalResourcesRequired\",\"focusable\",\"preserveAlpha\"].forEach(function(e){q[e]=new $(e,2,!1,e,null,!1)}),\"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope\".split(\" \").forEach(function(e){q[e]=new $(e,3,!1,e.toLowerCase(),null,!1)}),[\"checked\",\"multiple\",\"muted\",\"selected\"].forEach(function(e){q[e]=new $(e,3,!0,e,null,!1)}),[\"capture\",\"download\"].forEach(function(e){q[e]=new $(e,4,!1,e,null,!1)}),[\"cols\",\"rows\",\"size\",\"span\"].forEach(function(e){q[e]=new $(e,6,!1,e,null,!1)}),[\"rowSpan\",\"start\"].forEach(function(e){q[e]=new $(e,5,!1,e.toLowerCase(),null,!1)});var Y=/[\\-:]([a-z])/g;function X(e){return e[1].toUpperCase()}\"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,null,!1)}),\"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/1999/xlink\",!1)}),[\"xml:base\",\"xml:lang\",\"xml:space\"].forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/XML/1998/namespace\",!1)}),[\"tabIndex\",\"crossOrigin\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!1)}),q.xlinkHref=new $(\"xlinkHref\",1,!1,\"xlink:href\",\"http://www.w3.org/1999/xlink\",!0),[\"src\",\"href\",\"action\",\"formAction\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!0)});var G=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function Z(e,t,n,r){var l=q.hasOwnProperty(t)?q[t]:null;(null!==l?0===l.type:!r&&(2<t.length&&(\"o\"===t[0]||\"O\"===t[0])&&(\"n\"===t[1]||\"N\"===t[1])))||(K(t,n,l,r)&&(n=null),r||null===l?j(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,\"\"+n)):l.mustUseProperty?e[l.propertyName]=null===n?3!==l.type&&\"\":n:(t=l.attributeName,r=l.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(l=l.type)||4===l&&!0===n?\"\":\"\"+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}G.hasOwnProperty(\"ReactCurrentDispatcher\")||(G.ReactCurrentDispatcher={current:null}),G.hasOwnProperty(\"ReactCurrentBatchConfig\")||(G.ReactCurrentBatchConfig={suspense:null});var J=/^(.*)[\\\\\\/]/,ee=\"function\"==typeof Symbol&&Symbol.for,te=ee?Symbol.for(\"react.element\"):60103,ne=ee?Symbol.for(\"react.portal\"):60106,re=ee?Symbol.for(\"react.fragment\"):60107,le=ee?Symbol.for(\"react.strict_mode\"):60108,ie=ee?Symbol.for(\"react.profiler\"):60114,ae=ee?Symbol.for(\"react.provider\"):60109,oe=ee?Symbol.for(\"react.context\"):60110,ue=ee?Symbol.for(\"react.concurrent_mode\"):60111,ce=ee?Symbol.for(\"react.forward_ref\"):60112,se=ee?Symbol.for(\"react.suspense\"):60113,fe=ee?Symbol.for(\"react.suspense_list\"):60120,de=ee?Symbol.for(\"react.memo\"):60115,pe=ee?Symbol.for(\"react.lazy\"):60116,me=ee?Symbol.for(\"react.block\"):60121,he=\"function\"==typeof Symbol&&Symbol.iterator;function ge(e){return null===e||\"object\"!=typeof e?null:\"function\"==typeof(e=he&&e[he]||e[\"@@iterator\"])?e:null}function ve(e){if(-1===e._status){e._status=0;var t=e._ctor;t=t(),e._result=t,t.then(function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)},function(t){0===e._status&&(e._status=2,e._result=t)})}}function ye(e){if(null==e)return null;if(\"function\"==typeof e)return e.displayName||e.name||null;if(\"string\"==typeof e)return e;switch(e){case re:return\"Fragment\";case ne:return\"Portal\";case ie:return\"Profiler\";case le:return\"StrictMode\";case se:return\"Suspense\";case fe:return\"SuspenseList\"}if(\"object\"==typeof e)switch(e.$$typeof){case oe:return\"Context.Consumer\";case ae:return\"Context.Provider\";case ce:var t=e.render;return t=t.displayName||t.name||\"\",e.displayName||(\"\"!==t?\"ForwardRef(\"+t+\")\":\"ForwardRef\");case de:return ye(e.type);case me:return ye(e.render);case pe:if(e=1===e._status?e._result:null)return ye(e)}return null}function be(e){var t=\"\";do{e:switch(e.tag){case 3:case 4:case 6:case 7:case 10:case 9:var n=\"\";break e;default:var r=e._debugOwner,l=e._debugSource,i=ye(e.type);n=null,r&&(n=ye(r.type)),r=i,i=\"\",l?i=\" (at \"+l.fileName.replace(J,\"\")+\":\"+l.lineNumber+\")\":n&&(i=\" (created by \"+n+\")\"),n=\"\\n    in \"+(r||\"Unknown\")+i}t+=n,e=e.return}while(e);return t}function we(e){switch(typeof e){case\"boolean\":case\"number\":case\"object\":case\"string\":case\"undefined\":return e;default:return\"\"}}function ke(e){var t=e.type;return(e=e.nodeName)&&\"input\"===e.toLowerCase()&&(\"checkbox\"===t||\"radio\"===t)}function xe(e){var t=ke(e)?\"checked\":\"value\",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=\"\"+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&\"function\"==typeof n.get&&\"function\"==typeof n.set){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(e){r=\"\"+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=\"\"+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Te(e){e._valueTracker||(e._valueTracker=xe(e))}function Ee(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=\"\";return e&&(r=ke(e)?e.checked?\"true\":\"false\":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Se(e,n){var r=n.checked;return t({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:e._wrapperState.initialChecked})}function Ce(e,t){var n=null==t.defaultValue?\"\":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=we(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:\"checkbox\"===t.type||\"radio\"===t.type?null!=t.checked:null!=t.value}}function Pe(e,t){null!=(t=t.checked)&&Z(e,\"checked\",t,!1)}function _e(e,t){Pe(e,t);var n=we(t.value),r=t.type;if(null!=n)\"number\"===r?(0===n&&\"\"===e.value||e.value!=n)&&(e.value=\"\"+n):e.value!==\"\"+n&&(e.value=\"\"+n);else if(\"submit\"===r||\"reset\"===r)return void e.removeAttribute(\"value\");t.hasOwnProperty(\"value\")?ze(e,t.type,n):t.hasOwnProperty(\"defaultValue\")&&ze(e,t.type,we(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Ne(e,t,n){if(t.hasOwnProperty(\"value\")||t.hasOwnProperty(\"defaultValue\")){var r=t.type;if(!(\"submit\"!==r&&\"reset\"!==r||void 0!==t.value&&null!==t.value))return;t=\"\"+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}\"\"!==(n=e.name)&&(e.name=\"\"),e.defaultChecked=!!e._wrapperState.initialChecked,\"\"!==n&&(e.name=n)}function ze(e,t,n){\"number\"===t&&e.ownerDocument.activeElement===e||(null==n?e.defaultValue=\"\"+e._wrapperState.initialValue:e.defaultValue!==\"\"+n&&(e.defaultValue=\"\"+n))}function Me(t){var n=\"\";return e.Children.forEach(t,function(e){null!=e&&(n+=e)}),n}function Ie(e,n){return e=t({children:void 0},n),(n=Me(n.children))&&(e.children=n),e}function Fe(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t[\"$\"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty(\"$\"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=\"\"+we(n),t=null,l=0;l<e.length;l++){if(e[l].value===n)return e[l].selected=!0,void(r&&(e[l].defaultSelected=!0));null!==t||e[l].disabled||(t=e[l])}null!==t&&(t.selected=!0)}}function Oe(e,n){if(null!=n.dangerouslySetInnerHTML)throw Error(r(91));return t({},n,{value:void 0,defaultValue:void 0,children:\"\"+e._wrapperState.initialValue})}function Re(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(r(92));if(Array.isArray(n)){if(!(1>=n.length))throw Error(r(93));n=n[0]}t=n}null==t&&(t=\"\"),n=t}e._wrapperState={initialValue:we(n)}}function De(e,t){var n=we(t.value),r=we(t.defaultValue);null!=n&&((n=\"\"+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=\"\"+r)}function Le(e){var t=e.textContent;t===e._wrapperState.initialValue&&\"\"!==t&&null!==t&&(e.value=t)}var Ue={html:\"http://www.w3.org/1999/xhtml\",mathml:\"http://www.w3.org/1998/Math/MathML\",svg:\"http://www.w3.org/2000/svg\"};function Ae(e){switch(e){case\"svg\":return\"http://www.w3.org/2000/svg\";case\"math\":return\"http://www.w3.org/1998/Math/MathML\";default:return\"http://www.w3.org/1999/xhtml\"}}function Ve(e,t){return null==e||\"http://www.w3.org/1999/xhtml\"===e?Ae(t):\"http://www.w3.org/2000/svg\"===e&&\"foreignObject\"===t?\"http://www.w3.org/1999/xhtml\":e}var Qe,We=function(e){return\"undefined\"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==Ue.svg||\"innerHTML\"in e)e.innerHTML=t;else{for((Qe=Qe||document.createElement(\"div\")).innerHTML=\"<svg>\"+t.valueOf().toString()+\"</svg>\",t=Qe.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function He(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}function je(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[\"Webkit\"+e]=\"webkit\"+t,n[\"Moz\"+e]=\"moz\"+t,n}var Be={animationend:je(\"Animation\",\"AnimationEnd\"),animationiteration:je(\"Animation\",\"AnimationIteration\"),animationstart:je(\"Animation\",\"AnimationStart\"),transitionend:je(\"Transition\",\"TransitionEnd\")},Ke={},$e={};function qe(e){if(Ke[e])return Ke[e];if(!Be[e])return e;var t,n=Be[e];for(t in n)if(n.hasOwnProperty(t)&&t in $e)return Ke[e]=n[t];return e}S&&($e=document.createElement(\"div\").style,\"AnimationEvent\"in window||(delete Be.animationend.animation,delete Be.animationiteration.animation,delete Be.animationstart.animation),\"TransitionEvent\"in window||delete Be.transitionend.transition);var Ye=qe(\"animationend\"),Xe=qe(\"animationiteration\"),Ge=qe(\"animationstart\"),Ze=qe(\"transitionend\"),Je=\"abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting\".split(\" \"),et=new(\"function\"==typeof WeakMap?WeakMap:Map);function tt(e){var t=et.get(e);return void 0===t&&(t=new Map,et.set(e,t)),t}function nt(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!=(1026&(t=e).effectTag)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function rt(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function lt(e){if(nt(e)!==e)throw Error(r(188))}function it(e){var t=e.alternate;if(!t){if(null===(t=nt(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,l=t;;){var i=n.return;if(null===i)break;var a=i.alternate;if(null===a){if(null!==(l=i.return)){n=l;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return lt(i),e;if(a===l)return lt(i),t;a=a.sibling}throw Error(r(188))}if(n.return!==l.return)n=i,l=a;else{for(var o=!1,u=i.child;u;){if(u===n){o=!0,n=i,l=a;break}if(u===l){o=!0,l=i,n=a;break}u=u.sibling}if(!o){for(u=a.child;u;){if(u===n){o=!0,n=a,l=i;break}if(u===l){o=!0,l=a,n=i;break}u=u.sibling}if(!o)throw Error(r(189))}}if(n.alternate!==l)throw Error(r(190))}if(3!==n.tag)throw Error(r(188));return n.stateNode.current===n?e:t}function at(e){if(!(e=it(e)))return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function ot(e,t){if(null==t)throw Error(r(30));return null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function ut(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}var ct=null;function st(e){if(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))for(var r=0;r<t.length&&!e.isPropagationStopped();r++)h(e,t[r],n[r]);else t&&h(e,t,n);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function ft(e){if(null!==e&&(ct=ot(ct,e)),e=ct,ct=null,e){if(ut(e,st),ct)throw Error(r(95));if(o)throw e=u,o=!1,u=null,e}}function dt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}function pt(e){if(!S)return!1;var t=(e=\"on\"+e)in document;return t||((t=document.createElement(\"div\")).setAttribute(e,\"return;\"),t=\"function\"==typeof t[e]),t}var mt=[];function ht(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>mt.length&&mt.push(e)}function gt(e,t,n,r){if(mt.length){var l=mt.pop();return l.topLevelType=e,l.eventSystemFlags=r,l.nativeEvent=t,l.targetInst=n,l}return{topLevelType:e,eventSystemFlags:r,nativeEvent:t,targetInst:n,ancestors:[]}}function vt(e){var t=e.targetInst,n=t;do{if(!n){e.ancestors.push(n);break}var r=n;if(3===r.tag)r=r.stateNode.containerInfo;else{for(;r.return;)r=r.return;r=3!==r.tag?null:r.stateNode.containerInfo}if(!r)break;5!==(t=n.tag)&&6!==t||e.ancestors.push(n),n=Un(r)}while(n);for(n=0;n<e.ancestors.length;n++){t=e.ancestors[n];var l=dt(e.nativeEvent);r=e.topLevelType;var i=e.nativeEvent,a=e.eventSystemFlags;0===n&&(a|=64);for(var o=null,u=0;u<w.length;u++){var c=w[u];c&&(c=c.extractEvents(r,t,i,l,a))&&(o=ot(o,c))}ft(o)}}function yt(e,t,n){if(!n.has(e)){switch(e){case\"scroll\":en(t,\"scroll\",!0);break;case\"focus\":case\"blur\":en(t,\"focus\",!0),en(t,\"blur\",!0),n.set(\"blur\",null),n.set(\"focus\",null);break;case\"cancel\":case\"close\":pt(e)&&en(t,e,!0);break;case\"invalid\":case\"submit\":case\"reset\":break;default:-1===Je.indexOf(e)&&Jt(e,t)}n.set(e,null)}}var bt,wt,kt,xt=!1,Tt=[],Et=null,St=null,Ct=null,Pt=new Map,_t=new Map,Nt=[],zt=\"mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput close cancel copy cut paste click change contextmenu reset submit\".split(\" \"),Mt=\"focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture\".split(\" \");function It(e,t){var n=tt(t);zt.forEach(function(e){yt(e,t,n)}),Mt.forEach(function(e){yt(e,t,n)})}function Ft(e,t,n,r,l){return{blockedOn:e,topLevelType:t,eventSystemFlags:32|n,nativeEvent:l,container:r}}function Ot(e,t){switch(e){case\"focus\":case\"blur\":Et=null;break;case\"dragenter\":case\"dragleave\":St=null;break;case\"mouseover\":case\"mouseout\":Ct=null;break;case\"pointerover\":case\"pointerout\":Pt.delete(t.pointerId);break;case\"gotpointercapture\":case\"lostpointercapture\":_t.delete(t.pointerId)}}function Rt(e,t,n,r,l,i){return null===e||e.nativeEvent!==i?(e=Ft(t,n,r,l,i),null!==t&&(null!==(t=An(t))&&wt(t)),e):(e.eventSystemFlags|=r,e)}function Dt(e,t,n,r,l){switch(t){case\"focus\":return Et=Rt(Et,e,t,n,r,l),!0;case\"dragenter\":return St=Rt(St,e,t,n,r,l),!0;case\"mouseover\":return Ct=Rt(Ct,e,t,n,r,l),!0;case\"pointerover\":var i=l.pointerId;return Pt.set(i,Rt(Pt.get(i)||null,e,t,n,r,l)),!0;case\"gotpointercapture\":return i=l.pointerId,_t.set(i,Rt(_t.get(i)||null,e,t,n,r,l)),!0}return!1}function Lt(e){var t=Un(e.target);if(null!==t){var r=nt(t);if(null!==r)if(13===(t=r.tag)){if(null!==(t=rt(r)))return e.blockedOn=t,void n.unstable_runWithPriority(e.priority,function(){kt(r)})}else if(3===t&&r.stateNode.hydrate)return void(e.blockedOn=3===r.tag?r.stateNode.containerInfo:null)}e.blockedOn=null}function Ut(e){if(null!==e.blockedOn)return!1;var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(null!==t){var n=An(t);return null!==n&&wt(n),e.blockedOn=t,!1}return!0}function At(e,t,n){Ut(e)&&n.delete(t)}function Vt(){for(xt=!1;0<Tt.length;){var e=Tt[0];if(null!==e.blockedOn){null!==(e=An(e.blockedOn))&&bt(e);break}var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);null!==t?e.blockedOn=t:Tt.shift()}null!==Et&&Ut(Et)&&(Et=null),null!==St&&Ut(St)&&(St=null),null!==Ct&&Ut(Ct)&&(Ct=null),Pt.forEach(At),_t.forEach(At)}function Qt(e,t){e.blockedOn===t&&(e.blockedOn=null,xt||(xt=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Vt)))}function Wt(e){function t(t){return Qt(t,e)}if(0<Tt.length){Qt(Tt[0],e);for(var n=1;n<Tt.length;n++){var r=Tt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Et&&Qt(Et,e),null!==St&&Qt(St,e),null!==Ct&&Qt(Ct,e),Pt.forEach(t),_t.forEach(t),n=0;n<Nt.length;n++)(r=Nt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Nt.length&&null===(n=Nt[0]).blockedOn;)Lt(n),null===n.blockedOn&&Nt.shift()}var Ht={},jt=new Map,Bt=new Map,Kt=[\"abort\",\"abort\",Ye,\"animationEnd\",Xe,\"animationIteration\",Ge,\"animationStart\",\"canplay\",\"canPlay\",\"canplaythrough\",\"canPlayThrough\",\"durationchange\",\"durationChange\",\"emptied\",\"emptied\",\"encrypted\",\"encrypted\",\"ended\",\"ended\",\"error\",\"error\",\"gotpointercapture\",\"gotPointerCapture\",\"load\",\"load\",\"loadeddata\",\"loadedData\",\"loadedmetadata\",\"loadedMetadata\",\"loadstart\",\"loadStart\",\"lostpointercapture\",\"lostPointerCapture\",\"playing\",\"playing\",\"progress\",\"progress\",\"seeking\",\"seeking\",\"stalled\",\"stalled\",\"suspend\",\"suspend\",\"timeupdate\",\"timeUpdate\",Ze,\"transitionEnd\",\"waiting\",\"waiting\"];function $t(e,t){for(var n=0;n<e.length;n+=2){var r=e[n],l=e[n+1],i=\"on\"+(l[0].toUpperCase()+l.slice(1));i={phasedRegistrationNames:{bubbled:i,captured:i+\"Capture\"},dependencies:[r],eventPriority:t},Bt.set(r,t),jt.set(r,i),Ht[l]=i}}$t(\"blur blur cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focus focus input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange\".split(\" \"),0),$t(\"drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel\".split(\" \"),1),$t(Kt,2);for(var qt=\"change selectionchange textInput compositionstart compositionend compositionupdate\".split(\" \"),Yt=0;Yt<qt.length;Yt++)Bt.set(qt[Yt],0);var Xt=n.unstable_UserBlockingPriority,Gt=n.unstable_runWithPriority,Zt=!0;function Jt(e,t){en(t,e,!1)}function en(e,t,n){var r=Bt.get(t);switch(void 0===r?2:r){case 0:r=tn.bind(null,t,1,e);break;case 1:r=nn.bind(null,t,1,e);break;default:r=rn.bind(null,t,1,e)}n?e.addEventListener(t,r,!0):e.addEventListener(t,r,!1)}function tn(e,t,n,r){D||O();var l=rn,i=D;D=!0;try{F(l,e,t,n,r)}finally{(D=i)||U()}}function nn(e,t,n,r){Gt(Xt,rn.bind(null,e,t,n,r))}function rn(e,t,n,r){if(Zt)if(0<Tt.length&&-1<zt.indexOf(e))e=Ft(null,e,t,n,r),Tt.push(e);else{var l=ln(e,t,n,r);if(null===l)Ot(e,r);else if(-1<zt.indexOf(e))e=Ft(l,e,t,n,r),Tt.push(e);else if(!Dt(l,e,t,n,r)){Ot(e,r),e=gt(e,r,null,t);try{A(vt,e)}finally{ht(e)}}}}function ln(e,t,n,r){if(null!==(n=Un(n=dt(r)))){var l=nt(n);if(null===l)n=null;else{var i=l.tag;if(13===i){if(null!==(n=rt(l)))return n;n=null}else if(3===i){if(l.stateNode.hydrate)return 3===l.tag?l.stateNode.containerInfo:null;n=null}else l!==n&&(n=null)}}e=gt(e,r,n,t);try{A(vt,e)}finally{ht(e)}return null}var an={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},on=[\"Webkit\",\"ms\",\"Moz\",\"O\"];function un(e,t,n){return null==t||\"boolean\"==typeof t||\"\"===t?\"\":n||\"number\"!=typeof t||0===t||an.hasOwnProperty(e)&&an[e]?(\"\"+t).trim():t+\"px\"}function cn(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf(\"--\"),l=un(n,t[n],r);\"float\"===n&&(n=\"cssFloat\"),r?e.setProperty(n,l):e[n]=l}}Object.keys(an).forEach(function(e){on.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),an[t]=an[e]})});var sn=t({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fn(e,t){if(t){if(sn[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(r(137,e,\"\"));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(r(60));if(!(\"object\"==typeof t.dangerouslySetInnerHTML&&\"__html\"in t.dangerouslySetInnerHTML))throw Error(r(61))}if(null!=t.style&&\"object\"!=typeof t.style)throw Error(r(62,\"\"))}}function dn(e,t){if(-1===e.indexOf(\"-\"))return\"string\"==typeof t.is;switch(e){case\"annotation-xml\":case\"color-profile\":case\"font-face\":case\"font-face-src\":case\"font-face-uri\":case\"font-face-format\":case\"font-face-name\":case\"missing-glyph\":return!1;default:return!0}}var pn=Ue.html;function mn(e,t){var n=tt(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=T[t];for(var r=0;r<t.length;r++)yt(t[r],e,n)}function hn(){}function gn(e){if(void 0===(e=e||(\"undefined\"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function vn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yn(e,t){var n,r=vn(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=vn(r)}}function bn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?bn(e,t.parentNode):\"contains\"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function wn(){for(var e=window,t=gn();t instanceof e.HTMLIFrameElement;){try{var n=\"string\"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=gn((e=t.contentWindow).document)}return t}function kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(\"input\"===t&&(\"text\"===e.type||\"search\"===e.type||\"tel\"===e.type||\"url\"===e.type||\"password\"===e.type)||\"textarea\"===t||\"true\"===e.contentEditable)}var xn=\"$\",Tn=\"/$\",En=\"$?\",Sn=\"$!\",Cn=null,Pn=null;function _n(e,t){switch(e){case\"button\":case\"input\":case\"select\":case\"textarea\":return!!t.autoFocus}return!1}function Nn(e,t){return\"textarea\"===e||\"option\"===e||\"noscript\"===e||\"string\"==typeof t.children||\"number\"==typeof t.children||\"object\"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var zn=\"function\"==typeof setTimeout?setTimeout:void 0,Mn=\"function\"==typeof clearTimeout?clearTimeout:void 0;function In(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break}return e}function Fn(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if(n===xn||n===Sn||n===En){if(0===t)return e;t--}else n===Tn&&t++}e=e.previousSibling}return null}var On=Math.random().toString(36).slice(2),Rn=\"__reactInternalInstance$\"+On,Dn=\"__reactEventHandlers$\"+On,Ln=\"__reactContainere$\"+On;function Un(e){var t=e[Rn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ln]||n[Rn]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fn(e);null!==e;){if(n=e[Rn])return n;e=Fn(e)}return t}n=(e=n).parentNode}return null}function An(e){return!(e=e[Rn]||e[Ln])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Vn(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(r(33))}function Qn(e){return e[Dn]||null}function Wn(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function Hn(e,t){var n=e.stateNode;if(!n)return null;var l=d(n);if(!l)return null;n=l[t];e:switch(t){case\"onClick\":case\"onClickCapture\":case\"onDoubleClick\":case\"onDoubleClickCapture\":case\"onMouseDown\":case\"onMouseDownCapture\":case\"onMouseMove\":case\"onMouseMoveCapture\":case\"onMouseUp\":case\"onMouseUpCapture\":case\"onMouseEnter\":(l=!l.disabled)||(l=!(\"button\"===(e=e.type)||\"input\"===e||\"select\"===e||\"textarea\"===e)),e=!l;break e;default:e=!1}if(e)return null;if(n&&\"function\"!=typeof n)throw Error(r(231,t,typeof n));return n}function jn(e,t,n){(t=Hn(e,n.dispatchConfig.phasedRegistrationNames[t]))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function Bn(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,n=[];t;)n.push(t),t=Wn(t);for(t=n.length;0<t--;)jn(n[t],\"captured\",e);for(t=0;t<n.length;t++)jn(n[t],\"bubbled\",e)}}function Kn(e,t,n){e&&n&&n.dispatchConfig.registrationName&&(t=Hn(e,n.dispatchConfig.registrationName))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function $n(e){e&&e.dispatchConfig.registrationName&&Kn(e._targetInst,null,e)}function qn(e){ut(e,Bn)}var Yn=null,Xn=null,Gn=null;function Zn(){if(Gn)return Gn;var e,t,n=Xn,r=n.length,l=\"value\"in Yn?Yn.value:Yn.textContent,i=l.length;for(e=0;e<r&&n[e]===l[e];e++);var a=r-e;for(t=1;t<=a&&n[r-t]===l[i-t];t++);return Gn=l.slice(e,1<t?1-t:void 0)}function Jn(){return!0}function er(){return!1}function tr(e,t,n,r){for(var l in this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n,e=this.constructor.Interface)e.hasOwnProperty(l)&&((t=e[l])?this[l]=t(n):\"target\"===l?this.target=r:this[l]=n[l]);return this.isDefaultPrevented=(null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue)?Jn:er,this.isPropagationStopped=er,this}function nr(e,t,n,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,t,n,r),l}return new this(e,t,n,r)}function rr(e){if(!(e instanceof this))throw Error(r(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function lr(e){e.eventPool=[],e.getPooled=nr,e.release=rr}t(tr.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():\"unknown\"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Jn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():\"unknown\"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Jn)},persist:function(){this.isPersistent=Jn},isPersistent:er,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=er,this._dispatchInstances=this._dispatchListeners=null}}),tr.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},tr.extend=function(e){function n(){}function r(){return l.apply(this,arguments)}var l=this;n.prototype=l.prototype;var i=new n;return t(i,r.prototype),r.prototype=i,r.prototype.constructor=r,r.Interface=t({},l.Interface,e),r.extend=l.extend,lr(r),r},lr(tr);var ir=tr.extend({data:null}),ar=tr.extend({data:null}),or=[9,13,27,32],ur=S&&\"CompositionEvent\"in window,cr=null;S&&\"documentMode\"in document&&(cr=document.documentMode);var sr=S&&\"TextEvent\"in window&&!cr,fr=S&&(!ur||cr&&8<cr&&11>=cr),dr=String.fromCharCode(32),pr={beforeInput:{phasedRegistrationNames:{bubbled:\"onBeforeInput\",captured:\"onBeforeInputCapture\"},dependencies:[\"compositionend\",\"keypress\",\"textInput\",\"paste\"]},compositionEnd:{phasedRegistrationNames:{bubbled:\"onCompositionEnd\",captured:\"onCompositionEndCapture\"},dependencies:\"blur compositionend keydown keypress keyup mousedown\".split(\" \")},compositionStart:{phasedRegistrationNames:{bubbled:\"onCompositionStart\",captured:\"onCompositionStartCapture\"},dependencies:\"blur compositionstart keydown keypress keyup mousedown\".split(\" \")},compositionUpdate:{phasedRegistrationNames:{bubbled:\"onCompositionUpdate\",captured:\"onCompositionUpdateCapture\"},dependencies:\"blur compositionupdate keydown keypress keyup mousedown\".split(\" \")}},mr=!1;function hr(e,t){switch(e){case\"keyup\":return-1!==or.indexOf(t.keyCode);case\"keydown\":return 229!==t.keyCode;case\"keypress\":case\"mousedown\":case\"blur\":return!0;default:return!1}}function gr(e){return\"object\"==typeof(e=e.detail)&&\"data\"in e?e.data:null}var vr=!1;function yr(e,t){switch(e){case\"compositionend\":return gr(t);case\"keypress\":return 32!==t.which?null:(mr=!0,dr);case\"textInput\":return(e=t.data)===dr&&mr?null:e;default:return null}}function br(e,t){if(vr)return\"compositionend\"===e||!ur&&hr(e,t)?(e=Zn(),Gn=Xn=Yn=null,vr=!1,e):null;switch(e){case\"paste\":return null;case\"keypress\":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case\"compositionend\":return fr&&\"ko\"!==t.locale?null:t.data;default:return null}}var wr={eventTypes:pr,extractEvents:function(e,t,n,r){var l;if(ur)e:{switch(e){case\"compositionstart\":var i=pr.compositionStart;break e;case\"compositionend\":i=pr.compositionEnd;break e;case\"compositionupdate\":i=pr.compositionUpdate;break e}i=void 0}else vr?hr(e,n)&&(i=pr.compositionEnd):\"keydown\"===e&&229===n.keyCode&&(i=pr.compositionStart);return i?(fr&&\"ko\"!==n.locale&&(vr||i!==pr.compositionStart?i===pr.compositionEnd&&vr&&(l=Zn()):(Xn=\"value\"in(Yn=r)?Yn.value:Yn.textContent,vr=!0)),i=ir.getPooled(i,t,n,r),l?i.data=l:null!==(l=gr(n))&&(i.data=l),qn(i),l=i):l=null,(e=sr?yr(e,n):br(e,n))?((t=ar.getPooled(pr.beforeInput,t,n,r)).data=e,qn(t)):t=null,null===l?t:null===t?l:[l,t]}},kr={color:!0,date:!0,datetime:!0,\"datetime-local\":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return\"input\"===t?!!kr[e.type]:\"textarea\"===t}var Tr={change:{phasedRegistrationNames:{bubbled:\"onChange\",captured:\"onChangeCapture\"},dependencies:\"blur change click focus input keydown keyup selectionchange\".split(\" \")}};function Er(e,t,n){return(e=tr.getPooled(Tr.change,e,t,n)).type=\"change\",z(n),qn(e),e}var Sr=null,Cr=null;function Pr(e){ft(e)}function _r(e){if(Ee(Vn(e)))return e}function Nr(e,t){if(\"change\"===e)return t}var zr=!1;function Mr(){Sr&&(Sr.detachEvent(\"onpropertychange\",Ir),Cr=Sr=null)}function Ir(e){if(\"value\"===e.propertyName&&_r(Cr))if(e=Er(Cr,e,dt(e)),D)ft(e);else{D=!0;try{I(Pr,e)}finally{D=!1,U()}}}function Fr(e,t,n){\"focus\"===e?(Mr(),Cr=n,(Sr=t).attachEvent(\"onpropertychange\",Ir)):\"blur\"===e&&Mr()}function Or(e){if(\"selectionchange\"===e||\"keyup\"===e||\"keydown\"===e)return _r(Cr)}function Rr(e,t){if(\"click\"===e)return _r(t)}function Dr(e,t){if(\"input\"===e||\"change\"===e)return _r(t)}S&&(zr=pt(\"input\")&&(!document.documentMode||9<document.documentMode));var Lr={eventTypes:Tr,_isInputEventSupported:zr,extractEvents:function(e,t,n,r){var l=t?Vn(t):window,i=l.nodeName&&l.nodeName.toLowerCase();if(\"select\"===i||\"input\"===i&&\"file\"===l.type)var a=Nr;else if(xr(l))if(zr)a=Dr;else{a=Or;var o=Fr}else(i=l.nodeName)&&\"input\"===i.toLowerCase()&&(\"checkbox\"===l.type||\"radio\"===l.type)&&(a=Rr);if(a&&(a=a(e,t)))return Er(a,n,r);o&&o(e,l,t),\"blur\"===e&&(e=l._wrapperState)&&e.controlled&&\"number\"===l.type&&ze(l,\"number\",l.value)}},Ur=tr.extend({view:null,detail:null}),Ar={Alt:\"altKey\",Control:\"ctrlKey\",Meta:\"metaKey\",Shift:\"shiftKey\"};function Vr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function Qr(){return Vr}var Wr=0,Hr=0,jr=!1,Br=!1,Kr=Ur.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:Qr,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},movementX:function(e){if(\"movementX\"in e)return e.movementX;var t=Wr;return Wr=e.screenX,jr?\"mousemove\"===e.type?e.screenX-t:0:(jr=!0,0)},movementY:function(e){if(\"movementY\"in e)return e.movementY;var t=Hr;return Hr=e.screenY,Br?\"mousemove\"===e.type?e.screenY-t:0:(Br=!0,0)}}),$r=Kr.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),qr={mouseEnter:{registrationName:\"onMouseEnter\",dependencies:[\"mouseout\",\"mouseover\"]},mouseLeave:{registrationName:\"onMouseLeave\",dependencies:[\"mouseout\",\"mouseover\"]},pointerEnter:{registrationName:\"onPointerEnter\",dependencies:[\"pointerout\",\"pointerover\"]},pointerLeave:{registrationName:\"onPointerLeave\",dependencies:[\"pointerout\",\"pointerover\"]}},Yr={eventTypes:qr,extractEvents:function(e,t,n,r,l){var i=\"mouseover\"===e||\"pointerover\"===e,a=\"mouseout\"===e||\"pointerout\"===e;if(i&&0==(32&l)&&(n.relatedTarget||n.fromElement)||!a&&!i)return null;(i=r.window===r?r:(i=r.ownerDocument)?i.defaultView||i.parentWindow:window,a)?(a=t,null!==(t=(t=n.relatedTarget||n.toElement)?Un(t):null)&&(t!==nt(t)||5!==t.tag&&6!==t.tag)&&(t=null)):a=null;if(a===t)return null;if(\"mouseout\"===e||\"mouseover\"===e)var o=Kr,u=qr.mouseLeave,c=qr.mouseEnter,s=\"mouse\";else\"pointerout\"!==e&&\"pointerover\"!==e||(o=$r,u=qr.pointerLeave,c=qr.pointerEnter,s=\"pointer\");if(e=null==a?i:Vn(a),i=null==t?i:Vn(t),(u=o.getPooled(u,a,n,r)).type=s+\"leave\",u.target=e,u.relatedTarget=i,(n=o.getPooled(c,t,n,r)).type=s+\"enter\",n.target=i,n.relatedTarget=e,s=t,(r=a)&&s)e:{for(c=s,a=0,e=o=r;e;e=Wn(e))a++;for(e=0,t=c;t;t=Wn(t))e++;for(;0<a-e;)o=Wn(o),a--;for(;0<e-a;)c=Wn(c),e--;for(;a--;){if(o===c||o===c.alternate)break e;o=Wn(o),c=Wn(c)}o=null}else o=null;for(c=o,o=[];r&&r!==c&&(null===(a=r.alternate)||a!==c);)o.push(r),r=Wn(r);for(r=[];s&&s!==c&&(null===(a=s.alternate)||a!==c);)r.push(s),s=Wn(s);for(s=0;s<o.length;s++)Kn(o[s],\"bubbled\",u);for(s=r.length;0<s--;)Kn(r[s],\"captured\",n);return 0==(64&l)?[u]:[u,n]}};function Xr(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t}var Gr=\"function\"==typeof Object.is?Object.is:Xr,Zr=Object.prototype.hasOwnProperty;function Jr(e,t){if(Gr(e,t))return!0;if(\"object\"!=typeof e||null===e||\"object\"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++)if(!Zr.call(t,n[r])||!Gr(e[n[r]],t[n[r]]))return!1;return!0}var el=S&&\"documentMode\"in document&&11>=document.documentMode,tl={select:{phasedRegistrationNames:{bubbled:\"onSelect\",captured:\"onSelectCapture\"},dependencies:\"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange\".split(\" \")}},nl=null,rl=null,ll=null,il=!1;function al(e,t){var n=t.window===t?t.document:9===t.nodeType?t:t.ownerDocument;return il||null==nl||nl!==gn(n)?null:(\"selectionStart\"in(n=nl)&&kn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},ll&&Jr(ll,n)?null:(ll=n,(e=tr.getPooled(tl.select,rl,e,t)).type=\"select\",e.target=nl,qn(e),e))}var ol={eventTypes:tl,extractEvents:function(e,t,n,r,l,i){if(!(i=!(l=i||(r.window===r?r.document:9===r.nodeType?r:r.ownerDocument)))){e:{l=tt(l),i=T.onSelect;for(var a=0;a<i.length;a++)if(!l.has(i[a])){l=!1;break e}l=!0}i=!l}if(i)return null;switch(l=t?Vn(t):window,e){case\"focus\":(xr(l)||\"true\"===l.contentEditable)&&(nl=l,rl=t,ll=null);break;case\"blur\":ll=rl=nl=null;break;case\"mousedown\":il=!0;break;case\"contextmenu\":case\"mouseup\":case\"dragend\":return il=!1,al(n,r);case\"selectionchange\":if(el)break;case\"keydown\":case\"keyup\":return al(n,r)}return null}},ul=tr.extend({animationName:null,elapsedTime:null,pseudoElement:null}),cl=tr.extend({clipboardData:function(e){return\"clipboardData\"in e?e.clipboardData:window.clipboardData}}),sl=Ur.extend({relatedTarget:null});function fl(e){var t=e.keyCode;return\"charCode\"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}var dl={Esc:\"Escape\",Spacebar:\" \",Left:\"ArrowLeft\",Up:\"ArrowUp\",Right:\"ArrowRight\",Down:\"ArrowDown\",Del:\"Delete\",Win:\"OS\",Menu:\"ContextMenu\",Apps:\"ContextMenu\",Scroll:\"ScrollLock\",MozPrintableKey:\"Unidentified\"},pl={8:\"Backspace\",9:\"Tab\",12:\"Clear\",13:\"Enter\",16:\"Shift\",17:\"Control\",18:\"Alt\",19:\"Pause\",20:\"CapsLock\",27:\"Escape\",32:\" \",33:\"PageUp\",34:\"PageDown\",35:\"End\",36:\"Home\",37:\"ArrowLeft\",38:\"ArrowUp\",39:\"ArrowRight\",40:\"ArrowDown\",45:\"Insert\",46:\"Delete\",112:\"F1\",113:\"F2\",114:\"F3\",115:\"F4\",116:\"F5\",117:\"F6\",118:\"F7\",119:\"F8\",120:\"F9\",121:\"F10\",122:\"F11\",123:\"F12\",144:\"NumLock\",145:\"ScrollLock\",224:\"Meta\"},ml=Ur.extend({key:function(e){if(e.key){var t=dl[e.key]||e.key;if(\"Unidentified\"!==t)return t}return\"keypress\"===e.type?13===(e=fl(e))?\"Enter\":String.fromCharCode(e):\"keydown\"===e.type||\"keyup\"===e.type?pl[e.keyCode]||\"Unidentified\":\"\"},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Qr,charCode:function(e){return\"keypress\"===e.type?fl(e):0},keyCode:function(e){return\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0},which:function(e){return\"keypress\"===e.type?fl(e):\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0}}),hl=Kr.extend({dataTransfer:null}),gl=Ur.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Qr}),vl=tr.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),yl=Kr.extend({deltaX:function(e){return\"deltaX\"in e?e.deltaX:\"wheelDeltaX\"in e?-e.wheelDeltaX:0},deltaY:function(e){return\"deltaY\"in e?e.deltaY:\"wheelDeltaY\"in e?-e.wheelDeltaY:\"wheelDelta\"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),bl={eventTypes:Ht,extractEvents:function(e,t,n,r){var l=jt.get(e);if(!l)return null;switch(e){case\"keypress\":if(0===fl(n))return null;case\"keydown\":case\"keyup\":e=ml;break;case\"blur\":case\"focus\":e=sl;break;case\"click\":if(2===n.button)return null;case\"auxclick\":case\"dblclick\":case\"mousedown\":case\"mousemove\":case\"mouseup\":case\"mouseout\":case\"mouseover\":case\"contextmenu\":e=Kr;break;case\"drag\":case\"dragend\":case\"dragenter\":case\"dragexit\":case\"dragleave\":case\"dragover\":case\"dragstart\":case\"drop\":e=hl;break;case\"touchcancel\":case\"touchend\":case\"touchmove\":case\"touchstart\":e=gl;break;case Ye:case Xe:case Ge:e=ul;break;case Ze:e=vl;break;case\"scroll\":e=Ur;break;case\"wheel\":e=yl;break;case\"copy\":case\"cut\":case\"paste\":e=cl;break;case\"gotpointercapture\":case\"lostpointercapture\":case\"pointercancel\":case\"pointerdown\":case\"pointermove\":case\"pointerout\":case\"pointerover\":case\"pointerup\":e=$r;break;default:e=tr}return qn(t=e.getPooled(l,t,n,r)),t}};if(g)throw Error(r(101));g=Array.prototype.slice.call(\"ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin\".split(\" \")),y();var wl=An;d=Qn,p=wl,m=Vn,E({SimpleEventPlugin:bl,EnterLeaveEventPlugin:Yr,ChangeEventPlugin:Lr,SelectEventPlugin:ol,BeforeInputEventPlugin:wr});var kl=[],xl=-1;function Tl(e){0>xl||(e.current=kl[xl],kl[xl]=null,xl--)}function El(e,t){kl[++xl]=e.current,e.current=t}var Sl={},Cl={current:Sl},Pl={current:!1},_l=Sl;function Nl(e,t){var n=e.type.contextTypes;if(!n)return Sl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,i={};for(l in n)i[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function zl(e){return null!=(e=e.childContextTypes)}function Ml(){Tl(Pl),Tl(Cl)}function Il(e,t,n){if(Cl.current!==Sl)throw Error(r(168));El(Cl,t),El(Pl,n)}function Fl(e,n,l){var i=e.stateNode;if(e=n.childContextTypes,\"function\"!=typeof i.getChildContext)return l;for(var a in i=i.getChildContext())if(!(a in e))throw Error(r(108,ye(n)||\"Unknown\",a));return t({},l,{},i)}function Ol(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Sl,_l=Cl.current,El(Cl,e),El(Pl,Pl.current),!0}function Rl(e,t,n){var l=e.stateNode;if(!l)throw Error(r(169));n?(e=Fl(e,t,_l),l.__reactInternalMemoizedMergedChildContext=e,Tl(Pl),Tl(Cl),El(Cl,e)):Tl(Pl),El(Pl,n)}var Dl=n.unstable_runWithPriority,Ll=n.unstable_scheduleCallback,Ul=n.unstable_cancelCallback,Al=n.unstable_requestPaint,Vl=n.unstable_now,Ql=n.unstable_getCurrentPriorityLevel,Wl=n.unstable_ImmediatePriority,Hl=n.unstable_UserBlockingPriority,jl=n.unstable_NormalPriority,Bl=n.unstable_LowPriority,Kl=n.unstable_IdlePriority,$l={},ql=n.unstable_shouldYield,Yl=void 0!==Al?Al:function(){},Xl=null,Gl=null,Zl=!1,Jl=Vl(),ei=1e4>Jl?Vl:function(){return Vl()-Jl};function ti(){switch(Ql()){case Wl:return 99;case Hl:return 98;case jl:return 97;case Bl:return 96;case Kl:return 95;default:throw Error(r(332))}}function ni(e){switch(e){case 99:return Wl;case 98:return Hl;case 97:return jl;case 96:return Bl;case 95:return Kl;default:throw Error(r(332))}}function ri(e,t){return e=ni(e),Dl(e,t)}function li(e,t,n){return e=ni(e),Ll(e,t,n)}function ii(e){return null===Xl?(Xl=[e],Gl=Ll(Wl,oi)):Xl.push(e),$l}function ai(){if(null!==Gl){var e=Gl;Gl=null,Ul(e)}oi()}function oi(){if(!Zl&&null!==Xl){Zl=!0;var e=0;try{var t=Xl;ri(99,function(){for(;e<t.length;e++){var n=t[e];do{n=n(!0)}while(null!==n)}}),Xl=null}catch(n){throw null!==Xl&&(Xl=Xl.slice(e+1)),Ll(Wl,ai),n}finally{Zl=!1}}}function ui(e,t,n){return 1073741821-(1+((1073741821-e+t/10)/(n/=10)|0))*n}function ci(e,n){if(e&&e.defaultProps)for(var r in n=t({},n),e=e.defaultProps)void 0===n[r]&&(n[r]=e[r]);return n}var si={current:null},fi=null,di=null,pi=null;function mi(){pi=di=fi=null}function hi(e){var t=si.current;Tl(si),e.type._context._currentValue=t}function gi(e,t){for(;null!==e;){var n=e.alternate;if(e.childExpirationTime<t)e.childExpirationTime=t,null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t);else{if(!(null!==n&&n.childExpirationTime<t))break;n.childExpirationTime=t}e=e.return}}function vi(e,t){fi=e,pi=di=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(e.expirationTime>=t&&(ja=!0),e.firstContext=null)}function yi(e,t){if(pi!==e&&!1!==t&&0!==t)if(\"number\"==typeof t&&1073741823!==t||(pi=e,t=1073741823),t={context:e,observedBits:t,next:null},null===di){if(null===fi)throw Error(r(308));di=t,fi.dependencies={expirationTime:0,firstContext:t,responders:null}}else di=di.next=t;return e._currentValue}var bi=!1;function wi(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function ki(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function xi(e,t){return(e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null}).next=e}function Ti(e,t){if(null!==(e=e.updateQueue)){var n=(e=e.shared).pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}}function Ei(e,t){var n=e.alternate;null!==n&&ki(n,e),null===(n=(e=e.updateQueue).baseQueue)?(e.baseQueue=t.next=t,t.next=t):(t.next=n.next,n.next=t)}function Si(e,n,r,l){var i=e.updateQueue;bi=!1;var a=i.baseQueue,o=i.shared.pending;if(null!==o){if(null!==a){var u=a.next;a.next=o.next,o.next=u}a=o,i.shared.pending=null,null!==(u=e.alternate)&&(null!==(u=u.updateQueue)&&(u.baseQueue=o))}if(null!==a){u=a.next;var c=i.baseState,s=0,f=null,d=null,p=null;if(null!==u)for(var m=u;;){if((o=m.expirationTime)<l){var h={expirationTime:m.expirationTime,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null};null===p?(d=p=h,f=c):p=p.next=h,o>s&&(s=o)}else{null!==p&&(p=p.next={expirationTime:1073741823,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null}),Fu(o,m.suspenseConfig);e:{var g=e,v=m;switch(o=n,h=r,v.tag){case 1:if(\"function\"==typeof(g=v.payload)){c=g.call(h,c,o);break e}c=g;break e;case 3:g.effectTag=-4097&g.effectTag|64;case 0:if(null==(o=\"function\"==typeof(g=v.payload)?g.call(h,c,o):g))break e;c=t({},c,o);break e;case 2:bi=!0}}null!==m.callback&&(e.effectTag|=32,null===(o=i.effects)?i.effects=[m]:o.push(m))}if(null===(m=m.next)||m===u){if(null===(o=i.shared.pending))break;m=a.next=o.next,o.next=u,i.baseQueue=a=o,i.shared.pending=null}}null===p?f=c:p.next=d,i.baseState=f,i.baseQueue=p,Ou(s),e.expirationTime=s,e.memoizedState=c}}function Ci(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var l=e[t],i=l.callback;if(null!==i){if(l.callback=null,l=i,i=n,\"function\"!=typeof l)throw Error(r(191,l));l.call(i)}}}var Pi=G.ReactCurrentBatchConfig,_i=(new e.Component).refs;function Ni(e,n,r,l){r=null==(r=r(l,n=e.memoizedState))?n:t({},n,r),e.memoizedState=r,0===e.expirationTime&&(e.updateQueue.baseState=r)}var zi={isMounted:function(e){return!!(e=e._reactInternalFiber)&&nt(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueReplaceState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).tag=1,l.payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var n=bu(),r=Pi.suspense;(r=xi(n=wu(n,e,r),r)).tag=2,null!=t&&(r.callback=t),Ti(e,r),ku(e,n)}};function Mi(e,t,n,r,l,i,a){return\"function\"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,a):!t.prototype||!t.prototype.isPureReactComponent||(!Jr(n,r)||!Jr(l,i))}function Ii(e,t,n){var r=!1,l=Sl,i=t.contextType;return\"object\"==typeof i&&null!==i?i=yi(i):(l=zl(t)?_l:Cl.current,i=(r=null!=(r=t.contextTypes))?Nl(e,l):Sl),t=new t(n,i),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=zi,e.stateNode=t,t._reactInternalFiber=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function Fi(e,t,n,r){e=t.state,\"function\"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),\"function\"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zi.enqueueReplaceState(t,t.state,null)}function Oi(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs=_i,wi(e);var i=t.contextType;\"object\"==typeof i&&null!==i?l.context=yi(i):(i=zl(t)?_l:Cl.current,l.context=Nl(e,i)),Si(e,n,l,r),l.state=e.memoizedState,\"function\"==typeof(i=t.getDerivedStateFromProps)&&(Ni(e,t,i,n),l.state=e.memoizedState),\"function\"==typeof t.getDerivedStateFromProps||\"function\"==typeof l.getSnapshotBeforeUpdate||\"function\"!=typeof l.UNSAFE_componentWillMount&&\"function\"!=typeof l.componentWillMount||(t=l.state,\"function\"==typeof l.componentWillMount&&l.componentWillMount(),\"function\"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),t!==l.state&&zi.enqueueReplaceState(l,l.state,null),Si(e,n,l,r),l.state=e.memoizedState),\"function\"==typeof l.componentDidMount&&(e.effectTag|=4)}var Ri=Array.isArray;function Di(e,t,n){if(null!==(e=n.ref)&&\"function\"!=typeof e&&\"object\"!=typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(r(309));var l=n.stateNode}if(!l)throw Error(r(147,e));var i=\"\"+e;return null!==t&&null!==t.ref&&\"function\"==typeof t.ref&&t.ref._stringRef===i?t.ref:((t=function(e){var t=l.refs;t===_i&&(t=l.refs={}),null===e?delete t[i]:t[i]=e})._stringRef=i,t)}if(\"string\"!=typeof e)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Li(e,t){if(\"textarea\"!==e.type)throw Error(r(31,\"[object Object]\"===Object.prototype.toString.call(t)?\"object with keys {\"+Object.keys(t).join(\", \")+\"}\":t,\"\"))}function Ui(e){function t(t,n){if(e){var r=t.lastEffect;null!==r?(r.nextEffect=n,t.lastEffect=n):t.firstEffect=t.lastEffect=n,n.nextEffect=null,n.effectTag=8}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function l(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=nc(e,t)).index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.effectTag=2,n):r:(t.effectTag=2,n):n}function o(t){return e&&null===t.alternate&&(t.effectTag=2),t}function u(e,t,n,r){return null===t||6!==t.tag?((t=ic(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){return null!==t&&t.elementType===n.type?((r=i(t,n.props)).ref=Di(e,t,n),r.return=e,r):((r=rc(n.type,n.key,n.props,null,e.mode,r)).ref=Di(e,t,n),r.return=e,r)}function s(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=ac(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function f(e,t,n,r,l){return null===t||7!==t.tag?((t=lc(n,e.mode,r,l)).return=e,t):((t=i(t,n)).return=e,t)}function d(e,t,n){if(\"string\"==typeof t||\"number\"==typeof t)return(t=ic(\"\"+t,e.mode,n)).return=e,t;if(\"object\"==typeof t&&null!==t){switch(t.$$typeof){case te:return(n=rc(t.type,t.key,t.props,null,e.mode,n)).ref=Di(e,null,t),n.return=e,n;case ne:return(t=ac(t,e.mode,n)).return=e,t}if(Ri(t)||ge(t))return(t=lc(t,e.mode,n,null)).return=e,t;Li(e,t)}return null}function p(e,t,n,r){var l=null!==t?t.key:null;if(\"string\"==typeof n||\"number\"==typeof n)return null!==l?null:u(e,t,\"\"+n,r);if(\"object\"==typeof n&&null!==n){switch(n.$$typeof){case te:return n.key===l?n.type===re?f(e,t,n.props.children,r,l):c(e,t,n,r):null;case ne:return n.key===l?s(e,t,n,r):null}if(Ri(n)||ge(n))return null!==l?null:f(e,t,n,r,null);Li(e,n)}return null}function m(e,t,n,r,l){if(\"string\"==typeof r||\"number\"==typeof r)return u(t,e=e.get(n)||null,\"\"+r,l);if(\"object\"==typeof r&&null!==r){switch(r.$$typeof){case te:return e=e.get(null===r.key?n:r.key)||null,r.type===re?f(t,e,r.props.children,l,r.key):c(t,e,r,l);case ne:return s(t,e=e.get(null===r.key?n:r.key)||null,r,l)}if(Ri(r)||ge(r))return f(t,e=e.get(n)||null,r,l,null);Li(t,r)}return null}function h(r,i,o,u){for(var c=null,s=null,f=i,h=i=0,g=null;null!==f&&h<o.length;h++){f.index>h?(g=f,f=null):g=f.sibling;var v=p(r,f,o[h],u);if(null===v){null===f&&(f=g);break}e&&f&&null===v.alternate&&t(r,f),i=a(v,i,h),null===s?c=v:s.sibling=v,s=v,f=g}if(h===o.length)return n(r,f),c;if(null===f){for(;h<o.length;h++)null!==(f=d(r,o[h],u))&&(i=a(f,i,h),null===s?c=f:s.sibling=f,s=f);return c}for(f=l(r,f);h<o.length;h++)null!==(g=m(f,r,h,o[h],u))&&(e&&null!==g.alternate&&f.delete(null===g.key?h:g.key),i=a(g,i,h),null===s?c=g:s.sibling=g,s=g);return e&&f.forEach(function(e){return t(r,e)}),c}function g(i,o,u,c){var s=ge(u);if(\"function\"!=typeof s)throw Error(r(150));if(null==(u=s.call(u)))throw Error(r(151));for(var f=s=null,h=o,g=o=0,v=null,y=u.next();null!==h&&!y.done;g++,y=u.next()){h.index>g?(v=h,h=null):v=h.sibling;var b=p(i,h,y.value,c);if(null===b){null===h&&(h=v);break}e&&h&&null===b.alternate&&t(i,h),o=a(b,o,g),null===f?s=b:f.sibling=b,f=b,h=v}if(y.done)return n(i,h),s;if(null===h){for(;!y.done;g++,y=u.next())null!==(y=d(i,y.value,c))&&(o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return s}for(h=l(i,h);!y.done;g++,y=u.next())null!==(y=m(h,i,g,y.value,c))&&(e&&null!==y.alternate&&h.delete(null===y.key?g:y.key),o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return e&&h.forEach(function(e){return t(i,e)}),s}return function(e,l,a,u){var c=\"object\"==typeof a&&null!==a&&a.type===re&&null===a.key;c&&(a=a.props.children);var s=\"object\"==typeof a&&null!==a;if(s)switch(a.$$typeof){case te:e:{for(s=a.key,c=l;null!==c;){if(c.key===s){switch(c.tag){case 7:if(a.type===re){n(e,c.sibling),(l=i(c,a.props.children)).return=e,e=l;break e}break;default:if(c.elementType===a.type){n(e,c.sibling),(l=i(c,a.props)).ref=Di(e,c,a),l.return=e,e=l;break e}}n(e,c);break}t(e,c),c=c.sibling}a.type===re?((l=lc(a.props.children,e.mode,u,a.key)).return=e,e=l):((u=rc(a.type,a.key,a.props,null,e.mode,u)).ref=Di(e,l,a),u.return=e,e=u)}return o(e);case ne:e:{for(c=a.key;null!==l;){if(l.key===c){if(4===l.tag&&l.stateNode.containerInfo===a.containerInfo&&l.stateNode.implementation===a.implementation){n(e,l.sibling),(l=i(l,a.children||[])).return=e,e=l;break e}n(e,l);break}t(e,l),l=l.sibling}(l=ac(a,e.mode,u)).return=e,e=l}return o(e)}if(\"string\"==typeof a||\"number\"==typeof a)return a=\"\"+a,null!==l&&6===l.tag?(n(e,l.sibling),(l=i(l,a)).return=e,e=l):(n(e,l),(l=ic(a,e.mode,u)).return=e,e=l),o(e);if(Ri(a))return h(e,l,a,u);if(ge(a))return g(e,l,a,u);if(s&&Li(e,a),void 0===a&&!c)switch(e.tag){case 1:case 0:throw e=e.type,Error(r(152,e.displayName||e.name||\"Component\"))}return n(e,l)}}var Ai=Ui(!0),Vi=Ui(!1),Qi={},Wi={current:Qi},Hi={current:Qi},ji={current:Qi};function Bi(e){if(e===Qi)throw Error(r(174));return e}function Ki(e,t){switch(El(ji,t),El(Hi,e),El(Wi,Qi),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ve(null,\"\");break;default:t=Ve(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}Tl(Wi),El(Wi,t)}function $i(){Tl(Wi),Tl(Hi),Tl(ji)}function qi(e){Bi(ji.current);var t=Bi(Wi.current),n=Ve(t,e.type);t!==n&&(El(Hi,e),El(Wi,n))}function Yi(e){Hi.current===e&&(Tl(Wi),Tl(Hi))}var Xi={current:0};function Gi(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||n.data===En||n.data===Sn))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(64&t.effectTag))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Zi(e,t){return{responder:e,props:t}}var Ji=G.ReactCurrentDispatcher,ea=G.ReactCurrentBatchConfig,ta=0,na=null,ra=null,la=null,ia=!1;function aa(){throw Error(r(321))}function oa(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Gr(e[n],t[n]))return!1;return!0}function ua(e,t,n,l,i,a){if(ta=a,na=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,Ji.current=null===e||null===e.memoizedState?Ma:Ia,e=n(l,i),t.expirationTime===ta){a=0;do{if(t.expirationTime=0,!(25>a))throw Error(r(301));a+=1,la=ra=null,t.updateQueue=null,Ji.current=Fa,e=n(l,i)}while(t.expirationTime===ta)}if(Ji.current=za,t=null!==ra&&null!==ra.next,ta=0,la=ra=na=null,ia=!1,t)throw Error(r(300));return e}function ca(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===la?na.memoizedState=la=e:la=la.next=e,la}function sa(){if(null===ra){var e=na.alternate;e=null!==e?e.memoizedState:null}else e=ra.next;var t=null===la?na.memoizedState:la.next;if(null!==t)la=t,ra=e;else{if(null===e)throw Error(r(310));e={memoizedState:(ra=e).memoizedState,baseState:ra.baseState,baseQueue:ra.baseQueue,queue:ra.queue,next:null},null===la?na.memoizedState=la=e:la=la.next=e}return la}function fa(e,t){return\"function\"==typeof t?t(e):t}function da(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=ra,i=l.baseQueue,a=n.pending;if(null!==a){if(null!==i){var o=i.next;i.next=a.next,a.next=o}l.baseQueue=i=a,n.pending=null}if(null!==i){i=i.next,l=l.baseState;var u=o=a=null,c=i;do{var s=c.expirationTime;if(s<ta){var f={expirationTime:c.expirationTime,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null};null===u?(o=u=f,a=l):u=u.next=f,s>na.expirationTime&&(na.expirationTime=s,Ou(s))}else null!==u&&(u=u.next={expirationTime:1073741823,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null}),Fu(s,c.suspenseConfig),l=c.eagerReducer===e?c.eagerState:e(l,c.action);c=c.next}while(null!==c&&c!==i);null===u?a=l:u.next=o,Gr(l,t.memoizedState)||(ja=!0),t.memoizedState=l,t.baseState=a,t.baseQueue=u,n.lastRenderedState=l}return[t.memoizedState,n.dispatch]}function pa(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=n.dispatch,i=n.pending,a=t.memoizedState;if(null!==i){n.pending=null;var o=i=i.next;do{a=e(a,o.action),o=o.next}while(o!==i);Gr(a,t.memoizedState)||(ja=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),n.lastRenderedState=a}return[a,l]}function ma(e){var t=ca();return\"function\"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={pending:null,dispatch:null,lastRenderedReducer:fa,lastRenderedState:e}).dispatch=Na.bind(null,na,e),[t.memoizedState,e]}function ha(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=na.updateQueue)?(t={lastEffect:null},na.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ga(){return sa().memoizedState}function va(e,t,n,r){var l=ca();na.effectTag|=e,l.memoizedState=ha(1|t,n,void 0,void 0===r?null:r)}function ya(e,t,n,r){var l=sa();r=void 0===r?null:r;var i=void 0;if(null!==ra){var a=ra.memoizedState;if(i=a.destroy,null!==r&&oa(r,a.deps))return void ha(t,n,i,r)}na.effectTag|=e,l.memoizedState=ha(1|t,n,i,r)}function ba(e,t){return va(516,4,e,t)}function wa(e,t){return ya(516,4,e,t)}function ka(e,t){return ya(4,2,e,t)}function xa(e,t){return\"function\"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ta(e,t,n){return n=null!=n?n.concat([e]):null,ya(4,2,xa.bind(null,t,e),n)}function Ea(){}function Sa(e,t){return ca().memoizedState=[e,void 0===t?null:t],e}function Ca(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Pa(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function _a(e,t,n){var r=ti();ri(98>r?98:r,function(){e(!0)}),ri(97<r?97:r,function(){var r=ea.suspense;ea.suspense=void 0===t?null:t;try{e(!1),n()}finally{ea.suspense=r}})}function Na(e,t,n){var r=bu(),l=Pi.suspense;l={expirationTime:r=wu(r,e,l),suspenseConfig:l,action:n,eagerReducer:null,eagerState:null,next:null};var i=t.pending;if(null===i?l.next=l:(l.next=i.next,i.next=l),t.pending=l,i=e.alternate,e===na||null!==i&&i===na)ia=!0,l.expirationTime=ta,na.expirationTime=ta;else{if(0===e.expirationTime&&(null===i||0===i.expirationTime)&&null!==(i=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=i(a,n);if(l.eagerReducer=i,l.eagerState=o,Gr(o,a))return}catch(u){}ku(e,r)}}var za={readContext:yi,useCallback:aa,useContext:aa,useEffect:aa,useImperativeHandle:aa,useLayoutEffect:aa,useMemo:aa,useReducer:aa,useRef:aa,useState:aa,useDebugValue:aa,useResponder:aa,useDeferredValue:aa,useTransition:aa},Ma={readContext:yi,useCallback:Sa,useContext:yi,useEffect:ba,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,va(4,2,xa.bind(null,t,e),n)},useLayoutEffect:function(e,t){return va(4,2,e,t)},useMemo:function(e,t){var n=ca();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ca();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Na.bind(null,na,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ca().memoizedState=e},useState:ma,useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=ma(e),r=n[0],l=n[1];return ba(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=ma(!1),n=t[0];return t=t[1],[Sa(_a.bind(null,t,e),[t,e]),n]}},Ia={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:da,useRef:ga,useState:function(){return da(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=da(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=da(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Fa={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:pa,useRef:ga,useState:function(){return pa(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=pa(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=pa(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Oa=null,Ra=null,Da=!1;function La(e,t){var n=Ju(5,null,null,0);n.elementType=\"DELETED\",n.type=\"DELETED\",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function Ua(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=\"\"===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);case 13:default:return!1}}function Aa(e){if(Da){var t=Ra;if(t){var n=t;if(!Ua(e,t)){if(!(t=In(n.nextSibling))||!Ua(e,t))return e.effectTag=-1025&e.effectTag|2,Da=!1,void(Oa=e);La(Oa,n)}Oa=e,Ra=In(t.firstChild)}else e.effectTag=-1025&e.effectTag|2,Da=!1,Oa=e}}function Va(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;Oa=e}function Qa(e){if(e!==Oa)return!1;if(!Da)return Va(e),Da=!0,!1;var t=e.type;if(5!==e.tag||\"head\"!==t&&\"body\"!==t&&!Nn(t,e.memoizedProps))for(t=Ra;t;)La(e,t),t=In(t.nextSibling);if(Va(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if(n===Tn){if(0===t){Ra=In(e.nextSibling);break e}t--}else n!==xn&&n!==Sn&&n!==En||t++}e=e.nextSibling}Ra=null}}else Ra=Oa?In(e.stateNode.nextSibling):null;return!0}function Wa(){Ra=Oa=null,Da=!1}var Ha=G.ReactCurrentOwner,ja=!1;function Ba(e,t,n,r){t.child=null===e?Vi(t,null,n,r):Ai(t,e.child,n,r)}function Ka(e,t,n,r,l){n=n.render;var i=t.ref;return vi(t,l),r=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function $a(e,t,n,r,l,i){if(null===e){var a=n.type;return\"function\"!=typeof a||ec(a)||void 0!==a.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=rc(n.type,null,r,null,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,qa(e,t,a,r,l,i))}return a=e.child,l<i&&(l=a.memoizedProps,(n=null!==(n=n.compare)?n:Jr)(l,r)&&e.ref===t.ref)?co(e,t,i):(t.effectTag|=1,(e=nc(a,r)).ref=t.ref,e.return=t,t.child=e)}function qa(e,t,n,r,l,i){return null!==e&&Jr(e.memoizedProps,r)&&e.ref===t.ref&&(ja=!1,l<i)?(t.expirationTime=e.expirationTime,co(e,t,i)):Xa(e,t,n,r,i)}function Ya(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.effectTag|=128)}function Xa(e,t,n,r,l){var i=zl(n)?_l:Cl.current;return i=Nl(t,i),vi(t,l),n=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,n,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function Ga(e,t,n,r,l){if(zl(n)){var i=!0;Ol(t)}else i=!1;if(vi(t,l),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),Ii(t,n,r),Oi(t,n,r,l),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var u=a.context,c=n.contextType;\"object\"==typeof c&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current);var s=n.getDerivedStateFromProps,f=\"function\"==typeof s||\"function\"==typeof a.getSnapshotBeforeUpdate;f||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1;var d=t.memoizedState;a.state=d,Si(t,r,a,l),u=t.memoizedState,o!==r||d!==u||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),u=t.memoizedState),(o=bi||Mi(t,n,o,r,d,u,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillMount&&\"function\"!=typeof a.componentWillMount||(\"function\"==typeof a.componentWillMount&&a.componentWillMount(),\"function\"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),\"function\"==typeof a.componentDidMount&&(t.effectTag|=4)):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=c,r=o):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),r=!1)}else a=t.stateNode,ki(e,t),o=t.memoizedProps,a.props=t.type===t.elementType?o:ci(t.type,o),u=a.context,\"object\"==typeof(c=n.contextType)&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current),(f=\"function\"==typeof(s=n.getDerivedStateFromProps)||\"function\"==typeof a.getSnapshotBeforeUpdate)||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1,u=t.memoizedState,a.state=u,Si(t,r,a,l),d=t.memoizedState,o!==r||u!==d||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),d=t.memoizedState),(s=bi||Mi(t,n,o,r,u,d,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillUpdate&&\"function\"!=typeof a.componentWillUpdate||(\"function\"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,d,c),\"function\"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,d,c)),\"function\"==typeof a.componentDidUpdate&&(t.effectTag|=4),\"function\"==typeof a.getSnapshotBeforeUpdate&&(t.effectTag|=256)):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),t.memoizedProps=r,t.memoizedState=d),a.props=r,a.state=d,a.context=c,r=s):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),r=!1);return Za(e,t,n,r,i,l)}function Za(e,t,n,r,l,i){Ya(e,t);var a=0!=(64&t.effectTag);if(!r&&!a)return l&&Rl(t,n,!1),co(e,t,i);r=t.stateNode,Ha.current=t;var o=a&&\"function\"!=typeof n.getDerivedStateFromError?null:r.render();return t.effectTag|=1,null!==e&&a?(t.child=Ai(t,e.child,null,i),t.child=Ai(t,null,o,i)):Ba(e,t,o,i),t.memoizedState=r.state,l&&Rl(t,n,!0),t.child}function Ja(e){var t=e.stateNode;t.pendingContext?Il(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Il(e,t.context,!1),Ki(e,t.containerInfo)}var eo,to,no,ro,lo={dehydrated:null,retryTime:0};function io(e,t,n){var r,l=t.mode,i=t.pendingProps,a=Xi.current,o=!1;if((r=0!=(64&t.effectTag))||(r=0!=(2&a)&&(null===e||null!==e.memoizedState)),r?(o=!0,t.effectTag&=-65):null!==e&&null===e.memoizedState||void 0===i.fallback||!0===i.unstable_avoidThisFallback||(a|=1),El(Xi,1&a),null===e){if(void 0!==i.fallback&&Aa(t),o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,t.memoizedState=lo,t.child=i,n}return l=i.children,t.memoizedState=null,t.child=Vi(t,null,l,n)}if(null!==e.memoizedState){if(l=(e=e.child).sibling,o){if(i=i.fallback,(n=nc(e,e.pendingProps)).return=t,0==(2&t.mode)&&(o=null!==t.memoizedState?t.child.child:t.child)!==e.child)for(n.child=o;null!==o;)o.return=n,o=o.sibling;return(l=nc(l,i)).return=t,n.sibling=l,n.childExpirationTime=0,t.memoizedState=lo,t.child=n,l}return n=Ai(t,e.child,i.children,n),t.memoizedState=null,t.child=n}if(e=e.child,o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,i.child=e,null!==e&&(e.return=i),0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,n.effectTag|=2,i.childExpirationTime=0,t.memoizedState=lo,t.child=i,n}return t.memoizedState=null,t.child=Ai(t,e,i.children,n)}function ao(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t),gi(e.return,t)}function oo(e,t,n,r,l,i){var a=e.memoizedState;null===a?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailExpiration:0,tailMode:l,lastEffect:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailExpiration=0,a.tailMode=l,a.lastEffect=i)}function uo(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(Ba(e,t,r.children,n),0!=(2&(r=Xi.current)))r=1&r|2,t.effectTag|=64;else{if(null!==e&&0!=(64&e.effectTag))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ao(e,n);else if(19===e.tag)ao(e,n);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(El(Xi,r),0==(2&t.mode))t.memoizedState=null;else switch(l){case\"forwards\":for(n=t.child,l=null;null!==n;)null!==(e=n.alternate)&&null===Gi(e)&&(l=n),n=n.sibling;null===(n=l)?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),oo(t,!1,l,n,i,t.lastEffect);break;case\"backwards\":for(n=null,l=t.child,t.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Gi(e)){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}oo(t,!0,n,null,i,t.lastEffect);break;case\"together\":oo(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function co(e,t,n){null!==e&&(t.dependencies=e.dependencies);var l=t.expirationTime;if(0!==l&&Ou(l),t.childExpirationTime<n)return null;if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=nc(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=nc(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function so(e,t){switch(e.tailMode){case\"hidden\":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case\"collapsed\":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function fo(e,n,l){var i=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return zl(n.type)&&Ml(),null;case 3:return $i(),Tl(Pl),Tl(Cl),(l=n.stateNode).pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||!Qa(n)||(n.effectTag|=4),to(n),null;case 5:Yi(n),l=Bi(ji.current);var a=n.type;if(null!==e&&null!=n.stateNode)no(e,n,a,i,l),e.ref!==n.ref&&(n.effectTag|=128);else{if(!i){if(null===n.stateNode)throw Error(r(166));return null}if(e=Bi(Wi.current),Qa(n)){i=n.stateNode,a=n.type;var o=n.memoizedProps;switch(i[Rn]=n,i[Dn]=o,a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",i);break;case\"video\":case\"audio\":for(e=0;e<Je.length;e++)Jt(Je[e],i);break;case\"source\":Jt(\"error\",i);break;case\"img\":case\"image\":case\"link\":Jt(\"error\",i),Jt(\"load\",i);break;case\"form\":Jt(\"reset\",i),Jt(\"submit\",i);break;case\"details\":Jt(\"toggle\",i);break;case\"input\":Ce(i,o),Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"select\":i._wrapperState={wasMultiple:!!o.multiple},Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"textarea\":Re(i,o),Jt(\"invalid\",i),mn(l,\"onChange\")}for(var u in fn(a,o),e=null,o)if(o.hasOwnProperty(u)){var c=o[u];\"children\"===u?\"string\"==typeof c?i.textContent!==c&&(e=[\"children\",c]):\"number\"==typeof c&&i.textContent!==\"\"+c&&(e=[\"children\",\"\"+c]):x.hasOwnProperty(u)&&null!=c&&mn(l,u)}switch(a){case\"input\":Te(i),Ne(i,o,!0);break;case\"textarea\":Te(i),Le(i);break;case\"select\":case\"option\":break;default:\"function\"==typeof o.onClick&&(i.onclick=hn)}l=e,n.updateQueue=l,null!==l&&(n.effectTag|=4)}else{switch(u=9===l.nodeType?l:l.ownerDocument,e===pn&&(e=Ae(a)),e===pn?\"script\"===a?((e=u.createElement(\"div\")).innerHTML=\"<script><\\/script>\",e=e.removeChild(e.firstChild)):\"string\"==typeof i.is?e=u.createElement(a,{is:i.is}):(e=u.createElement(a),\"select\"===a&&(u=e,i.multiple?u.multiple=!0:i.size&&(u.size=i.size))):e=u.createElementNS(e,a),e[Rn]=n,e[Dn]=i,eo(e,n,!1,!1),n.stateNode=e,u=dn(a,i),a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",e),c=i;break;case\"video\":case\"audio\":for(c=0;c<Je.length;c++)Jt(Je[c],e);c=i;break;case\"source\":Jt(\"error\",e),c=i;break;case\"img\":case\"image\":case\"link\":Jt(\"error\",e),Jt(\"load\",e),c=i;break;case\"form\":Jt(\"reset\",e),Jt(\"submit\",e),c=i;break;case\"details\":Jt(\"toggle\",e),c=i;break;case\"input\":Ce(e,i),c=Se(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"option\":c=Ie(e,i);break;case\"select\":e._wrapperState={wasMultiple:!!i.multiple},c=t({},i,{value:void 0}),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"textarea\":Re(e,i),c=Oe(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;default:c=i}fn(a,c);var s=c;for(o in s)if(s.hasOwnProperty(o)){var f=s[o];\"style\"===o?cn(e,f):\"dangerouslySetInnerHTML\"===o?null!=(f=f?f.__html:void 0)&&We(e,f):\"children\"===o?\"string\"==typeof f?(\"textarea\"!==a||\"\"!==f)&&He(e,f):\"number\"==typeof f&&He(e,\"\"+f):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?null!=f&&mn(l,o):null!=f&&Z(e,o,f,u))}switch(a){case\"input\":Te(e),Ne(e,i,!1);break;case\"textarea\":Te(e),Le(e);break;case\"option\":null!=i.value&&e.setAttribute(\"value\",\"\"+we(i.value));break;case\"select\":e.multiple=!!i.multiple,null!=(l=i.value)?Fe(e,!!i.multiple,l,!1):null!=i.defaultValue&&Fe(e,!!i.multiple,i.defaultValue,!0);break;default:\"function\"==typeof c.onClick&&(e.onclick=hn)}_n(a,i)&&(n.effectTag|=4)}null!==n.ref&&(n.effectTag|=128)}return null;case 6:if(e&&null!=n.stateNode)ro(e,n,e.memoizedProps,i);else{if(\"string\"!=typeof i&&null===n.stateNode)throw Error(r(166));l=Bi(ji.current),Bi(Wi.current),Qa(n)?(l=n.stateNode,i=n.memoizedProps,l[Rn]=n,l.nodeValue!==i&&(n.effectTag|=4)):((l=(9===l.nodeType?l:l.ownerDocument).createTextNode(i))[Rn]=n,n.stateNode=l)}return null;case 13:return Tl(Xi),i=n.memoizedState,0!=(64&n.effectTag)?(n.expirationTime=l,n):(l=null!==i,i=!1,null===e?void 0!==n.memoizedProps.fallback&&Qa(n):(i=null!==(a=e.memoizedState),l||null===a||null!==(a=e.child.sibling)&&(null!==(o=n.firstEffect)?(n.firstEffect=a,a.nextEffect=o):(n.firstEffect=n.lastEffect=a,a.nextEffect=null),a.effectTag=8)),l&&!i&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&Xi.current)?Jo===Ho&&(Jo=Ko):(Jo!==Ho&&Jo!==Ko||(Jo=$o),0!==lu&&null!==Xo&&(cc(Xo,Zo),sc(Xo,lu)))),(l||i)&&(n.effectTag|=4),null);case 4:return $i(),to(n),null;case 10:return hi(n),null;case 17:return zl(n.type)&&Ml(),null;case 19:if(Tl(Xi),null===(i=n.memoizedState))return null;if(a=0!=(64&n.effectTag),null===(o=i.rendering)){if(a)so(i,!1);else if(Jo!==Ho||null!==e&&0!=(64&e.effectTag))for(o=n.child;null!==o;){if(null!==(e=Gi(o))){for(n.effectTag|=64,so(i,!1),null!==(a=e.updateQueue)&&(n.updateQueue=a,n.effectTag|=4),null===i.lastEffect&&(n.firstEffect=null),n.lastEffect=i.lastEffect,i=n.child;null!==i;)o=l,(a=i).effectTag&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,null===(e=a.alternate)?(a.childExpirationTime=0,a.expirationTime=o,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null):(a.childExpirationTime=e.childExpirationTime,a.expirationTime=e.expirationTime,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,o=e.dependencies,a.dependencies=null===o?null:{expirationTime:o.expirationTime,firstContext:o.firstContext,responders:o.responders}),i=i.sibling;return El(Xi,1&Xi.current|2),n.child}o=o.sibling}}else{if(!a)if(null!==(e=Gi(o))){if(n.effectTag|=64,a=!0,null!==(l=e.updateQueue)&&(n.updateQueue=l,n.effectTag|=4),so(i,!0),null===i.tail&&\"hidden\"===i.tailMode&&!o.alternate)return null!==(n=n.lastEffect=i.lastEffect)&&(n.nextEffect=null),null}else 2*ei()-i.renderingStartTime>i.tailExpiration&&1<l&&(n.effectTag|=64,a=!0,so(i,!1),n.expirationTime=n.childExpirationTime=l-1);i.isBackwards?(o.sibling=n.child,n.child=o):(null!==(l=i.last)?l.sibling=o:n.child=o,i.last=o)}return null!==i.tail?(0===i.tailExpiration&&(i.tailExpiration=ei()+500),l=i.tail,i.rendering=l,i.tail=l.sibling,i.lastEffect=n.lastEffect,i.renderingStartTime=ei(),l.sibling=null,n=Xi.current,El(Xi,a?1&n|2:1&n),l):null}throw Error(r(156,n.tag))}function po(e){switch(e.tag){case 1:zl(e.type)&&Ml();var t=e.effectTag;return 4096&t?(e.effectTag=-4097&t|64,e):null;case 3:if($i(),Tl(Pl),Tl(Cl),0!=(64&(t=e.effectTag)))throw Error(r(285));return e.effectTag=-4097&t|64,e;case 5:return Yi(e),null;case 13:return Tl(Xi),4096&(t=e.effectTag)?(e.effectTag=-4097&t|64,e):null;case 19:return Tl(Xi),null;case 4:return $i(),null;case 10:return hi(e),null;default:return null}}function mo(e,t){return{value:e,source:t,stack:be(t)}}eo=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},to=function(){},no=function(e,n,r,l,i){var a=e.memoizedProps;if(a!==l){var o,u,c=n.stateNode;switch(Bi(Wi.current),e=null,r){case\"input\":a=Se(c,a),l=Se(c,l),e=[];break;case\"option\":a=Ie(c,a),l=Ie(c,l),e=[];break;case\"select\":a=t({},a,{value:void 0}),l=t({},l,{value:void 0}),e=[];break;case\"textarea\":a=Oe(c,a),l=Oe(c,l),e=[];break;default:\"function\"!=typeof a.onClick&&\"function\"==typeof l.onClick&&(c.onclick=hn)}for(o in fn(r,l),r=null,a)if(!l.hasOwnProperty(o)&&a.hasOwnProperty(o)&&null!=a[o])if(\"style\"===o)for(u in c=a[o])c.hasOwnProperty(u)&&(r||(r={}),r[u]=\"\");else\"dangerouslySetInnerHTML\"!==o&&\"children\"!==o&&\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?e||(e=[]):(e=e||[]).push(o,null));for(o in l){var s=l[o];if(c=null!=a?a[o]:void 0,l.hasOwnProperty(o)&&s!==c&&(null!=s||null!=c))if(\"style\"===o)if(c){for(u in c)!c.hasOwnProperty(u)||s&&s.hasOwnProperty(u)||(r||(r={}),r[u]=\"\");for(u in s)s.hasOwnProperty(u)&&c[u]!==s[u]&&(r||(r={}),r[u]=s[u])}else r||(e||(e=[]),e.push(o,r)),r=s;else\"dangerouslySetInnerHTML\"===o?(s=s?s.__html:void 0,c=c?c.__html:void 0,null!=s&&c!==s&&(e=e||[]).push(o,s)):\"children\"===o?c===s||\"string\"!=typeof s&&\"number\"!=typeof s||(e=e||[]).push(o,\"\"+s):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&(x.hasOwnProperty(o)?(null!=s&&mn(i,o),e||c===s||(e=[])):(e=e||[]).push(o,s))}r&&(e=e||[]).push(\"style\",r),i=e,(n.updateQueue=i)&&(n.effectTag|=4)}},ro=function(e,t,n,r){n!==r&&(t.effectTag|=4)};var ho=\"function\"==typeof WeakSet?WeakSet:Set;function go(e,t){var n=t.source,r=t.stack;null===r&&null!==n&&(r=be(n)),null!==n&&ye(n.type),t=t.value,null!==e&&1===e.tag&&ye(e.type);try{console.error(t)}catch(l){setTimeout(function(){throw l})}}function vo(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(n){Ku(e,n)}}function yo(e){var t=e.ref;if(null!==t)if(\"function\"==typeof t)try{t(null)}catch(n){Ku(e,n)}else t.current=null}function bo(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&t.effectTag&&null!==e){var n=e.memoizedProps,l=e.memoizedState;t=(e=t.stateNode).getSnapshotBeforeUpdate(t.elementType===t.type?n:ci(t.type,n),l),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(r(163))}function wo(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.destroy;n.destroy=void 0,void 0!==r&&r()}n=n.next}while(n!==t)}}function ko(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xo(e,t,n){switch(n.tag){case 0:case 11:case 15:case 22:return void ko(3,n);case 1:if(e=n.stateNode,4&n.effectTag)if(null===t)e.componentDidMount();else{var l=n.elementType===n.type?t.memoizedProps:ci(n.type,t.memoizedProps);e.componentDidUpdate(l,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}return void(null!==(t=n.updateQueue)&&Ci(n,t,e));case 3:if(null!==(t=n.updateQueue)){if(e=null,null!==n.child)switch(n.child.tag){case 5:e=n.child.stateNode;break;case 1:e=n.child.stateNode}Ci(n,t,e)}return;case 5:return e=n.stateNode,void(null===t&&4&n.effectTag&&_n(n.type,n.memoizedProps)&&e.focus());case 6:case 4:case 12:return;case 13:return void(null===n.memoizedState&&(n=n.alternate,null!==n&&(n=n.memoizedState,null!==n&&(n=n.dehydrated,null!==n&&Wt(n)))));case 19:case 17:case 20:case 21:return}throw Error(r(163))}function To(e,t,n){switch(\"function\"==typeof Xu&&Xu(t),t.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e.next;ri(97<n?97:n,function(){var e=r;do{var n=e.destroy;if(void 0!==n){var l=t;try{n()}catch(i){Ku(l,i)}}e=e.next}while(e!==r)})}break;case 1:yo(t),\"function\"==typeof(n=t.stateNode).componentWillUnmount&&vo(t,n);break;case 5:yo(t);break;case 4:No(e,t,n)}}function Eo(e){var t=e.alternate;e.return=null,e.child=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.alternate=null,e.firstEffect=null,e.lastEffect=null,e.pendingProps=null,e.memoizedProps=null,e.stateNode=null,null!==t&&Eo(t)}function So(e){return 5===e.tag||3===e.tag||4===e.tag}function Co(e){e:{for(var t=e.return;null!==t;){if(So(t)){var n=t;break e}t=t.return}throw Error(r(160))}switch(t=n.stateNode,n.tag){case 5:var l=!1;break;case 3:case 4:t=t.containerInfo,l=!0;break;default:throw Error(r(161))}16&n.effectTag&&(He(t,\"\"),n.effectTag&=-17);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||So(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;5!==n.tag&&6!==n.tag&&18!==n.tag;){if(2&n.effectTag)continue t;if(null===n.child||4===n.tag)continue t;n.child.return=n,n=n.child}if(!(2&n.effectTag)){n=n.stateNode;break e}}l?Po(e,n,t):_o(e,n,t)}function Po(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=hn));else if(4!==r&&null!==(e=e.child))for(Po(e,t,n),e=e.sibling;null!==e;)Po(e,t,n),e=e.sibling}function _o(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(_o(e,t,n),e=e.sibling;null!==e;)_o(e,t,n),e=e.sibling}function No(e,t,n){for(var l,i,a=t,o=!1;;){if(!o){o=a.return;e:for(;;){if(null===o)throw Error(r(160));switch(l=o.stateNode,o.tag){case 5:i=!1;break e;case 3:case 4:l=l.containerInfo,i=!0;break e}o=o.return}o=!0}if(5===a.tag||6===a.tag){e:for(var u=e,c=a,s=n,f=c;;)if(To(u,f,s),null!==f.child&&4!==f.tag)f.child.return=f,f=f.child;else{if(f===c)break e;for(;null===f.sibling;){if(null===f.return||f.return===c)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}i?(u=l,c=a.stateNode,8===u.nodeType?u.parentNode.removeChild(c):u.removeChild(c)):l.removeChild(a.stateNode)}else if(4===a.tag){if(null!==a.child){l=a.stateNode.containerInfo,i=!0,a.child.return=a,a=a.child;continue}}else if(To(e,a,n),null!==a.child){a.child.return=a,a=a.child;continue}if(a===t)break;for(;null===a.sibling;){if(null===a.return||a.return===t)return;4===(a=a.return).tag&&(o=!1)}a.sibling.return=a.return,a=a.sibling}}function zo(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:return void wo(3,t);case 1:return;case 5:var n=t.stateNode;if(null!=n){var l=t.memoizedProps,i=null!==e?e.memoizedProps:l;e=t.type;var a=t.updateQueue;if(t.updateQueue=null,null!==a){for(n[Dn]=l,\"input\"===e&&\"radio\"===l.type&&null!=l.name&&Pe(n,l),dn(e,i),t=dn(e,l),i=0;i<a.length;i+=2){var o=a[i],u=a[i+1];\"style\"===o?cn(n,u):\"dangerouslySetInnerHTML\"===o?We(n,u):\"children\"===o?He(n,u):Z(n,o,u,t)}switch(e){case\"input\":_e(n,l);break;case\"textarea\":De(n,l);break;case\"select\":t=n._wrapperState.wasMultiple,n._wrapperState.wasMultiple=!!l.multiple,null!=(e=l.value)?Fe(n,!!l.multiple,e,!1):t!==!!l.multiple&&(null!=l.defaultValue?Fe(n,!!l.multiple,l.defaultValue,!0):Fe(n,!!l.multiple,l.multiple?[]:\"\",!1))}}}return;case 6:if(null===t.stateNode)throw Error(r(162));return void(t.stateNode.nodeValue=t.memoizedProps);case 3:return void((t=t.stateNode).hydrate&&(t.hydrate=!1,Wt(t.containerInfo)));case 12:return;case 13:if(n=t,null===t.memoizedState?l=!1:(l=!0,n=t.child,au=ei()),null!==n)e:for(e=n;;){if(5===e.tag)a=e.stateNode,l?\"function\"==typeof(a=a.style).setProperty?a.setProperty(\"display\",\"none\",\"important\"):a.display=\"none\":(a=e.stateNode,i=null!=(i=e.memoizedProps.style)&&i.hasOwnProperty(\"display\")?i.display:null,a.style.display=un(\"display\",i));else if(6===e.tag)e.stateNode.nodeValue=l?\"\":e.memoizedProps;else{if(13===e.tag&&null!==e.memoizedState&&null===e.memoizedState.dehydrated){(a=e.child.sibling).return=e,e=a;continue}if(null!==e.child){e.child.return=e,e=e.child;continue}}if(e===n)break;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}return void Mo(t);case 19:return void Mo(t);case 17:return}throw Error(r(163))}function Mo(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new ho),t.forEach(function(t){var r=qu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}var Io=\"function\"==typeof WeakMap?WeakMap:Map;function Fo(e,t,n){(n=xi(n,null)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){cu||(cu=!0,su=r),go(e,t)},n}function Oo(e,t,n){(n=xi(n,null)).tag=3;var r=e.type.getDerivedStateFromError;if(\"function\"==typeof r){var l=t.value;n.payload=function(){return go(e,t),r(l)}}var i=e.stateNode;return null!==i&&\"function\"==typeof i.componentDidCatch&&(n.callback=function(){\"function\"!=typeof r&&(null===fu?fu=new Set([this]):fu.add(this),go(e,t));var n=t.stack;this.componentDidCatch(t.value,{componentStack:null!==n?n:\"\"})}),n}var Ro,Do=Math.ceil,Lo=G.ReactCurrentDispatcher,Uo=G.ReactCurrentOwner,Ao=0,Vo=8,Qo=16,Wo=32,Ho=0,jo=1,Bo=2,Ko=3,$o=4,qo=5,Yo=Ao,Xo=null,Go=null,Zo=0,Jo=Ho,eu=null,tu=1073741823,nu=1073741823,ru=null,lu=0,iu=!1,au=0,ou=500,uu=null,cu=!1,su=null,fu=null,du=!1,pu=null,mu=90,hu=null,gu=0,vu=null,yu=0;function bu(){return(Yo&(Qo|Wo))!==Ao?1073741821-(ei()/10|0):0!==yu?yu:yu=1073741821-(ei()/10|0)}function wu(e,t,n){if(0==(2&(t=t.mode)))return 1073741823;var l=ti();if(0==(4&t))return 99===l?1073741823:1073741822;if((Yo&Qo)!==Ao)return Zo;if(null!==n)e=ui(e,0|n.timeoutMs||5e3,250);else switch(l){case 99:e=1073741823;break;case 98:e=ui(e,150,100);break;case 97:case 96:e=ui(e,5e3,250);break;case 95:e=2;break;default:throw Error(r(326))}return null!==Xo&&e===Zo&&--e,e}function ku(e,t){if(50<gu)throw gu=0,vu=null,Error(r(185));if(null!==(e=xu(e,t))){var n=ti();1073741823===t?(Yo&Vo)!==Ao&&(Yo&(Qo|Wo))===Ao?Cu(e):(Eu(e),Yo===Ao&&ai()):Eu(e),(4&Yo)===Ao||98!==n&&99!==n||(null===hu?hu=new Map([[e,t]]):(void 0===(n=hu.get(e))||n>t)&&hu.set(e,t))}}function xu(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t);var r=e.return,l=null;if(null===r&&3===e.tag)l=e.stateNode;else for(;null!==r;){if(n=r.alternate,r.childExpirationTime<t&&(r.childExpirationTime=t),null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t),null===r.return&&3===r.tag){l=r.stateNode;break}r=r.return}return null!==l&&(Xo===l&&(Ou(t),Jo===$o&&cc(l,Zo)),sc(l,t)),l}function Tu(e){var t=e.lastExpiredTime;if(0!==t)return t;if(!uc(e,t=e.firstPendingTime))return t;var n=e.lastPingedTime;return 2>=(e=n>(e=e.nextKnownPendingLevel)?n:e)&&t!==e?0:e}function Eu(e){if(0!==e.lastExpiredTime)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=ii(Cu.bind(null,e));else{var t=Tu(e),n=e.callbackNode;if(0===t)null!==n&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var r=bu();if(1073741823===t?r=99:1===t||2===t?r=95:r=0>=(r=10*(1073741821-t)-10*(1073741821-r))?99:250>=r?98:5250>=r?97:95,null!==n){var l=e.callbackPriority;if(e.callbackExpirationTime===t&&l>=r)return;n!==$l&&Ul(n)}e.callbackExpirationTime=t,e.callbackPriority=r,t=1073741823===t?ii(Cu.bind(null,e)):li(r,Su.bind(null,e),{timeout:10*(1073741821-t)-ei()}),e.callbackNode=t}}}function Su(e,t){if(yu=0,t)return fc(e,t=bu()),Eu(e),null;var n=Tu(e);if(0!==n){if(t=e.callbackNode,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&n===Zo||zu(e,n),null!==Go){var l=Yo;Yo|=Qo;for(var i=Iu();;)try{Du();break}catch(u){Mu(e,u)}if(mi(),Yo=l,Lo.current=i,Jo===jo)throw t=eu,zu(e,n),cc(e,n),Eu(e),t;if(null===Go)switch(i=e.finishedWork=e.current.alternate,e.finishedExpirationTime=n,l=Jo,Xo=null,l){case Ho:case jo:throw Error(r(345));case Bo:fc(e,2<n?2:n);break;case Ko:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),1073741823===tu&&10<(i=au+ou-ei())){if(iu){var a=e.lastPingedTime;if(0===a||a>=n){e.lastPingedTime=n,zu(e,n);break}}if(0!==(a=Tu(e))&&a!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}e.timeoutHandle=zn(Vu.bind(null,e),i);break}Vu(e);break;case $o:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),iu&&(0===(i=e.lastPingedTime)||i>=n)){e.lastPingedTime=n,zu(e,n);break}if(0!==(i=Tu(e))&&i!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}if(1073741823!==nu?l=10*(1073741821-nu)-ei():1073741823===tu?l=0:(l=10*(1073741821-tu)-5e3,0>(l=(i=ei())-l)&&(l=0),(n=10*(1073741821-n)-i)<(l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Do(l/1960))-l)&&(l=n)),10<l){e.timeoutHandle=zn(Vu.bind(null,e),l);break}Vu(e);break;case qo:if(1073741823!==tu&&null!==ru){a=tu;var o=ru;if(0>=(l=0|o.busyMinDurationMs)?l=0:(i=0|o.busyDelayMs,l=(a=ei()-(10*(1073741821-a)-(0|o.timeoutMs||5e3)))<=i?0:i+l-a),10<l){cc(e,n),e.timeoutHandle=zn(Vu.bind(null,e),l);break}}Vu(e);break;default:throw Error(r(329))}if(Eu(e),e.callbackNode===t)return Su.bind(null,e)}}return null}function Cu(e){var t=e.lastExpiredTime;if(t=0!==t?t:1073741823,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&t===Zo||zu(e,t),null!==Go){var n=Yo;Yo|=Qo;for(var l=Iu();;)try{Ru();break}catch(i){Mu(e,i)}if(mi(),Yo=n,Lo.current=l,Jo===jo)throw n=eu,zu(e,t),cc(e,t),Eu(e),n;if(null!==Go)throw Error(r(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Xo=null,Vu(e),Eu(e)}return null}function Pu(){if(null!==hu){var e=hu;hu=null,e.forEach(function(e,t){fc(t,e),Eu(t)}),ai()}}function _u(e,t){var n=Yo;Yo|=1;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function Nu(e,t){var n=Yo;Yo&=-2,Yo|=Vo;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function zu(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,Mn(n)),null!==Go)for(n=Go.return;null!==n;){var r=n;switch(r.tag){case 1:null!=(r=r.type.childContextTypes)&&Ml();break;case 3:$i(),Tl(Pl),Tl(Cl);break;case 5:Yi(r);break;case 4:$i();break;case 13:case 19:Tl(Xi);break;case 10:hi(r)}n=n.return}Xo=e,Go=nc(e.current,null),Zo=t,Jo=Ho,eu=null,nu=tu=1073741823,ru=null,lu=0,iu=!1}function Mu(e,t){for(;;){try{if(mi(),Ji.current=za,ia)for(var n=na.memoizedState;null!==n;){var r=n.queue;null!==r&&(r.pending=null),n=n.next}if(ta=0,la=ra=na=null,ia=!1,null===Go||null===Go.return)return Jo=jo,eu=t,Go=null;e:{var l=e,i=Go.return,a=Go,o=t;if(t=Zo,a.effectTag|=2048,a.firstEffect=a.lastEffect=null,null!==o&&\"object\"==typeof o&&\"function\"==typeof o.then){var u=o;if(0==(2&a.mode)){var c=a.alternate;c?(a.updateQueue=c.updateQueue,a.memoizedState=c.memoizedState,a.expirationTime=c.expirationTime):(a.updateQueue=null,a.memoizedState=null)}var s=0!=(1&Xi.current),f=i;do{var d;if(d=13===f.tag){var p=f.memoizedState;if(null!==p)d=null!==p.dehydrated;else{var m=f.memoizedProps;d=void 0!==m.fallback&&(!0!==m.unstable_avoidThisFallback||!s)}}if(d){var h=f.updateQueue;if(null===h){var g=new Set;g.add(u),f.updateQueue=g}else h.add(u);if(0==(2&f.mode)){if(f.effectTag|=64,a.effectTag&=-2981,1===a.tag)if(null===a.alternate)a.tag=17;else{var v=xi(1073741823,null);v.tag=2,Ti(a,v)}a.expirationTime=1073741823;break e}o=void 0,a=t;var y=l.pingCache;if(null===y?(y=l.pingCache=new Io,o=new Set,y.set(u,o)):void 0===(o=y.get(u))&&(o=new Set,y.set(u,o)),!o.has(a)){o.add(a);var b=$u.bind(null,l,u,a);u.then(b,b)}f.effectTag|=4096,f.expirationTime=t;break e}f=f.return}while(null!==f);o=Error((ye(a.type)||\"A React component\")+\" suspended while rendering, but no fallback UI was specified.\\n\\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.\"+be(a))}Jo!==qo&&(Jo=Bo),o=mo(o,a),f=i;do{switch(f.tag){case 3:u=o,f.effectTag|=4096,f.expirationTime=t,Ei(f,Fo(f,u,t));break e;case 1:u=o;var w=f.type,k=f.stateNode;if(0==(64&f.effectTag)&&(\"function\"==typeof w.getDerivedStateFromError||null!==k&&\"function\"==typeof k.componentDidCatch&&(null===fu||!fu.has(k)))){f.effectTag|=4096,f.expirationTime=t,Ei(f,Oo(f,u,t));break e}}f=f.return}while(null!==f)}Go=Uu(Go)}catch(x){t=x;continue}break}}function Iu(){var e=Lo.current;return Lo.current=za,null===e?za:e}function Fu(e,t){e<tu&&2<e&&(tu=e),null!==t&&e<nu&&2<e&&(nu=e,ru=t)}function Ou(e){e>lu&&(lu=e)}function Ru(){for(;null!==Go;)Go=Lu(Go)}function Du(){for(;null!==Go&&!ql();)Go=Lu(Go)}function Lu(e){var t=Ro(e.alternate,e,Zo);return e.memoizedProps=e.pendingProps,null===t&&(t=Uu(e)),Uo.current=null,t}function Uu(e){Go=e;do{var t=Go.alternate;if(e=Go.return,0==(2048&Go.effectTag)){if(t=fo(t,Go,Zo),1===Zo||1!==Go.childExpirationTime){for(var n=0,r=Go.child;null!==r;){var l=r.expirationTime,i=r.childExpirationTime;l>n&&(n=l),i>n&&(n=i),r=r.sibling}Go.childExpirationTime=n}if(null!==t)return t;null!==e&&0==(2048&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=Go.firstEffect),null!==Go.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=Go.firstEffect),e.lastEffect=Go.lastEffect),1<Go.effectTag&&(null!==e.lastEffect?e.lastEffect.nextEffect=Go:e.firstEffect=Go,e.lastEffect=Go))}else{if(null!==(t=po(Go)))return t.effectTag&=2047,t;null!==e&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(null!==(t=Go.sibling))return t;Go=e}while(null!==Go);return Jo===Ho&&(Jo=qo),null}function Au(e){var t=e.expirationTime;return t>(e=e.childExpirationTime)?t:e}function Vu(e){var t=ti();return ri(99,Qu.bind(null,e,t)),null}function Qu(e,t){do{Hu()}while(null!==pu);if((Yo&(Qo|Wo))!==Ao)throw Error(r(327));var n=e.finishedWork,l=e.finishedExpirationTime;if(null===n)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var i=Au(n);if(e.firstPendingTime=i,l<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:l<=e.firstSuspendedTime&&(e.firstSuspendedTime=l-1),l<=e.lastPingedTime&&(e.lastPingedTime=0),l<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===Xo&&(Go=Xo=null,Zo=0),1<n.effectTag?null!==n.lastEffect?(n.lastEffect.nextEffect=n,i=n.firstEffect):i=n:i=n.firstEffect,null!==i){var a=Yo;Yo|=Wo,Uo.current=null,Cn=Zt;var o=wn();if(kn(o)){if(\"selectionStart\"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{var c=(u=(u=o.ownerDocument)&&u.defaultView||window).getSelection&&u.getSelection();if(c&&0!==c.rangeCount){u=c.anchorNode;var s=c.anchorOffset,f=c.focusNode;c=c.focusOffset;try{u.nodeType,f.nodeType}catch(C){u=null;break e}var d=0,p=-1,m=-1,h=0,g=0,v=o,y=null;t:for(;;){for(var b;v!==u||0!==s&&3!==v.nodeType||(p=d+s),v!==f||0!==c&&3!==v.nodeType||(m=d+c),3===v.nodeType&&(d+=v.nodeValue.length),null!==(b=v.firstChild);)y=v,v=b;for(;;){if(v===o)break t;if(y===u&&++h===s&&(p=d),y===f&&++g===c&&(m=d),null!==(b=v.nextSibling))break;y=(v=y).parentNode}v=b}u=-1===p||-1===m?null:{start:p,end:m}}else u=null}u=u||{start:0,end:0}}else u=null;Pn={activeElementDetached:null,focusedElem:o,selectionRange:u},Zt=!1,uu=i;do{try{Wu()}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=i;do{try{for(o=e,u=t;null!==uu;){var w=uu.effectTag;if(16&w&&He(uu.stateNode,\"\"),128&w){var k=uu.alternate;if(null!==k){var x=k.ref;null!==x&&(\"function\"==typeof x?x(null):x.current=null)}}switch(1038&w){case 2:Co(uu),uu.effectTag&=-3;break;case 6:Co(uu),uu.effectTag&=-3,zo(uu.alternate,uu);break;case 1024:uu.effectTag&=-1025;break;case 1028:uu.effectTag&=-1025,zo(uu.alternate,uu);break;case 4:zo(uu.alternate,uu);break;case 8:No(o,s=uu,u),Eo(s)}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);if(x=Pn,k=wn(),w=x.focusedElem,u=x.selectionRange,k!==w&&w&&w.ownerDocument&&bn(w.ownerDocument.documentElement,w)){null!==u&&kn(w)&&(k=u.start,void 0===(x=u.end)&&(x=k),\"selectionStart\"in w?(w.selectionStart=k,w.selectionEnd=Math.min(x,w.value.length)):(x=(k=w.ownerDocument||document)&&k.defaultView||window).getSelection&&(x=x.getSelection(),s=w.textContent.length,o=Math.min(u.start,s),u=void 0===u.end?o:Math.min(u.end,s),!x.extend&&o>u&&(s=u,u=o,o=s),s=yn(w,o),f=yn(w,u),s&&f&&(1!==x.rangeCount||x.anchorNode!==s.node||x.anchorOffset!==s.offset||x.focusNode!==f.node||x.focusOffset!==f.offset)&&((k=k.createRange()).setStart(s.node,s.offset),x.removeAllRanges(),o>u?(x.addRange(k),x.extend(f.node,f.offset)):(k.setEnd(f.node,f.offset),x.addRange(k))))),k=[];for(x=w;x=x.parentNode;)1===x.nodeType&&k.push({element:x,left:x.scrollLeft,top:x.scrollTop});for(\"function\"==typeof w.focus&&w.focus(),w=0;w<k.length;w++)(x=k[w]).element.scrollLeft=x.left,x.element.scrollTop=x.top}Zt=!!Cn,Pn=Cn=null,e.current=n,uu=i;do{try{for(w=e;null!==uu;){var T=uu.effectTag;if(36&T&&xo(w,uu.alternate,uu),128&T){k=void 0;var E=uu.ref;if(null!==E){var S=uu.stateNode;switch(uu.tag){case 5:k=S;break;default:k=S}\"function\"==typeof E?E(k):E.current=k}}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=null,Yl(),Yo=a}else e.current=n;if(du)du=!1,pu=e,mu=t;else for(uu=i;null!==uu;)t=uu.nextEffect,uu.nextEffect=null,uu=t;if(0===(t=e.firstPendingTime)&&(fu=null),1073741823===t?e===vu?gu++:(gu=0,vu=e):gu=0,\"function\"==typeof Yu&&Yu(n.stateNode,l),Eu(e),cu)throw cu=!1,e=su,su=null,e;return(Yo&Vo)!==Ao?null:(ai(),null)}function Wu(){for(;null!==uu;){var e=uu.effectTag;0!=(256&e)&&bo(uu.alternate,uu),0==(512&e)||du||(du=!0,li(97,function(){return Hu(),null})),uu=uu.nextEffect}}function Hu(){if(90!==mu){var e=97<mu?97:mu;return mu=90,ri(e,ju)}}function ju(){if(null===pu)return!1;var e=pu;if(pu=null,(Yo&(Qo|Wo))!==Ao)throw Error(r(331));var t=Yo;for(Yo|=Wo,e=e.current.firstEffect;null!==e;){try{var n=e;if(0!=(512&n.effectTag))switch(n.tag){case 0:case 11:case 15:case 22:wo(5,n),ko(5,n)}}catch(l){if(null===e)throw Error(r(330));Ku(e,l)}n=e.nextEffect,e.nextEffect=null,e=n}return Yo=t,ai(),!0}function Bu(e,t,n){Ti(e,t=Fo(e,t=mo(n,t),1073741823)),null!==(e=xu(e,1073741823))&&Eu(e)}function Ku(e,t){if(3===e.tag)Bu(e,e,t);else for(var n=e.return;null!==n;){if(3===n.tag){Bu(n,e,t);break}if(1===n.tag){var r=n.stateNode;if(\"function\"==typeof n.type.getDerivedStateFromError||\"function\"==typeof r.componentDidCatch&&(null===fu||!fu.has(r))){Ti(n,e=Oo(n,e=mo(t,e),1073741823)),null!==(n=xu(n,1073741823))&&Eu(n);break}}n=n.return}}function $u(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),Xo===e&&Zo===n?Jo===$o||Jo===Ko&&1073741823===tu&&ei()-au<ou?zu(e,Zo):iu=!0:uc(e,n)&&(0!==(t=e.lastPingedTime)&&t<n||(e.lastPingedTime=n,Eu(e)))}function qu(e,t){var n=e.stateNode;null!==n&&n.delete(t),0===(t=0)&&(t=wu(t=bu(),e,null)),null!==(e=xu(e,t))&&Eu(e)}Ro=function(e,t,n){var l=t.expirationTime;if(null!==e){var i=t.pendingProps;if(e.memoizedProps!==i||Pl.current)ja=!0;else{if(l<n){switch(ja=!1,t.tag){case 3:Ja(t),Wa();break;case 5:if(qi(t),4&t.mode&&1!==n&&i.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:zl(t.type)&&Ol(t);break;case 4:Ki(t,t.stateNode.containerInfo);break;case 10:l=t.memoizedProps.value,i=t.type._context,El(si,i._currentValue),i._currentValue=l;break;case 13:if(null!==t.memoizedState)return 0!==(l=t.child.childExpirationTime)&&l>=n?io(e,t,n):(El(Xi,1&Xi.current),null!==(t=co(e,t,n))?t.sibling:null);El(Xi,1&Xi.current);break;case 19:if(l=t.childExpirationTime>=n,0!=(64&e.effectTag)){if(l)return uo(e,t,n);t.effectTag|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null),El(Xi,Xi.current),!l)return null}return co(e,t,n)}ja=!1}}else ja=!1;switch(t.expirationTime=0,t.tag){case 2:if(l=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,i=Nl(t,Cl.current),vi(t,n),i=ua(null,t,l,e,i,n),t.effectTag|=1,\"object\"==typeof i&&null!==i&&\"function\"==typeof i.render&&void 0===i.$$typeof){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,zl(l)){var a=!0;Ol(t)}else a=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,wi(t);var o=l.getDerivedStateFromProps;\"function\"==typeof o&&Ni(t,l,o,e),i.updater=zi,t.stateNode=i,i._reactInternalFiber=t,Oi(t,l,e,n),t=Za(null,t,l,!0,a,n)}else t.tag=0,Ba(null,t,i,n),t=t.child;return t;case 16:e:{if(i=t.elementType,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,ve(i),1!==i._status)throw i._result;switch(i=i._result,t.type=i,a=t.tag=tc(i),e=ci(i,e),a){case 0:t=Xa(null,t,i,e,n);break e;case 1:t=Ga(null,t,i,e,n);break e;case 11:t=Ka(null,t,i,e,n);break e;case 14:t=$a(null,t,i,ci(i.type,e),l,n);break e}throw Error(r(306,i,\"\"))}return t;case 0:return l=t.type,i=t.pendingProps,Xa(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 1:return l=t.type,i=t.pendingProps,Ga(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 3:if(Ja(t),l=t.updateQueue,null===e||null===l)throw Error(r(282));if(l=t.pendingProps,i=null!==(i=t.memoizedState)?i.element:null,ki(e,t),Si(t,l,null,n),(l=t.memoizedState.element)===i)Wa(),t=co(e,t,n);else{if((i=t.stateNode.hydrate)&&(Ra=In(t.stateNode.containerInfo.firstChild),Oa=t,i=Da=!0),i)for(n=Vi(t,null,l,n),t.child=n;n;)n.effectTag=-3&n.effectTag|1024,n=n.sibling;else Ba(e,t,l,n),Wa();t=t.child}return t;case 5:return qi(t),null===e&&Aa(t),l=t.type,i=t.pendingProps,a=null!==e?e.memoizedProps:null,o=i.children,Nn(l,i)?o=null:null!==a&&Nn(l,a)&&(t.effectTag|=16),Ya(e,t),4&t.mode&&1!==n&&i.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(Ba(e,t,o,n),t=t.child),t;case 6:return null===e&&Aa(t),null;case 13:return io(e,t,n);case 4:return Ki(t,t.stateNode.containerInfo),l=t.pendingProps,null===e?t.child=Ai(t,null,l,n):Ba(e,t,l,n),t.child;case 11:return l=t.type,i=t.pendingProps,Ka(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 7:return Ba(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ba(e,t,t.pendingProps.children,n),t.child;case 10:e:{l=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value;var u=t.type._context;if(El(si,u._currentValue),u._currentValue=a,null!==o)if(u=o.value,0===(a=Gr(u,a)?0:0|(\"function\"==typeof l._calculateChangedBits?l._calculateChangedBits(u,a):1073741823))){if(o.children===i.children&&!Pl.current){t=co(e,t,n);break e}}else for(null!==(u=t.child)&&(u.return=t);null!==u;){var c=u.dependencies;if(null!==c){o=u.child;for(var s=c.firstContext;null!==s;){if(s.context===l&&0!=(s.observedBits&a)){1===u.tag&&((s=xi(n,null)).tag=2,Ti(u,s)),u.expirationTime<n&&(u.expirationTime=n),null!==(s=u.alternate)&&s.expirationTime<n&&(s.expirationTime=n),gi(u.return,n),c.expirationTime<n&&(c.expirationTime=n);break}s=s.next}}else o=10===u.tag&&u.type===t.type?null:u.child;if(null!==o)o.return=u;else for(o=u;null!==o;){if(o===t){o=null;break}if(null!==(u=o.sibling)){u.return=o.return,o=u;break}o=o.return}u=o}Ba(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,l=(a=t.pendingProps).children,vi(t,n),l=l(i=yi(i,a.unstable_observedBits)),t.effectTag|=1,Ba(e,t,l,n),t.child;case 14:return a=ci(i=t.type,t.pendingProps),$a(e,t,i,a=ci(i.type,a),l,n);case 15:return qa(e,t,t.type,t.pendingProps,l,n);case 17:return l=t.type,i=t.pendingProps,i=t.elementType===l?i:ci(l,i),null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,zl(l)?(e=!0,Ol(t)):e=!1,vi(t,n),Ii(t,l,i),Oi(t,l,i,n),Za(null,t,l,!0,e,n);case 19:return uo(e,t,n)}throw Error(r(156,t.tag))};var Yu=null,Xu=null;function Gu(e){if(\"undefined\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var n=t.inject(e);Yu=function(e){try{t.onCommitFiberRoot(n,e,void 0,64==(64&e.current.effectTag))}catch(r){}},Xu=function(e){try{t.onCommitFiberUnmount(n,e)}catch(r){}}}catch(r){}return!0}function Zu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childExpirationTime=this.expirationTime=0,this.alternate=null}function Ju(e,t,n,r){return new Zu(e,t,n,r)}function ec(e){return!(!(e=e.prototype)||!e.isReactComponent)}function tc(e){if(\"function\"==typeof e)return ec(e)?1:0;if(null!=e){if((e=e.$$typeof)===ce)return 11;if(e===de)return 14}return 2}function nc(e,t){var n=e.alternate;return null===n?((n=Ju(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.effectTag=0,n.nextEffect=null,n.firstEffect=null,n.lastEffect=null),n.childExpirationTime=e.childExpirationTime,n.expirationTime=e.expirationTime,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{expirationTime:t.expirationTime,firstContext:t.firstContext,responders:t.responders},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function rc(e,t,n,l,i,a){var o=2;if(l=e,\"function\"==typeof e)ec(e)&&(o=1);else if(\"string\"==typeof e)o=5;else e:switch(e){case re:return lc(n.children,i,a,t);case ue:o=8,i|=7;break;case le:o=8,i|=1;break;case ie:return(e=Ju(12,n,t,8|i)).elementType=ie,e.type=ie,e.expirationTime=a,e;case se:return(e=Ju(13,n,t,i)).type=se,e.elementType=se,e.expirationTime=a,e;case fe:return(e=Ju(19,n,t,i)).elementType=fe,e.expirationTime=a,e;default:if(\"object\"==typeof e&&null!==e)switch(e.$$typeof){case ae:o=10;break e;case oe:o=9;break e;case ce:o=11;break e;case de:o=14;break e;case pe:o=16,l=null;break e;case me:o=22;break e}throw Error(r(130,null==e?e:typeof e,\"\"))}return(t=Ju(o,n,t,i)).elementType=e,t.type=l,t.expirationTime=a,t}function lc(e,t,n,r){return(e=Ju(7,e,r,t)).expirationTime=n,e}function ic(e,t,n){return(e=Ju(6,e,null,t)).expirationTime=n,e}function ac(e,t,n){return(t=Ju(4,null!==e.children?e.children:[],e.key,t)).expirationTime=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function oc(e,t,n){this.tag=t,this.current=null,this.containerInfo=e,this.pingCache=this.pendingChildren=null,this.finishedExpirationTime=0,this.finishedWork=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=n,this.callbackNode=null,this.callbackPriority=90,this.lastExpiredTime=this.lastPingedTime=this.nextKnownPendingLevel=this.lastSuspendedTime=this.firstSuspendedTime=this.firstPendingTime=0}function uc(e,t){var n=e.firstSuspendedTime;return e=e.lastSuspendedTime,0!==n&&n>=t&&e<=t}function cc(e,t){var n=e.firstSuspendedTime,r=e.lastSuspendedTime;n<t&&(e.firstSuspendedTime=t),(r>t||0===n)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function sc(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var n=e.firstSuspendedTime;0!==n&&(t>=n?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function fc(e,t){var n=e.lastExpiredTime;(0===n||n>t)&&(e.lastExpiredTime=t)}function dc(e,t,n,l){var i=t.current,a=bu(),o=Pi.suspense;a=wu(a,i,o);e:if(n){t:{if(nt(n=n._reactInternalFiber)!==n||1!==n.tag)throw Error(r(170));var u=n;do{switch(u.tag){case 3:u=u.stateNode.context;break t;case 1:if(zl(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break t}}u=u.return}while(null!==u);throw Error(r(171))}if(1===n.tag){var c=n.type;if(zl(c)){n=Fl(n,c,u);break e}}n=u}else n=Sl;return null===t.context?t.context=n:t.pendingContext=n,(t=xi(a,o)).payload={element:e},null!==(l=void 0===l?null:l)&&(t.callback=l),Ti(i,t),ku(i,a),a}function pc(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 5:default:return e.child.stateNode}}function mc(e,t){null!==(e=e.memoizedState)&&null!==e.dehydrated&&e.retryTime<t&&(e.retryTime=t)}function hc(e,t){mc(e,t),(e=e.alternate)&&mc(e,t)}function gc(e,t,n){var r=new oc(e,t,n=null!=n&&!0===n.hydrate),l=Ju(3,null,null,2===t?7:1===t?3:0);r.current=l,l.stateNode=r,wi(l),e[Ln]=r.current,n&&0!==t&&It(e,9===e.nodeType?e:e.ownerDocument),this._internalRoot=r}function vc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||\" react-mount-point-unstable \"!==e.nodeValue))}function yc(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute(\"data-reactroot\"))),!t)for(var n;n=e.lastChild;)e.removeChild(n);return new gc(e,0,t?{hydrate:!0}:void 0)}function bc(e,t,n,r,l){var i=n._reactRootContainer;if(i){var a=i._internalRoot;if(\"function\"==typeof l){var o=l;l=function(){var e=pc(a);o.call(e)}}dc(t,a,e,l)}else{if(i=n._reactRootContainer=yc(n,r),a=i._internalRoot,\"function\"==typeof l){var u=l;l=function(){var e=pc(a);u.call(e)}}Nu(function(){dc(t,a,e,l)})}return pc(a)}function wc(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:ne,key:null==r?null:\"\"+r,children:e,containerInfo:t,implementation:n}}function kc(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!vc(t))throw Error(r(200));return wc(e,t,null,n)}gc.prototype.render=function(e){dc(e,this._internalRoot,null,null)},gc.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;dc(null,e,null,function(){t[Ln]=null})},bt=function(e){if(13===e.tag){var t=ui(bu(),150,100);ku(e,t),hc(e,t)}},wt=function(e){13===e.tag&&(ku(e,3),hc(e,3))},kt=function(e){if(13===e.tag){var t=bu();ku(e,t=wu(t,e,null)),hc(e,t)}},C=function(e,t,n){switch(t){case\"input\":if(_e(e,n),t=n.name,\"radio\"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(\"input[name=\"+JSON.stringify(\"\"+t)+'][type=\"radio\"]'),t=0;t<n.length;t++){var l=n[t];if(l!==e&&l.form===e.form){var i=Qn(l);if(!i)throw Error(r(90));Ee(l),_e(l,i)}}}break;case\"textarea\":De(e,n);break;case\"select\":null!=(t=n.value)&&Fe(e,!!n.multiple,t,!1)}},I=_u,F=function(e,t,n,r,l){var i=Yo;Yo|=4;try{return ri(98,e.bind(null,t,n,r,l))}finally{(Yo=i)===Ao&&ai()}},O=function(){(Yo&(1|Qo|Wo))===Ao&&(Pu(),Hu())},R=function(e,t){var n=Yo;Yo|=2;try{return e(t)}finally{(Yo=n)===Ao&&ai()}};var xc={Events:[An,Vn,Qn,E,k,qn,function(e){ut(e,$n)},z,M,rn,ft,Hu,{current:!1}]};!function(e){var n=e.findFiberByHostInstance;Gu(t({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:G.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=at(e))?null:e.stateNode},findFiberByHostInstance:function(e){return n?n(e):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))}({findFiberByHostInstance:Un,bundleType:0,version:\"16.14.0\",rendererPackageName:\"react-dom\"}),exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xc,exports.createPortal=kc,exports.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternalFiber;if(void 0===t){if(\"function\"==typeof e.render)throw Error(r(188));throw Error(r(268,Object.keys(e)))}return e=null===(e=at(t))?null:e.stateNode},exports.flushSync=function(e,t){if((Yo&(Qo|Wo))!==Ao)throw Error(r(187));var n=Yo;Yo|=1;try{return ri(99,e.bind(null,t))}finally{Yo=n,ai()}},exports.hydrate=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!0,n)},exports.render=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!1,n)},exports.unmountComponentAtNode=function(e){if(!vc(e))throw Error(r(40));return!!e._reactRootContainer&&(Nu(function(){bc(null,null,e,!1,function(){e._reactRootContainer=null,e[Ln]=null})}),!0)},exports.unstable_batchedUpdates=_u,exports.unstable_createPortal=function(e,t){return kc(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},exports.unstable_renderSubtreeIntoContainer=function(e,t,n,l){if(!vc(n))throw Error(r(200));if(null==e||void 0===e._reactInternalFiber)throw Error(r(38));return bc(e,t,n,!1,l)},exports.version=\"16.14.0\";\n},{\"react\":\"n8MK\",\"object-assign\":\"J4Nk\",\"scheduler\":\"MDSO\"}],\"NKHc\":[function(require,module,exports) {\n\"use strict\";function _(){if(\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_)}catch(O){console.error(O)}}}_(),module.exports=require(\"./cjs/react-dom.production.min.js\");\n},{\"./cjs/react-dom.production.min.js\":\"i17t\"}],\"zm2Q\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.customAlphabet=exports.nanoid=void 0;let e=\"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\",t=(e,t)=>()=>{let o=\"\",r=t;for(;r--;)o+=e[Math.random()*e.length|0];return o};exports.customAlphabet=t;let o=(t=21)=>{let o=\"\",r=t;for(;r--;)o+=e[64*Math.random()|0];return o};exports.nanoid=o;\n},{}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"Sn21\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=r,exports.R=void 0;class t{constructor(t){const e=s();this.c=1,this.s0=e(\" \"),this.s1=e(\" \"),this.s2=e(\" \"),this.s0-=e(t),this.s0<0&&(this.s0+=1),this.s1-=e(t),this.s1<0&&(this.s1+=1),this.s2-=e(t),this.s2<0&&(this.s2+=1)}next(){const t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=t-(this.c=Math.trunc(t))}}function s(){let t=4022871197;return function(s){const e=s.toString();for(let r=0;r<e.length;r++){let s=.02519603282416938*(t+=e.charCodeAt(r));s-=t=s>>>0,t=(s*=t)>>>0,t+=4294967296*(s-=t)}return 2.3283064365386963e-10*(t>>>0)}}function e(t,s){return s.c=t.c,s.s0=t.s0,s.s1=t.s1,s.s2=t.s2,s}function r(s,r){const n=new t(s),i=n.next.bind(n);return r&&e(r,n),i.state=(()=>e(n,{})),i}class n{constructor(t){this.state=t||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const t=this.state,s=r(t.prngstate?\"\":t.seed,t.prngstate),e=s();return this.state={...t,prngstate:s.state()},e}api(){const t=this._random.bind(this),s={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},e={};for(const r in s){const n=s[r];e[r]=(s=>void 0===s?Math.floor(t()*n)+1:Array.from({length:s}).map(()=>Math.floor(t()*n)+1))}return{...e,Die:function(s=6,e){return void 0===e?Math.floor(t()*s)+1:Array.from({length:e}).map(()=>Math.floor(t()*s)+1)},Number:()=>t(),Shuffle:s=>{const e=[...s];let r=s.length,n=0;const i=Array.from({length:r});for(;r;){const s=Math.trunc(r*t());i[n++]=e[s],e[s]=e[--r]}return i},_private:this}}}const i={name:\"random\",noClient:({api:t})=>t._private.isUsed(),flush:({api:t})=>t._private.getState(),api:({data:t})=>{return new n(t).api()},setup:({game:t})=>{let{seed:s}=t;return void 0===s&&(s=n.seed()),{seed:s}},playerView:()=>void 0};exports.R=i;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"MZmr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ae,exports.U=ne,exports.a=X,exports.b=Z,exports.c=ee,exports.e=B,exports.i=C,exports.z=exports.y=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.T=exports.S=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=a(require(\"immer\")),t=require(\"./plugin-random-087f861e.js\"),r=a(require(\"lodash.isplainobject\"));function a(e){return e&&e.__esModule?e:{default:e}}const n=\"MAKE_MOVE\";exports.M=n;const s=\"GAME_EVENT\";exports.o=s;const o=\"REDO\";exports.R=o;const i=\"RESET\";exports.l=i;const l=\"SYNC\";exports.j=l;const p=\"UNDO\";exports.h=p;const c=\"UPDATE\";exports.k=c;const d=\"PATCH\";exports.P=d;const u=\"PLUGIN\";exports.d=u;const y=\"STRIP_TRANSIENTS\";exports.p=y;const v=(e,t,r,a)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:a}});exports.B=v;const g=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a}});exports.g=g;const x=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a},automatic:!0}),h=e=>({type:l,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=h;const m=(e,t,r,a)=>({type:d,prevStateID:e,stateID:t,patch:r,deltalog:a,clientOnly:!0});exports.y=m;const f=(e,t)=>({type:c,state:e,deltalog:t,clientOnly:!0});exports.z=f;const P=e=>({type:i,state:e,clientOnly:!0});exports.u=P;const E=(e,t)=>({type:p,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=E;const O=(e,t)=>({type:o,payload:{type:null,args:null,playerID:e,credentials:t}});exports.w=O;const _=(e,t,r,a)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:a}}),M=()=>({type:y});exports.r=M;var N=Object.freeze({__proto__:null,makeMove:v,gameEvent:g,automaticGameEvent:x,sync:h,patch:m,update:f,reset:P,undo:E,redo:O,plugin:_,stripTransients:M});exports.A=N;const T=\"INVALID_MOVE\";exports.n=T;const I={name:\"plugin-immer\",fnWrap:t=>(r,a,...n)=>{let s=!1;const o=(0,e.default)(r,e=>{const r=t(e,a,...n);if(r!==T)return r;s=!0});return s?T:o}};var A,S;exports.G=A,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(A||(exports.G=A={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(S||(S={}));class b{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let a=0;a<this.dispatch.length;a++){const t=this.dispatch[a],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,S.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,S.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case A.TURN_ON_END:case A.PHASE_ON_END:return r(t.error,S.StageEventInOnEnd);case A.PHASE_ON_BEGIN:return r(t.error,S.StageEventInPhaseBegin);case A.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,S.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===A.TURN_ON_END||t.calledFrom===A.PHASE_ON_END)return r(t.error,S.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===A.PHASE_ON_END)return r(t.error,S.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const s=x(t.type,t.args,this.playerID);e=this.flow.processEvent(e,s)}return e}}const D={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,a,...n)=>{const s=a.events;return s&&s._private.updateTurnContext(a,t),r=e(r,a,...n),s&&s._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new b(e.flow,t,r).api()},G={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function U(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,r.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!U(e[t]))return!1;return!0}const R={name:\"plugin-serializable\",fnWrap:e=>(t,r,...a)=>{const n=e(t,r,...a);return n}},k=!0,L=()=>{},w=(...e)=>console.error(...e);function C(e){L(`INFO: ${e}`)}function B(e){w(\"ERROR:\",e)}const j=[I,t.R,G,R],F=[...j,D],H=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[a]:{...n,data:s}}}}),e);exports.f=H;const V=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=V;const $=(e,t,r)=>[...j,...r,D].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=$;const q=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const a=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[a]:{data:n}}}}),e);exports.t=q;const W=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[a]:{...n,api:s}}}}),e);exports.m=W;const z=(e,t)=>([...j,...t.game.plugins,D].reverse().forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}};if(r.flush){const a=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}else if(r.dangerouslyFlushRawState){const s=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[a].data;e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}}),e),K=(e,t)=>[...F,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const a=r.name,n=e.plugins[a];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=K;const Y=(e,t)=>{return[...F,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:a}=r,n=e.plugins[a],s=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!s&&{plugin:a,message:s}}).find(e=>e)||!1},J=(e,t)=>{const r=z(e,t),a=Y(r,t);if(!a)return[r];const{plugin:n,message:s}=a;return B(`${n} plugin declared action invalid:\\n${s}`),[e,a]};exports.q=J;const Q=({G:e,ctx:t,plugins:r={}},{game:a,playerID:n})=>([...F,...a.plugins].forEach(({name:s,playerView:o})=>{if(!o)return;const{data:i}=r[s]||{data:{}},l=o({G:e,ctx:t,game:a,data:i,playerID:n});r={...r,[s]:{data:l}}}),r);function X(e,t=!1){e.moveLimit&&(t&&(e.minMoves=e.moveLimit),e.maxMoves=e.moveLimit,delete e.moveLimit)}function Z(e,t){let r={},a=[],n=null,s={},o={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=oe.NULL),r=e}else{if(X(t),t.next&&(n=t.next),t.revert&&(a=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMinMoves:e._activePlayersMinMoves,_activePlayersMaxMoves:e._activePlayersMaxMoves,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&te(r,s,o,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let a=0;a<e.playOrder.length;a++){const n=e.playOrder[a];n!==e.currentPlayer&&te(r,s,o,n,t.others)}if(void 0!==t.all)for(let a=0;a<e.playOrder.length;a++){te(r,s,o,e.playOrder[a],t.all)}if(t.value)for(const e in t.value)te(r,s,o,e,t.value[e]);if(t.minMoves)for(const e in r)void 0===s[e]&&(s[e]=t.minMoves);if(t.maxMoves)for(const e in r)void 0===o[e]&&(o[e]=t.maxMoves)}0===Object.keys(r).length&&(r=null),0===Object.keys(s).length&&(s=null),0===Object.keys(o).length&&(o=null);const i={};for(const l in r)i[l]=0;return{...e,activePlayers:r,_activePlayersMinMoves:s,_activePlayersMaxMoves:o,_activePlayersNumMoves:i,_prevActivePlayers:a,_nextActivePlayers:n}}function ee(e){let{activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s,_nextActivePlayers:o}=e;if(t&&0===Object.keys(t).length)if(o)e=Z(e,o),({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}=e);else if(s.length>0){const e=s.length-1;({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n}=s[e]),s=s.slice(0,e)}else t=null,r=null,a=null;return{...e,activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}}function te(e,t,r,a,n){\"object\"==typeof n&&n!==oe.NULL||(n={stage:n}),void 0!==n.stage&&(X(n),e[a]=n.stage,n.minMoves&&(t[a]=n.minMoves),n.maxMoves&&(r[a]=n.maxMoves))}function re(e,t){return e[t]+\"\"}function ae(e,t){let{G:r,ctx:a}=e;const{numPlayers:n}=a,s=V(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,s));const l=o.first(r,s),p=typeof l;\"number\"!==p&&B(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=re(i,l);return a=Z(a={...a,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function ne(e,t,r,a){const n=r.order;let{G:s,ctx:o}=e,i=o.playOrderPos,l=!1;if(a&&!0!==a)\"object\"!=typeof a&&B(`invalid argument to endTurn: ${a}`),Object.keys(a).forEach(e=>{switch(e){case\"remove\":t=re(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(a.next),t=a.next;break;default:B(`invalid argument to endTurn: ${e}`)}});else{const r=V(e),a=n.next(s,r),p=typeof a;void 0!==a&&\"number\"!==p&&B(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${a}”.`),void 0===a?l=!0:(i=a,t=re(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.x=Q;const se={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=se;const oe={NULL:null};exports.S=oe;const ie={ALL:{all:oe.NULL},ALL_ONCE:{all:oe.NULL,minMoves:1,maxMoves:1},OTHERS:{others:oe.NULL},OTHERS_ONCE:{others:oe.NULL,minMoves:1,maxMoves:1}};exports.C=ie;\n},{\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)e=o,\"__proto__\"!=(n=this.tokens[r])&&\"constructor\"!=n&&\"prototype\"!=n&&(o=(e||{})[n]);return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"iEGk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=g,exports.I=i,exports.P=s,exports.T=void 0;var e,t,n=require(\"./turn-order-0b7dce3d.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:s,plugins:i}){void 0===e&&(e={}),void 0===s&&(s={}),void 0===i&&(i=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const c={...t};\"\"in c&&(0,n.e)(\"cannot specify phase with empty name\"),c[\"\"]={};const u={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,i);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const B in c){const e=c[B];if(!0===e.start&&(d=B),void 0!==e.moves)for(const t of Object.keys(e.moves))u[B+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={}),(0,n.a)(e.turn,!0);for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){u[B+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?c[e.phase]:c[\"\"]}function g(e){return e}function m(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:s,...i}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const c=[];if(e=o(e,{...i,arg:s,next:c}),o===w)break;const u=G(e);if(u){t.push({fn:w,arg:u,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([g,M,D].includes(o)){const n=b(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...c)}}return e}function x(e,{next:t}){return t.push({fn:h}),e}function h(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.b)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const s=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:s,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:s}=e;if(t&&t.next){if(!(t.next in c))return(0,n.e)(\"invalid phase: \"+t.next),e;s={...s,phase:t.next}}else s={...s,phase:o.wrapped.next(e)||null};return e={...e,ctx:s},a.push({fn:h}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:s}=e;const i=y(s),{endPhase:c,ctx:u}=(0,n.U)(e,a,i.turn,t);return s=u,e={...e,G:o,ctx:s},c?r.push({fn:N,turn:s.turn,phase:s.phase}):r.push({fn:I,currentPlayer:s.currentPlayer}),e}function M(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.S.NULL||(t={stage:t}),\"object\"!=typeof t)return e;(0,n.a)(t);let{ctx:r}=e,{activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,c[a]=0,t.minMoves&&(null===s&&(s={}),s[a]=t.minMoves),t.maxMoves&&(null===i&&(i={}),i[a]=t.maxMoves)),r={...r,activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c},{...e,ctx:r}}function D(e,{arg:t}){return{...e,ctx:(0,n.b)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function b(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.maxMoves&&n>=t.turn.maxMoves)||t.turn.wrapped.endIf(e)}function w(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:s,turn:i}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:s}),null===s)return e;const c=y(e.ctx).wrapped.onEnd(e),u={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:i,phase:s};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:c,ctx:u,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:s,playerID:i}){if(r!==e.ctx.turn)return e;const{currentPlayer:c,numMoves:u,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=u||0;if(!o&&p.turn.minMoves&&v<p.turn.minMoves)return(0,n.i)(`cannot end turn before making ${p.turn.minMoves} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:c});let g={...e.ctx,activePlayers:null};if(t&&t.remove){i=i||c;const t=g.playOrder.filter(e=>e!=i),n=g.playOrderPos>t.length-1?0:g.playOrderPos;if(g={...g,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const m=(0,n.g)(\"endTurn\",t),{_stateID:x}=e,h={action:m,_stateID:x,turn:d,phase:l};s&&(h.automatic=!0);const I=[...e.deltalog||[],h];return{...e,G:f,ctx:g,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:s,_stateID:i}=e,{activePlayers:c,_activePlayersNumMoves:u,_activePlayersMinMoves:l,_activePlayersMaxMoves:d,phase:p,turn:v}=s;const f=null!==c&&o in c,g=y(s);if(!t&&f){const e=g.turn.stages[c[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:M,arg:t,playerID:o}),!f)return e;const m=u[o]||0;if(l&&l[o]&&m<l[o])return(0,n.i)(`cannot end stage before making ${l[o]} moves`),e;delete(c={...c})[o],l&&delete(l={...l})[o],d&&delete(d={...d})[o],s=(0,n.c)({...s,activePlayers:c,_activePlayersMinMoves:l,_activePlayersMaxMoves:d});const x={action:(0,n.g)(\"endStage\",t),_stateID:i,turn:v,phase:p};r&&(x.automatic=!0);const h=[...e.deltalog||[],x];return{...e,ctx:s,deltalog:h}}function S(t,a,r){const o=y(t),s=o.turn.stages,{activePlayers:i}=t;if(i&&void 0!==i[r]&&i[r]!==n.S.NULL&&void 0!==s[i[r]]&&void 0!==s[i[r]].moves){const e=s[i[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const U={endStage:function(e,t){return m(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return m(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return m(e,[{fn:w,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return m(e,[{fn:D,arg:n}])}},T=[];return!1!==s.endTurn&&T.push(\"endTurn\"),!1!==s.pass&&T.push(\"pass\"),!1!==s.endPhase&&T.push(\"endPhase\"),!1!==s.setPhase&&T.push(\"setPhase\"),!1!==s.endGame&&T.push(\"endGame\"),!1!==s.setActivePlayers&&T.push(\"setActivePlayers\"),!1!==s.endStage&&T.push(\"endStage\"),!1!==s.setStage&&T.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>m(e,[{fn:x}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:U,eventNames:Object.keys(U),enabledEventNames:T,moveMap:u,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{currentPlayer:r,activePlayers:o,_activePlayersMaxMoves:s}=e.ctx,i=S(e.ctx,a,n),c=!i||\"function\"==typeof i||!0!==i.noLimit;let{numMoves:u,_activePlayersNumMoves:l}=e.ctx;c&&(n===r&&u++,o&&l[n]++),e={...e,ctx:{...e.ctx,numMoves:u,_activePlayersNumMoves:l}},s&&l[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const d=y(e.ctx).turn.wrapped.onMove({...e,ctx:{...e.ctx,playerID:n}});return m(e={...e,G:d},[{fn:g}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof U[n]?e:U[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function s(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(i(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),s={...(0,n.E)(a),playerID:r.playerID};let i=[];return void 0!==r.args&&(i=Array.isArray(r.args)?r.args:[r.args]),t(a.G,s,...i)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function i(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const c=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,u=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,s]=(0,n.q)(e,r);return s?[o,f(a,t.PluginActionInvalid,s)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.p:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.r)()),{...r,transients:t}):r}}};function g({game:r,isClient:o}){return r=s(r),(s=null,i)=>{let[y]=v(s);switch(i.type){case n.p:return y;case n.o:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed event: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:!1,playerID:i.payload.playerID});let e,a=r.flow.processEvent(y,i);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:i}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,i.payload.type,i.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:o,playerID:i.payload.playerID});const s=r.processMove(y,i.payload);if(s===n.n)return(0,n.e)(`invalid move: ${i.payload.type} args: ${i.payload.args}`),f(y,t.InvalidMove);const u={...y,G:s};if(o&&(0,n.N)(u,{game:r}))return y;if(y=u,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,i,a),y=r.flow.processMove(y,i.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:i}),{...y,_stateID:y._stateID+1})}case n.l:case n.k:case n.j:return i.state;case n.h:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:s,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(c(i)&&i.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!u(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,i),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...s]}}case n.R:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const s=a[0];return c(i)&&i.payload.playerID!==s.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,i),{...y,G:s.G,ctx:s.ctx,plugins:s.plugins,_stateID:o+1,_undo:[...e,s],_redo:a.slice(1)})}case n.d:return(0,n.f)(y,i,{game:r});case n.P:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,i.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(i.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"lU15\":[function(require,module,exports) {\nvar global = arguments[3];\nvar process = require(\"process\");\nvar e=arguments[3],t=require(\"process\");!function(e,n){\"use strict\";if(!e.setImmediate){var a,s,o,c,i,r=1,f={},u=!1,l=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,\"[object process]\"==={}.toString.call(e.process)?a=function(e){t.nextTick(function(){m(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(\"\",\"*\"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},a=function(e){o.port2.postMessage(e)}):l&&\"onreadystatechange\"in l.createElement(\"script\")?(s=l.documentElement,a=function(e){var t=l.createElement(\"script\");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):a=function(e){setTimeout(m,0,e)}:(c=\"setImmediate$\"+Math.random()+\"$\",i=function(t){t.source===e&&\"string\"==typeof t.data&&0===t.data.indexOf(c)&&m(+t.data.slice(c.length))},e.addEventListener?e.addEventListener(\"message\",i,!1):e.attachEvent(\"onmessage\",i),a=function(t){e.postMessage(c+t,\"*\")}),d.setImmediate=function(e){\"function\"!=typeof e&&(e=new Function(\"\"+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var s={callback:e,args:t};return f[r]=s,a(r),r++},d.clearImmediate=g}function g(e){delete f[e]}function m(e){if(u)setTimeout(m,0,e);else{var t=f[e];if(t){u=!0;try{!function(e){var t=e.callback,a=e.args;switch(a.length){case 0:t();break;case 1:t(a[0]);break;case 2:t(a[0],a[1]);break;case 3:t(a[0],a[1],a[2]);break;default:t.apply(n,a)}}(t)}finally{g(e),u=!1}}}}}(\"undefined\"==typeof self?void 0===e?this:e:self);\n},{\"process\":\"pBGv\"}],\"pO2S\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=o,exports.a=c,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./plugin-random-087f861e.js\"),r=require(\"./reducer-07c7b307.js\");require(\"setimmediate\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:r}){this._opts[t]={range:e,value:r}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,r,a){return this.enumerateFn(e,r,a).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.B)(e.move,e.args,a):\"event\"in e?(0,t.g)(e.event,e.args,a):void 0)}random(t){let r;if(void 0!==this.seed){const t=this.prngstate?\"\":this.seed,a=(0,e.a)(t,this.prngstate);r=a(),this.prngstate=a.state()}else r=Math.random();if(t){if(Array.isArray(t)){return t[Math.floor(r*t.length)]}return Math.floor(r*t)}return r}}exports.B=a;const s=25;class i extends a{constructor({enumerate:t,seed:e,objectives:a,game:s,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:e}),void 0===a&&(a=(()=>({}))),this.objectives=a,this.iterationCallback=o||(()=>{}),this.reducer=(0,r.C)({game:s}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:r,playerID:a}){const{G:s,ctx:i}=t;let n=[],o=[];if(void 0!==a)n=this.enumerate(s,i,a),o=this.objectives(s,i,a);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(s,i,c)),o.push(this.objectives(s,i,c));else n=this.enumerate(s,i,i.currentPlayer),o=this.objectives(s,i,i.currentPlayer);return{state:t,parent:r,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,r=0;for(const a of t.children){const s=a.visits+Number.EPSILON,i=a.value/s+Math.sqrt(2*Math.log(t.visits)/s);(null==e||i>r)&&(r=i,e=a)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const r=this.random(e.length),a=e[r];t.actions.splice(r,1);const s=this.reducer(t.state,a),i=this.createNode({state:s,parentAction:a,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let r=0;r<e&&void 0===t.ctx.gameover;r++){const{G:e,ctx:r}=t;let a=r.currentPlayer;r.activePlayers&&(a=Object.keys(r.activePlayers)[0]);const s=this.enumerate(e,r,a),i=this.objectives(e,r,a),n=Object.keys(i).reduce((t,a)=>{const s=i[a];return s.checker(e,r)?t+s.weight:t},0);if(n>0)return{score:n};if(!s||0===s.length)return;const o=this.random(s.length);t=this.reducer(t,s[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const r=this.createNode({state:t,playerID:e});let a=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(a=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of r.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:r}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<a;t++){const t=this.select(r),e=this.expand(t),a=this.playout(e);this.backpropagate(e,a),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:a,metadata:r})};if(this.iterationCounter=0,this.getOpt(\"async\")){const r=()=>{this.iterationCounter<a?(e(),setImmediate(r)):t(i())};r()}else{for(;this.iterationCounter<a;)e();t(i())}})}}exports.M=i;class n extends a{play({G:t,ctx:e},r){const a=this.enumerate(t,e,r);return Promise.resolve({action:this.random(a)})}}async function o(t,e){const r=t.store.getState();let a=r.ctx.currentPlayer;r.ctx.activePlayers&&(a=Object.keys(r.ctx.activePlayers)[0]);const{action:s,metadata:i}=await e.play(r,a);if(s){const e={...s,payload:{...s.payload,metadata:i}};return t.store.dispatch(e),e}}async function c({game:t,bots:e,state:s,depth:i}){void 0===i&&(i=1e4);const n=(0,r.C)({game:t});let o=null,c=0;for(;void 0===s.ctx.gameover&&c<i;){let t=s.ctx.currentPlayer;s.ctx.activePlayers&&(t=Object.keys(s.ctx.activePlayers)[0]);const r=e instanceof a?e:e[t],i=await r.play(s,t);if(!i.action)break;o=i.metadata,s=n(s,i.action),c++}return{state:s,metadata:o}}exports.R=n;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./plugin-random-087f861e.js\":\"Sn21\",\"./reducer-07c7b307.js\":\"iEGk\",\"setimmediate\":\"lU15\"}],\"uvSB\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\"),n=require(\"flatted\"),r=require(\"./ai-3099ce9a.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function W(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function X(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const Y=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);Y.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(Y.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Y.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=X(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(X(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function We(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Xe(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function Ye(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},Ye)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1xg9v5h\",\".menu.svelte-1xg9v5h{display:flex;margin-top:43px;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;margin-right:-500px;transform-origin:bottom right;transform:rotate(-90deg) translate(0, -500px)}.menu-item.svelte-1xg9v5h{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1xg9v5h:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1xg9v5h:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1xg9v5h{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1xg9v5h:hover,.menu-item.svelte-1xg9v5h:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1xg9v5h\"),W(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&W(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1xg9v5h\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),W(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&W(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),W(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&W(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&W(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&W(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Wt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Xt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Yt,Xt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),W(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&W(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&W(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&W(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Wt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Wn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Xn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),W(t,\"current\",e[7]==e[0].currentPlayer),W(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&W(t,\"current\",e[7]==e[0].currentPlayer),6&o&&W(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Yn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Xn(Wn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Wn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Xn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Yn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){if(t&&(\"object\"==typeof t||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return pr(e)}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t,{ToggleVisibility:c}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager),\"ToggleVisibility\"in e&&n(3,c=e.ToggleVisibility)}),[s,r,i,c]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2,ToggleVisibility:3},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Wr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Xr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Yr,Xr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),W(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&W(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Wr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),W(t,\"clickable\",e[1].length>0),W(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&W(t,\"clickable\",e[1].length>0),1&l&&W(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),W(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&W(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[6]=t[n][0],r[7]=t[n][1],r[8]=t,r[9]=n,r}function Bl(e){let t,n,r,l;function o(){e[5].call(t,e[6])}return{c(){G(t=M(\"input\"),\"id\",n=e[3](e[6])),G(t,\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(n,a){q(n,t,a),t.checked=e[1][e[6]],r||(l=[R(t,\"change\",o),R(t,\"change\",e[2])],r=!0)},p(r,l){e=r,1&l&&n!==(n=e[3](e[6]))&&G(t,\"id\",n),3&l&&(t.checked=e[1][e[6]])},d(e){e&&I(t),r=!1,c(l)}}}function Rl(e){let t,n,r,l,o,a,s,i,u,d=e[1][e[6]]+\"\";function f(){e[4].call(l,e[6])}return{c(){t=M(\"span\"),n=N(d),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"id\",o=e[3](e[6])),G(l,\"type\",\"range\"),G(l,\"min\",a=e[7].range.min),G(l,\"max\",s=e[7].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[6]]),i||(u=[R(l,\"change\",f),R(l,\"input\",f),R(l,\"change\",e[2])],i=!0)},p(t,r){e=t,3&r&&d!==(d=e[1][e[6]]+\"\")&&F(n,d),1&r&&o!==(o=e[3](e[6]))&&G(l,\"id\",o),1&r&&a!==(a=e[7].range.min)&&G(l,\"min\",a),1&r&&s!==(s=e[7].range.max)&&G(l,\"max\",s),3&r&&H(l,e[1][e[6]])},d(e){e&&I(t),e&&I(r),e&&I(l),i=!1,c(u)}}}function Kl(e){let t,n,r,l,o,a,s=e[6]+\"\";function i(e,t){return e[7].range?Rl:\"boolean\"==typeof e[7].value?Bl:void 0}let c=i(e),u=c&&c(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),o=V(),u&&u.c(),a=V(),G(n,\"for\",l=e[3](e[6])),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),u&&u.m(t,null),A(t,a)},p(e,o){1&o&&s!==(s=e[6]+\"\")&&F(r,s),1&o&&l!==(l=e[3](e[6]))&&G(n,\"for\",l),c===(c=i(e))&&u?u.p(e,o):(u&&u.d(1),(u=c&&c(e))&&(u.c(),u.m(t,a)))},d(e){e&&I(t),u&&u.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(15&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},e=>\"ai-option-\"+e,function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Xl(Hl(e,E,c));let z=j&&Yl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[17].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[17]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Xl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Yl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Xl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Yl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"for\",\"ai-option-debug\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"id\",\"ai-option-debug\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[18]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Wl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t,{ToggleVisibility:a}=t;const{secondaryPane:s}=de(\"secondaryPane\"),i={MCTS:r.M,Random:r.R};let c=!1,u=null,d=0,f=null;const p=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,d=e),n(2,u=e/t),f=r,c&&f&&s.set({component:jl,metadata:f})};let m,g,v,$;function y(){l.overrideGameState(null),s.set(null),n(1,c=!1)}return l.game.ai&&(m=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})).setOpt(\"async\",!0),ie(y),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager),\"ToggleVisibility\"in e&&n(16,a=e.ToggleVisibility)}),[l,c,u,d,g,v,$,m,i,function(){c&&f?s.set({component:jl,metadata:f}):s.set(null)},function(){const e=i[g];n(7,m=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})),m.setOpt(\"async\",!0),n(5,v=null),f=null,s.set(null),n(3,d=0)},async function(){n(5,v=null),f=null,n(3,d=0);const e=await(0,r.S)(l,m);e&&(n(5,v=e.payload.type),n(6,$=e.payload.args))},function(e=1e4,t=100){return n(5,v=null),f=null,n(3,d=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,m);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,v=null),f=null,n(3,d=0),y()},function(e){27==e.keyCode&&y()},o,a,function(){g=U(this),n(4,g),n(8,i)},function(){c=this.checked,n(1,c)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15,ToggleVisibility:16},Fl)}}function oo(e){z(e,\"svelte-8ymctk\",\".debug-panel.svelte-8ymctk.svelte-8ymctk{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-8ymctk.svelte-8ymctk{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-8ymctk.svelte-8ymctk{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-8ymctk.svelte-8ymctk:hover,.visibility-toggle.svelte-8ymctk.svelte-8ymctk:focus{background:#eee}.opener.svelte-8ymctk.svelte-8ymctk{right:10px}.closer.svelte-8ymctk.svelte-8ymctk{left:-326px}@keyframes svelte-8ymctk-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-8ymctk.svelte-8ymctk{display:flex;height:100%;animation:svelte-8ymctk-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-8ymctk .icon.svelte-8ymctk{animation-direction:reverse}.pane.svelte-8ymctk.svelte-8ymctk{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-8ymctk.svelte-8ymctk{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-8ymctk button,.debug-panel.svelte-8ymctk select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-8ymctk select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-8ymctk section{margin-bottom:20px}.debug-panel.svelte-8ymctk .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u=e[10]&&io(e);(r=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var d=e[6][e[2]].component;function f(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}d&&(a=new d(f(e)));let p=e[5]&&co(e);return{c(){t=M(\"div\"),u&&u.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"div\"),a&&Be(a.$$.fragment),s=V(),p&&p.c(),G(o,\"class\",\"pane svelte-8ymctk\"),G(o,\"role\",\"region\"),G(o,\"aria-label\",e[2]),G(o,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-8ymctk\")},m(i,d){q(i,t,d),u&&u.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),a&&Re(a,o,null),e[16](o),A(t,s),p&&p.m(t,null),c=!0},p(n,l){(e=n)[10]&&u.p(e,l);const s={};4&l&&(s.pane=e[2]),r.$set(s);const i={};if(16&l&&(i.client=e[4]),1&l&&(i.clientManager=e[0]),d!==(d=e[6][e[2]].component)){if(a){_e();const e=a;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}d?(Be((a=new d(f(e))).$$.fragment),Ce(a.$$.fragment,1),Re(a,o,null)):a=null}else d&&a.$set(i);(!c||4&l)&&G(o,\"aria-label\",e[2]),e[5]?p?(p.p(e,l),32&l&&Ce(p,1)):((p=co(e)).c(),Ce(p,1),p.m(t,null)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se())},i(n){c||(Ce(u),Ce(r.$$.fragment,n),a&&Ce(a.$$.fragment,n),Ce(p),be(()=>{i||(i=De(t,We,{x:400,...e[12]},!0)),i.run(1)}),c=!0)},o(n){qe(u),qe(r.$$.fragment,n),a&&qe(a.$$.fragment,n),qe(p),i||(i=De(t,We,{x:400,...e[12]},!1)),i.run(0),c=!1},d(n){n&&I(t),u&&u.d(),Ke(r),a&&Ke(a),e[16](null),p&&p.d(),n&&i&&i.end()}}}function so(e){let t,n,r=e[10]&&uo(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,t){e[10]&&r.p(e,t)},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function io(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle closer svelte-8ymctk\"),G(t,\"title\",\"Hide Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function co(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-8ymctk\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function uo(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-8ymctk\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function fo(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-8ymctk\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[11]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function po(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(15,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,h=!h)}const y=o.client.debugOpt;let h=!y||!y.collapseOnLoad;const b=!y||!y.hideToggleButton;const x={duration:150,easing:Ze},[w,k]=Xe(x);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{32768&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,h,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,b,function(e){\".\"!=e.key?h&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},x,w,k,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class mo extends Le{constructor(e){super(),Je(this,e,po,fo,d,{clientManager:0},oo)}}exports.D=mo;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"flatted\":\"O5av\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"Wibm\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.t)(n,{game:r}),n=(0,e.m)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.q)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\"}],\"zA0v\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class t{constructor({transportDataCallback:t,gameName:a,playerID:s,matchID:e,credentials:n,numPlayers:i}){this.connectionStatusCallback=(()=>{}),this.isConnected=!1,this.transportDataCallback=t,this.gameName=a||\"default\",this.playerID=s||null,this.matchID=e||\"default\",this.credentials=n,this.numPlayers=i||2}subscribeToConnectionStatus(t){this.connectionStatusCallback=t}setConnectionStatus(t){this.isConnected=t,this.connectionStatusCallback()}notifyClient(t){this.transportDataCallback(t)}}exports.T=t;\n},{}],\"FkTq\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid/non-secure\"),e=require(\"./Debug-fd09b8bc.js\"),s=require(\"redux\"),i=require(\"./turn-order-0b7dce3d.js\"),r=require(\"./reducer-07c7b307.js\"),a=require(\"./initialize-9ac1bbf5.js\"),n=require(\"./transport-ce07b771.js\");class h extends n.T{connect(){}disconnect(){}sendAction(){}sendChatMessage(){}requestSync(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const c=t=>new h(t);class l{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const u=new l;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const c of e)h[c]=((...e)=>{const h=i.A[t](c,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:l,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g||\"default\",this.credentials=d,this.multiplayer=l,this.debugOpt=n,this.manager=u,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==l}),this.initialState=null,l||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.u)(this.initialState))}),this.undo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.w)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.p||this.transport.sendAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.o:case i.h:case i.R:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.l:this.log=[];break;case i.P:case i.k:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.j:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),l||(l=c),this.transport=l({transportDataCallback:t=>this.receiveTransportData(t),gameKey:e,game:this.game,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.sendChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})})}receiveMatchData(t){this.matchData=t,this.notifySubscribers()}receiveChatMessage(t){this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()}receiveTransportData(t){const[e]=t.args;if(e===this.matchID)switch(t.type){case\"sync\":{const[,e]=t.args,s=(0,i.s)(e);this.receiveMatchData(e.filteredMetadata),this.store.dispatch(s);break}case\"update\":{const[,e,s]=t.args,r=this.store.getState();if(e._stateID>=r._stateID){const t=(0,i.z)(e,s);this.store.dispatch(t)}break}case\"patch\":{const[,e,s,r,a]=t.args,n=this.store.getState()._stateID;if(e!==n)break;const h=(0,i.y)(e,s,r,a);this.store.dispatch(h),this.store.getState()._stateID===n&&this.transport.requestSync();break}case\"matchData\":{const[,e]=t.args;this.receiveMatchData(e);break}case\"chat\":{const[,e]=t.args;this.receiveChatMessage(e);break}}}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribeToConnectionStatus(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.x)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\"}],\"mOPV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const e=(e,t)=>{if(!e||\"string\"!=typeof e)throw new Error(`Expected ${t} string, got \"${e}\".`)},t=t=>e(t,\"game name\"),s=t=>e(t,\"match ID\"),r=(e,t)=>{if(!e)throw new Error(`Expected body, got “${e}”.`);for(const s in t){const r=t[s],a=Array.isArray(r)?r:[r],n=e[s];if(!a.includes(typeof n)){const e=a.join(\"|\");throw new TypeError(`Expected body.${s} to be of type ${e}, got “${n}”.`)}}};class a extends Error{constructor(e,t){super(e),this.details=t}}exports.a=a;class n{constructor({server:e=\"\"}={}){this.server=e.replace(/\\/$/,\"\")}async request(e,t){const s=await fetch(this.server+e,t);if(!s.ok){let e;try{e=await s.clone().json()}catch{try{e=await s.text()}catch(r){e=r.message}}throw new a(`HTTP status ${s.status}`,e)}return s.json()}async post(e,t){let s={method:\"post\",body:JSON.stringify(t.body),headers:{\"Content-Type\":\"application/json\"}};return t.init&&(s={...s,...t.init,headers:{...s.headers,...t.init.headers}}),this.request(e,s)}async listGames(e){return this.request(\"/games\",e)}async listMatches(e,s,r){t(e);let a=\"\";if(s){const e=[],{isGameover:t,updatedBefore:r,updatedAfter:n}=s;void 0!==t&&e.push(`isGameover=${t}`),r&&e.push(`updatedBefore=${r}`),n&&e.push(`updatedAfter=${n}`),e.length>0&&(a=\"?\"+e.join(\"&\"))}return this.request(`/games/${e}${a}`,r)}async getMatch(e,r,a){return t(e),s(r),this.request(`/games/${e}/${r}`,a)}async createMatch(e,s,a){return t(e),r(s,{numPlayers:\"number\"}),this.post(`/games/${e}/create`,{body:s,init:a})}async joinMatch(e,a,n,i){return t(e),s(a),r(n,{playerID:[\"string\",\"undefined\"],playerName:\"string\"}),this.post(`/games/${e}/${a}/join`,{body:n,init:i})}async leaveMatch(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/leave`,{body:n,init:i})}async updatePlayer(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/update`,{body:n,init:i})}async playAgain(e,a,n,i){return t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${e}/${a}/playAgain`,{body:n,init:i})}}exports.L=n;\n},{}],\"L8uO\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"SAdv\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"L8uO\"}],\"PB2Y\":[function(require,module,exports) {\n\"use strict\";var _=\"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED\";module.exports=_;\n},{}],\"cTRg\":[function(require,module,exports) {\n\"use strict\";var e=require(\"./lib/ReactPropTypesSecret\");function r(){}function t(){}t.resetWarningCache=r,module.exports=function(){function n(r,t,n,o,a,p){if(p!==e){var c=new Error(\"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types\");throw c.name=\"Invariant Violation\",c}}function o(){return n}n.isRequired=n;var a={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:o,element:n,elementType:n,instanceOf:o,node:n,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:t,resetWarningCache:r};return a.PropTypes=a,a};\n},{\"./lib/ReactPropTypesSecret\":\"PB2Y\"}],\"yu5W\":[function(require,module,exports) {\nvar r,e;module.exports=require(\"./factoryWithThrowingShims\")();\n},{\"./factoryWithThrowingShims\":\"cTRg\"}],\"KAZ5\":[function(require,module,exports) {\n\"use strict\";exports.parse=n,exports.serialize=o;var e=decodeURIComponent,t=encodeURIComponent,r=/; */,i=/^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;function n(t,i){if(\"string\"!=typeof t)throw new TypeError(\"argument str must be a string\");for(var n={},o=i||{},s=t.split(r),p=o.decode||e,f=0;f<s.length;f++){var u=s[f],m=u.indexOf(\"=\");if(!(m<0)){var c=u.substr(0,m).trim(),l=u.substr(++m,u.length).trim();'\"'==l[0]&&(l=l.slice(1,-1)),null==n[c]&&(n[c]=a(l,p))}}return n}function o(e,r,n){var o=n||{},a=o.encode||t;if(\"function\"!=typeof a)throw new TypeError(\"option encode is invalid\");if(!i.test(e))throw new TypeError(\"argument name is invalid\");var s=a(r);if(s&&!i.test(s))throw new TypeError(\"argument val is invalid\");var p=e+\"=\"+s;if(null!=o.maxAge){var f=o.maxAge-0;if(isNaN(f))throw new Error(\"maxAge should be a Number\");p+=\"; Max-Age=\"+Math.floor(f)}if(o.domain){if(!i.test(o.domain))throw new TypeError(\"option domain is invalid\");p+=\"; Domain=\"+o.domain}if(o.path){if(!i.test(o.path))throw new TypeError(\"option path is invalid\");p+=\"; Path=\"+o.path}if(o.expires){if(\"function\"!=typeof o.expires.toUTCString)throw new TypeError(\"option expires is invalid\");p+=\"; Expires=\"+o.expires.toUTCString()}if(o.httpOnly&&(p+=\"; HttpOnly\"),o.secure&&(p+=\"; Secure\"),o.sameSite)switch(\"string\"==typeof o.sameSite?o.sameSite.toLowerCase():o.sameSite){case!0:p+=\"; SameSite=Strict\";break;case\"lax\":p+=\"; SameSite=Lax\";break;case\"strict\":p+=\"; SameSite=Strict\";break;default:throw new TypeError(\"option sameSite is invalid\")}return p}function a(e,t){try{return t(e)}catch(r){return e}}\n},{}],\"kpSY\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");Object.defineProperty(exports,\"__esModule\",{value:!0});var o=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e};exports.load=f,exports.loadAll=l,exports.select=p,exports.save=y,exports.remove=v,exports.setRawCookie=k,exports.plugToRequest=m;var t=require(\"cookie\"),r=u(t),n=require(\"object-assign\"),i=u(n);function u(e){return e&&e.__esModule?e:{default:e}}var c=\"undefined\"==typeof document||void 0!==e&&e.env&&!1,a={},s=void 0;function d(){return s&&!s.headersSent}function f(e,o){var t=c?a:r.default.parse(document.cookie),n=t&&t[e];if(void 0===o&&(o=!n||\"{\"!==n[0]&&\"[\"!==n[0]),!o)try{n=JSON.parse(n)}catch(i){}return n}function l(e){var o=c?a:r.default.parse(document.cookie);if(void 0===e&&(e=!o||\"{\"!==o[0]&&\"[\"!==o[0]),!e)try{o=JSON.parse(o)}catch(t){}return o}function p(e){var o=c?a:r.default.parse(document.cookie);return o?e?Object.keys(o).reduce(function(t,r){if(!e.test(r))return t;var n={};return n[r]=o[r],(0,i.default)({},t,n)},{}):o:{}}function y(e,t,n){a[e]=t,\"object\"===(void 0===t?\"undefined\":o(t))&&(a[e]=JSON.stringify(t)),c||(document.cookie=r.default.serialize(e,a[e],n)),d()&&s.cookie&&s.cookie(e,t,n)}function v(e,o){delete a[e],o=void 0===o?{}:\"string\"==typeof o?{path:o}:(0,i.default)({},o),\"undefined\"!=typeof document&&(o.expires=new Date(1970,1,1,0,0,1),o.maxAge=0,document.cookie=r.default.serialize(e,\"\",o)),d()&&s.clearCookie&&s.clearCookie(e,o)}function k(e){a=e?r.default.parse(e):{}}function m(e,o){return e.cookie?a=e.cookie:e.cookies?a=e.cookies:e.headers&&e.headers.cookie?k(e.headers.cookie):a={},s=o,function(){s=null,a={}}}exports.default={setRawCookie:k,load:f,loadAll:l,select:p,save:y,remove:v,plugToRequest:m};\n},{\"cookie\":\"KAZ5\",\"object-assign\":\"J4Nk\",\"process\":\"pBGv\"}],\"pSNY\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=a,exports.c=exports.S=exports.A=void 0;var e,t=require(\"./initialize-9ac1bbf5.js\");function a(t){return t.type()===e.SYNC}!function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class s{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=s;class n{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=n;const o=({game:e,unlisted:t,setupData:a,numPlayers:s})=>{const n={gameName:e.name,unlisted:!!t,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==a&&(n.setupData=a);for(let o=0;o<s;o++)n.players[o]={id:o};return n},r=({game:e,numPlayers:a,setupData:s,unlisted:n})=>{a&&\"number\"==typeof a||(a=2);const r=e.validateSetupData&&e.validateSetupData(s,a);return void 0!==r?{setupDataError:r}:{metadata:o({game:e,numPlayers:a,setupData:s,unlisted:n}),initialState:(0,t.I)({game:e,numPlayers:a,setupData:s})}};exports.c=r;\n},{\"./initialize-9ac1bbf5.js\":\"Wibm\"}],\"gTRl\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./reducer-07c7b307.js\"),r=require(\"./util-b1699aa1.js\");const s=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),i=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class o{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(s,o,n,c){if(!s||!s.payload)return{error:\"missing action or action payload\"};let l;if((0,r.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(n,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:c,credentials:s.payload.credentials,metadata:l})))return{error:\"unauthorized action\"}}const d=i(s),h=n;let u;if((0,r.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${c}]`+` - action[${d.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),y=(0,t.createStore)(p,u,g);if(d.type==a.h||d.type==a.R){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===c;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[c]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${c}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,c))return void(0,a.e)(`player not active - playerID=[${c}]`+` - action[${d.payload.type}]`);const m=d.type==a.M?this.game.flow.getMove(u.ctx,d.payload.type,c):null;if(d.type==a.M&&!m)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${c}]`+` - action[${d.payload.type}]`);if(u._stateID!==o&&!(m&&(0,e.I)(m)&&m.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${o}], expected=[${u._stateID}]`+` - playerID=[${c}] - action[${d.payload.type}]`);const I=y.getState();y.dispatch(d),u=y.getState(),this.subscribeCallback({state:u,action:d,matchID:n}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[n,o,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[n,u]});const{deltalog:f,...P}=u;let A;if(!l||void 0!==l.gameover&&null!==l.gameover||(A={...l,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,r.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,i=2){const o=t,n={state:!0,metadata:!0,log:!0,initialState:!0},c=(0,r.i)(this.storageAPI)?this.storageAPI.fetch(o,n):await this.storageAPI.fetch(o,n);let{state:l,initialState:d,log:h,metadata:u}=c;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:u})))return{error:\"unauthorized\"}}if(void 0===l){const a=(0,r.c)({game:this.game,unlisted:!0,numPlayers:i,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};d=l=a.initialState,u=a.metadata,this.subscribeCallback({state:l,matchID:t}),(0,r.i)(this.storageAPI)?this.storageAPI.createMatch(o,{initialState:d,metadata:u}):await this.storageAPI.createMatch(o,{initialState:d,metadata:u})}const p={state:l,log:h,filteredMetadata:u?s(u):void 0,initialState:d};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,p]})}async onConnectionChange(t,e,i,o){const n=t;if(null==e)return;let c;if((0,r.i)(this.storageAPI)?({metadata:c}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:c}=await this.storageAPI.fetch(n,{metadata:!0})),void 0===c)return(0,a.e)(`metadata not found for matchID=[${n}]`),{error:\"metadata not found\"};if(void 0===c.players[e])return(0,a.e)(`Player not in the match, matchID=[${n}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:i,metadata:c})))return{error:\"unauthorized\"}}c.players[e].isConnected=o;const l=s(c);this.transportAPI.sendAll({type:\"matchData\",args:[t,l]}),(0,r.i)(this.storageAPI)?this.storageAPI.setMetadata(n,c):await this.storageAPI.setMetadata(n,c)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=o;\n},{\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./util-b1699aa1.js\":\"pSNY\"}],\"AbzV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.g=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"rfc6902\");const r=(t,r,a)=>({...a,G:t.playerView(a.G,a.ctx,r),plugins:(0,e.x)(a,{playerID:r,game:t}),deltalog:void 0,_undo:[],_redo:[]}),a=e=>(a,s)=>{switch(s.type){case\"patch\":{const[c,n,l,u]=s.args,d=o(u.deltalog,a),p=r(e,a,u),i=u._stateID,g=r(e,a,l);return{type:\"patch\",args:[c,n,i,(0,t.createPatch)(g,p),d]}}case\"update\":{const[t,c]=s.args,n=o(c.deltalog,a);return{type:\"update\",args:[t,r(e,a,c),n]}}case\"sync\":{const[t,c]=s.args,n=r(e,a,c.state),l=o(c.log,a);return{type:\"sync\",args:[t,{...c,state:n,log:l}]}}default:return s}};function o(e,t){return void 0===e?e:e.map(e=>{if(null!==t&&+t==+e.action.payload.playerID)return e;if(!0!==e.redact)return e;const r={...e.action.payload,args:null},a={...e,action:{...e.action,payload:r}},{redact:o,...s}=a;return s})}exports.g=a;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"UzxM\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=p,exports.S=g;var t=require(\"./transport-ce07b771.js\"),e=require(\"./util-b1699aa1.js\"),s=require(\"./master-be1abdd0.js\"),i=require(\"./filter-player-view-c30cdfbf.js\"),a=n(require(\"socket.io-client\"));function n(t){return t&&t.__esModule?t:{default:t}}class r extends e.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class c extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends r{constructor(t=\"bgio\"){super();const e=e=>new c(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}function h(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class l extends s.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const n={},c={};if(t&&t.ai&&e)for(const i in e){const s=e[i];c[i]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const l=({playerID:t,...e})=>{const s=n[t];void 0!==s&&s(u(t,e))},u=(0,i.g)(t),d={send:l,sendAll:t=>{for(const e in n)l({playerID:e,...t})}};super(t,a?new o(s):new r,d),this.connect=((t,e)=>{n[t]=e}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const i=h(t,c);null!==i&&setTimeout(async()=>{const e=await c[i].play(t,i);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class u extends t.T{constructor({master:t,...e}){super(e),this.master=t}sendChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}sendAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}requestSync(){this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}connect(){this.setConnectionStatus(!0),this.master.connect(this.playerID,t=>this.notifyClient(t)),this.requestSync()}disconnect(){this.setConnectionStatus(!1)}updateMatchID(t){this.matchID=t,this.connect()}updatePlayerID(t){this.playerID=t,this.connect()}updateCredentials(t){this.credentials=t,this.connect()}}const d=new Map;function p({bots:t,persist:e,storageKey:s}={}){return i=>{const{gameKey:a,game:n}=i;let r;const c=d.get(a);return c&&c.bots===t&&c.storageKey===s&&c.persist===e&&(r=c.master),r||(r=new l({game:n,bots:t,persist:e,storageKey:s}),d.set(a,{master:r,bots:t,persist:e,storageKey:s})),new u({master:r,...i})}}const m=a.default;class y extends t.T{constructor({socket:t,socketOpts:e,server:s,...i}){super(i),this.server=s,this.socket=t,this.socketOpts=e}sendAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}sendChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=m(t+this.gameName,this.socketOpts)}else this.socket=m(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(t,e,s,i,a)=>{this.notifyClient({type:\"patch\",args:[t,e,s,i,a]})}),this.socket.on(\"update\",(t,e,s)=>{this.notifyClient({type:\"update\",args:[t,e,s]})}),this.socket.on(\"sync\",(t,e)=>{this.notifyClient({type:\"sync\",args:[t,e]})}),this.socket.on(\"matchData\",(t,e)=>{this.notifyClient({type:\"matchData\",args:[t,e]})}),this.socket.on(\"chat\",(t,e)=>{this.notifyClient({type:\"chat\",args:[t,e]})}),this.socket.on(\"connect\",()=>{this.requestSync(),this.setConnectionStatus(!0)}),this.socket.on(\"disconnect\",()=>{this.setConnectionStatus(!1)})}disconnect(){this.socket.close(),this.socket=null,this.setConnectionStatus(!1)}requestSync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}updateMatchID(t){this.matchID=t,this.requestSync()}updatePlayerID(t){this.playerID=t,this.requestSync()}updateCredentials(t){this.credentials=t,this.requestSync()}}function g({server:t,socketOpts:e}={}){return s=>new y({server:t,socketOpts:e,...s})}\n},{\"./transport-ce07b771.js\":\"zA0v\",\"./util-b1699aa1.js\":\"pSNY\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"PUvW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Client=o,exports.Lobby=void 0,require(\"nanoid/non-secure\"),require(\"./Debug-fd09b8bc.js\"),require(\"redux\"),require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"./initialize-9ac1bbf5.js\"),require(\"./transport-ce07b771.js\");var e=require(\"./client-fa36c03a.js\");require(\"flatted\"),require(\"setimmediate\");var t=require(\"./ai-3099ce9a.js\"),a=require(\"./client-5f57c3f2.js\"),s=c(require(\"react\")),r=c(require(\"prop-types\")),n=c(require(\"react-cookies\"));require(\"./util-b1699aa1.js\");var i,l=require(\"./socketio-e4fb268a.js\");function c(e){return e&&e.__esModule?e:{default:e}}function o(t){var a;const{game:n,numPlayers:i,board:l,multiplayer:c,enhancer:o}=t;let{loading:h,debug:m}=t;if(void 0===h){h=(()=>s.default.createElement(\"div\",{className:\"bgio-loading\"},\"connecting...\"))}return(a=class extends s.default.Component{constructor(t){super(t),void 0===m&&(m=t.debug),this.client=(0,e.C)({game:n,debug:m,numPlayers:i,multiplayer:c,matchID:t.matchID,playerID:t.playerID,credentials:t.credentials,enhancer:o})}componentDidMount(){this.unsubscribe=this.client.subscribe(()=>this.forceUpdate()),this.client.start()}componentWillUnmount(){this.client.stop(),this.unsubscribe()}componentDidUpdate(e){this.props.matchID!=e.matchID&&this.client.updateMatchID(this.props.matchID),this.props.playerID!=e.playerID&&this.client.updatePlayerID(this.props.playerID),this.props.credentials!=e.credentials&&this.client.updateCredentials(this.props.credentials)}render(){const e=this.client.getState();if(null===e)return s.default.createElement(h);let t=null;return l&&(t=s.default.createElement(l,{...e,...this.props,isMultiplayer:!!c,moves:this.client.moves,events:this.client.events,matchID:this.client.matchID,playerID:this.client.playerID,reset:this.client.reset,undo:this.client.undo,redo:this.client.redo,log:this.client.log,matchData:this.client.matchData,sendChatMessage:this.client.sendChatMessage,chatMessages:this.client.chatMessages})),s.default.createElement(\"div\",{className:\"bgio-client\"},t)}}).propTypes={matchID:r.default.string,playerID:r.default.string,credentials:r.default.string,debug:r.default.any},a.defaultProps={matchID:\"default\",playerID:null,credentials:null,debug:!0},a}require(\"./master-be1abdd0.js\"),require(\"./filter-player-view-c30cdfbf.js\"),require(\"socket.io-client\");class h{constructor({server:e,gameComponents:t,playerName:s,playerCredentials:r}){this.client=new a.L({server:e}),this.gameComponents=t,this.playerName=s||\"Visitor\",this.playerCredentials=r,this.matches=[]}async refresh(){try{this.matches=[];const t=await this.client.listGames();for(const e of t){if(!this._getGameComponents(e))continue;const{matches:t}=await this.client.listMatches(e);this.matches.push(...t)}}catch(e){throw new Error(\"failed to retrieve list of matches (\"+e+\")\")}}_getMatchInstance(e){for(const t of this.matches)if(t.matchID===e)return t}_getGameComponents(e){for(const t of this.gameComponents)if(t.game.name===e)return t}_findPlayer(e){for(const t of this.matches)if(t.players.some(t=>t.name===e))return t}async join(e,t,a){try{let r=this._findPlayer(this.playerName);if(r)throw new Error(\"player has already joined \"+r.matchID);if(!(r=this._getMatchInstance(t)))throw new Error(\"game instance \"+t+\" not found\");const n=await this.client.joinMatch(e,t,{playerID:a,playerName:this.playerName});r.players[Number.parseInt(a)].name=this.playerName,this.playerCredentials=n.playerCredentials}catch(s){throw new Error(\"failed to join match \"+t+\" (\"+s+\")\")}}async leave(e,t){try{const s=this._getMatchInstance(t);if(!s)throw new Error(\"match instance not found\");for(const a of s.players)if(a.name===this.playerName)return await this.client.leaveMatch(e,t,{playerID:a.id.toString(),credentials:this.playerCredentials}),delete a.name,void delete this.playerCredentials;throw new Error(\"player not found in match\")}catch(a){throw new Error(\"failed to leave match \"+t+\" (\"+a+\")\")}}async disconnect(){const e=this._findPlayer(this.playerName);e&&await this.leave(e.gameName,e.matchID),this.matches=[],this.playerName=\"Visitor\"}async create(e,t){try{const s=this._getGameComponents(e);if(!s)throw new Error(\"game not found\");if(t<s.game.minPlayers||t>s.game.maxPlayers)throw new Error(\"invalid number of players \"+t);await this.client.createMatch(e,{numPlayers:t})}catch(a){throw new Error(\"failed to create match for \"+e+\" (\"+a+\")\")}}}function m(e){return new h(e)}class u extends s.default.Component{constructor(){super(...arguments),this.state={playerName:this.props.playerName,nameErrorMsg:\"\"},this.onClickEnter=(()=>{\"\"!==this.state.playerName&&this.props.onEnter(this.state.playerName)}),this.onKeyPress=(e=>{\"Enter\"===e.key&&this.onClickEnter()}),this.onChangePlayerName=(e=>{const t=e.target.value.trim();this.setState({playerName:t,nameErrorMsg:t.length>0?\"\":\"empty player name\"})})}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"p\",{className:\"phase-title\"},\"Choose a player name:\"),s.default.createElement(\"input\",{type:\"text\",value:this.state.playerName,onChange:this.onChangePlayerName,onKeyPress:this.onKeyPress}),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{className:\"buttons\",onClick:this.onClickEnter},\"Enter\")),s.default.createElement(\"br\",null),s.default.createElement(\"span\",{className:\"error-msg\"},this.state.nameErrorMsg,s.default.createElement(\"br\",null)))}}u.defaultProps={playerName:\"\"};class p extends s.default.Component{constructor(){super(...arguments),this._createSeat=(e=>e.name||\"[free]\"),this._createButtonJoin=((e,t)=>s.default.createElement(\"button\",{key:\"button-join-\"+e.matchID,onClick:()=>this.props.onClickJoin(e.gameName,e.matchID,\"\"+t)},\"Join\")),this._createButtonLeave=(e=>s.default.createElement(\"button\",{key:\"button-leave-\"+e.matchID,onClick:()=>this.props.onClickLeave(e.gameName,e.matchID)},\"Leave\")),this._createButtonPlay=((e,t)=>s.default.createElement(\"button\",{key:\"button-play-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,playerID:\"\"+t,numPlayers:e.players.length})},\"Play\")),this._createButtonSpectate=(e=>s.default.createElement(\"button\",{key:\"button-spectate-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,numPlayers:e.players.length})},\"Spectate\")),this._createInstanceButtons=(e=>{const t=e.players.find(e=>e.name===this.props.playerName),a=e.players.find(e=>!e.name);return t&&a?this._createButtonLeave(e):a?this._createButtonJoin(e,a.id):t?s.default.createElement(\"div\",null,[this._createButtonPlay(e,t.id),this._createButtonLeave(e)]):this._createButtonSpectate(e)})}render(){const e=this.props.match;let t=\"OPEN\";return e.players.some(e=>!e.name)||(t=\"RUNNING\"),s.default.createElement(\"tr\",{key:\"line-\"+e.matchID},s.default.createElement(\"td\",{key:\"cell-name-\"+e.matchID},e.gameName),s.default.createElement(\"td\",{key:\"cell-status-\"+e.matchID},t),s.default.createElement(\"td\",{key:\"cell-seats-\"+e.matchID},e.players.map(e=>this._createSeat(e)).join(\", \")),s.default.createElement(\"td\",{key:\"cell-buttons-\"+e.matchID},this._createInstanceButtons(e)))}}class d extends s.default.Component{constructor(e){super(e),this.state={selectedGame:0,numPlayers:2},this._createGameNameOption=((e,t)=>s.default.createElement(\"option\",{key:\"name-option-\"+t,value:t},e.game.name)),this._createNumPlayersOption=(e=>s.default.createElement(\"option\",{key:\"num-option-\"+e,value:e},e)),this._createNumPlayersRange=(e=>Array.from({length:e.maxPlayers+1}).map((e,t)=>t).slice(e.minPlayers)),this.onChangeNumPlayers=(e=>{this.setState({numPlayers:Number.parseInt(e.target.value)})}),this.onChangeSelectedGame=(e=>{const t=Number.parseInt(e.target.value);this.setState({selectedGame:t,numPlayers:this.props.games[t].game.minPlayers})}),this.onClickCreate=(()=>{this.props.createMatch(this.props.games[this.state.selectedGame].game.name,this.state.numPlayers)});for(const t of e.games){const e=t.game;e.minPlayers||(e.minPlayers=1),e.maxPlayers||(e.maxPlayers=4),console.assert(e.maxPlayers>=e.minPlayers)}this.state={selectedGame:0,numPlayers:e.games[0].game.minPlayers}}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"select\",{value:this.state.selectedGame,onChange:e=>this.onChangeSelectedGame(e)},this.props.games.map((e,t)=>this._createGameNameOption(e,t))),s.default.createElement(\"span\",null,\"Players:\"),s.default.createElement(\"select\",{value:this.state.numPlayers,onChange:this.onChangeNumPlayers},this._createNumPlayersRange(this.props.games[this.state.selectedGame].game).map(e=>this._createNumPlayersOption(e))),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{onClick:this.onClickCreate},\"Create\")))}}!function(e){e.ENTER=\"enter\",e.PLAY=\"play\",e.LIST=\"list\"}(i||(i={}));class y extends s.default.Component{constructor(e){super(e),this.state={phase:i.ENTER,playerName:\"Visitor\",runningMatch:null,errorMsg:\"\",credentialStore:{}},this._createConnection=(e=>{const t=this.state.playerName;this.connection=m({server:e.lobbyServer,gameComponents:e.gameComponents,playerName:t,playerCredentials:this.state.credentialStore[t]})}),this._updateCredentials=((e,t)=>{this.setState(a=>{const s=Object.assign({},a.credentialStore);return s[e]=t,{credentialStore:s}})}),this._updateConnection=(async()=>{await this.connection.refresh(),this.forceUpdate()}),this._enterLobby=(e=>{this._startRefreshInterval(),this.setState({playerName:e,phase:i.LIST})}),this._exitLobby=(async()=>{this._clearRefreshInterval(),await this.connection.disconnect(),this.setState({phase:i.ENTER,errorMsg:\"\"})}),this._createMatch=(async(e,t)=>{try{await this.connection.create(e,t),await this.connection.refresh(),this.setState({})}catch(a){this.setState({errorMsg:a.message})}}),this._joinMatch=(async(e,t,a)=>{try{await this.connection.join(e,t,a),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(s){this.setState({errorMsg:s.message})}}),this._leaveMatch=(async(e,t)=>{try{await this.connection.leave(e,t),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(a){this.setState({errorMsg:a.message})}}),this._startMatch=((e,a)=>{const s=this.connection._getGameComponents(e);if(!s)return void this.setState({errorMsg:\"game \"+e+\" not supported\"});let r=void 0;if(a.numPlayers>1&&(r=this.props.gameServer?(0,l.S)({server:this.props.gameServer}):(0,l.S)()),1==a.numPlayers){const e=s.game.maxPlayers,a={};for(let s=1;s<e;s++)a[s+\"\"]=t.M;r=(0,l.L)({bots:a})}const n={app:this.props.clientFactory({game:s.game,board:s.board,debug:this.props.debug,multiplayer:r}),matchID:a.matchID,playerID:a.numPlayers>1?a.playerID:\"0\",credentials:this.connection.playerCredentials};this._clearRefreshInterval(),this.setState({phase:i.PLAY,runningMatch:n})}),this._exitMatch=(()=>{this._startRefreshInterval(),this.setState({phase:i.LIST,runningMatch:null})}),this._getPhaseVisibility=(e=>this.state.phase!==e?\"hidden\":\"phase\"),this.renderMatches=((e,t)=>e.map(e=>{const{matchID:a,gameName:r,players:n}=e;return s.default.createElement(p,{key:\"instance-\"+a,match:{matchID:a,gameName:r,players:Object.values(n)},playerName:t,onClickJoin:this._joinMatch,onClickLeave:this._leaveMatch,onClickPlay:this._startMatch})})),this._createConnection(this.props)}componentDidMount(){const e=n.default.load(\"lobbyState\")||{};e.phase&&e.phase===i.PLAY&&(e.phase=i.LIST),e.phase&&e.phase!==i.ENTER&&this._startRefreshInterval(),this.setState({phase:e.phase||i.ENTER,playerName:e.playerName||\"Visitor\",credentialStore:e.credentialStore||{}})}componentDidUpdate(e,t){const a=this.state.playerName,s=this.state.credentialStore[a];if(t.phase!==this.state.phase||t.credentialStore[a]!==s||t.playerName!==a){this._createConnection(this.props),this._updateConnection();const e={phase:this.state.phase,playerName:a,credentialStore:this.state.credentialStore};n.default.save(\"lobbyState\",e,{path:\"/\"})}e.refreshInterval!==this.props.refreshInterval&&this._startRefreshInterval()}componentWillUnmount(){this._clearRefreshInterval()}_startRefreshInterval(){this._clearRefreshInterval(),this._currentInterval=setInterval(this._updateConnection,this.props.refreshInterval)}_clearRefreshInterval(){clearInterval(this._currentInterval)}render(){const{gameComponents:e,renderer:t}=this.props,{errorMsg:a,playerName:r,phase:n,runningMatch:l}=this.state;return t?t({errorMsg:a,gameComponents:e,matches:this.connection.matches,phase:n,playerName:r,runningMatch:l,handleEnterLobby:this._enterLobby,handleExitLobby:this._exitLobby,handleCreateMatch:this._createMatch,handleJoinMatch:this._joinMatch,handleLeaveMatch:this._leaveMatch,handleExitMatch:this._exitMatch,handleRefreshMatches:this._updateConnection,handleStartMatch:this._startMatch}):s.default.createElement(\"div\",{id:\"lobby-view\",style:{padding:50}},s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.ENTER)},s.default.createElement(u,{key:r,playerName:r,onEnter:this._enterLobby})),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.LIST)},s.default.createElement(\"p\",null,\"Welcome, \",r),s.default.createElement(\"div\",{className:\"phase-title\",id:\"match-creation\"},s.default.createElement(\"span\",null,\"Create a match:\"),s.default.createElement(d,{games:e,createMatch:this._createMatch})),s.default.createElement(\"p\",{className:\"phase-title\"},\"Join a match:\"),s.default.createElement(\"div\",{id:\"instances\"},s.default.createElement(\"table\",null,s.default.createElement(\"tbody\",null,this.renderMatches(this.connection.matches,r))),s.default.createElement(\"span\",{className:\"error-msg\"},a,s.default.createElement(\"br\",null))),s.default.createElement(\"p\",{className:\"phase-title\"},\"Matches that become empty are automatically deleted.\")),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.PLAY)},l&&s.default.createElement(l.app,{matchID:l.matchID,playerID:l.playerID,credentials:l.credentials}),s.default.createElement(\"div\",{className:\"buttons\",id:\"match-exit\"},s.default.createElement(\"button\",{onClick:this._exitMatch},\"Exit match\"))),s.default.createElement(\"div\",{className:\"buttons\",id:\"lobby-exit\"},s.default.createElement(\"button\",{onClick:this._exitLobby},\"Exit lobby\")))}}exports.Lobby=y,y.propTypes={gameComponents:r.default.array.isRequired,lobbyServer:r.default.string,gameServer:r.default.string,debug:r.default.bool,clientFactory:r.default.func,refreshInterval:r.default.number},y.defaultProps={debug:!1,clientFactory:o,refreshInterval:2e3};\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\",\"./client-fa36c03a.js\":\"FkTq\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\",\"./client-5f57c3f2.js\":\"mOPV\",\"react\":\"SAdv\",\"prop-types\":\"yu5W\",\"react-cookies\":\"kpSY\",\"./util-b1699aa1.js\":\"pSNY\",\"./socketio-e4fb268a.js\":\"UzxM\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"Prnk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Debug\",{enumerable:!0,get:function(){return e.D}});var e=require(\"./Debug-fd09b8bc.js\");require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"flatted\"),require(\"setimmediate\"),require(\"./ai-3099ce9a.js\");\n},{\"./Debug-fd09b8bc.js\":\"uvSB\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"CnBY\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"ActivePlayers\",{enumerable:!0,get:function(){return e.C}}),Object.defineProperty(exports,\"GameMethod\",{enumerable:!0,get:function(){return e.G}}),Object.defineProperty(exports,\"INVALID_MOVE\",{enumerable:!0,get:function(){return e.n}}),Object.defineProperty(exports,\"Stage\",{enumerable:!0,get:function(){return e.S}}),Object.defineProperty(exports,\"TurnOrder\",{enumerable:!0,get:function(){return e.T}}),exports.PlayerView=void 0;var e=require(\"./turn-order-0b7dce3d.js\");require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\");const r={STRIP_SECRETS:(e,r,t)=>{const n={...e};return void 0!==n.secret&&delete n.secret,n.players&&(n.players=t?{[t]:n.players[t]}:{}),n}};exports.PlayerView=r;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\"}],\"yqkG\":[function(require,module,exports) {\n\"use strict\";var e=a(require(\"react\")),l=a(require(\"react-dom\")),t=require(\"boardgame.io/react\"),r=require(\"boardgame.io/debug\"),n=require(\"boardgame.io/core\");function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].map(l=>{const t=l.map(l=>e[l]);return t.every(e=>null!==e&&e===t[0])}).some(e=>!0===e)}const u={setup:()=>({cells:Array(9).fill(null)}),moves:{clickCell(e,l,t){if(null!==e.cells[t])return n.INVALID_MOVE;e.cells[t]=l.currentPlayer}},turn:{minMoves:1,maxMoves:1},endIf:(e,l)=>i(e.cells)?{winner:l.currentPlayer}:0==e.cells.filter(e=>null===e).length?{draw:!0}:void 0,ai:{enumerate:(e,l)=>{let t=[];for(let r=0;r<9;r++)null===e.cells[r]&&t.push({move:\"clickCell\",args:[r]});return t}}};function o({ctx:l,G:t,moves:r}){const n=e=>r.clickCell(e);let a=\"\";l.gameover&&(a=void 0!==l.gameover.winner?e.default.createElement(\"div\",{id:\"winner\"},\"Winner: \",l.gameover.winner):e.default.createElement(\"div\",{id:\"winner\"},\"Draw!\"));const i={border:\"1px solid #555\",width:\"50px\",height:\"50px\",lineHeight:\"50px\",textAlign:\"center\",fontFamily:\"monospace\",fontSize:\"20px\",fontWeight:\"bold\",padding:\"0\",boxSizing:\"border-box\"};let u=[];for(let o=0;o<3;o++){let l=[];for(let r=0;r<3;r++){const a=3*o+r;l.push(e.default.createElement(\"td\",{key:a},t.cells[a]?e.default.createElement(\"div\",{style:i},t.cells[a]):e.default.createElement(\"button\",{style:i,onClick:()=>n(a)})))}u.push(e.default.createElement(\"tr\",{key:o},l))}return e.default.createElement(\"div\",null,e.default.createElement(\"table\",{id:\"board\"},e.default.createElement(\"tbody\",null,u)),a)}var c=(0,t.Client)({board:o,game:u,debug:{impl:r.Debug}});l.default.render(e.default.createElement(c,null),document.getElementById(\"app\"));\n},{\"react\":\"n8MK\",\"react-dom\":\"NKHc\",\"boardgame.io/react\":\"PUvW\",\"boardgame.io/debug\":\"Prnk\",\"boardgame.io/core\":\"CnBY\"}]},{},[\"yqkG\"], null)"
  },
  {
    "path": "docs/documentation/snippets/multiplayer/index.html",
    "content": "<!DOCTYPE html><html><head><style>body{padding:1.25rem}.msg{position:absolute;bottom:0;left:1.25rem;color:#aaa;font-size:.75rem;margin-bottom:1.25rem}@media screen and (max-width:420px){:root{font-size:75%}}</style></head><body> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/multiplayer.54b541fd.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/multiplayer.54b541fd.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"J4Nk\":[function(require,module,exports) {\n\"use strict\";var r=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function n(r){if(null==r)throw new TypeError(\"Object.assign cannot be called with null or undefined\");return Object(r)}function o(){try{if(!Object.assign)return!1;var r=new String(\"abc\");if(r[5]=\"de\",\"5\"===Object.getOwnPropertyNames(r)[0])return!1;for(var t={},e=0;e<10;e++)t[\"_\"+String.fromCharCode(e)]=e;if(\"0123456789\"!==Object.getOwnPropertyNames(t).map(function(r){return t[r]}).join(\"\"))return!1;var n={};return\"abcdefghijklmnopqrst\".split(\"\").forEach(function(r){n[r]=r}),\"abcdefghijklmnopqrst\"===Object.keys(Object.assign({},n)).join(\"\")}catch(o){return!1}}module.exports=o()?Object.assign:function(o,c){for(var a,i,s=n(o),f=1;f<arguments.length;f++){for(var u in a=Object(arguments[f]))t.call(a,u)&&(s[u]=a[u]);if(r){i=r(a);for(var b=0;b<i.length;b++)e.call(a,i[b])&&(s[i[b]]=a[i[b]])}}return s};\n},{}],\"awqi\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"n8MK\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"awqi\"}],\"IvPb\":[function(require,module,exports) {\n\"use strict\";var e,n,t,r,o;if(\"undefined\"==typeof window||\"function\"!=typeof MessageChannel){var a=null,l=null,i=function(){if(null!==a)try{var e=exports.unstable_now();a(!0,e),a=null}catch(n){throw setTimeout(i,0),n}},u=Date.now();exports.unstable_now=function(){return Date.now()-u},e=function(n){null!==a?setTimeout(e,0,n):(a=n,setTimeout(i,0))},n=function(e,n){l=setTimeout(e,n)},t=function(){clearTimeout(l)},r=function(){return!1},o=exports.unstable_forceFrameRate=function(){}}else{var s=window.performance,c=window.Date,f=window.setTimeout,p=window.clearTimeout;if(\"undefined\"!=typeof console){var b=window.cancelAnimationFrame;\"function\"!=typeof window.requestAnimationFrame&&console.error(\"This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\"),\"function\"!=typeof b&&console.error(\"This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\")}if(\"object\"==typeof s&&\"function\"==typeof s.now)exports.unstable_now=function(){return s.now()};else{var d=c.now();exports.unstable_now=function(){return c.now()-d}}var v=!1,x=null,w=-1,m=5,y=0;r=function(){return exports.unstable_now()>=y},o=function(){},exports.unstable_forceFrameRate=function(e){0>e||125<e?console.error(\"forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported\"):m=0<e?Math.floor(1e3/e):5};var _=new MessageChannel,h=_.port2;_.port1.onmessage=function(){if(null!==x){var e=exports.unstable_now();y=e+m;try{x(!0,e)?h.postMessage(null):(v=!1,x=null)}catch(n){throw h.postMessage(null),n}}else v=!1},e=function(e){x=e,v||(v=!0,h.postMessage(null))},n=function(e,n){w=f(function(){e(exports.unstable_now())},n)},t=function(){p(w),w=-1}}function k(e,n){var t=e.length;e.push(n);e:for(;;){var r=t-1>>>1,o=e[r];if(!(void 0!==o&&0<P(o,n)))break e;e[r]=n,e[t]=o,t=r}}function T(e){return void 0===(e=e[0])?null:e}function g(e){var n=e[0];if(void 0!==n){var t=e.pop();if(t!==n){e[0]=t;e:for(var r=0,o=e.length;r<o;){var a=2*(r+1)-1,l=e[a],i=a+1,u=e[i];if(void 0!==l&&0>P(l,t))void 0!==u&&0>P(u,l)?(e[r]=u,e[i]=t,r=i):(e[r]=l,e[a]=t,r=a);else{if(!(void 0!==u&&0>P(u,t)))break e;e[r]=u,e[i]=t,r=i}}}return n}return null}function P(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}var F=[],I=[],M=1,C=null,A=3,L=!1,q=!1,D=!1;function R(e){for(var n=T(I);null!==n;){if(null===n.callback)g(I);else{if(!(n.startTime<=e))break;g(I),n.sortIndex=n.expirationTime,k(F,n)}n=T(I)}}function j(t){if(D=!1,R(t),!q)if(null!==T(F))q=!0,e(E);else{var r=T(I);null!==r&&n(j,r.startTime-t)}}function E(e,o){q=!1,D&&(D=!1,t()),L=!0;var a=A;try{for(R(o),C=T(F);null!==C&&(!(C.expirationTime>o)||e&&!r());){var l=C.callback;if(null!==l){C.callback=null,A=C.priorityLevel;var i=l(C.expirationTime<=o);o=exports.unstable_now(),\"function\"==typeof i?C.callback=i:C===T(F)&&g(F),R(o)}else g(F);C=T(F)}if(null!==C)var u=!0;else{var s=T(I);null!==s&&n(j,s.startTime-o),u=!1}return u}finally{C=null,A=a,L=!1}}function N(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var B=o;exports.unstable_IdlePriority=5,exports.unstable_ImmediatePriority=1,exports.unstable_LowPriority=4,exports.unstable_NormalPriority=3,exports.unstable_Profiling=null,exports.unstable_UserBlockingPriority=2,exports.unstable_cancelCallback=function(e){e.callback=null},exports.unstable_continueExecution=function(){q||L||(q=!0,e(E))},exports.unstable_getCurrentPriorityLevel=function(){return A},exports.unstable_getFirstCallbackNode=function(){return T(F)},exports.unstable_next=function(e){switch(A){case 1:case 2:case 3:var n=3;break;default:n=A}var t=A;A=n;try{return e()}finally{A=t}},exports.unstable_pauseExecution=function(){},exports.unstable_requestPaint=B,exports.unstable_runWithPriority=function(e,n){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var t=A;A=e;try{return n()}finally{A=t}},exports.unstable_scheduleCallback=function(r,o,a){var l=exports.unstable_now();if(\"object\"==typeof a&&null!==a){var i=a.delay;i=\"number\"==typeof i&&0<i?l+i:l,a=\"number\"==typeof a.timeout?a.timeout:N(r)}else a=N(r),i=l;return r={id:M++,callback:o,priorityLevel:r,startTime:i,expirationTime:a=i+a,sortIndex:-1},i>l?(r.sortIndex=i,k(I,r),null===T(F)&&r===T(I)&&(D?t():D=!0,n(j,i-l))):(r.sortIndex=a,k(F,r),q||L||(q=!0,e(E))),r},exports.unstable_shouldYield=function(){var e=exports.unstable_now();R(e);var n=T(F);return n!==C&&null!==C&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTime<C.expirationTime||r()},exports.unstable_wrapCallback=function(e){var n=A;return function(){var t=A;A=n;try{return e.apply(this,arguments)}finally{A=t}}};\n},{}],\"MDSO\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/scheduler.production.min.js\");\n},{\"./cjs/scheduler.production.min.js\":\"IvPb\"}],\"i17t\":[function(require,module,exports) {\n\"use strict\";var e=require(\"react\"),t=require(\"object-assign\"),n=require(\"scheduler\");function r(e){for(var t=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,n=1;n<arguments.length;n++)t+=\"&args[]=\"+encodeURIComponent(arguments[n]);return\"Minified React error #\"+e+\"; visit \"+t+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}if(!e)throw Error(r(227));function l(e,t,n,r,l,i,a,o,u){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(s){this.onError(s)}}var i=!1,a=null,o=!1,u=null,c={onError:function(e){i=!0,a=e}};function s(e,t,n,r,o,u,s,f,d){i=!1,a=null,l.apply(c,arguments)}function f(e,t,n,l,c,f,d,p,m){if(s.apply(this,arguments),i){if(!i)throw Error(r(198));var h=a;i=!1,a=null,o||(o=!0,u=h)}}var d=null,p=null,m=null;function h(e,t,n){var r=e.type||\"unknown-event\";e.currentTarget=m(n),f(r,t,void 0,e),e.currentTarget=null}var g=null,v={};function y(){if(g)for(var e in v){var t=v[e],n=g.indexOf(e);if(!(-1<n))throw Error(r(96,e));if(!w[n]){if(!t.extractEvents)throw Error(r(97,e));for(var l in w[n]=t,n=t.eventTypes){var i=void 0,a=n[l],o=t,u=l;if(k.hasOwnProperty(u))throw Error(r(99,u));k[u]=a;var c=a.phasedRegistrationNames;if(c){for(i in c)c.hasOwnProperty(i)&&b(c[i],o,u);i=!0}else a.registrationName?(b(a.registrationName,o,u),i=!0):i=!1;if(!i)throw Error(r(98,l,e))}}}}function b(e,t,n){if(x[e])throw Error(r(100,e));x[e]=t,T[e]=t.eventTypes[n].dependencies}var w=[],k={},x={},T={};function E(e){var t,n=!1;for(t in e)if(e.hasOwnProperty(t)){var l=e[t];if(!v.hasOwnProperty(t)||v[t]!==l){if(v[t])throw Error(r(102,t));v[t]=l,n=!0}}n&&y()}var S=!(\"undefined\"==typeof window||void 0===window.document||void 0===window.document.createElement),C=null,P=null,_=null;function N(e){if(e=p(e)){if(\"function\"!=typeof C)throw Error(r(280));var t=e.stateNode;t&&(t=d(t),C(e.stateNode,e.type,t))}}function z(e){P?_?_.push(e):_=[e]:P=e}function M(){if(P){var e=P,t=_;if(_=P=null,N(e),t)for(e=0;e<t.length;e++)N(t[e])}}function I(e,t){return e(t)}function F(e,t,n,r,l){return e(t,n,r,l)}function O(){}var R=I,D=!1,L=!1;function U(){null===P&&null===_||(O(),M())}function A(e,t,n){if(L)return e(t,n);L=!0;try{return R(e,t,n)}finally{L=!1,U()}}var V=/^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$/,Q=Object.prototype.hasOwnProperty,W={},H={};function j(e){return!!Q.call(H,e)||!Q.call(W,e)&&(V.test(e)?H[e]=!0:(W[e]=!0,!1))}function B(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case\"function\":case\"symbol\":return!0;case\"boolean\":return!r&&(null!==n?!n.acceptsBooleans:\"data-\"!==(e=e.toLowerCase().slice(0,5))&&\"aria-\"!==e);default:return!1}}function K(e,t,n,r){if(null==t||B(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function $(e,t,n,r,l,i){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i}var q={};\"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style\".split(\" \").forEach(function(e){q[e]=new $(e,0,!1,e,null,!1)}),[[\"acceptCharset\",\"accept-charset\"],[\"className\",\"class\"],[\"htmlFor\",\"for\"],[\"httpEquiv\",\"http-equiv\"]].forEach(function(e){var t=e[0];q[t]=new $(t,1,!1,e[1],null,!1)}),[\"contentEditable\",\"draggable\",\"spellCheck\",\"value\"].forEach(function(e){q[e]=new $(e,2,!1,e.toLowerCase(),null,!1)}),[\"autoReverse\",\"externalResourcesRequired\",\"focusable\",\"preserveAlpha\"].forEach(function(e){q[e]=new $(e,2,!1,e,null,!1)}),\"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope\".split(\" \").forEach(function(e){q[e]=new $(e,3,!1,e.toLowerCase(),null,!1)}),[\"checked\",\"multiple\",\"muted\",\"selected\"].forEach(function(e){q[e]=new $(e,3,!0,e,null,!1)}),[\"capture\",\"download\"].forEach(function(e){q[e]=new $(e,4,!1,e,null,!1)}),[\"cols\",\"rows\",\"size\",\"span\"].forEach(function(e){q[e]=new $(e,6,!1,e,null,!1)}),[\"rowSpan\",\"start\"].forEach(function(e){q[e]=new $(e,5,!1,e.toLowerCase(),null,!1)});var Y=/[\\-:]([a-z])/g;function X(e){return e[1].toUpperCase()}\"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,null,!1)}),\"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type\".split(\" \").forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/1999/xlink\",!1)}),[\"xml:base\",\"xml:lang\",\"xml:space\"].forEach(function(e){var t=e.replace(Y,X);q[t]=new $(t,1,!1,e,\"http://www.w3.org/XML/1998/namespace\",!1)}),[\"tabIndex\",\"crossOrigin\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!1)}),q.xlinkHref=new $(\"xlinkHref\",1,!1,\"xlink:href\",\"http://www.w3.org/1999/xlink\",!0),[\"src\",\"href\",\"action\",\"formAction\"].forEach(function(e){q[e]=new $(e,1,!1,e.toLowerCase(),null,!0)});var G=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function Z(e,t,n,r){var l=q.hasOwnProperty(t)?q[t]:null;(null!==l?0===l.type:!r&&(2<t.length&&(\"o\"===t[0]||\"O\"===t[0])&&(\"n\"===t[1]||\"N\"===t[1])))||(K(t,n,l,r)&&(n=null),r||null===l?j(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,\"\"+n)):l.mustUseProperty?e[l.propertyName]=null===n?3!==l.type&&\"\":n:(t=l.attributeName,r=l.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(l=l.type)||4===l&&!0===n?\"\":\"\"+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}G.hasOwnProperty(\"ReactCurrentDispatcher\")||(G.ReactCurrentDispatcher={current:null}),G.hasOwnProperty(\"ReactCurrentBatchConfig\")||(G.ReactCurrentBatchConfig={suspense:null});var J=/^(.*)[\\\\\\/]/,ee=\"function\"==typeof Symbol&&Symbol.for,te=ee?Symbol.for(\"react.element\"):60103,ne=ee?Symbol.for(\"react.portal\"):60106,re=ee?Symbol.for(\"react.fragment\"):60107,le=ee?Symbol.for(\"react.strict_mode\"):60108,ie=ee?Symbol.for(\"react.profiler\"):60114,ae=ee?Symbol.for(\"react.provider\"):60109,oe=ee?Symbol.for(\"react.context\"):60110,ue=ee?Symbol.for(\"react.concurrent_mode\"):60111,ce=ee?Symbol.for(\"react.forward_ref\"):60112,se=ee?Symbol.for(\"react.suspense\"):60113,fe=ee?Symbol.for(\"react.suspense_list\"):60120,de=ee?Symbol.for(\"react.memo\"):60115,pe=ee?Symbol.for(\"react.lazy\"):60116,me=ee?Symbol.for(\"react.block\"):60121,he=\"function\"==typeof Symbol&&Symbol.iterator;function ge(e){return null===e||\"object\"!=typeof e?null:\"function\"==typeof(e=he&&e[he]||e[\"@@iterator\"])?e:null}function ve(e){if(-1===e._status){e._status=0;var t=e._ctor;t=t(),e._result=t,t.then(function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)},function(t){0===e._status&&(e._status=2,e._result=t)})}}function ye(e){if(null==e)return null;if(\"function\"==typeof e)return e.displayName||e.name||null;if(\"string\"==typeof e)return e;switch(e){case re:return\"Fragment\";case ne:return\"Portal\";case ie:return\"Profiler\";case le:return\"StrictMode\";case se:return\"Suspense\";case fe:return\"SuspenseList\"}if(\"object\"==typeof e)switch(e.$$typeof){case oe:return\"Context.Consumer\";case ae:return\"Context.Provider\";case ce:var t=e.render;return t=t.displayName||t.name||\"\",e.displayName||(\"\"!==t?\"ForwardRef(\"+t+\")\":\"ForwardRef\");case de:return ye(e.type);case me:return ye(e.render);case pe:if(e=1===e._status?e._result:null)return ye(e)}return null}function be(e){var t=\"\";do{e:switch(e.tag){case 3:case 4:case 6:case 7:case 10:case 9:var n=\"\";break e;default:var r=e._debugOwner,l=e._debugSource,i=ye(e.type);n=null,r&&(n=ye(r.type)),r=i,i=\"\",l?i=\" (at \"+l.fileName.replace(J,\"\")+\":\"+l.lineNumber+\")\":n&&(i=\" (created by \"+n+\")\"),n=\"\\n    in \"+(r||\"Unknown\")+i}t+=n,e=e.return}while(e);return t}function we(e){switch(typeof e){case\"boolean\":case\"number\":case\"object\":case\"string\":case\"undefined\":return e;default:return\"\"}}function ke(e){var t=e.type;return(e=e.nodeName)&&\"input\"===e.toLowerCase()&&(\"checkbox\"===t||\"radio\"===t)}function xe(e){var t=ke(e)?\"checked\":\"value\",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=\"\"+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&\"function\"==typeof n.get&&\"function\"==typeof n.set){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(e){r=\"\"+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=\"\"+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Te(e){e._valueTracker||(e._valueTracker=xe(e))}function Ee(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=\"\";return e&&(r=ke(e)?e.checked?\"true\":\"false\":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Se(e,n){var r=n.checked;return t({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:e._wrapperState.initialChecked})}function Ce(e,t){var n=null==t.defaultValue?\"\":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=we(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:\"checkbox\"===t.type||\"radio\"===t.type?null!=t.checked:null!=t.value}}function Pe(e,t){null!=(t=t.checked)&&Z(e,\"checked\",t,!1)}function _e(e,t){Pe(e,t);var n=we(t.value),r=t.type;if(null!=n)\"number\"===r?(0===n&&\"\"===e.value||e.value!=n)&&(e.value=\"\"+n):e.value!==\"\"+n&&(e.value=\"\"+n);else if(\"submit\"===r||\"reset\"===r)return void e.removeAttribute(\"value\");t.hasOwnProperty(\"value\")?ze(e,t.type,n):t.hasOwnProperty(\"defaultValue\")&&ze(e,t.type,we(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Ne(e,t,n){if(t.hasOwnProperty(\"value\")||t.hasOwnProperty(\"defaultValue\")){var r=t.type;if(!(\"submit\"!==r&&\"reset\"!==r||void 0!==t.value&&null!==t.value))return;t=\"\"+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}\"\"!==(n=e.name)&&(e.name=\"\"),e.defaultChecked=!!e._wrapperState.initialChecked,\"\"!==n&&(e.name=n)}function ze(e,t,n){\"number\"===t&&e.ownerDocument.activeElement===e||(null==n?e.defaultValue=\"\"+e._wrapperState.initialValue:e.defaultValue!==\"\"+n&&(e.defaultValue=\"\"+n))}function Me(t){var n=\"\";return e.Children.forEach(t,function(e){null!=e&&(n+=e)}),n}function Ie(e,n){return e=t({children:void 0},n),(n=Me(n.children))&&(e.children=n),e}function Fe(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t[\"$\"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty(\"$\"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=\"\"+we(n),t=null,l=0;l<e.length;l++){if(e[l].value===n)return e[l].selected=!0,void(r&&(e[l].defaultSelected=!0));null!==t||e[l].disabled||(t=e[l])}null!==t&&(t.selected=!0)}}function Oe(e,n){if(null!=n.dangerouslySetInnerHTML)throw Error(r(91));return t({},n,{value:void 0,defaultValue:void 0,children:\"\"+e._wrapperState.initialValue})}function Re(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(r(92));if(Array.isArray(n)){if(!(1>=n.length))throw Error(r(93));n=n[0]}t=n}null==t&&(t=\"\"),n=t}e._wrapperState={initialValue:we(n)}}function De(e,t){var n=we(t.value),r=we(t.defaultValue);null!=n&&((n=\"\"+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=\"\"+r)}function Le(e){var t=e.textContent;t===e._wrapperState.initialValue&&\"\"!==t&&null!==t&&(e.value=t)}var Ue={html:\"http://www.w3.org/1999/xhtml\",mathml:\"http://www.w3.org/1998/Math/MathML\",svg:\"http://www.w3.org/2000/svg\"};function Ae(e){switch(e){case\"svg\":return\"http://www.w3.org/2000/svg\";case\"math\":return\"http://www.w3.org/1998/Math/MathML\";default:return\"http://www.w3.org/1999/xhtml\"}}function Ve(e,t){return null==e||\"http://www.w3.org/1999/xhtml\"===e?Ae(t):\"http://www.w3.org/2000/svg\"===e&&\"foreignObject\"===t?\"http://www.w3.org/1999/xhtml\":e}var Qe,We=function(e){return\"undefined\"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(t,n,r,l){MSApp.execUnsafeLocalFunction(function(){return e(t,n)})}:e}(function(e,t){if(e.namespaceURI!==Ue.svg||\"innerHTML\"in e)e.innerHTML=t;else{for((Qe=Qe||document.createElement(\"div\")).innerHTML=\"<svg>\"+t.valueOf().toString()+\"</svg>\",t=Qe.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function He(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}function je(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[\"Webkit\"+e]=\"webkit\"+t,n[\"Moz\"+e]=\"moz\"+t,n}var Be={animationend:je(\"Animation\",\"AnimationEnd\"),animationiteration:je(\"Animation\",\"AnimationIteration\"),animationstart:je(\"Animation\",\"AnimationStart\"),transitionend:je(\"Transition\",\"TransitionEnd\")},Ke={},$e={};function qe(e){if(Ke[e])return Ke[e];if(!Be[e])return e;var t,n=Be[e];for(t in n)if(n.hasOwnProperty(t)&&t in $e)return Ke[e]=n[t];return e}S&&($e=document.createElement(\"div\").style,\"AnimationEvent\"in window||(delete Be.animationend.animation,delete Be.animationiteration.animation,delete Be.animationstart.animation),\"TransitionEvent\"in window||delete Be.transitionend.transition);var Ye=qe(\"animationend\"),Xe=qe(\"animationiteration\"),Ge=qe(\"animationstart\"),Ze=qe(\"transitionend\"),Je=\"abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting\".split(\" \"),et=new(\"function\"==typeof WeakMap?WeakMap:Map);function tt(e){var t=et.get(e);return void 0===t&&(t=new Map,et.set(e,t)),t}function nt(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!=(1026&(t=e).effectTag)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function rt(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function lt(e){if(nt(e)!==e)throw Error(r(188))}function it(e){var t=e.alternate;if(!t){if(null===(t=nt(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,l=t;;){var i=n.return;if(null===i)break;var a=i.alternate;if(null===a){if(null!==(l=i.return)){n=l;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return lt(i),e;if(a===l)return lt(i),t;a=a.sibling}throw Error(r(188))}if(n.return!==l.return)n=i,l=a;else{for(var o=!1,u=i.child;u;){if(u===n){o=!0,n=i,l=a;break}if(u===l){o=!0,l=i,n=a;break}u=u.sibling}if(!o){for(u=a.child;u;){if(u===n){o=!0,n=a,l=i;break}if(u===l){o=!0,l=a,n=i;break}u=u.sibling}if(!o)throw Error(r(189))}}if(n.alternate!==l)throw Error(r(190))}if(3!==n.tag)throw Error(r(188));return n.stateNode.current===n?e:t}function at(e){if(!(e=it(e)))return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function ot(e,t){if(null==t)throw Error(r(30));return null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function ut(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}var ct=null;function st(e){if(e){var t=e._dispatchListeners,n=e._dispatchInstances;if(Array.isArray(t))for(var r=0;r<t.length&&!e.isPropagationStopped();r++)h(e,t[r],n[r]);else t&&h(e,t,n);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function ft(e){if(null!==e&&(ct=ot(ct,e)),e=ct,ct=null,e){if(ut(e,st),ct)throw Error(r(95));if(o)throw e=u,o=!1,u=null,e}}function dt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}function pt(e){if(!S)return!1;var t=(e=\"on\"+e)in document;return t||((t=document.createElement(\"div\")).setAttribute(e,\"return;\"),t=\"function\"==typeof t[e]),t}var mt=[];function ht(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>mt.length&&mt.push(e)}function gt(e,t,n,r){if(mt.length){var l=mt.pop();return l.topLevelType=e,l.eventSystemFlags=r,l.nativeEvent=t,l.targetInst=n,l}return{topLevelType:e,eventSystemFlags:r,nativeEvent:t,targetInst:n,ancestors:[]}}function vt(e){var t=e.targetInst,n=t;do{if(!n){e.ancestors.push(n);break}var r=n;if(3===r.tag)r=r.stateNode.containerInfo;else{for(;r.return;)r=r.return;r=3!==r.tag?null:r.stateNode.containerInfo}if(!r)break;5!==(t=n.tag)&&6!==t||e.ancestors.push(n),n=Un(r)}while(n);for(n=0;n<e.ancestors.length;n++){t=e.ancestors[n];var l=dt(e.nativeEvent);r=e.topLevelType;var i=e.nativeEvent,a=e.eventSystemFlags;0===n&&(a|=64);for(var o=null,u=0;u<w.length;u++){var c=w[u];c&&(c=c.extractEvents(r,t,i,l,a))&&(o=ot(o,c))}ft(o)}}function yt(e,t,n){if(!n.has(e)){switch(e){case\"scroll\":en(t,\"scroll\",!0);break;case\"focus\":case\"blur\":en(t,\"focus\",!0),en(t,\"blur\",!0),n.set(\"blur\",null),n.set(\"focus\",null);break;case\"cancel\":case\"close\":pt(e)&&en(t,e,!0);break;case\"invalid\":case\"submit\":case\"reset\":break;default:-1===Je.indexOf(e)&&Jt(e,t)}n.set(e,null)}}var bt,wt,kt,xt=!1,Tt=[],Et=null,St=null,Ct=null,Pt=new Map,_t=new Map,Nt=[],zt=\"mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput close cancel copy cut paste click change contextmenu reset submit\".split(\" \"),Mt=\"focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture\".split(\" \");function It(e,t){var n=tt(t);zt.forEach(function(e){yt(e,t,n)}),Mt.forEach(function(e){yt(e,t,n)})}function Ft(e,t,n,r,l){return{blockedOn:e,topLevelType:t,eventSystemFlags:32|n,nativeEvent:l,container:r}}function Ot(e,t){switch(e){case\"focus\":case\"blur\":Et=null;break;case\"dragenter\":case\"dragleave\":St=null;break;case\"mouseover\":case\"mouseout\":Ct=null;break;case\"pointerover\":case\"pointerout\":Pt.delete(t.pointerId);break;case\"gotpointercapture\":case\"lostpointercapture\":_t.delete(t.pointerId)}}function Rt(e,t,n,r,l,i){return null===e||e.nativeEvent!==i?(e=Ft(t,n,r,l,i),null!==t&&(null!==(t=An(t))&&wt(t)),e):(e.eventSystemFlags|=r,e)}function Dt(e,t,n,r,l){switch(t){case\"focus\":return Et=Rt(Et,e,t,n,r,l),!0;case\"dragenter\":return St=Rt(St,e,t,n,r,l),!0;case\"mouseover\":return Ct=Rt(Ct,e,t,n,r,l),!0;case\"pointerover\":var i=l.pointerId;return Pt.set(i,Rt(Pt.get(i)||null,e,t,n,r,l)),!0;case\"gotpointercapture\":return i=l.pointerId,_t.set(i,Rt(_t.get(i)||null,e,t,n,r,l)),!0}return!1}function Lt(e){var t=Un(e.target);if(null!==t){var r=nt(t);if(null!==r)if(13===(t=r.tag)){if(null!==(t=rt(r)))return e.blockedOn=t,void n.unstable_runWithPriority(e.priority,function(){kt(r)})}else if(3===t&&r.stateNode.hydrate)return void(e.blockedOn=3===r.tag?r.stateNode.containerInfo:null)}e.blockedOn=null}function Ut(e){if(null!==e.blockedOn)return!1;var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(null!==t){var n=An(t);return null!==n&&wt(n),e.blockedOn=t,!1}return!0}function At(e,t,n){Ut(e)&&n.delete(t)}function Vt(){for(xt=!1;0<Tt.length;){var e=Tt[0];if(null!==e.blockedOn){null!==(e=An(e.blockedOn))&&bt(e);break}var t=ln(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);null!==t?e.blockedOn=t:Tt.shift()}null!==Et&&Ut(Et)&&(Et=null),null!==St&&Ut(St)&&(St=null),null!==Ct&&Ut(Ct)&&(Ct=null),Pt.forEach(At),_t.forEach(At)}function Qt(e,t){e.blockedOn===t&&(e.blockedOn=null,xt||(xt=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Vt)))}function Wt(e){function t(t){return Qt(t,e)}if(0<Tt.length){Qt(Tt[0],e);for(var n=1;n<Tt.length;n++){var r=Tt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Et&&Qt(Et,e),null!==St&&Qt(St,e),null!==Ct&&Qt(Ct,e),Pt.forEach(t),_t.forEach(t),n=0;n<Nt.length;n++)(r=Nt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Nt.length&&null===(n=Nt[0]).blockedOn;)Lt(n),null===n.blockedOn&&Nt.shift()}var Ht={},jt=new Map,Bt=new Map,Kt=[\"abort\",\"abort\",Ye,\"animationEnd\",Xe,\"animationIteration\",Ge,\"animationStart\",\"canplay\",\"canPlay\",\"canplaythrough\",\"canPlayThrough\",\"durationchange\",\"durationChange\",\"emptied\",\"emptied\",\"encrypted\",\"encrypted\",\"ended\",\"ended\",\"error\",\"error\",\"gotpointercapture\",\"gotPointerCapture\",\"load\",\"load\",\"loadeddata\",\"loadedData\",\"loadedmetadata\",\"loadedMetadata\",\"loadstart\",\"loadStart\",\"lostpointercapture\",\"lostPointerCapture\",\"playing\",\"playing\",\"progress\",\"progress\",\"seeking\",\"seeking\",\"stalled\",\"stalled\",\"suspend\",\"suspend\",\"timeupdate\",\"timeUpdate\",Ze,\"transitionEnd\",\"waiting\",\"waiting\"];function $t(e,t){for(var n=0;n<e.length;n+=2){var r=e[n],l=e[n+1],i=\"on\"+(l[0].toUpperCase()+l.slice(1));i={phasedRegistrationNames:{bubbled:i,captured:i+\"Capture\"},dependencies:[r],eventPriority:t},Bt.set(r,t),jt.set(r,i),Ht[l]=i}}$t(\"blur blur cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focus focus input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange\".split(\" \"),0),$t(\"drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel\".split(\" \"),1),$t(Kt,2);for(var qt=\"change selectionchange textInput compositionstart compositionend compositionupdate\".split(\" \"),Yt=0;Yt<qt.length;Yt++)Bt.set(qt[Yt],0);var Xt=n.unstable_UserBlockingPriority,Gt=n.unstable_runWithPriority,Zt=!0;function Jt(e,t){en(t,e,!1)}function en(e,t,n){var r=Bt.get(t);switch(void 0===r?2:r){case 0:r=tn.bind(null,t,1,e);break;case 1:r=nn.bind(null,t,1,e);break;default:r=rn.bind(null,t,1,e)}n?e.addEventListener(t,r,!0):e.addEventListener(t,r,!1)}function tn(e,t,n,r){D||O();var l=rn,i=D;D=!0;try{F(l,e,t,n,r)}finally{(D=i)||U()}}function nn(e,t,n,r){Gt(Xt,rn.bind(null,e,t,n,r))}function rn(e,t,n,r){if(Zt)if(0<Tt.length&&-1<zt.indexOf(e))e=Ft(null,e,t,n,r),Tt.push(e);else{var l=ln(e,t,n,r);if(null===l)Ot(e,r);else if(-1<zt.indexOf(e))e=Ft(l,e,t,n,r),Tt.push(e);else if(!Dt(l,e,t,n,r)){Ot(e,r),e=gt(e,r,null,t);try{A(vt,e)}finally{ht(e)}}}}function ln(e,t,n,r){if(null!==(n=Un(n=dt(r)))){var l=nt(n);if(null===l)n=null;else{var i=l.tag;if(13===i){if(null!==(n=rt(l)))return n;n=null}else if(3===i){if(l.stateNode.hydrate)return 3===l.tag?l.stateNode.containerInfo:null;n=null}else l!==n&&(n=null)}}e=gt(e,r,n,t);try{A(vt,e)}finally{ht(e)}return null}var an={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},on=[\"Webkit\",\"ms\",\"Moz\",\"O\"];function un(e,t,n){return null==t||\"boolean\"==typeof t||\"\"===t?\"\":n||\"number\"!=typeof t||0===t||an.hasOwnProperty(e)&&an[e]?(\"\"+t).trim():t+\"px\"}function cn(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf(\"--\"),l=un(n,t[n],r);\"float\"===n&&(n=\"cssFloat\"),r?e.setProperty(n,l):e[n]=l}}Object.keys(an).forEach(function(e){on.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),an[t]=an[e]})});var sn=t({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fn(e,t){if(t){if(sn[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(r(137,e,\"\"));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(r(60));if(!(\"object\"==typeof t.dangerouslySetInnerHTML&&\"__html\"in t.dangerouslySetInnerHTML))throw Error(r(61))}if(null!=t.style&&\"object\"!=typeof t.style)throw Error(r(62,\"\"))}}function dn(e,t){if(-1===e.indexOf(\"-\"))return\"string\"==typeof t.is;switch(e){case\"annotation-xml\":case\"color-profile\":case\"font-face\":case\"font-face-src\":case\"font-face-uri\":case\"font-face-format\":case\"font-face-name\":case\"missing-glyph\":return!1;default:return!0}}var pn=Ue.html;function mn(e,t){var n=tt(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=T[t];for(var r=0;r<t.length;r++)yt(t[r],e,n)}function hn(){}function gn(e){if(void 0===(e=e||(\"undefined\"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function vn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yn(e,t){var n,r=vn(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=vn(r)}}function bn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?bn(e,t.parentNode):\"contains\"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function wn(){for(var e=window,t=gn();t instanceof e.HTMLIFrameElement;){try{var n=\"string\"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=gn((e=t.contentWindow).document)}return t}function kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(\"input\"===t&&(\"text\"===e.type||\"search\"===e.type||\"tel\"===e.type||\"url\"===e.type||\"password\"===e.type)||\"textarea\"===t||\"true\"===e.contentEditable)}var xn=\"$\",Tn=\"/$\",En=\"$?\",Sn=\"$!\",Cn=null,Pn=null;function _n(e,t){switch(e){case\"button\":case\"input\":case\"select\":case\"textarea\":return!!t.autoFocus}return!1}function Nn(e,t){return\"textarea\"===e||\"option\"===e||\"noscript\"===e||\"string\"==typeof t.children||\"number\"==typeof t.children||\"object\"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var zn=\"function\"==typeof setTimeout?setTimeout:void 0,Mn=\"function\"==typeof clearTimeout?clearTimeout:void 0;function In(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break}return e}function Fn(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if(n===xn||n===Sn||n===En){if(0===t)return e;t--}else n===Tn&&t++}e=e.previousSibling}return null}var On=Math.random().toString(36).slice(2),Rn=\"__reactInternalInstance$\"+On,Dn=\"__reactEventHandlers$\"+On,Ln=\"__reactContainere$\"+On;function Un(e){var t=e[Rn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ln]||n[Rn]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fn(e);null!==e;){if(n=e[Rn])return n;e=Fn(e)}return t}n=(e=n).parentNode}return null}function An(e){return!(e=e[Rn]||e[Ln])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Vn(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(r(33))}function Qn(e){return e[Dn]||null}function Wn(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function Hn(e,t){var n=e.stateNode;if(!n)return null;var l=d(n);if(!l)return null;n=l[t];e:switch(t){case\"onClick\":case\"onClickCapture\":case\"onDoubleClick\":case\"onDoubleClickCapture\":case\"onMouseDown\":case\"onMouseDownCapture\":case\"onMouseMove\":case\"onMouseMoveCapture\":case\"onMouseUp\":case\"onMouseUpCapture\":case\"onMouseEnter\":(l=!l.disabled)||(l=!(\"button\"===(e=e.type)||\"input\"===e||\"select\"===e||\"textarea\"===e)),e=!l;break e;default:e=!1}if(e)return null;if(n&&\"function\"!=typeof n)throw Error(r(231,t,typeof n));return n}function jn(e,t,n){(t=Hn(e,n.dispatchConfig.phasedRegistrationNames[t]))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function Bn(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,n=[];t;)n.push(t),t=Wn(t);for(t=n.length;0<t--;)jn(n[t],\"captured\",e);for(t=0;t<n.length;t++)jn(n[t],\"bubbled\",e)}}function Kn(e,t,n){e&&n&&n.dispatchConfig.registrationName&&(t=Hn(e,n.dispatchConfig.registrationName))&&(n._dispatchListeners=ot(n._dispatchListeners,t),n._dispatchInstances=ot(n._dispatchInstances,e))}function $n(e){e&&e.dispatchConfig.registrationName&&Kn(e._targetInst,null,e)}function qn(e){ut(e,Bn)}var Yn=null,Xn=null,Gn=null;function Zn(){if(Gn)return Gn;var e,t,n=Xn,r=n.length,l=\"value\"in Yn?Yn.value:Yn.textContent,i=l.length;for(e=0;e<r&&n[e]===l[e];e++);var a=r-e;for(t=1;t<=a&&n[r-t]===l[i-t];t++);return Gn=l.slice(e,1<t?1-t:void 0)}function Jn(){return!0}function er(){return!1}function tr(e,t,n,r){for(var l in this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=n,e=this.constructor.Interface)e.hasOwnProperty(l)&&((t=e[l])?this[l]=t(n):\"target\"===l?this.target=r:this[l]=n[l]);return this.isDefaultPrevented=(null!=n.defaultPrevented?n.defaultPrevented:!1===n.returnValue)?Jn:er,this.isPropagationStopped=er,this}function nr(e,t,n,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,t,n,r),l}return new this(e,t,n,r)}function rr(e){if(!(e instanceof this))throw Error(r(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function lr(e){e.eventPool=[],e.getPooled=nr,e.release=rr}t(tr.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():\"unknown\"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Jn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():\"unknown\"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Jn)},persist:function(){this.isPersistent=Jn},isPersistent:er,destructor:function(){var e,t=this.constructor.Interface;for(e in t)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=er,this._dispatchInstances=this._dispatchListeners=null}}),tr.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},tr.extend=function(e){function n(){}function r(){return l.apply(this,arguments)}var l=this;n.prototype=l.prototype;var i=new n;return t(i,r.prototype),r.prototype=i,r.prototype.constructor=r,r.Interface=t({},l.Interface,e),r.extend=l.extend,lr(r),r},lr(tr);var ir=tr.extend({data:null}),ar=tr.extend({data:null}),or=[9,13,27,32],ur=S&&\"CompositionEvent\"in window,cr=null;S&&\"documentMode\"in document&&(cr=document.documentMode);var sr=S&&\"TextEvent\"in window&&!cr,fr=S&&(!ur||cr&&8<cr&&11>=cr),dr=String.fromCharCode(32),pr={beforeInput:{phasedRegistrationNames:{bubbled:\"onBeforeInput\",captured:\"onBeforeInputCapture\"},dependencies:[\"compositionend\",\"keypress\",\"textInput\",\"paste\"]},compositionEnd:{phasedRegistrationNames:{bubbled:\"onCompositionEnd\",captured:\"onCompositionEndCapture\"},dependencies:\"blur compositionend keydown keypress keyup mousedown\".split(\" \")},compositionStart:{phasedRegistrationNames:{bubbled:\"onCompositionStart\",captured:\"onCompositionStartCapture\"},dependencies:\"blur compositionstart keydown keypress keyup mousedown\".split(\" \")},compositionUpdate:{phasedRegistrationNames:{bubbled:\"onCompositionUpdate\",captured:\"onCompositionUpdateCapture\"},dependencies:\"blur compositionupdate keydown keypress keyup mousedown\".split(\" \")}},mr=!1;function hr(e,t){switch(e){case\"keyup\":return-1!==or.indexOf(t.keyCode);case\"keydown\":return 229!==t.keyCode;case\"keypress\":case\"mousedown\":case\"blur\":return!0;default:return!1}}function gr(e){return\"object\"==typeof(e=e.detail)&&\"data\"in e?e.data:null}var vr=!1;function yr(e,t){switch(e){case\"compositionend\":return gr(t);case\"keypress\":return 32!==t.which?null:(mr=!0,dr);case\"textInput\":return(e=t.data)===dr&&mr?null:e;default:return null}}function br(e,t){if(vr)return\"compositionend\"===e||!ur&&hr(e,t)?(e=Zn(),Gn=Xn=Yn=null,vr=!1,e):null;switch(e){case\"paste\":return null;case\"keypress\":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case\"compositionend\":return fr&&\"ko\"!==t.locale?null:t.data;default:return null}}var wr={eventTypes:pr,extractEvents:function(e,t,n,r){var l;if(ur)e:{switch(e){case\"compositionstart\":var i=pr.compositionStart;break e;case\"compositionend\":i=pr.compositionEnd;break e;case\"compositionupdate\":i=pr.compositionUpdate;break e}i=void 0}else vr?hr(e,n)&&(i=pr.compositionEnd):\"keydown\"===e&&229===n.keyCode&&(i=pr.compositionStart);return i?(fr&&\"ko\"!==n.locale&&(vr||i!==pr.compositionStart?i===pr.compositionEnd&&vr&&(l=Zn()):(Xn=\"value\"in(Yn=r)?Yn.value:Yn.textContent,vr=!0)),i=ir.getPooled(i,t,n,r),l?i.data=l:null!==(l=gr(n))&&(i.data=l),qn(i),l=i):l=null,(e=sr?yr(e,n):br(e,n))?((t=ar.getPooled(pr.beforeInput,t,n,r)).data=e,qn(t)):t=null,null===l?t:null===t?l:[l,t]}},kr={color:!0,date:!0,datetime:!0,\"datetime-local\":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return\"input\"===t?!!kr[e.type]:\"textarea\"===t}var Tr={change:{phasedRegistrationNames:{bubbled:\"onChange\",captured:\"onChangeCapture\"},dependencies:\"blur change click focus input keydown keyup selectionchange\".split(\" \")}};function Er(e,t,n){return(e=tr.getPooled(Tr.change,e,t,n)).type=\"change\",z(n),qn(e),e}var Sr=null,Cr=null;function Pr(e){ft(e)}function _r(e){if(Ee(Vn(e)))return e}function Nr(e,t){if(\"change\"===e)return t}var zr=!1;function Mr(){Sr&&(Sr.detachEvent(\"onpropertychange\",Ir),Cr=Sr=null)}function Ir(e){if(\"value\"===e.propertyName&&_r(Cr))if(e=Er(Cr,e,dt(e)),D)ft(e);else{D=!0;try{I(Pr,e)}finally{D=!1,U()}}}function Fr(e,t,n){\"focus\"===e?(Mr(),Cr=n,(Sr=t).attachEvent(\"onpropertychange\",Ir)):\"blur\"===e&&Mr()}function Or(e){if(\"selectionchange\"===e||\"keyup\"===e||\"keydown\"===e)return _r(Cr)}function Rr(e,t){if(\"click\"===e)return _r(t)}function Dr(e,t){if(\"input\"===e||\"change\"===e)return _r(t)}S&&(zr=pt(\"input\")&&(!document.documentMode||9<document.documentMode));var Lr={eventTypes:Tr,_isInputEventSupported:zr,extractEvents:function(e,t,n,r){var l=t?Vn(t):window,i=l.nodeName&&l.nodeName.toLowerCase();if(\"select\"===i||\"input\"===i&&\"file\"===l.type)var a=Nr;else if(xr(l))if(zr)a=Dr;else{a=Or;var o=Fr}else(i=l.nodeName)&&\"input\"===i.toLowerCase()&&(\"checkbox\"===l.type||\"radio\"===l.type)&&(a=Rr);if(a&&(a=a(e,t)))return Er(a,n,r);o&&o(e,l,t),\"blur\"===e&&(e=l._wrapperState)&&e.controlled&&\"number\"===l.type&&ze(l,\"number\",l.value)}},Ur=tr.extend({view:null,detail:null}),Ar={Alt:\"altKey\",Control:\"ctrlKey\",Meta:\"metaKey\",Shift:\"shiftKey\"};function Vr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function Qr(){return Vr}var Wr=0,Hr=0,jr=!1,Br=!1,Kr=Ur.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:Qr,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},movementX:function(e){if(\"movementX\"in e)return e.movementX;var t=Wr;return Wr=e.screenX,jr?\"mousemove\"===e.type?e.screenX-t:0:(jr=!0,0)},movementY:function(e){if(\"movementY\"in e)return e.movementY;var t=Hr;return Hr=e.screenY,Br?\"mousemove\"===e.type?e.screenY-t:0:(Br=!0,0)}}),$r=Kr.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),qr={mouseEnter:{registrationName:\"onMouseEnter\",dependencies:[\"mouseout\",\"mouseover\"]},mouseLeave:{registrationName:\"onMouseLeave\",dependencies:[\"mouseout\",\"mouseover\"]},pointerEnter:{registrationName:\"onPointerEnter\",dependencies:[\"pointerout\",\"pointerover\"]},pointerLeave:{registrationName:\"onPointerLeave\",dependencies:[\"pointerout\",\"pointerover\"]}},Yr={eventTypes:qr,extractEvents:function(e,t,n,r,l){var i=\"mouseover\"===e||\"pointerover\"===e,a=\"mouseout\"===e||\"pointerout\"===e;if(i&&0==(32&l)&&(n.relatedTarget||n.fromElement)||!a&&!i)return null;(i=r.window===r?r:(i=r.ownerDocument)?i.defaultView||i.parentWindow:window,a)?(a=t,null!==(t=(t=n.relatedTarget||n.toElement)?Un(t):null)&&(t!==nt(t)||5!==t.tag&&6!==t.tag)&&(t=null)):a=null;if(a===t)return null;if(\"mouseout\"===e||\"mouseover\"===e)var o=Kr,u=qr.mouseLeave,c=qr.mouseEnter,s=\"mouse\";else\"pointerout\"!==e&&\"pointerover\"!==e||(o=$r,u=qr.pointerLeave,c=qr.pointerEnter,s=\"pointer\");if(e=null==a?i:Vn(a),i=null==t?i:Vn(t),(u=o.getPooled(u,a,n,r)).type=s+\"leave\",u.target=e,u.relatedTarget=i,(n=o.getPooled(c,t,n,r)).type=s+\"enter\",n.target=i,n.relatedTarget=e,s=t,(r=a)&&s)e:{for(c=s,a=0,e=o=r;e;e=Wn(e))a++;for(e=0,t=c;t;t=Wn(t))e++;for(;0<a-e;)o=Wn(o),a--;for(;0<e-a;)c=Wn(c),e--;for(;a--;){if(o===c||o===c.alternate)break e;o=Wn(o),c=Wn(c)}o=null}else o=null;for(c=o,o=[];r&&r!==c&&(null===(a=r.alternate)||a!==c);)o.push(r),r=Wn(r);for(r=[];s&&s!==c&&(null===(a=s.alternate)||a!==c);)r.push(s),s=Wn(s);for(s=0;s<o.length;s++)Kn(o[s],\"bubbled\",u);for(s=r.length;0<s--;)Kn(r[s],\"captured\",n);return 0==(64&l)?[u]:[u,n]}};function Xr(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t}var Gr=\"function\"==typeof Object.is?Object.is:Xr,Zr=Object.prototype.hasOwnProperty;function Jr(e,t){if(Gr(e,t))return!0;if(\"object\"!=typeof e||null===e||\"object\"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++)if(!Zr.call(t,n[r])||!Gr(e[n[r]],t[n[r]]))return!1;return!0}var el=S&&\"documentMode\"in document&&11>=document.documentMode,tl={select:{phasedRegistrationNames:{bubbled:\"onSelect\",captured:\"onSelectCapture\"},dependencies:\"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange\".split(\" \")}},nl=null,rl=null,ll=null,il=!1;function al(e,t){var n=t.window===t?t.document:9===t.nodeType?t:t.ownerDocument;return il||null==nl||nl!==gn(n)?null:(\"selectionStart\"in(n=nl)&&kn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},ll&&Jr(ll,n)?null:(ll=n,(e=tr.getPooled(tl.select,rl,e,t)).type=\"select\",e.target=nl,qn(e),e))}var ol={eventTypes:tl,extractEvents:function(e,t,n,r,l,i){if(!(i=!(l=i||(r.window===r?r.document:9===r.nodeType?r:r.ownerDocument)))){e:{l=tt(l),i=T.onSelect;for(var a=0;a<i.length;a++)if(!l.has(i[a])){l=!1;break e}l=!0}i=!l}if(i)return null;switch(l=t?Vn(t):window,e){case\"focus\":(xr(l)||\"true\"===l.contentEditable)&&(nl=l,rl=t,ll=null);break;case\"blur\":ll=rl=nl=null;break;case\"mousedown\":il=!0;break;case\"contextmenu\":case\"mouseup\":case\"dragend\":return il=!1,al(n,r);case\"selectionchange\":if(el)break;case\"keydown\":case\"keyup\":return al(n,r)}return null}},ul=tr.extend({animationName:null,elapsedTime:null,pseudoElement:null}),cl=tr.extend({clipboardData:function(e){return\"clipboardData\"in e?e.clipboardData:window.clipboardData}}),sl=Ur.extend({relatedTarget:null});function fl(e){var t=e.keyCode;return\"charCode\"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}var dl={Esc:\"Escape\",Spacebar:\" \",Left:\"ArrowLeft\",Up:\"ArrowUp\",Right:\"ArrowRight\",Down:\"ArrowDown\",Del:\"Delete\",Win:\"OS\",Menu:\"ContextMenu\",Apps:\"ContextMenu\",Scroll:\"ScrollLock\",MozPrintableKey:\"Unidentified\"},pl={8:\"Backspace\",9:\"Tab\",12:\"Clear\",13:\"Enter\",16:\"Shift\",17:\"Control\",18:\"Alt\",19:\"Pause\",20:\"CapsLock\",27:\"Escape\",32:\" \",33:\"PageUp\",34:\"PageDown\",35:\"End\",36:\"Home\",37:\"ArrowLeft\",38:\"ArrowUp\",39:\"ArrowRight\",40:\"ArrowDown\",45:\"Insert\",46:\"Delete\",112:\"F1\",113:\"F2\",114:\"F3\",115:\"F4\",116:\"F5\",117:\"F6\",118:\"F7\",119:\"F8\",120:\"F9\",121:\"F10\",122:\"F11\",123:\"F12\",144:\"NumLock\",145:\"ScrollLock\",224:\"Meta\"},ml=Ur.extend({key:function(e){if(e.key){var t=dl[e.key]||e.key;if(\"Unidentified\"!==t)return t}return\"keypress\"===e.type?13===(e=fl(e))?\"Enter\":String.fromCharCode(e):\"keydown\"===e.type||\"keyup\"===e.type?pl[e.keyCode]||\"Unidentified\":\"\"},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Qr,charCode:function(e){return\"keypress\"===e.type?fl(e):0},keyCode:function(e){return\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0},which:function(e){return\"keypress\"===e.type?fl(e):\"keydown\"===e.type||\"keyup\"===e.type?e.keyCode:0}}),hl=Kr.extend({dataTransfer:null}),gl=Ur.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Qr}),vl=tr.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),yl=Kr.extend({deltaX:function(e){return\"deltaX\"in e?e.deltaX:\"wheelDeltaX\"in e?-e.wheelDeltaX:0},deltaY:function(e){return\"deltaY\"in e?e.deltaY:\"wheelDeltaY\"in e?-e.wheelDeltaY:\"wheelDelta\"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),bl={eventTypes:Ht,extractEvents:function(e,t,n,r){var l=jt.get(e);if(!l)return null;switch(e){case\"keypress\":if(0===fl(n))return null;case\"keydown\":case\"keyup\":e=ml;break;case\"blur\":case\"focus\":e=sl;break;case\"click\":if(2===n.button)return null;case\"auxclick\":case\"dblclick\":case\"mousedown\":case\"mousemove\":case\"mouseup\":case\"mouseout\":case\"mouseover\":case\"contextmenu\":e=Kr;break;case\"drag\":case\"dragend\":case\"dragenter\":case\"dragexit\":case\"dragleave\":case\"dragover\":case\"dragstart\":case\"drop\":e=hl;break;case\"touchcancel\":case\"touchend\":case\"touchmove\":case\"touchstart\":e=gl;break;case Ye:case Xe:case Ge:e=ul;break;case Ze:e=vl;break;case\"scroll\":e=Ur;break;case\"wheel\":e=yl;break;case\"copy\":case\"cut\":case\"paste\":e=cl;break;case\"gotpointercapture\":case\"lostpointercapture\":case\"pointercancel\":case\"pointerdown\":case\"pointermove\":case\"pointerout\":case\"pointerover\":case\"pointerup\":e=$r;break;default:e=tr}return qn(t=e.getPooled(l,t,n,r)),t}};if(g)throw Error(r(101));g=Array.prototype.slice.call(\"ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin\".split(\" \")),y();var wl=An;d=Qn,p=wl,m=Vn,E({SimpleEventPlugin:bl,EnterLeaveEventPlugin:Yr,ChangeEventPlugin:Lr,SelectEventPlugin:ol,BeforeInputEventPlugin:wr});var kl=[],xl=-1;function Tl(e){0>xl||(e.current=kl[xl],kl[xl]=null,xl--)}function El(e,t){kl[++xl]=e.current,e.current=t}var Sl={},Cl={current:Sl},Pl={current:!1},_l=Sl;function Nl(e,t){var n=e.type.contextTypes;if(!n)return Sl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,i={};for(l in n)i[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function zl(e){return null!=(e=e.childContextTypes)}function Ml(){Tl(Pl),Tl(Cl)}function Il(e,t,n){if(Cl.current!==Sl)throw Error(r(168));El(Cl,t),El(Pl,n)}function Fl(e,n,l){var i=e.stateNode;if(e=n.childContextTypes,\"function\"!=typeof i.getChildContext)return l;for(var a in i=i.getChildContext())if(!(a in e))throw Error(r(108,ye(n)||\"Unknown\",a));return t({},l,{},i)}function Ol(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Sl,_l=Cl.current,El(Cl,e),El(Pl,Pl.current),!0}function Rl(e,t,n){var l=e.stateNode;if(!l)throw Error(r(169));n?(e=Fl(e,t,_l),l.__reactInternalMemoizedMergedChildContext=e,Tl(Pl),Tl(Cl),El(Cl,e)):Tl(Pl),El(Pl,n)}var Dl=n.unstable_runWithPriority,Ll=n.unstable_scheduleCallback,Ul=n.unstable_cancelCallback,Al=n.unstable_requestPaint,Vl=n.unstable_now,Ql=n.unstable_getCurrentPriorityLevel,Wl=n.unstable_ImmediatePriority,Hl=n.unstable_UserBlockingPriority,jl=n.unstable_NormalPriority,Bl=n.unstable_LowPriority,Kl=n.unstable_IdlePriority,$l={},ql=n.unstable_shouldYield,Yl=void 0!==Al?Al:function(){},Xl=null,Gl=null,Zl=!1,Jl=Vl(),ei=1e4>Jl?Vl:function(){return Vl()-Jl};function ti(){switch(Ql()){case Wl:return 99;case Hl:return 98;case jl:return 97;case Bl:return 96;case Kl:return 95;default:throw Error(r(332))}}function ni(e){switch(e){case 99:return Wl;case 98:return Hl;case 97:return jl;case 96:return Bl;case 95:return Kl;default:throw Error(r(332))}}function ri(e,t){return e=ni(e),Dl(e,t)}function li(e,t,n){return e=ni(e),Ll(e,t,n)}function ii(e){return null===Xl?(Xl=[e],Gl=Ll(Wl,oi)):Xl.push(e),$l}function ai(){if(null!==Gl){var e=Gl;Gl=null,Ul(e)}oi()}function oi(){if(!Zl&&null!==Xl){Zl=!0;var e=0;try{var t=Xl;ri(99,function(){for(;e<t.length;e++){var n=t[e];do{n=n(!0)}while(null!==n)}}),Xl=null}catch(n){throw null!==Xl&&(Xl=Xl.slice(e+1)),Ll(Wl,ai),n}finally{Zl=!1}}}function ui(e,t,n){return 1073741821-(1+((1073741821-e+t/10)/(n/=10)|0))*n}function ci(e,n){if(e&&e.defaultProps)for(var r in n=t({},n),e=e.defaultProps)void 0===n[r]&&(n[r]=e[r]);return n}var si={current:null},fi=null,di=null,pi=null;function mi(){pi=di=fi=null}function hi(e){var t=si.current;Tl(si),e.type._context._currentValue=t}function gi(e,t){for(;null!==e;){var n=e.alternate;if(e.childExpirationTime<t)e.childExpirationTime=t,null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t);else{if(!(null!==n&&n.childExpirationTime<t))break;n.childExpirationTime=t}e=e.return}}function vi(e,t){fi=e,pi=di=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(e.expirationTime>=t&&(ja=!0),e.firstContext=null)}function yi(e,t){if(pi!==e&&!1!==t&&0!==t)if(\"number\"==typeof t&&1073741823!==t||(pi=e,t=1073741823),t={context:e,observedBits:t,next:null},null===di){if(null===fi)throw Error(r(308));di=t,fi.dependencies={expirationTime:0,firstContext:t,responders:null}}else di=di.next=t;return e._currentValue}var bi=!1;function wi(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function ki(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function xi(e,t){return(e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null}).next=e}function Ti(e,t){if(null!==(e=e.updateQueue)){var n=(e=e.shared).pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}}function Ei(e,t){var n=e.alternate;null!==n&&ki(n,e),null===(n=(e=e.updateQueue).baseQueue)?(e.baseQueue=t.next=t,t.next=t):(t.next=n.next,n.next=t)}function Si(e,n,r,l){var i=e.updateQueue;bi=!1;var a=i.baseQueue,o=i.shared.pending;if(null!==o){if(null!==a){var u=a.next;a.next=o.next,o.next=u}a=o,i.shared.pending=null,null!==(u=e.alternate)&&(null!==(u=u.updateQueue)&&(u.baseQueue=o))}if(null!==a){u=a.next;var c=i.baseState,s=0,f=null,d=null,p=null;if(null!==u)for(var m=u;;){if((o=m.expirationTime)<l){var h={expirationTime:m.expirationTime,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null};null===p?(d=p=h,f=c):p=p.next=h,o>s&&(s=o)}else{null!==p&&(p=p.next={expirationTime:1073741823,suspenseConfig:m.suspenseConfig,tag:m.tag,payload:m.payload,callback:m.callback,next:null}),Fu(o,m.suspenseConfig);e:{var g=e,v=m;switch(o=n,h=r,v.tag){case 1:if(\"function\"==typeof(g=v.payload)){c=g.call(h,c,o);break e}c=g;break e;case 3:g.effectTag=-4097&g.effectTag|64;case 0:if(null==(o=\"function\"==typeof(g=v.payload)?g.call(h,c,o):g))break e;c=t({},c,o);break e;case 2:bi=!0}}null!==m.callback&&(e.effectTag|=32,null===(o=i.effects)?i.effects=[m]:o.push(m))}if(null===(m=m.next)||m===u){if(null===(o=i.shared.pending))break;m=a.next=o.next,o.next=u,i.baseQueue=a=o,i.shared.pending=null}}null===p?f=c:p.next=d,i.baseState=f,i.baseQueue=p,Ou(s),e.expirationTime=s,e.memoizedState=c}}function Ci(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var l=e[t],i=l.callback;if(null!==i){if(l.callback=null,l=i,i=n,\"function\"!=typeof l)throw Error(r(191,l));l.call(i)}}}var Pi=G.ReactCurrentBatchConfig,_i=(new e.Component).refs;function Ni(e,n,r,l){r=null==(r=r(l,n=e.memoizedState))?n:t({},n,r),e.memoizedState=r,0===e.expirationTime&&(e.updateQueue.baseState=r)}var zi={isMounted:function(e){return!!(e=e._reactInternalFiber)&&nt(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueReplaceState:function(e,t,n){e=e._reactInternalFiber;var r=bu(),l=Pi.suspense;(l=xi(r=wu(r,e,l),l)).tag=1,l.payload=t,null!=n&&(l.callback=n),Ti(e,l),ku(e,r)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var n=bu(),r=Pi.suspense;(r=xi(n=wu(n,e,r),r)).tag=2,null!=t&&(r.callback=t),Ti(e,r),ku(e,n)}};function Mi(e,t,n,r,l,i,a){return\"function\"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,a):!t.prototype||!t.prototype.isPureReactComponent||(!Jr(n,r)||!Jr(l,i))}function Ii(e,t,n){var r=!1,l=Sl,i=t.contextType;return\"object\"==typeof i&&null!==i?i=yi(i):(l=zl(t)?_l:Cl.current,i=(r=null!=(r=t.contextTypes))?Nl(e,l):Sl),t=new t(n,i),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=zi,e.stateNode=t,t._reactInternalFiber=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=i),t}function Fi(e,t,n,r){e=t.state,\"function\"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),\"function\"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zi.enqueueReplaceState(t,t.state,null)}function Oi(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs=_i,wi(e);var i=t.contextType;\"object\"==typeof i&&null!==i?l.context=yi(i):(i=zl(t)?_l:Cl.current,l.context=Nl(e,i)),Si(e,n,l,r),l.state=e.memoizedState,\"function\"==typeof(i=t.getDerivedStateFromProps)&&(Ni(e,t,i,n),l.state=e.memoizedState),\"function\"==typeof t.getDerivedStateFromProps||\"function\"==typeof l.getSnapshotBeforeUpdate||\"function\"!=typeof l.UNSAFE_componentWillMount&&\"function\"!=typeof l.componentWillMount||(t=l.state,\"function\"==typeof l.componentWillMount&&l.componentWillMount(),\"function\"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),t!==l.state&&zi.enqueueReplaceState(l,l.state,null),Si(e,n,l,r),l.state=e.memoizedState),\"function\"==typeof l.componentDidMount&&(e.effectTag|=4)}var Ri=Array.isArray;function Di(e,t,n){if(null!==(e=n.ref)&&\"function\"!=typeof e&&\"object\"!=typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(r(309));var l=n.stateNode}if(!l)throw Error(r(147,e));var i=\"\"+e;return null!==t&&null!==t.ref&&\"function\"==typeof t.ref&&t.ref._stringRef===i?t.ref:((t=function(e){var t=l.refs;t===_i&&(t=l.refs={}),null===e?delete t[i]:t[i]=e})._stringRef=i,t)}if(\"string\"!=typeof e)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Li(e,t){if(\"textarea\"!==e.type)throw Error(r(31,\"[object Object]\"===Object.prototype.toString.call(t)?\"object with keys {\"+Object.keys(t).join(\", \")+\"}\":t,\"\"))}function Ui(e){function t(t,n){if(e){var r=t.lastEffect;null!==r?(r.nextEffect=n,t.lastEffect=n):t.firstEffect=t.lastEffect=n,n.nextEffect=null,n.effectTag=8}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function l(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=nc(e,t)).index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.effectTag=2,n):r:(t.effectTag=2,n):n}function o(t){return e&&null===t.alternate&&(t.effectTag=2),t}function u(e,t,n,r){return null===t||6!==t.tag?((t=ic(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){return null!==t&&t.elementType===n.type?((r=i(t,n.props)).ref=Di(e,t,n),r.return=e,r):((r=rc(n.type,n.key,n.props,null,e.mode,r)).ref=Di(e,t,n),r.return=e,r)}function s(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=ac(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function f(e,t,n,r,l){return null===t||7!==t.tag?((t=lc(n,e.mode,r,l)).return=e,t):((t=i(t,n)).return=e,t)}function d(e,t,n){if(\"string\"==typeof t||\"number\"==typeof t)return(t=ic(\"\"+t,e.mode,n)).return=e,t;if(\"object\"==typeof t&&null!==t){switch(t.$$typeof){case te:return(n=rc(t.type,t.key,t.props,null,e.mode,n)).ref=Di(e,null,t),n.return=e,n;case ne:return(t=ac(t,e.mode,n)).return=e,t}if(Ri(t)||ge(t))return(t=lc(t,e.mode,n,null)).return=e,t;Li(e,t)}return null}function p(e,t,n,r){var l=null!==t?t.key:null;if(\"string\"==typeof n||\"number\"==typeof n)return null!==l?null:u(e,t,\"\"+n,r);if(\"object\"==typeof n&&null!==n){switch(n.$$typeof){case te:return n.key===l?n.type===re?f(e,t,n.props.children,r,l):c(e,t,n,r):null;case ne:return n.key===l?s(e,t,n,r):null}if(Ri(n)||ge(n))return null!==l?null:f(e,t,n,r,null);Li(e,n)}return null}function m(e,t,n,r,l){if(\"string\"==typeof r||\"number\"==typeof r)return u(t,e=e.get(n)||null,\"\"+r,l);if(\"object\"==typeof r&&null!==r){switch(r.$$typeof){case te:return e=e.get(null===r.key?n:r.key)||null,r.type===re?f(t,e,r.props.children,l,r.key):c(t,e,r,l);case ne:return s(t,e=e.get(null===r.key?n:r.key)||null,r,l)}if(Ri(r)||ge(r))return f(t,e=e.get(n)||null,r,l,null);Li(t,r)}return null}function h(r,i,o,u){for(var c=null,s=null,f=i,h=i=0,g=null;null!==f&&h<o.length;h++){f.index>h?(g=f,f=null):g=f.sibling;var v=p(r,f,o[h],u);if(null===v){null===f&&(f=g);break}e&&f&&null===v.alternate&&t(r,f),i=a(v,i,h),null===s?c=v:s.sibling=v,s=v,f=g}if(h===o.length)return n(r,f),c;if(null===f){for(;h<o.length;h++)null!==(f=d(r,o[h],u))&&(i=a(f,i,h),null===s?c=f:s.sibling=f,s=f);return c}for(f=l(r,f);h<o.length;h++)null!==(g=m(f,r,h,o[h],u))&&(e&&null!==g.alternate&&f.delete(null===g.key?h:g.key),i=a(g,i,h),null===s?c=g:s.sibling=g,s=g);return e&&f.forEach(function(e){return t(r,e)}),c}function g(i,o,u,c){var s=ge(u);if(\"function\"!=typeof s)throw Error(r(150));if(null==(u=s.call(u)))throw Error(r(151));for(var f=s=null,h=o,g=o=0,v=null,y=u.next();null!==h&&!y.done;g++,y=u.next()){h.index>g?(v=h,h=null):v=h.sibling;var b=p(i,h,y.value,c);if(null===b){null===h&&(h=v);break}e&&h&&null===b.alternate&&t(i,h),o=a(b,o,g),null===f?s=b:f.sibling=b,f=b,h=v}if(y.done)return n(i,h),s;if(null===h){for(;!y.done;g++,y=u.next())null!==(y=d(i,y.value,c))&&(o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return s}for(h=l(i,h);!y.done;g++,y=u.next())null!==(y=m(h,i,g,y.value,c))&&(e&&null!==y.alternate&&h.delete(null===y.key?g:y.key),o=a(y,o,g),null===f?s=y:f.sibling=y,f=y);return e&&h.forEach(function(e){return t(i,e)}),s}return function(e,l,a,u){var c=\"object\"==typeof a&&null!==a&&a.type===re&&null===a.key;c&&(a=a.props.children);var s=\"object\"==typeof a&&null!==a;if(s)switch(a.$$typeof){case te:e:{for(s=a.key,c=l;null!==c;){if(c.key===s){switch(c.tag){case 7:if(a.type===re){n(e,c.sibling),(l=i(c,a.props.children)).return=e,e=l;break e}break;default:if(c.elementType===a.type){n(e,c.sibling),(l=i(c,a.props)).ref=Di(e,c,a),l.return=e,e=l;break e}}n(e,c);break}t(e,c),c=c.sibling}a.type===re?((l=lc(a.props.children,e.mode,u,a.key)).return=e,e=l):((u=rc(a.type,a.key,a.props,null,e.mode,u)).ref=Di(e,l,a),u.return=e,e=u)}return o(e);case ne:e:{for(c=a.key;null!==l;){if(l.key===c){if(4===l.tag&&l.stateNode.containerInfo===a.containerInfo&&l.stateNode.implementation===a.implementation){n(e,l.sibling),(l=i(l,a.children||[])).return=e,e=l;break e}n(e,l);break}t(e,l),l=l.sibling}(l=ac(a,e.mode,u)).return=e,e=l}return o(e)}if(\"string\"==typeof a||\"number\"==typeof a)return a=\"\"+a,null!==l&&6===l.tag?(n(e,l.sibling),(l=i(l,a)).return=e,e=l):(n(e,l),(l=ic(a,e.mode,u)).return=e,e=l),o(e);if(Ri(a))return h(e,l,a,u);if(ge(a))return g(e,l,a,u);if(s&&Li(e,a),void 0===a&&!c)switch(e.tag){case 1:case 0:throw e=e.type,Error(r(152,e.displayName||e.name||\"Component\"))}return n(e,l)}}var Ai=Ui(!0),Vi=Ui(!1),Qi={},Wi={current:Qi},Hi={current:Qi},ji={current:Qi};function Bi(e){if(e===Qi)throw Error(r(174));return e}function Ki(e,t){switch(El(ji,t),El(Hi,e),El(Wi,Qi),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ve(null,\"\");break;default:t=Ve(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}Tl(Wi),El(Wi,t)}function $i(){Tl(Wi),Tl(Hi),Tl(ji)}function qi(e){Bi(ji.current);var t=Bi(Wi.current),n=Ve(t,e.type);t!==n&&(El(Hi,e),El(Wi,n))}function Yi(e){Hi.current===e&&(Tl(Wi),Tl(Hi))}var Xi={current:0};function Gi(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||n.data===En||n.data===Sn))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!=(64&t.effectTag))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Zi(e,t){return{responder:e,props:t}}var Ji=G.ReactCurrentDispatcher,ea=G.ReactCurrentBatchConfig,ta=0,na=null,ra=null,la=null,ia=!1;function aa(){throw Error(r(321))}function oa(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Gr(e[n],t[n]))return!1;return!0}function ua(e,t,n,l,i,a){if(ta=a,na=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,Ji.current=null===e||null===e.memoizedState?Ma:Ia,e=n(l,i),t.expirationTime===ta){a=0;do{if(t.expirationTime=0,!(25>a))throw Error(r(301));a+=1,la=ra=null,t.updateQueue=null,Ji.current=Fa,e=n(l,i)}while(t.expirationTime===ta)}if(Ji.current=za,t=null!==ra&&null!==ra.next,ta=0,la=ra=na=null,ia=!1,t)throw Error(r(300));return e}function ca(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===la?na.memoizedState=la=e:la=la.next=e,la}function sa(){if(null===ra){var e=na.alternate;e=null!==e?e.memoizedState:null}else e=ra.next;var t=null===la?na.memoizedState:la.next;if(null!==t)la=t,ra=e;else{if(null===e)throw Error(r(310));e={memoizedState:(ra=e).memoizedState,baseState:ra.baseState,baseQueue:ra.baseQueue,queue:ra.queue,next:null},null===la?na.memoizedState=la=e:la=la.next=e}return la}function fa(e,t){return\"function\"==typeof t?t(e):t}function da(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=ra,i=l.baseQueue,a=n.pending;if(null!==a){if(null!==i){var o=i.next;i.next=a.next,a.next=o}l.baseQueue=i=a,n.pending=null}if(null!==i){i=i.next,l=l.baseState;var u=o=a=null,c=i;do{var s=c.expirationTime;if(s<ta){var f={expirationTime:c.expirationTime,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null};null===u?(o=u=f,a=l):u=u.next=f,s>na.expirationTime&&(na.expirationTime=s,Ou(s))}else null!==u&&(u=u.next={expirationTime:1073741823,suspenseConfig:c.suspenseConfig,action:c.action,eagerReducer:c.eagerReducer,eagerState:c.eagerState,next:null}),Fu(s,c.suspenseConfig),l=c.eagerReducer===e?c.eagerState:e(l,c.action);c=c.next}while(null!==c&&c!==i);null===u?a=l:u.next=o,Gr(l,t.memoizedState)||(ja=!0),t.memoizedState=l,t.baseState=a,t.baseQueue=u,n.lastRenderedState=l}return[t.memoizedState,n.dispatch]}function pa(e){var t=sa(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var l=n.dispatch,i=n.pending,a=t.memoizedState;if(null!==i){n.pending=null;var o=i=i.next;do{a=e(a,o.action),o=o.next}while(o!==i);Gr(a,t.memoizedState)||(ja=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),n.lastRenderedState=a}return[a,l]}function ma(e){var t=ca();return\"function\"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={pending:null,dispatch:null,lastRenderedReducer:fa,lastRenderedState:e}).dispatch=Na.bind(null,na,e),[t.memoizedState,e]}function ha(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=na.updateQueue)?(t={lastEffect:null},na.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ga(){return sa().memoizedState}function va(e,t,n,r){var l=ca();na.effectTag|=e,l.memoizedState=ha(1|t,n,void 0,void 0===r?null:r)}function ya(e,t,n,r){var l=sa();r=void 0===r?null:r;var i=void 0;if(null!==ra){var a=ra.memoizedState;if(i=a.destroy,null!==r&&oa(r,a.deps))return void ha(t,n,i,r)}na.effectTag|=e,l.memoizedState=ha(1|t,n,i,r)}function ba(e,t){return va(516,4,e,t)}function wa(e,t){return ya(516,4,e,t)}function ka(e,t){return ya(4,2,e,t)}function xa(e,t){return\"function\"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ta(e,t,n){return n=null!=n?n.concat([e]):null,ya(4,2,xa.bind(null,t,e),n)}function Ea(){}function Sa(e,t){return ca().memoizedState=[e,void 0===t?null:t],e}function Ca(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Pa(e,t){var n=sa();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&oa(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function _a(e,t,n){var r=ti();ri(98>r?98:r,function(){e(!0)}),ri(97<r?97:r,function(){var r=ea.suspense;ea.suspense=void 0===t?null:t;try{e(!1),n()}finally{ea.suspense=r}})}function Na(e,t,n){var r=bu(),l=Pi.suspense;l={expirationTime:r=wu(r,e,l),suspenseConfig:l,action:n,eagerReducer:null,eagerState:null,next:null};var i=t.pending;if(null===i?l.next=l:(l.next=i.next,i.next=l),t.pending=l,i=e.alternate,e===na||null!==i&&i===na)ia=!0,l.expirationTime=ta,na.expirationTime=ta;else{if(0===e.expirationTime&&(null===i||0===i.expirationTime)&&null!==(i=t.lastRenderedReducer))try{var a=t.lastRenderedState,o=i(a,n);if(l.eagerReducer=i,l.eagerState=o,Gr(o,a))return}catch(u){}ku(e,r)}}var za={readContext:yi,useCallback:aa,useContext:aa,useEffect:aa,useImperativeHandle:aa,useLayoutEffect:aa,useMemo:aa,useReducer:aa,useRef:aa,useState:aa,useDebugValue:aa,useResponder:aa,useDeferredValue:aa,useTransition:aa},Ma={readContext:yi,useCallback:Sa,useContext:yi,useEffect:ba,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,va(4,2,xa.bind(null,t,e),n)},useLayoutEffect:function(e,t){return va(4,2,e,t)},useMemo:function(e,t){var n=ca();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ca();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Na.bind(null,na,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ca().memoizedState=e},useState:ma,useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=ma(e),r=n[0],l=n[1];return ba(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=ma(!1),n=t[0];return t=t[1],[Sa(_a.bind(null,t,e),[t,e]),n]}},Ia={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:da,useRef:ga,useState:function(){return da(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=da(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=da(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Fa={readContext:yi,useCallback:Ca,useContext:yi,useEffect:wa,useImperativeHandle:Ta,useLayoutEffect:ka,useMemo:Pa,useReducer:pa,useRef:ga,useState:function(){return pa(fa)},useDebugValue:Ea,useResponder:Zi,useDeferredValue:function(e,t){var n=pa(fa),r=n[0],l=n[1];return wa(function(){var n=ea.suspense;ea.suspense=void 0===t?null:t;try{l(e)}finally{ea.suspense=n}},[e,t]),r},useTransition:function(e){var t=pa(fa),n=t[0];return t=t[1],[Ca(_a.bind(null,t,e),[t,e]),n]}},Oa=null,Ra=null,Da=!1;function La(e,t){var n=Ju(5,null,null,0);n.elementType=\"DELETED\",n.type=\"DELETED\",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function Ua(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=\"\"===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);case 13:default:return!1}}function Aa(e){if(Da){var t=Ra;if(t){var n=t;if(!Ua(e,t)){if(!(t=In(n.nextSibling))||!Ua(e,t))return e.effectTag=-1025&e.effectTag|2,Da=!1,void(Oa=e);La(Oa,n)}Oa=e,Ra=In(t.firstChild)}else e.effectTag=-1025&e.effectTag|2,Da=!1,Oa=e}}function Va(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;Oa=e}function Qa(e){if(e!==Oa)return!1;if(!Da)return Va(e),Da=!0,!1;var t=e.type;if(5!==e.tag||\"head\"!==t&&\"body\"!==t&&!Nn(t,e.memoizedProps))for(t=Ra;t;)La(e,t),t=In(t.nextSibling);if(Va(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if(n===Tn){if(0===t){Ra=In(e.nextSibling);break e}t--}else n!==xn&&n!==Sn&&n!==En||t++}e=e.nextSibling}Ra=null}}else Ra=Oa?In(e.stateNode.nextSibling):null;return!0}function Wa(){Ra=Oa=null,Da=!1}var Ha=G.ReactCurrentOwner,ja=!1;function Ba(e,t,n,r){t.child=null===e?Vi(t,null,n,r):Ai(t,e.child,n,r)}function Ka(e,t,n,r,l){n=n.render;var i=t.ref;return vi(t,l),r=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function $a(e,t,n,r,l,i){if(null===e){var a=n.type;return\"function\"!=typeof a||ec(a)||void 0!==a.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=rc(n.type,null,r,null,t.mode,i)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=a,qa(e,t,a,r,l,i))}return a=e.child,l<i&&(l=a.memoizedProps,(n=null!==(n=n.compare)?n:Jr)(l,r)&&e.ref===t.ref)?co(e,t,i):(t.effectTag|=1,(e=nc(a,r)).ref=t.ref,e.return=t,t.child=e)}function qa(e,t,n,r,l,i){return null!==e&&Jr(e.memoizedProps,r)&&e.ref===t.ref&&(ja=!1,l<i)?(t.expirationTime=e.expirationTime,co(e,t,i)):Xa(e,t,n,r,i)}function Ya(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.effectTag|=128)}function Xa(e,t,n,r,l){var i=zl(n)?_l:Cl.current;return i=Nl(t,i),vi(t,l),n=ua(e,t,n,r,i,l),null===e||ja?(t.effectTag|=1,Ba(e,t,n,l),t.child):(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=l&&(e.expirationTime=0),co(e,t,l))}function Ga(e,t,n,r,l){if(zl(n)){var i=!0;Ol(t)}else i=!1;if(vi(t,l),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),Ii(t,n,r),Oi(t,n,r,l),r=!0;else if(null===e){var a=t.stateNode,o=t.memoizedProps;a.props=o;var u=a.context,c=n.contextType;\"object\"==typeof c&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current);var s=n.getDerivedStateFromProps,f=\"function\"==typeof s||\"function\"==typeof a.getSnapshotBeforeUpdate;f||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1;var d=t.memoizedState;a.state=d,Si(t,r,a,l),u=t.memoizedState,o!==r||d!==u||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),u=t.memoizedState),(o=bi||Mi(t,n,o,r,d,u,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillMount&&\"function\"!=typeof a.componentWillMount||(\"function\"==typeof a.componentWillMount&&a.componentWillMount(),\"function\"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),\"function\"==typeof a.componentDidMount&&(t.effectTag|=4)):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=c,r=o):(\"function\"==typeof a.componentDidMount&&(t.effectTag|=4),r=!1)}else a=t.stateNode,ki(e,t),o=t.memoizedProps,a.props=t.type===t.elementType?o:ci(t.type,o),u=a.context,\"object\"==typeof(c=n.contextType)&&null!==c?c=yi(c):c=Nl(t,c=zl(n)?_l:Cl.current),(f=\"function\"==typeof(s=n.getDerivedStateFromProps)||\"function\"==typeof a.getSnapshotBeforeUpdate)||\"function\"!=typeof a.UNSAFE_componentWillReceiveProps&&\"function\"!=typeof a.componentWillReceiveProps||(o!==r||u!==c)&&Fi(t,a,r,c),bi=!1,u=t.memoizedState,a.state=u,Si(t,r,a,l),d=t.memoizedState,o!==r||u!==d||Pl.current||bi?(\"function\"==typeof s&&(Ni(t,n,s,r),d=t.memoizedState),(s=bi||Mi(t,n,o,r,u,d,c))?(f||\"function\"!=typeof a.UNSAFE_componentWillUpdate&&\"function\"!=typeof a.componentWillUpdate||(\"function\"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,d,c),\"function\"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,d,c)),\"function\"==typeof a.componentDidUpdate&&(t.effectTag|=4),\"function\"==typeof a.getSnapshotBeforeUpdate&&(t.effectTag|=256)):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),t.memoizedProps=r,t.memoizedState=d),a.props=r,a.state=d,a.context=c,r=s):(\"function\"!=typeof a.componentDidUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),\"function\"!=typeof a.getSnapshotBeforeUpdate||o===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=256),r=!1);return Za(e,t,n,r,i,l)}function Za(e,t,n,r,l,i){Ya(e,t);var a=0!=(64&t.effectTag);if(!r&&!a)return l&&Rl(t,n,!1),co(e,t,i);r=t.stateNode,Ha.current=t;var o=a&&\"function\"!=typeof n.getDerivedStateFromError?null:r.render();return t.effectTag|=1,null!==e&&a?(t.child=Ai(t,e.child,null,i),t.child=Ai(t,null,o,i)):Ba(e,t,o,i),t.memoizedState=r.state,l&&Rl(t,n,!0),t.child}function Ja(e){var t=e.stateNode;t.pendingContext?Il(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Il(e,t.context,!1),Ki(e,t.containerInfo)}var eo,to,no,ro,lo={dehydrated:null,retryTime:0};function io(e,t,n){var r,l=t.mode,i=t.pendingProps,a=Xi.current,o=!1;if((r=0!=(64&t.effectTag))||(r=0!=(2&a)&&(null===e||null!==e.memoizedState)),r?(o=!0,t.effectTag&=-65):null!==e&&null===e.memoizedState||void 0===i.fallback||!0===i.unstable_avoidThisFallback||(a|=1),El(Xi,1&a),null===e){if(void 0!==i.fallback&&Aa(t),o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,t.memoizedState=lo,t.child=i,n}return l=i.children,t.memoizedState=null,t.child=Vi(t,null,l,n)}if(null!==e.memoizedState){if(l=(e=e.child).sibling,o){if(i=i.fallback,(n=nc(e,e.pendingProps)).return=t,0==(2&t.mode)&&(o=null!==t.memoizedState?t.child.child:t.child)!==e.child)for(n.child=o;null!==o;)o.return=n,o=o.sibling;return(l=nc(l,i)).return=t,n.sibling=l,n.childExpirationTime=0,t.memoizedState=lo,t.child=n,l}return n=Ai(t,e.child,i.children,n),t.memoizedState=null,t.child=n}if(e=e.child,o){if(o=i.fallback,(i=lc(null,l,0,null)).return=t,i.child=e,null!==e&&(e.return=i),0==(2&t.mode))for(e=null!==t.memoizedState?t.child.child:t.child,i.child=e;null!==e;)e.return=i,e=e.sibling;return(n=lc(o,l,n,null)).return=t,i.sibling=n,n.effectTag|=2,i.childExpirationTime=0,t.memoizedState=lo,t.child=i,n}return t.memoizedState=null,t.child=Ai(t,e,i.children,n)}function ao(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t),gi(e.return,t)}function oo(e,t,n,r,l,i){var a=e.memoizedState;null===a?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailExpiration:0,tailMode:l,lastEffect:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailExpiration=0,a.tailMode=l,a.lastEffect=i)}function uo(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(Ba(e,t,r.children,n),0!=(2&(r=Xi.current)))r=1&r|2,t.effectTag|=64;else{if(null!==e&&0!=(64&e.effectTag))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ao(e,n);else if(19===e.tag)ao(e,n);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(El(Xi,r),0==(2&t.mode))t.memoizedState=null;else switch(l){case\"forwards\":for(n=t.child,l=null;null!==n;)null!==(e=n.alternate)&&null===Gi(e)&&(l=n),n=n.sibling;null===(n=l)?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),oo(t,!1,l,n,i,t.lastEffect);break;case\"backwards\":for(n=null,l=t.child,t.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Gi(e)){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}oo(t,!0,n,null,i,t.lastEffect);break;case\"together\":oo(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function co(e,t,n){null!==e&&(t.dependencies=e.dependencies);var l=t.expirationTime;if(0!==l&&Ou(l),t.childExpirationTime<n)return null;if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=nc(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=nc(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function so(e,t){switch(e.tailMode){case\"hidden\":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case\"collapsed\":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function fo(e,n,l){var i=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return zl(n.type)&&Ml(),null;case 3:return $i(),Tl(Pl),Tl(Cl),(l=n.stateNode).pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||!Qa(n)||(n.effectTag|=4),to(n),null;case 5:Yi(n),l=Bi(ji.current);var a=n.type;if(null!==e&&null!=n.stateNode)no(e,n,a,i,l),e.ref!==n.ref&&(n.effectTag|=128);else{if(!i){if(null===n.stateNode)throw Error(r(166));return null}if(e=Bi(Wi.current),Qa(n)){i=n.stateNode,a=n.type;var o=n.memoizedProps;switch(i[Rn]=n,i[Dn]=o,a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",i);break;case\"video\":case\"audio\":for(e=0;e<Je.length;e++)Jt(Je[e],i);break;case\"source\":Jt(\"error\",i);break;case\"img\":case\"image\":case\"link\":Jt(\"error\",i),Jt(\"load\",i);break;case\"form\":Jt(\"reset\",i),Jt(\"submit\",i);break;case\"details\":Jt(\"toggle\",i);break;case\"input\":Ce(i,o),Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"select\":i._wrapperState={wasMultiple:!!o.multiple},Jt(\"invalid\",i),mn(l,\"onChange\");break;case\"textarea\":Re(i,o),Jt(\"invalid\",i),mn(l,\"onChange\")}for(var u in fn(a,o),e=null,o)if(o.hasOwnProperty(u)){var c=o[u];\"children\"===u?\"string\"==typeof c?i.textContent!==c&&(e=[\"children\",c]):\"number\"==typeof c&&i.textContent!==\"\"+c&&(e=[\"children\",\"\"+c]):x.hasOwnProperty(u)&&null!=c&&mn(l,u)}switch(a){case\"input\":Te(i),Ne(i,o,!0);break;case\"textarea\":Te(i),Le(i);break;case\"select\":case\"option\":break;default:\"function\"==typeof o.onClick&&(i.onclick=hn)}l=e,n.updateQueue=l,null!==l&&(n.effectTag|=4)}else{switch(u=9===l.nodeType?l:l.ownerDocument,e===pn&&(e=Ae(a)),e===pn?\"script\"===a?((e=u.createElement(\"div\")).innerHTML=\"<script><\\/script>\",e=e.removeChild(e.firstChild)):\"string\"==typeof i.is?e=u.createElement(a,{is:i.is}):(e=u.createElement(a),\"select\"===a&&(u=e,i.multiple?u.multiple=!0:i.size&&(u.size=i.size))):e=u.createElementNS(e,a),e[Rn]=n,e[Dn]=i,eo(e,n,!1,!1),n.stateNode=e,u=dn(a,i),a){case\"iframe\":case\"object\":case\"embed\":Jt(\"load\",e),c=i;break;case\"video\":case\"audio\":for(c=0;c<Je.length;c++)Jt(Je[c],e);c=i;break;case\"source\":Jt(\"error\",e),c=i;break;case\"img\":case\"image\":case\"link\":Jt(\"error\",e),Jt(\"load\",e),c=i;break;case\"form\":Jt(\"reset\",e),Jt(\"submit\",e),c=i;break;case\"details\":Jt(\"toggle\",e),c=i;break;case\"input\":Ce(e,i),c=Se(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"option\":c=Ie(e,i);break;case\"select\":e._wrapperState={wasMultiple:!!i.multiple},c=t({},i,{value:void 0}),Jt(\"invalid\",e),mn(l,\"onChange\");break;case\"textarea\":Re(e,i),c=Oe(e,i),Jt(\"invalid\",e),mn(l,\"onChange\");break;default:c=i}fn(a,c);var s=c;for(o in s)if(s.hasOwnProperty(o)){var f=s[o];\"style\"===o?cn(e,f):\"dangerouslySetInnerHTML\"===o?null!=(f=f?f.__html:void 0)&&We(e,f):\"children\"===o?\"string\"==typeof f?(\"textarea\"!==a||\"\"!==f)&&He(e,f):\"number\"==typeof f&&He(e,\"\"+f):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?null!=f&&mn(l,o):null!=f&&Z(e,o,f,u))}switch(a){case\"input\":Te(e),Ne(e,i,!1);break;case\"textarea\":Te(e),Le(e);break;case\"option\":null!=i.value&&e.setAttribute(\"value\",\"\"+we(i.value));break;case\"select\":e.multiple=!!i.multiple,null!=(l=i.value)?Fe(e,!!i.multiple,l,!1):null!=i.defaultValue&&Fe(e,!!i.multiple,i.defaultValue,!0);break;default:\"function\"==typeof c.onClick&&(e.onclick=hn)}_n(a,i)&&(n.effectTag|=4)}null!==n.ref&&(n.effectTag|=128)}return null;case 6:if(e&&null!=n.stateNode)ro(e,n,e.memoizedProps,i);else{if(\"string\"!=typeof i&&null===n.stateNode)throw Error(r(166));l=Bi(ji.current),Bi(Wi.current),Qa(n)?(l=n.stateNode,i=n.memoizedProps,l[Rn]=n,l.nodeValue!==i&&(n.effectTag|=4)):((l=(9===l.nodeType?l:l.ownerDocument).createTextNode(i))[Rn]=n,n.stateNode=l)}return null;case 13:return Tl(Xi),i=n.memoizedState,0!=(64&n.effectTag)?(n.expirationTime=l,n):(l=null!==i,i=!1,null===e?void 0!==n.memoizedProps.fallback&&Qa(n):(i=null!==(a=e.memoizedState),l||null===a||null!==(a=e.child.sibling)&&(null!==(o=n.firstEffect)?(n.firstEffect=a,a.nextEffect=o):(n.firstEffect=n.lastEffect=a,a.nextEffect=null),a.effectTag=8)),l&&!i&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&Xi.current)?Jo===Ho&&(Jo=Ko):(Jo!==Ho&&Jo!==Ko||(Jo=$o),0!==lu&&null!==Xo&&(cc(Xo,Zo),sc(Xo,lu)))),(l||i)&&(n.effectTag|=4),null);case 4:return $i(),to(n),null;case 10:return hi(n),null;case 17:return zl(n.type)&&Ml(),null;case 19:if(Tl(Xi),null===(i=n.memoizedState))return null;if(a=0!=(64&n.effectTag),null===(o=i.rendering)){if(a)so(i,!1);else if(Jo!==Ho||null!==e&&0!=(64&e.effectTag))for(o=n.child;null!==o;){if(null!==(e=Gi(o))){for(n.effectTag|=64,so(i,!1),null!==(a=e.updateQueue)&&(n.updateQueue=a,n.effectTag|=4),null===i.lastEffect&&(n.firstEffect=null),n.lastEffect=i.lastEffect,i=n.child;null!==i;)o=l,(a=i).effectTag&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,null===(e=a.alternate)?(a.childExpirationTime=0,a.expirationTime=o,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null):(a.childExpirationTime=e.childExpirationTime,a.expirationTime=e.expirationTime,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,o=e.dependencies,a.dependencies=null===o?null:{expirationTime:o.expirationTime,firstContext:o.firstContext,responders:o.responders}),i=i.sibling;return El(Xi,1&Xi.current|2),n.child}o=o.sibling}}else{if(!a)if(null!==(e=Gi(o))){if(n.effectTag|=64,a=!0,null!==(l=e.updateQueue)&&(n.updateQueue=l,n.effectTag|=4),so(i,!0),null===i.tail&&\"hidden\"===i.tailMode&&!o.alternate)return null!==(n=n.lastEffect=i.lastEffect)&&(n.nextEffect=null),null}else 2*ei()-i.renderingStartTime>i.tailExpiration&&1<l&&(n.effectTag|=64,a=!0,so(i,!1),n.expirationTime=n.childExpirationTime=l-1);i.isBackwards?(o.sibling=n.child,n.child=o):(null!==(l=i.last)?l.sibling=o:n.child=o,i.last=o)}return null!==i.tail?(0===i.tailExpiration&&(i.tailExpiration=ei()+500),l=i.tail,i.rendering=l,i.tail=l.sibling,i.lastEffect=n.lastEffect,i.renderingStartTime=ei(),l.sibling=null,n=Xi.current,El(Xi,a?1&n|2:1&n),l):null}throw Error(r(156,n.tag))}function po(e){switch(e.tag){case 1:zl(e.type)&&Ml();var t=e.effectTag;return 4096&t?(e.effectTag=-4097&t|64,e):null;case 3:if($i(),Tl(Pl),Tl(Cl),0!=(64&(t=e.effectTag)))throw Error(r(285));return e.effectTag=-4097&t|64,e;case 5:return Yi(e),null;case 13:return Tl(Xi),4096&(t=e.effectTag)?(e.effectTag=-4097&t|64,e):null;case 19:return Tl(Xi),null;case 4:return $i(),null;case 10:return hi(e),null;default:return null}}function mo(e,t){return{value:e,source:t,stack:be(t)}}eo=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},to=function(){},no=function(e,n,r,l,i){var a=e.memoizedProps;if(a!==l){var o,u,c=n.stateNode;switch(Bi(Wi.current),e=null,r){case\"input\":a=Se(c,a),l=Se(c,l),e=[];break;case\"option\":a=Ie(c,a),l=Ie(c,l),e=[];break;case\"select\":a=t({},a,{value:void 0}),l=t({},l,{value:void 0}),e=[];break;case\"textarea\":a=Oe(c,a),l=Oe(c,l),e=[];break;default:\"function\"!=typeof a.onClick&&\"function\"==typeof l.onClick&&(c.onclick=hn)}for(o in fn(r,l),r=null,a)if(!l.hasOwnProperty(o)&&a.hasOwnProperty(o)&&null!=a[o])if(\"style\"===o)for(u in c=a[o])c.hasOwnProperty(u)&&(r||(r={}),r[u]=\"\");else\"dangerouslySetInnerHTML\"!==o&&\"children\"!==o&&\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&\"autoFocus\"!==o&&(x.hasOwnProperty(o)?e||(e=[]):(e=e||[]).push(o,null));for(o in l){var s=l[o];if(c=null!=a?a[o]:void 0,l.hasOwnProperty(o)&&s!==c&&(null!=s||null!=c))if(\"style\"===o)if(c){for(u in c)!c.hasOwnProperty(u)||s&&s.hasOwnProperty(u)||(r||(r={}),r[u]=\"\");for(u in s)s.hasOwnProperty(u)&&c[u]!==s[u]&&(r||(r={}),r[u]=s[u])}else r||(e||(e=[]),e.push(o,r)),r=s;else\"dangerouslySetInnerHTML\"===o?(s=s?s.__html:void 0,c=c?c.__html:void 0,null!=s&&c!==s&&(e=e||[]).push(o,s)):\"children\"===o?c===s||\"string\"!=typeof s&&\"number\"!=typeof s||(e=e||[]).push(o,\"\"+s):\"suppressContentEditableWarning\"!==o&&\"suppressHydrationWarning\"!==o&&(x.hasOwnProperty(o)?(null!=s&&mn(i,o),e||c===s||(e=[])):(e=e||[]).push(o,s))}r&&(e=e||[]).push(\"style\",r),i=e,(n.updateQueue=i)&&(n.effectTag|=4)}},ro=function(e,t,n,r){n!==r&&(t.effectTag|=4)};var ho=\"function\"==typeof WeakSet?WeakSet:Set;function go(e,t){var n=t.source,r=t.stack;null===r&&null!==n&&(r=be(n)),null!==n&&ye(n.type),t=t.value,null!==e&&1===e.tag&&ye(e.type);try{console.error(t)}catch(l){setTimeout(function(){throw l})}}function vo(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(n){Ku(e,n)}}function yo(e){var t=e.ref;if(null!==t)if(\"function\"==typeof t)try{t(null)}catch(n){Ku(e,n)}else t.current=null}function bo(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&t.effectTag&&null!==e){var n=e.memoizedProps,l=e.memoizedState;t=(e=t.stateNode).getSnapshotBeforeUpdate(t.elementType===t.type?n:ci(t.type,n),l),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(r(163))}function wo(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.destroy;n.destroy=void 0,void 0!==r&&r()}n=n.next}while(n!==t)}}function ko(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xo(e,t,n){switch(n.tag){case 0:case 11:case 15:case 22:return void ko(3,n);case 1:if(e=n.stateNode,4&n.effectTag)if(null===t)e.componentDidMount();else{var l=n.elementType===n.type?t.memoizedProps:ci(n.type,t.memoizedProps);e.componentDidUpdate(l,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}return void(null!==(t=n.updateQueue)&&Ci(n,t,e));case 3:if(null!==(t=n.updateQueue)){if(e=null,null!==n.child)switch(n.child.tag){case 5:e=n.child.stateNode;break;case 1:e=n.child.stateNode}Ci(n,t,e)}return;case 5:return e=n.stateNode,void(null===t&&4&n.effectTag&&_n(n.type,n.memoizedProps)&&e.focus());case 6:case 4:case 12:return;case 13:return void(null===n.memoizedState&&(n=n.alternate,null!==n&&(n=n.memoizedState,null!==n&&(n=n.dehydrated,null!==n&&Wt(n)))));case 19:case 17:case 20:case 21:return}throw Error(r(163))}function To(e,t,n){switch(\"function\"==typeof Xu&&Xu(t),t.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e.next;ri(97<n?97:n,function(){var e=r;do{var n=e.destroy;if(void 0!==n){var l=t;try{n()}catch(i){Ku(l,i)}}e=e.next}while(e!==r)})}break;case 1:yo(t),\"function\"==typeof(n=t.stateNode).componentWillUnmount&&vo(t,n);break;case 5:yo(t);break;case 4:No(e,t,n)}}function Eo(e){var t=e.alternate;e.return=null,e.child=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.alternate=null,e.firstEffect=null,e.lastEffect=null,e.pendingProps=null,e.memoizedProps=null,e.stateNode=null,null!==t&&Eo(t)}function So(e){return 5===e.tag||3===e.tag||4===e.tag}function Co(e){e:{for(var t=e.return;null!==t;){if(So(t)){var n=t;break e}t=t.return}throw Error(r(160))}switch(t=n.stateNode,n.tag){case 5:var l=!1;break;case 3:case 4:t=t.containerInfo,l=!0;break;default:throw Error(r(161))}16&n.effectTag&&(He(t,\"\"),n.effectTag&=-17);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||So(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;5!==n.tag&&6!==n.tag&&18!==n.tag;){if(2&n.effectTag)continue t;if(null===n.child||4===n.tag)continue t;n.child.return=n,n=n.child}if(!(2&n.effectTag)){n=n.stateNode;break e}}l?Po(e,n,t):_o(e,n,t)}function Po(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=hn));else if(4!==r&&null!==(e=e.child))for(Po(e,t,n),e=e.sibling;null!==e;)Po(e,t,n),e=e.sibling}function _o(e,t,n){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(_o(e,t,n),e=e.sibling;null!==e;)_o(e,t,n),e=e.sibling}function No(e,t,n){for(var l,i,a=t,o=!1;;){if(!o){o=a.return;e:for(;;){if(null===o)throw Error(r(160));switch(l=o.stateNode,o.tag){case 5:i=!1;break e;case 3:case 4:l=l.containerInfo,i=!0;break e}o=o.return}o=!0}if(5===a.tag||6===a.tag){e:for(var u=e,c=a,s=n,f=c;;)if(To(u,f,s),null!==f.child&&4!==f.tag)f.child.return=f,f=f.child;else{if(f===c)break e;for(;null===f.sibling;){if(null===f.return||f.return===c)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}i?(u=l,c=a.stateNode,8===u.nodeType?u.parentNode.removeChild(c):u.removeChild(c)):l.removeChild(a.stateNode)}else if(4===a.tag){if(null!==a.child){l=a.stateNode.containerInfo,i=!0,a.child.return=a,a=a.child;continue}}else if(To(e,a,n),null!==a.child){a.child.return=a,a=a.child;continue}if(a===t)break;for(;null===a.sibling;){if(null===a.return||a.return===t)return;4===(a=a.return).tag&&(o=!1)}a.sibling.return=a.return,a=a.sibling}}function zo(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:return void wo(3,t);case 1:return;case 5:var n=t.stateNode;if(null!=n){var l=t.memoizedProps,i=null!==e?e.memoizedProps:l;e=t.type;var a=t.updateQueue;if(t.updateQueue=null,null!==a){for(n[Dn]=l,\"input\"===e&&\"radio\"===l.type&&null!=l.name&&Pe(n,l),dn(e,i),t=dn(e,l),i=0;i<a.length;i+=2){var o=a[i],u=a[i+1];\"style\"===o?cn(n,u):\"dangerouslySetInnerHTML\"===o?We(n,u):\"children\"===o?He(n,u):Z(n,o,u,t)}switch(e){case\"input\":_e(n,l);break;case\"textarea\":De(n,l);break;case\"select\":t=n._wrapperState.wasMultiple,n._wrapperState.wasMultiple=!!l.multiple,null!=(e=l.value)?Fe(n,!!l.multiple,e,!1):t!==!!l.multiple&&(null!=l.defaultValue?Fe(n,!!l.multiple,l.defaultValue,!0):Fe(n,!!l.multiple,l.multiple?[]:\"\",!1))}}}return;case 6:if(null===t.stateNode)throw Error(r(162));return void(t.stateNode.nodeValue=t.memoizedProps);case 3:return void((t=t.stateNode).hydrate&&(t.hydrate=!1,Wt(t.containerInfo)));case 12:return;case 13:if(n=t,null===t.memoizedState?l=!1:(l=!0,n=t.child,au=ei()),null!==n)e:for(e=n;;){if(5===e.tag)a=e.stateNode,l?\"function\"==typeof(a=a.style).setProperty?a.setProperty(\"display\",\"none\",\"important\"):a.display=\"none\":(a=e.stateNode,i=null!=(i=e.memoizedProps.style)&&i.hasOwnProperty(\"display\")?i.display:null,a.style.display=un(\"display\",i));else if(6===e.tag)e.stateNode.nodeValue=l?\"\":e.memoizedProps;else{if(13===e.tag&&null!==e.memoizedState&&null===e.memoizedState.dehydrated){(a=e.child.sibling).return=e,e=a;continue}if(null!==e.child){e.child.return=e,e=e.child;continue}}if(e===n)break;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}return void Mo(t);case 19:return void Mo(t);case 17:return}throw Error(r(163))}function Mo(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new ho),t.forEach(function(t){var r=qu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}var Io=\"function\"==typeof WeakMap?WeakMap:Map;function Fo(e,t,n){(n=xi(n,null)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){cu||(cu=!0,su=r),go(e,t)},n}function Oo(e,t,n){(n=xi(n,null)).tag=3;var r=e.type.getDerivedStateFromError;if(\"function\"==typeof r){var l=t.value;n.payload=function(){return go(e,t),r(l)}}var i=e.stateNode;return null!==i&&\"function\"==typeof i.componentDidCatch&&(n.callback=function(){\"function\"!=typeof r&&(null===fu?fu=new Set([this]):fu.add(this),go(e,t));var n=t.stack;this.componentDidCatch(t.value,{componentStack:null!==n?n:\"\"})}),n}var Ro,Do=Math.ceil,Lo=G.ReactCurrentDispatcher,Uo=G.ReactCurrentOwner,Ao=0,Vo=8,Qo=16,Wo=32,Ho=0,jo=1,Bo=2,Ko=3,$o=4,qo=5,Yo=Ao,Xo=null,Go=null,Zo=0,Jo=Ho,eu=null,tu=1073741823,nu=1073741823,ru=null,lu=0,iu=!1,au=0,ou=500,uu=null,cu=!1,su=null,fu=null,du=!1,pu=null,mu=90,hu=null,gu=0,vu=null,yu=0;function bu(){return(Yo&(Qo|Wo))!==Ao?1073741821-(ei()/10|0):0!==yu?yu:yu=1073741821-(ei()/10|0)}function wu(e,t,n){if(0==(2&(t=t.mode)))return 1073741823;var l=ti();if(0==(4&t))return 99===l?1073741823:1073741822;if((Yo&Qo)!==Ao)return Zo;if(null!==n)e=ui(e,0|n.timeoutMs||5e3,250);else switch(l){case 99:e=1073741823;break;case 98:e=ui(e,150,100);break;case 97:case 96:e=ui(e,5e3,250);break;case 95:e=2;break;default:throw Error(r(326))}return null!==Xo&&e===Zo&&--e,e}function ku(e,t){if(50<gu)throw gu=0,vu=null,Error(r(185));if(null!==(e=xu(e,t))){var n=ti();1073741823===t?(Yo&Vo)!==Ao&&(Yo&(Qo|Wo))===Ao?Cu(e):(Eu(e),Yo===Ao&&ai()):Eu(e),(4&Yo)===Ao||98!==n&&99!==n||(null===hu?hu=new Map([[e,t]]):(void 0===(n=hu.get(e))||n>t)&&hu.set(e,t))}}function xu(e,t){e.expirationTime<t&&(e.expirationTime=t);var n=e.alternate;null!==n&&n.expirationTime<t&&(n.expirationTime=t);var r=e.return,l=null;if(null===r&&3===e.tag)l=e.stateNode;else for(;null!==r;){if(n=r.alternate,r.childExpirationTime<t&&(r.childExpirationTime=t),null!==n&&n.childExpirationTime<t&&(n.childExpirationTime=t),null===r.return&&3===r.tag){l=r.stateNode;break}r=r.return}return null!==l&&(Xo===l&&(Ou(t),Jo===$o&&cc(l,Zo)),sc(l,t)),l}function Tu(e){var t=e.lastExpiredTime;if(0!==t)return t;if(!uc(e,t=e.firstPendingTime))return t;var n=e.lastPingedTime;return 2>=(e=n>(e=e.nextKnownPendingLevel)?n:e)&&t!==e?0:e}function Eu(e){if(0!==e.lastExpiredTime)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=ii(Cu.bind(null,e));else{var t=Tu(e),n=e.callbackNode;if(0===t)null!==n&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var r=bu();if(1073741823===t?r=99:1===t||2===t?r=95:r=0>=(r=10*(1073741821-t)-10*(1073741821-r))?99:250>=r?98:5250>=r?97:95,null!==n){var l=e.callbackPriority;if(e.callbackExpirationTime===t&&l>=r)return;n!==$l&&Ul(n)}e.callbackExpirationTime=t,e.callbackPriority=r,t=1073741823===t?ii(Cu.bind(null,e)):li(r,Su.bind(null,e),{timeout:10*(1073741821-t)-ei()}),e.callbackNode=t}}}function Su(e,t){if(yu=0,t)return fc(e,t=bu()),Eu(e),null;var n=Tu(e);if(0!==n){if(t=e.callbackNode,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&n===Zo||zu(e,n),null!==Go){var l=Yo;Yo|=Qo;for(var i=Iu();;)try{Du();break}catch(u){Mu(e,u)}if(mi(),Yo=l,Lo.current=i,Jo===jo)throw t=eu,zu(e,n),cc(e,n),Eu(e),t;if(null===Go)switch(i=e.finishedWork=e.current.alternate,e.finishedExpirationTime=n,l=Jo,Xo=null,l){case Ho:case jo:throw Error(r(345));case Bo:fc(e,2<n?2:n);break;case Ko:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),1073741823===tu&&10<(i=au+ou-ei())){if(iu){var a=e.lastPingedTime;if(0===a||a>=n){e.lastPingedTime=n,zu(e,n);break}}if(0!==(a=Tu(e))&&a!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}e.timeoutHandle=zn(Vu.bind(null,e),i);break}Vu(e);break;case $o:if(cc(e,n),n===(l=e.lastSuspendedTime)&&(e.nextKnownPendingLevel=Au(i)),iu&&(0===(i=e.lastPingedTime)||i>=n)){e.lastPingedTime=n,zu(e,n);break}if(0!==(i=Tu(e))&&i!==n)break;if(0!==l&&l!==n){e.lastPingedTime=l;break}if(1073741823!==nu?l=10*(1073741821-nu)-ei():1073741823===tu?l=0:(l=10*(1073741821-tu)-5e3,0>(l=(i=ei())-l)&&(l=0),(n=10*(1073741821-n)-i)<(l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Do(l/1960))-l)&&(l=n)),10<l){e.timeoutHandle=zn(Vu.bind(null,e),l);break}Vu(e);break;case qo:if(1073741823!==tu&&null!==ru){a=tu;var o=ru;if(0>=(l=0|o.busyMinDurationMs)?l=0:(i=0|o.busyDelayMs,l=(a=ei()-(10*(1073741821-a)-(0|o.timeoutMs||5e3)))<=i?0:i+l-a),10<l){cc(e,n),e.timeoutHandle=zn(Vu.bind(null,e),l);break}}Vu(e);break;default:throw Error(r(329))}if(Eu(e),e.callbackNode===t)return Su.bind(null,e)}}return null}function Cu(e){var t=e.lastExpiredTime;if(t=0!==t?t:1073741823,(Yo&(Qo|Wo))!==Ao)throw Error(r(327));if(Hu(),e===Xo&&t===Zo||zu(e,t),null!==Go){var n=Yo;Yo|=Qo;for(var l=Iu();;)try{Ru();break}catch(i){Mu(e,i)}if(mi(),Yo=n,Lo.current=l,Jo===jo)throw n=eu,zu(e,t),cc(e,t),Eu(e),n;if(null!==Go)throw Error(r(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Xo=null,Vu(e),Eu(e)}return null}function Pu(){if(null!==hu){var e=hu;hu=null,e.forEach(function(e,t){fc(t,e),Eu(t)}),ai()}}function _u(e,t){var n=Yo;Yo|=1;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function Nu(e,t){var n=Yo;Yo&=-2,Yo|=Vo;try{return e(t)}finally{(Yo=n)===Ao&&ai()}}function zu(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,Mn(n)),null!==Go)for(n=Go.return;null!==n;){var r=n;switch(r.tag){case 1:null!=(r=r.type.childContextTypes)&&Ml();break;case 3:$i(),Tl(Pl),Tl(Cl);break;case 5:Yi(r);break;case 4:$i();break;case 13:case 19:Tl(Xi);break;case 10:hi(r)}n=n.return}Xo=e,Go=nc(e.current,null),Zo=t,Jo=Ho,eu=null,nu=tu=1073741823,ru=null,lu=0,iu=!1}function Mu(e,t){for(;;){try{if(mi(),Ji.current=za,ia)for(var n=na.memoizedState;null!==n;){var r=n.queue;null!==r&&(r.pending=null),n=n.next}if(ta=0,la=ra=na=null,ia=!1,null===Go||null===Go.return)return Jo=jo,eu=t,Go=null;e:{var l=e,i=Go.return,a=Go,o=t;if(t=Zo,a.effectTag|=2048,a.firstEffect=a.lastEffect=null,null!==o&&\"object\"==typeof o&&\"function\"==typeof o.then){var u=o;if(0==(2&a.mode)){var c=a.alternate;c?(a.updateQueue=c.updateQueue,a.memoizedState=c.memoizedState,a.expirationTime=c.expirationTime):(a.updateQueue=null,a.memoizedState=null)}var s=0!=(1&Xi.current),f=i;do{var d;if(d=13===f.tag){var p=f.memoizedState;if(null!==p)d=null!==p.dehydrated;else{var m=f.memoizedProps;d=void 0!==m.fallback&&(!0!==m.unstable_avoidThisFallback||!s)}}if(d){var h=f.updateQueue;if(null===h){var g=new Set;g.add(u),f.updateQueue=g}else h.add(u);if(0==(2&f.mode)){if(f.effectTag|=64,a.effectTag&=-2981,1===a.tag)if(null===a.alternate)a.tag=17;else{var v=xi(1073741823,null);v.tag=2,Ti(a,v)}a.expirationTime=1073741823;break e}o=void 0,a=t;var y=l.pingCache;if(null===y?(y=l.pingCache=new Io,o=new Set,y.set(u,o)):void 0===(o=y.get(u))&&(o=new Set,y.set(u,o)),!o.has(a)){o.add(a);var b=$u.bind(null,l,u,a);u.then(b,b)}f.effectTag|=4096,f.expirationTime=t;break e}f=f.return}while(null!==f);o=Error((ye(a.type)||\"A React component\")+\" suspended while rendering, but no fallback UI was specified.\\n\\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.\"+be(a))}Jo!==qo&&(Jo=Bo),o=mo(o,a),f=i;do{switch(f.tag){case 3:u=o,f.effectTag|=4096,f.expirationTime=t,Ei(f,Fo(f,u,t));break e;case 1:u=o;var w=f.type,k=f.stateNode;if(0==(64&f.effectTag)&&(\"function\"==typeof w.getDerivedStateFromError||null!==k&&\"function\"==typeof k.componentDidCatch&&(null===fu||!fu.has(k)))){f.effectTag|=4096,f.expirationTime=t,Ei(f,Oo(f,u,t));break e}}f=f.return}while(null!==f)}Go=Uu(Go)}catch(x){t=x;continue}break}}function Iu(){var e=Lo.current;return Lo.current=za,null===e?za:e}function Fu(e,t){e<tu&&2<e&&(tu=e),null!==t&&e<nu&&2<e&&(nu=e,ru=t)}function Ou(e){e>lu&&(lu=e)}function Ru(){for(;null!==Go;)Go=Lu(Go)}function Du(){for(;null!==Go&&!ql();)Go=Lu(Go)}function Lu(e){var t=Ro(e.alternate,e,Zo);return e.memoizedProps=e.pendingProps,null===t&&(t=Uu(e)),Uo.current=null,t}function Uu(e){Go=e;do{var t=Go.alternate;if(e=Go.return,0==(2048&Go.effectTag)){if(t=fo(t,Go,Zo),1===Zo||1!==Go.childExpirationTime){for(var n=0,r=Go.child;null!==r;){var l=r.expirationTime,i=r.childExpirationTime;l>n&&(n=l),i>n&&(n=i),r=r.sibling}Go.childExpirationTime=n}if(null!==t)return t;null!==e&&0==(2048&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=Go.firstEffect),null!==Go.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=Go.firstEffect),e.lastEffect=Go.lastEffect),1<Go.effectTag&&(null!==e.lastEffect?e.lastEffect.nextEffect=Go:e.firstEffect=Go,e.lastEffect=Go))}else{if(null!==(t=po(Go)))return t.effectTag&=2047,t;null!==e&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(null!==(t=Go.sibling))return t;Go=e}while(null!==Go);return Jo===Ho&&(Jo=qo),null}function Au(e){var t=e.expirationTime;return t>(e=e.childExpirationTime)?t:e}function Vu(e){var t=ti();return ri(99,Qu.bind(null,e,t)),null}function Qu(e,t){do{Hu()}while(null!==pu);if((Yo&(Qo|Wo))!==Ao)throw Error(r(327));var n=e.finishedWork,l=e.finishedExpirationTime;if(null===n)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var i=Au(n);if(e.firstPendingTime=i,l<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:l<=e.firstSuspendedTime&&(e.firstSuspendedTime=l-1),l<=e.lastPingedTime&&(e.lastPingedTime=0),l<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===Xo&&(Go=Xo=null,Zo=0),1<n.effectTag?null!==n.lastEffect?(n.lastEffect.nextEffect=n,i=n.firstEffect):i=n:i=n.firstEffect,null!==i){var a=Yo;Yo|=Wo,Uo.current=null,Cn=Zt;var o=wn();if(kn(o)){if(\"selectionStart\"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{var c=(u=(u=o.ownerDocument)&&u.defaultView||window).getSelection&&u.getSelection();if(c&&0!==c.rangeCount){u=c.anchorNode;var s=c.anchorOffset,f=c.focusNode;c=c.focusOffset;try{u.nodeType,f.nodeType}catch(C){u=null;break e}var d=0,p=-1,m=-1,h=0,g=0,v=o,y=null;t:for(;;){for(var b;v!==u||0!==s&&3!==v.nodeType||(p=d+s),v!==f||0!==c&&3!==v.nodeType||(m=d+c),3===v.nodeType&&(d+=v.nodeValue.length),null!==(b=v.firstChild);)y=v,v=b;for(;;){if(v===o)break t;if(y===u&&++h===s&&(p=d),y===f&&++g===c&&(m=d),null!==(b=v.nextSibling))break;y=(v=y).parentNode}v=b}u=-1===p||-1===m?null:{start:p,end:m}}else u=null}u=u||{start:0,end:0}}else u=null;Pn={activeElementDetached:null,focusedElem:o,selectionRange:u},Zt=!1,uu=i;do{try{Wu()}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=i;do{try{for(o=e,u=t;null!==uu;){var w=uu.effectTag;if(16&w&&He(uu.stateNode,\"\"),128&w){var k=uu.alternate;if(null!==k){var x=k.ref;null!==x&&(\"function\"==typeof x?x(null):x.current=null)}}switch(1038&w){case 2:Co(uu),uu.effectTag&=-3;break;case 6:Co(uu),uu.effectTag&=-3,zo(uu.alternate,uu);break;case 1024:uu.effectTag&=-1025;break;case 1028:uu.effectTag&=-1025,zo(uu.alternate,uu);break;case 4:zo(uu.alternate,uu);break;case 8:No(o,s=uu,u),Eo(s)}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);if(x=Pn,k=wn(),w=x.focusedElem,u=x.selectionRange,k!==w&&w&&w.ownerDocument&&bn(w.ownerDocument.documentElement,w)){null!==u&&kn(w)&&(k=u.start,void 0===(x=u.end)&&(x=k),\"selectionStart\"in w?(w.selectionStart=k,w.selectionEnd=Math.min(x,w.value.length)):(x=(k=w.ownerDocument||document)&&k.defaultView||window).getSelection&&(x=x.getSelection(),s=w.textContent.length,o=Math.min(u.start,s),u=void 0===u.end?o:Math.min(u.end,s),!x.extend&&o>u&&(s=u,u=o,o=s),s=yn(w,o),f=yn(w,u),s&&f&&(1!==x.rangeCount||x.anchorNode!==s.node||x.anchorOffset!==s.offset||x.focusNode!==f.node||x.focusOffset!==f.offset)&&((k=k.createRange()).setStart(s.node,s.offset),x.removeAllRanges(),o>u?(x.addRange(k),x.extend(f.node,f.offset)):(k.setEnd(f.node,f.offset),x.addRange(k))))),k=[];for(x=w;x=x.parentNode;)1===x.nodeType&&k.push({element:x,left:x.scrollLeft,top:x.scrollTop});for(\"function\"==typeof w.focus&&w.focus(),w=0;w<k.length;w++)(x=k[w]).element.scrollLeft=x.left,x.element.scrollTop=x.top}Zt=!!Cn,Pn=Cn=null,e.current=n,uu=i;do{try{for(w=e;null!==uu;){var T=uu.effectTag;if(36&T&&xo(w,uu.alternate,uu),128&T){k=void 0;var E=uu.ref;if(null!==E){var S=uu.stateNode;switch(uu.tag){case 5:k=S;break;default:k=S}\"function\"==typeof E?E(k):E.current=k}}uu=uu.nextEffect}}catch(C){if(null===uu)throw Error(r(330));Ku(uu,C),uu=uu.nextEffect}}while(null!==uu);uu=null,Yl(),Yo=a}else e.current=n;if(du)du=!1,pu=e,mu=t;else for(uu=i;null!==uu;)t=uu.nextEffect,uu.nextEffect=null,uu=t;if(0===(t=e.firstPendingTime)&&(fu=null),1073741823===t?e===vu?gu++:(gu=0,vu=e):gu=0,\"function\"==typeof Yu&&Yu(n.stateNode,l),Eu(e),cu)throw cu=!1,e=su,su=null,e;return(Yo&Vo)!==Ao?null:(ai(),null)}function Wu(){for(;null!==uu;){var e=uu.effectTag;0!=(256&e)&&bo(uu.alternate,uu),0==(512&e)||du||(du=!0,li(97,function(){return Hu(),null})),uu=uu.nextEffect}}function Hu(){if(90!==mu){var e=97<mu?97:mu;return mu=90,ri(e,ju)}}function ju(){if(null===pu)return!1;var e=pu;if(pu=null,(Yo&(Qo|Wo))!==Ao)throw Error(r(331));var t=Yo;for(Yo|=Wo,e=e.current.firstEffect;null!==e;){try{var n=e;if(0!=(512&n.effectTag))switch(n.tag){case 0:case 11:case 15:case 22:wo(5,n),ko(5,n)}}catch(l){if(null===e)throw Error(r(330));Ku(e,l)}n=e.nextEffect,e.nextEffect=null,e=n}return Yo=t,ai(),!0}function Bu(e,t,n){Ti(e,t=Fo(e,t=mo(n,t),1073741823)),null!==(e=xu(e,1073741823))&&Eu(e)}function Ku(e,t){if(3===e.tag)Bu(e,e,t);else for(var n=e.return;null!==n;){if(3===n.tag){Bu(n,e,t);break}if(1===n.tag){var r=n.stateNode;if(\"function\"==typeof n.type.getDerivedStateFromError||\"function\"==typeof r.componentDidCatch&&(null===fu||!fu.has(r))){Ti(n,e=Oo(n,e=mo(t,e),1073741823)),null!==(n=xu(n,1073741823))&&Eu(n);break}}n=n.return}}function $u(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),Xo===e&&Zo===n?Jo===$o||Jo===Ko&&1073741823===tu&&ei()-au<ou?zu(e,Zo):iu=!0:uc(e,n)&&(0!==(t=e.lastPingedTime)&&t<n||(e.lastPingedTime=n,Eu(e)))}function qu(e,t){var n=e.stateNode;null!==n&&n.delete(t),0===(t=0)&&(t=wu(t=bu(),e,null)),null!==(e=xu(e,t))&&Eu(e)}Ro=function(e,t,n){var l=t.expirationTime;if(null!==e){var i=t.pendingProps;if(e.memoizedProps!==i||Pl.current)ja=!0;else{if(l<n){switch(ja=!1,t.tag){case 3:Ja(t),Wa();break;case 5:if(qi(t),4&t.mode&&1!==n&&i.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:zl(t.type)&&Ol(t);break;case 4:Ki(t,t.stateNode.containerInfo);break;case 10:l=t.memoizedProps.value,i=t.type._context,El(si,i._currentValue),i._currentValue=l;break;case 13:if(null!==t.memoizedState)return 0!==(l=t.child.childExpirationTime)&&l>=n?io(e,t,n):(El(Xi,1&Xi.current),null!==(t=co(e,t,n))?t.sibling:null);El(Xi,1&Xi.current);break;case 19:if(l=t.childExpirationTime>=n,0!=(64&e.effectTag)){if(l)return uo(e,t,n);t.effectTag|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null),El(Xi,Xi.current),!l)return null}return co(e,t,n)}ja=!1}}else ja=!1;switch(t.expirationTime=0,t.tag){case 2:if(l=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,i=Nl(t,Cl.current),vi(t,n),i=ua(null,t,l,e,i,n),t.effectTag|=1,\"object\"==typeof i&&null!==i&&\"function\"==typeof i.render&&void 0===i.$$typeof){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,zl(l)){var a=!0;Ol(t)}else a=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,wi(t);var o=l.getDerivedStateFromProps;\"function\"==typeof o&&Ni(t,l,o,e),i.updater=zi,t.stateNode=i,i._reactInternalFiber=t,Oi(t,l,e,n),t=Za(null,t,l,!0,a,n)}else t.tag=0,Ba(null,t,i,n),t=t.child;return t;case 16:e:{if(i=t.elementType,null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,ve(i),1!==i._status)throw i._result;switch(i=i._result,t.type=i,a=t.tag=tc(i),e=ci(i,e),a){case 0:t=Xa(null,t,i,e,n);break e;case 1:t=Ga(null,t,i,e,n);break e;case 11:t=Ka(null,t,i,e,n);break e;case 14:t=$a(null,t,i,ci(i.type,e),l,n);break e}throw Error(r(306,i,\"\"))}return t;case 0:return l=t.type,i=t.pendingProps,Xa(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 1:return l=t.type,i=t.pendingProps,Ga(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 3:if(Ja(t),l=t.updateQueue,null===e||null===l)throw Error(r(282));if(l=t.pendingProps,i=null!==(i=t.memoizedState)?i.element:null,ki(e,t),Si(t,l,null,n),(l=t.memoizedState.element)===i)Wa(),t=co(e,t,n);else{if((i=t.stateNode.hydrate)&&(Ra=In(t.stateNode.containerInfo.firstChild),Oa=t,i=Da=!0),i)for(n=Vi(t,null,l,n),t.child=n;n;)n.effectTag=-3&n.effectTag|1024,n=n.sibling;else Ba(e,t,l,n),Wa();t=t.child}return t;case 5:return qi(t),null===e&&Aa(t),l=t.type,i=t.pendingProps,a=null!==e?e.memoizedProps:null,o=i.children,Nn(l,i)?o=null:null!==a&&Nn(l,a)&&(t.effectTag|=16),Ya(e,t),4&t.mode&&1!==n&&i.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(Ba(e,t,o,n),t=t.child),t;case 6:return null===e&&Aa(t),null;case 13:return io(e,t,n);case 4:return Ki(t,t.stateNode.containerInfo),l=t.pendingProps,null===e?t.child=Ai(t,null,l,n):Ba(e,t,l,n),t.child;case 11:return l=t.type,i=t.pendingProps,Ka(e,t,l,i=t.elementType===l?i:ci(l,i),n);case 7:return Ba(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ba(e,t,t.pendingProps.children,n),t.child;case 10:e:{l=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value;var u=t.type._context;if(El(si,u._currentValue),u._currentValue=a,null!==o)if(u=o.value,0===(a=Gr(u,a)?0:0|(\"function\"==typeof l._calculateChangedBits?l._calculateChangedBits(u,a):1073741823))){if(o.children===i.children&&!Pl.current){t=co(e,t,n);break e}}else for(null!==(u=t.child)&&(u.return=t);null!==u;){var c=u.dependencies;if(null!==c){o=u.child;for(var s=c.firstContext;null!==s;){if(s.context===l&&0!=(s.observedBits&a)){1===u.tag&&((s=xi(n,null)).tag=2,Ti(u,s)),u.expirationTime<n&&(u.expirationTime=n),null!==(s=u.alternate)&&s.expirationTime<n&&(s.expirationTime=n),gi(u.return,n),c.expirationTime<n&&(c.expirationTime=n);break}s=s.next}}else o=10===u.tag&&u.type===t.type?null:u.child;if(null!==o)o.return=u;else for(o=u;null!==o;){if(o===t){o=null;break}if(null!==(u=o.sibling)){u.return=o.return,o=u;break}o=o.return}u=o}Ba(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,l=(a=t.pendingProps).children,vi(t,n),l=l(i=yi(i,a.unstable_observedBits)),t.effectTag|=1,Ba(e,t,l,n),t.child;case 14:return a=ci(i=t.type,t.pendingProps),$a(e,t,i,a=ci(i.type,a),l,n);case 15:return qa(e,t,t.type,t.pendingProps,l,n);case 17:return l=t.type,i=t.pendingProps,i=t.elementType===l?i:ci(l,i),null!==e&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,zl(l)?(e=!0,Ol(t)):e=!1,vi(t,n),Ii(t,l,i),Oi(t,l,i,n),Za(null,t,l,!0,e,n);case 19:return uo(e,t,n)}throw Error(r(156,t.tag))};var Yu=null,Xu=null;function Gu(e){if(\"undefined\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var n=t.inject(e);Yu=function(e){try{t.onCommitFiberRoot(n,e,void 0,64==(64&e.current.effectTag))}catch(r){}},Xu=function(e){try{t.onCommitFiberUnmount(n,e)}catch(r){}}}catch(r){}return!0}function Zu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childExpirationTime=this.expirationTime=0,this.alternate=null}function Ju(e,t,n,r){return new Zu(e,t,n,r)}function ec(e){return!(!(e=e.prototype)||!e.isReactComponent)}function tc(e){if(\"function\"==typeof e)return ec(e)?1:0;if(null!=e){if((e=e.$$typeof)===ce)return 11;if(e===de)return 14}return 2}function nc(e,t){var n=e.alternate;return null===n?((n=Ju(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.effectTag=0,n.nextEffect=null,n.firstEffect=null,n.lastEffect=null),n.childExpirationTime=e.childExpirationTime,n.expirationTime=e.expirationTime,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{expirationTime:t.expirationTime,firstContext:t.firstContext,responders:t.responders},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function rc(e,t,n,l,i,a){var o=2;if(l=e,\"function\"==typeof e)ec(e)&&(o=1);else if(\"string\"==typeof e)o=5;else e:switch(e){case re:return lc(n.children,i,a,t);case ue:o=8,i|=7;break;case le:o=8,i|=1;break;case ie:return(e=Ju(12,n,t,8|i)).elementType=ie,e.type=ie,e.expirationTime=a,e;case se:return(e=Ju(13,n,t,i)).type=se,e.elementType=se,e.expirationTime=a,e;case fe:return(e=Ju(19,n,t,i)).elementType=fe,e.expirationTime=a,e;default:if(\"object\"==typeof e&&null!==e)switch(e.$$typeof){case ae:o=10;break e;case oe:o=9;break e;case ce:o=11;break e;case de:o=14;break e;case pe:o=16,l=null;break e;case me:o=22;break e}throw Error(r(130,null==e?e:typeof e,\"\"))}return(t=Ju(o,n,t,i)).elementType=e,t.type=l,t.expirationTime=a,t}function lc(e,t,n,r){return(e=Ju(7,e,r,t)).expirationTime=n,e}function ic(e,t,n){return(e=Ju(6,e,null,t)).expirationTime=n,e}function ac(e,t,n){return(t=Ju(4,null!==e.children?e.children:[],e.key,t)).expirationTime=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function oc(e,t,n){this.tag=t,this.current=null,this.containerInfo=e,this.pingCache=this.pendingChildren=null,this.finishedExpirationTime=0,this.finishedWork=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=n,this.callbackNode=null,this.callbackPriority=90,this.lastExpiredTime=this.lastPingedTime=this.nextKnownPendingLevel=this.lastSuspendedTime=this.firstSuspendedTime=this.firstPendingTime=0}function uc(e,t){var n=e.firstSuspendedTime;return e=e.lastSuspendedTime,0!==n&&n>=t&&e<=t}function cc(e,t){var n=e.firstSuspendedTime,r=e.lastSuspendedTime;n<t&&(e.firstSuspendedTime=t),(r>t||0===n)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function sc(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var n=e.firstSuspendedTime;0!==n&&(t>=n?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function fc(e,t){var n=e.lastExpiredTime;(0===n||n>t)&&(e.lastExpiredTime=t)}function dc(e,t,n,l){var i=t.current,a=bu(),o=Pi.suspense;a=wu(a,i,o);e:if(n){t:{if(nt(n=n._reactInternalFiber)!==n||1!==n.tag)throw Error(r(170));var u=n;do{switch(u.tag){case 3:u=u.stateNode.context;break t;case 1:if(zl(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break t}}u=u.return}while(null!==u);throw Error(r(171))}if(1===n.tag){var c=n.type;if(zl(c)){n=Fl(n,c,u);break e}}n=u}else n=Sl;return null===t.context?t.context=n:t.pendingContext=n,(t=xi(a,o)).payload={element:e},null!==(l=void 0===l?null:l)&&(t.callback=l),Ti(i,t),ku(i,a),a}function pc(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 5:default:return e.child.stateNode}}function mc(e,t){null!==(e=e.memoizedState)&&null!==e.dehydrated&&e.retryTime<t&&(e.retryTime=t)}function hc(e,t){mc(e,t),(e=e.alternate)&&mc(e,t)}function gc(e,t,n){var r=new oc(e,t,n=null!=n&&!0===n.hydrate),l=Ju(3,null,null,2===t?7:1===t?3:0);r.current=l,l.stateNode=r,wi(l),e[Ln]=r.current,n&&0!==t&&It(e,9===e.nodeType?e:e.ownerDocument),this._internalRoot=r}function vc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||\" react-mount-point-unstable \"!==e.nodeValue))}function yc(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute(\"data-reactroot\"))),!t)for(var n;n=e.lastChild;)e.removeChild(n);return new gc(e,0,t?{hydrate:!0}:void 0)}function bc(e,t,n,r,l){var i=n._reactRootContainer;if(i){var a=i._internalRoot;if(\"function\"==typeof l){var o=l;l=function(){var e=pc(a);o.call(e)}}dc(t,a,e,l)}else{if(i=n._reactRootContainer=yc(n,r),a=i._internalRoot,\"function\"==typeof l){var u=l;l=function(){var e=pc(a);u.call(e)}}Nu(function(){dc(t,a,e,l)})}return pc(a)}function wc(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:ne,key:null==r?null:\"\"+r,children:e,containerInfo:t,implementation:n}}function kc(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!vc(t))throw Error(r(200));return wc(e,t,null,n)}gc.prototype.render=function(e){dc(e,this._internalRoot,null,null)},gc.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;dc(null,e,null,function(){t[Ln]=null})},bt=function(e){if(13===e.tag){var t=ui(bu(),150,100);ku(e,t),hc(e,t)}},wt=function(e){13===e.tag&&(ku(e,3),hc(e,3))},kt=function(e){if(13===e.tag){var t=bu();ku(e,t=wu(t,e,null)),hc(e,t)}},C=function(e,t,n){switch(t){case\"input\":if(_e(e,n),t=n.name,\"radio\"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(\"input[name=\"+JSON.stringify(\"\"+t)+'][type=\"radio\"]'),t=0;t<n.length;t++){var l=n[t];if(l!==e&&l.form===e.form){var i=Qn(l);if(!i)throw Error(r(90));Ee(l),_e(l,i)}}}break;case\"textarea\":De(e,n);break;case\"select\":null!=(t=n.value)&&Fe(e,!!n.multiple,t,!1)}},I=_u,F=function(e,t,n,r,l){var i=Yo;Yo|=4;try{return ri(98,e.bind(null,t,n,r,l))}finally{(Yo=i)===Ao&&ai()}},O=function(){(Yo&(1|Qo|Wo))===Ao&&(Pu(),Hu())},R=function(e,t){var n=Yo;Yo|=2;try{return e(t)}finally{(Yo=n)===Ao&&ai()}};var xc={Events:[An,Vn,Qn,E,k,qn,function(e){ut(e,$n)},z,M,rn,ft,Hu,{current:!1}]};!function(e){var n=e.findFiberByHostInstance;Gu(t({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:G.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=at(e))?null:e.stateNode},findFiberByHostInstance:function(e){return n?n(e):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))}({findFiberByHostInstance:Un,bundleType:0,version:\"16.14.0\",rendererPackageName:\"react-dom\"}),exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xc,exports.createPortal=kc,exports.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternalFiber;if(void 0===t){if(\"function\"==typeof e.render)throw Error(r(188));throw Error(r(268,Object.keys(e)))}return e=null===(e=at(t))?null:e.stateNode},exports.flushSync=function(e,t){if((Yo&(Qo|Wo))!==Ao)throw Error(r(187));var n=Yo;Yo|=1;try{return ri(99,e.bind(null,t))}finally{Yo=n,ai()}},exports.hydrate=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!0,n)},exports.render=function(e,t,n){if(!vc(t))throw Error(r(200));return bc(null,e,t,!1,n)},exports.unmountComponentAtNode=function(e){if(!vc(e))throw Error(r(40));return!!e._reactRootContainer&&(Nu(function(){bc(null,null,e,!1,function(){e._reactRootContainer=null,e[Ln]=null})}),!0)},exports.unstable_batchedUpdates=_u,exports.unstable_createPortal=function(e,t){return kc(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},exports.unstable_renderSubtreeIntoContainer=function(e,t,n,l){if(!vc(n))throw Error(r(200));if(null==e||void 0===e._reactInternalFiber)throw Error(r(38));return bc(e,t,n,!1,l)},exports.version=\"16.14.0\";\n},{\"react\":\"n8MK\",\"object-assign\":\"J4Nk\",\"scheduler\":\"MDSO\"}],\"NKHc\":[function(require,module,exports) {\n\"use strict\";function _(){if(\"undefined\"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&\"function\"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_)}catch(O){console.error(O)}}}_(),module.exports=require(\"./cjs/react-dom.production.min.js\");\n},{\"./cjs/react-dom.production.min.js\":\"i17t\"}],\"zm2Q\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.customAlphabet=exports.nanoid=void 0;let e=\"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\",t=(e,t)=>()=>{let o=\"\",r=t;for(;r--;)o+=e[Math.random()*e.length|0];return o};exports.customAlphabet=t;let o=(t=21)=>{let o=\"\",r=t;for(;r--;)o+=e[64*Math.random()|0];return o};exports.nanoid=o;\n},{}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"Sn21\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=r,exports.R=void 0;class t{constructor(t){const e=s();this.c=1,this.s0=e(\" \"),this.s1=e(\" \"),this.s2=e(\" \"),this.s0-=e(t),this.s0<0&&(this.s0+=1),this.s1-=e(t),this.s1<0&&(this.s1+=1),this.s2-=e(t),this.s2<0&&(this.s2+=1)}next(){const t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=t-(this.c=Math.trunc(t))}}function s(){let t=4022871197;return function(s){const e=s.toString();for(let r=0;r<e.length;r++){let s=.02519603282416938*(t+=e.charCodeAt(r));s-=t=s>>>0,t=(s*=t)>>>0,t+=4294967296*(s-=t)}return 2.3283064365386963e-10*(t>>>0)}}function e(t,s){return s.c=t.c,s.s0=t.s0,s.s1=t.s1,s.s2=t.s2,s}function r(s,r){const n=new t(s),i=n.next.bind(n);return r&&e(r,n),i.state=(()=>e(n,{})),i}class n{constructor(t){this.state=t||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const t=this.state,s=r(t.prngstate?\"\":t.seed,t.prngstate),e=s();return this.state={...t,prngstate:s.state()},e}api(){const t=this._random.bind(this),s={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},e={};for(const r in s){const n=s[r];e[r]=(s=>void 0===s?Math.floor(t()*n)+1:Array.from({length:s}).map(()=>Math.floor(t()*n)+1))}return{...e,Die:function(s=6,e){return void 0===e?Math.floor(t()*s)+1:Array.from({length:e}).map(()=>Math.floor(t()*s)+1)},Number:()=>t(),Shuffle:s=>{const e=[...s];let r=s.length,n=0;const i=Array.from({length:r});for(;r;){const s=Math.trunc(r*t());i[n++]=e[s],e[s]=e[--r]}return i},_private:this}}}const i={name:\"random\",noClient:({api:t})=>t._private.isUsed(),flush:({api:t})=>t._private.getState(),api:({data:t})=>{return new n(t).api()},setup:({game:t})=>{let{seed:s}=t;return void 0===s&&(s=n.seed()),{seed:s}},playerView:()=>void 0};exports.R=i;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"MZmr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ae,exports.U=ne,exports.a=X,exports.b=Z,exports.c=ee,exports.e=B,exports.i=C,exports.z=exports.y=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.T=exports.S=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=a(require(\"immer\")),t=require(\"./plugin-random-087f861e.js\"),r=a(require(\"lodash.isplainobject\"));function a(e){return e&&e.__esModule?e:{default:e}}const n=\"MAKE_MOVE\";exports.M=n;const s=\"GAME_EVENT\";exports.o=s;const o=\"REDO\";exports.R=o;const i=\"RESET\";exports.l=i;const l=\"SYNC\";exports.j=l;const p=\"UNDO\";exports.h=p;const c=\"UPDATE\";exports.k=c;const d=\"PATCH\";exports.P=d;const u=\"PLUGIN\";exports.d=u;const y=\"STRIP_TRANSIENTS\";exports.p=y;const v=(e,t,r,a)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:a}});exports.B=v;const g=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a}});exports.g=g;const x=(e,t,r,a)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:a},automatic:!0}),h=e=>({type:l,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=h;const m=(e,t,r,a)=>({type:d,prevStateID:e,stateID:t,patch:r,deltalog:a,clientOnly:!0});exports.y=m;const f=(e,t)=>({type:c,state:e,deltalog:t,clientOnly:!0});exports.z=f;const P=e=>({type:i,state:e,clientOnly:!0});exports.u=P;const E=(e,t)=>({type:p,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=E;const O=(e,t)=>({type:o,payload:{type:null,args:null,playerID:e,credentials:t}});exports.w=O;const _=(e,t,r,a)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:a}}),M=()=>({type:y});exports.r=M;var N=Object.freeze({__proto__:null,makeMove:v,gameEvent:g,automaticGameEvent:x,sync:h,patch:m,update:f,reset:P,undo:E,redo:O,plugin:_,stripTransients:M});exports.A=N;const T=\"INVALID_MOVE\";exports.n=T;const I={name:\"plugin-immer\",fnWrap:t=>(r,a,...n)=>{let s=!1;const o=(0,e.default)(r,e=>{const r=t(e,a,...n);if(r!==T)return r;s=!0});return s?T:o}};var A,S;exports.G=A,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(A||(exports.G=A={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(S||(S={}));class b{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let a=0;a<this.dispatch.length;a++){const t=this.dispatch[a],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,S.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,S.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case A.TURN_ON_END:case A.PHASE_ON_END:return r(t.error,S.StageEventInOnEnd);case A.PHASE_ON_BEGIN:return r(t.error,S.StageEventInPhaseBegin);case A.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,S.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===A.TURN_ON_END||t.calledFrom===A.PHASE_ON_END)return r(t.error,S.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===A.PHASE_ON_END)return r(t.error,S.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const s=x(t.type,t.args,this.playerID);e=this.flow.processEvent(e,s)}return e}}const D={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,a,...n)=>{const s=a.events;return s&&s._private.updateTurnContext(a,t),r=e(r,a,...n),s&&s._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new b(e.flow,t,r).api()},G={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function U(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,r.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!U(e[t]))return!1;return!0}const R={name:\"plugin-serializable\",fnWrap:e=>(t,r,...a)=>{const n=e(t,r,...a);return n}},k=!0,L=()=>{},w=(...e)=>console.error(...e);function C(e){L(`INFO: ${e}`)}function B(e){w(\"ERROR:\",e)}const j=[I,t.R,G,R],F=[...j,D],H=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[a]:{...n,data:s}}}}),e);exports.f=H;const V=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=V;const $=(e,t,r)=>[...j,...r,D].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=$;const q=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const a=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[a]:{data:n}}}}),e);exports.t=q;const W=(e,t)=>([...F,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}},s=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[a]:{...n,api:s}}}}),e);exports.m=W;const z=(e,t)=>([...j,...t.game.plugins,D].reverse().forEach(r=>{const a=r.name,n=e.plugins[a]||{data:{}};if(r.flush){const a=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}else if(r.dangerouslyFlushRawState){const s=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[a].data;e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}}),e),K=(e,t)=>[...F,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const a=r.name,n=e.plugins[a];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=K;const Y=(e,t)=>{return[...F,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:a}=r,n=e.plugins[a],s=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!s&&{plugin:a,message:s}}).find(e=>e)||!1},J=(e,t)=>{const r=z(e,t),a=Y(r,t);if(!a)return[r];const{plugin:n,message:s}=a;return B(`${n} plugin declared action invalid:\\n${s}`),[e,a]};exports.q=J;const Q=({G:e,ctx:t,plugins:r={}},{game:a,playerID:n})=>([...F,...a.plugins].forEach(({name:s,playerView:o})=>{if(!o)return;const{data:i}=r[s]||{data:{}},l=o({G:e,ctx:t,game:a,data:i,playerID:n});r={...r,[s]:{data:l}}}),r);function X(e,t=!1){e.moveLimit&&(t&&(e.minMoves=e.moveLimit),e.maxMoves=e.moveLimit,delete e.moveLimit)}function Z(e,t){let r={},a=[],n=null,s={},o={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=oe.NULL),r=e}else{if(X(t),t.next&&(n=t.next),t.revert&&(a=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMinMoves:e._activePlayersMinMoves,_activePlayersMaxMoves:e._activePlayersMaxMoves,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&te(r,s,o,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let a=0;a<e.playOrder.length;a++){const n=e.playOrder[a];n!==e.currentPlayer&&te(r,s,o,n,t.others)}if(void 0!==t.all)for(let a=0;a<e.playOrder.length;a++){te(r,s,o,e.playOrder[a],t.all)}if(t.value)for(const e in t.value)te(r,s,o,e,t.value[e]);if(t.minMoves)for(const e in r)void 0===s[e]&&(s[e]=t.minMoves);if(t.maxMoves)for(const e in r)void 0===o[e]&&(o[e]=t.maxMoves)}0===Object.keys(r).length&&(r=null),0===Object.keys(s).length&&(s=null),0===Object.keys(o).length&&(o=null);const i={};for(const l in r)i[l]=0;return{...e,activePlayers:r,_activePlayersMinMoves:s,_activePlayersMaxMoves:o,_activePlayersNumMoves:i,_prevActivePlayers:a,_nextActivePlayers:n}}function ee(e){let{activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s,_nextActivePlayers:o}=e;if(t&&0===Object.keys(t).length)if(o)e=Z(e,o),({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}=e);else if(s.length>0){const e=s.length-1;({activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n}=s[e]),s=s.slice(0,e)}else t=null,r=null,a=null;return{...e,activePlayers:t,_activePlayersMinMoves:r,_activePlayersMaxMoves:a,_activePlayersNumMoves:n,_prevActivePlayers:s}}function te(e,t,r,a,n){\"object\"==typeof n&&n!==oe.NULL||(n={stage:n}),void 0!==n.stage&&(X(n),e[a]=n.stage,n.minMoves&&(t[a]=n.minMoves),n.maxMoves&&(r[a]=n.maxMoves))}function re(e,t){return e[t]+\"\"}function ae(e,t){let{G:r,ctx:a}=e;const{numPlayers:n}=a,s=V(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,s));const l=o.first(r,s),p=typeof l;\"number\"!==p&&B(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=re(i,l);return a=Z(a={...a,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function ne(e,t,r,a){const n=r.order;let{G:s,ctx:o}=e,i=o.playOrderPos,l=!1;if(a&&!0!==a)\"object\"!=typeof a&&B(`invalid argument to endTurn: ${a}`),Object.keys(a).forEach(e=>{switch(e){case\"remove\":t=re(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(a.next),t=a.next;break;default:B(`invalid argument to endTurn: ${e}`)}});else{const r=V(e),a=n.next(s,r),p=typeof a;void 0!==a&&\"number\"!==p&&B(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${a}”.`),void 0===a?l=!0:(i=a,t=re(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.x=Q;const se={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=se;const oe={NULL:null};exports.S=oe;const ie={ALL:{all:oe.NULL},ALL_ONCE:{all:oe.NULL,minMoves:1,maxMoves:1},OTHERS:{others:oe.NULL},OTHERS_ONCE:{others:oe.NULL,minMoves:1,maxMoves:1}};exports.C=ie;\n},{\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)e=o,\"__proto__\"!=(n=this.tokens[r])&&\"constructor\"!=n&&\"prototype\"!=n&&(o=(e||{})[n]);return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"iEGk\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=g,exports.I=i,exports.P=s,exports.T=void 0;var e,t,n=require(\"./turn-order-0b7dce3d.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:s,plugins:i}){void 0===e&&(e={}),void 0===s&&(s={}),void 0===i&&(i=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const c={...t};\"\"in c&&(0,n.e)(\"cannot specify phase with empty name\"),c[\"\"]={};const u={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,i);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const B in c){const e=c[B];if(!0===e.start&&(d=B),void 0!==e.moves)for(const t of Object.keys(e.moves))u[B+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={}),(0,n.a)(e.turn,!0);for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){u[B+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?c[e.phase]:c[\"\"]}function g(e){return e}function m(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:s,...i}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const c=[];if(e=o(e,{...i,arg:s,next:c}),o===w)break;const u=G(e);if(u){t.push({fn:w,arg:u,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([g,M,D].includes(o)){const n=b(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...c)}}return e}function x(e,{next:t}){return t.push({fn:h}),e}function h(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.b)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const s=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:s,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:s}=e;if(t&&t.next){if(!(t.next in c))return(0,n.e)(\"invalid phase: \"+t.next),e;s={...s,phase:t.next}}else s={...s,phase:o.wrapped.next(e)||null};return e={...e,ctx:s},a.push({fn:h}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:s}=e;const i=y(s),{endPhase:c,ctx:u}=(0,n.U)(e,a,i.turn,t);return s=u,e={...e,G:o,ctx:s},c?r.push({fn:N,turn:s.turn,phase:s.phase}):r.push({fn:I,currentPlayer:s.currentPlayer}),e}function M(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.S.NULL||(t={stage:t}),\"object\"!=typeof t)return e;(0,n.a)(t);let{ctx:r}=e,{activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,c[a]=0,t.minMoves&&(null===s&&(s={}),s[a]=t.minMoves),t.maxMoves&&(null===i&&(i={}),i[a]=t.maxMoves)),r={...r,activePlayers:o,_activePlayersMinMoves:s,_activePlayersMaxMoves:i,_activePlayersNumMoves:c},{...e,ctx:r}}function D(e,{arg:t}){return{...e,ctx:(0,n.b)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function b(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.maxMoves&&n>=t.turn.maxMoves)||t.turn.wrapped.endIf(e)}function w(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:s,turn:i}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:s}),null===s)return e;const c=y(e.ctx).wrapped.onEnd(e),u={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:i,phase:s};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:c,ctx:u,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:s,playerID:i}){if(r!==e.ctx.turn)return e;const{currentPlayer:c,numMoves:u,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=u||0;if(!o&&p.turn.minMoves&&v<p.turn.minMoves)return(0,n.i)(`cannot end turn before making ${p.turn.minMoves} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:c});let g={...e.ctx,activePlayers:null};if(t&&t.remove){i=i||c;const t=g.playOrder.filter(e=>e!=i),n=g.playOrderPos>t.length-1?0:g.playOrderPos;if(g={...g,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const m=(0,n.g)(\"endTurn\",t),{_stateID:x}=e,h={action:m,_stateID:x,turn:d,phase:l};s&&(h.automatic=!0);const I=[...e.deltalog||[],h];return{...e,G:f,ctx:g,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:s,_stateID:i}=e,{activePlayers:c,_activePlayersNumMoves:u,_activePlayersMinMoves:l,_activePlayersMaxMoves:d,phase:p,turn:v}=s;const f=null!==c&&o in c,g=y(s);if(!t&&f){const e=g.turn.stages[c[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:M,arg:t,playerID:o}),!f)return e;const m=u[o]||0;if(l&&l[o]&&m<l[o])return(0,n.i)(`cannot end stage before making ${l[o]} moves`),e;delete(c={...c})[o],l&&delete(l={...l})[o],d&&delete(d={...d})[o],s=(0,n.c)({...s,activePlayers:c,_activePlayersMinMoves:l,_activePlayersMaxMoves:d});const x={action:(0,n.g)(\"endStage\",t),_stateID:i,turn:v,phase:p};r&&(x.automatic=!0);const h=[...e.deltalog||[],x];return{...e,ctx:s,deltalog:h}}function S(t,a,r){const o=y(t),s=o.turn.stages,{activePlayers:i}=t;if(i&&void 0!==i[r]&&i[r]!==n.S.NULL&&void 0!==s[i[r]]&&void 0!==s[i[r]].moves){const e=s[i[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const U={endStage:function(e,t){return m(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return m(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return m(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return m(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return m(e,[{fn:w,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return m(e,[{fn:D,arg:n}])}},T=[];return!1!==s.endTurn&&T.push(\"endTurn\"),!1!==s.pass&&T.push(\"pass\"),!1!==s.endPhase&&T.push(\"endPhase\"),!1!==s.setPhase&&T.push(\"setPhase\"),!1!==s.endGame&&T.push(\"endGame\"),!1!==s.setActivePlayers&&T.push(\"setActivePlayers\"),!1!==s.endStage&&T.push(\"endStage\"),!1!==s.setStage&&T.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>m(e,[{fn:x}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:U,eventNames:Object.keys(U),enabledEventNames:T,moveMap:u,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{currentPlayer:r,activePlayers:o,_activePlayersMaxMoves:s}=e.ctx,i=S(e.ctx,a,n),c=!i||\"function\"==typeof i||!0!==i.noLimit;let{numMoves:u,_activePlayersNumMoves:l}=e.ctx;c&&(n===r&&u++,o&&l[n]++),e={...e,ctx:{...e.ctx,numMoves:u,_activePlayersNumMoves:l}},s&&l[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const d=y(e.ctx).turn.wrapped.onMove({...e,ctx:{...e.ctx,playerID:n}});return m(e={...e,G:d},[{fn:g}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof U[n]?e:U[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function s(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(i(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),s={...(0,n.E)(a),playerID:r.playerID};let i=[];return void 0!==r.args&&(i=Array.isArray(r.args)?r.args:[r.args]),t(a.G,s,...i)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function i(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const c=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,u=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,s]=(0,n.q)(e,r);return s?[o,f(a,t.PluginActionInvalid,s)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.p:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.r)()),{...r,transients:t}):r}}};function g({game:r,isClient:o}){return r=s(r),(s=null,i)=>{let[y]=v(s);switch(i.type){case n.p:return y;case n.o:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed event: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:!1,playerID:i.payload.playerID});let e,a=r.flow.processEvent(y,i);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:i}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,i.payload.type,i.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(c(i)&&!r.flow.isPlayerActive(y.G,y.ctx,i.payload.playerID))return(0,n.e)(`disallowed move: ${i.payload.type}`),f(y,t.InactivePlayer);y=(0,n.m)(y,{game:r,isClient:o,playerID:i.payload.playerID});const s=r.processMove(y,i.payload);if(s===n.n)return(0,n.e)(`invalid move: ${i.payload.type} args: ${i.payload.args}`),f(y,t.InvalidMove);const u={...y,G:s};if(o&&(0,n.N)(u,{game:r}))return y;if(y=u,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,i,a),y=r.flow.processMove(y,i.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:i}),{...y,_stateID:y._stateID+1})}case n.l:case n.k:case n.j:return i.state;case n.h:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:s,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(c(i)&&i.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!u(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,i),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...s]}}case n.R:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const s=a[0];return c(i)&&i.payload.playerID!==s.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,i),{...y,G:s.G,ctx:s.ctx,plugins:s.plugins,_stateID:o+1,_undo:[...e,s],_redo:a.slice(1)})}case n.d:return(0,n.f)(y,i,{game:r});case n.P:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,i.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(i.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"lU15\":[function(require,module,exports) {\nvar global = arguments[3];\nvar process = require(\"process\");\nvar e=arguments[3],t=require(\"process\");!function(e,n){\"use strict\";if(!e.setImmediate){var a,s,o,c,i,r=1,f={},u=!1,l=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,\"[object process]\"==={}.toString.call(e.process)?a=function(e){t.nextTick(function(){m(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(\"\",\"*\"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},a=function(e){o.port2.postMessage(e)}):l&&\"onreadystatechange\"in l.createElement(\"script\")?(s=l.documentElement,a=function(e){var t=l.createElement(\"script\");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):a=function(e){setTimeout(m,0,e)}:(c=\"setImmediate$\"+Math.random()+\"$\",i=function(t){t.source===e&&\"string\"==typeof t.data&&0===t.data.indexOf(c)&&m(+t.data.slice(c.length))},e.addEventListener?e.addEventListener(\"message\",i,!1):e.attachEvent(\"onmessage\",i),a=function(t){e.postMessage(c+t,\"*\")}),d.setImmediate=function(e){\"function\"!=typeof e&&(e=new Function(\"\"+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var s={callback:e,args:t};return f[r]=s,a(r),r++},d.clearImmediate=g}function g(e){delete f[e]}function m(e){if(u)setTimeout(m,0,e);else{var t=f[e];if(t){u=!0;try{!function(e){var t=e.callback,a=e.args;switch(a.length){case 0:t();break;case 1:t(a[0]);break;case 2:t(a[0],a[1]);break;case 3:t(a[0],a[1],a[2]);break;default:t.apply(n,a)}}(t)}finally{g(e),u=!1}}}}}(\"undefined\"==typeof self?void 0===e?this:e:self);\n},{\"process\":\"pBGv\"}],\"pO2S\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=o,exports.a=c,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./plugin-random-087f861e.js\"),r=require(\"./reducer-07c7b307.js\");require(\"setimmediate\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:r}){this._opts[t]={range:e,value:r}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,r,a){return this.enumerateFn(e,r,a).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.B)(e.move,e.args,a):\"event\"in e?(0,t.g)(e.event,e.args,a):void 0)}random(t){let r;if(void 0!==this.seed){const t=this.prngstate?\"\":this.seed,a=(0,e.a)(t,this.prngstate);r=a(),this.prngstate=a.state()}else r=Math.random();if(t){if(Array.isArray(t)){return t[Math.floor(r*t.length)]}return Math.floor(r*t)}return r}}exports.B=a;const s=25;class i extends a{constructor({enumerate:t,seed:e,objectives:a,game:s,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:e}),void 0===a&&(a=(()=>({}))),this.objectives=a,this.iterationCallback=o||(()=>{}),this.reducer=(0,r.C)({game:s}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:r,playerID:a}){const{G:s,ctx:i}=t;let n=[],o=[];if(void 0!==a)n=this.enumerate(s,i,a),o=this.objectives(s,i,a);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(s,i,c)),o.push(this.objectives(s,i,c));else n=this.enumerate(s,i,i.currentPlayer),o=this.objectives(s,i,i.currentPlayer);return{state:t,parent:r,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,r=0;for(const a of t.children){const s=a.visits+Number.EPSILON,i=a.value/s+Math.sqrt(2*Math.log(t.visits)/s);(null==e||i>r)&&(r=i,e=a)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const r=this.random(e.length),a=e[r];t.actions.splice(r,1);const s=this.reducer(t.state,a),i=this.createNode({state:s,parentAction:a,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let r=0;r<e&&void 0===t.ctx.gameover;r++){const{G:e,ctx:r}=t;let a=r.currentPlayer;r.activePlayers&&(a=Object.keys(r.activePlayers)[0]);const s=this.enumerate(e,r,a),i=this.objectives(e,r,a),n=Object.keys(i).reduce((t,a)=>{const s=i[a];return s.checker(e,r)?t+s.weight:t},0);if(n>0)return{score:n};if(!s||0===s.length)return;const o=this.random(s.length);t=this.reducer(t,s[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const r=this.createNode({state:t,playerID:e});let a=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(a=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of r.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:r}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<a;t++){const t=this.select(r),e=this.expand(t),a=this.playout(e);this.backpropagate(e,a),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:a,metadata:r})};if(this.iterationCounter=0,this.getOpt(\"async\")){const r=()=>{this.iterationCounter<a?(e(),setImmediate(r)):t(i())};r()}else{for(;this.iterationCounter<a;)e();t(i())}})}}exports.M=i;class n extends a{play({G:t,ctx:e},r){const a=this.enumerate(t,e,r);return Promise.resolve({action:this.random(a)})}}async function o(t,e){const r=t.store.getState();let a=r.ctx.currentPlayer;r.ctx.activePlayers&&(a=Object.keys(r.ctx.activePlayers)[0]);const{action:s,metadata:i}=await e.play(r,a);if(s){const e={...s,payload:{...s.payload,metadata:i}};return t.store.dispatch(e),e}}async function c({game:t,bots:e,state:s,depth:i}){void 0===i&&(i=1e4);const n=(0,r.C)({game:t});let o=null,c=0;for(;void 0===s.ctx.gameover&&c<i;){let t=s.ctx.currentPlayer;s.ctx.activePlayers&&(t=Object.keys(s.ctx.activePlayers)[0]);const r=e instanceof a?e:e[t],i=await r.play(s,t);if(!i.action)break;o=i.metadata,s=n(s,i.action),c++}return{state:s,metadata:o}}exports.R=n;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./plugin-random-087f861e.js\":\"Sn21\",\"./reducer-07c7b307.js\":\"iEGk\",\"setimmediate\":\"lU15\"}],\"uvSB\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\"),n=require(\"flatted\"),r=require(\"./ai-3099ce9a.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function W(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function X(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const Y=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);Y.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(Y.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),Y.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=X(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(X(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function We(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Xe(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function Ye(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},Ye)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1xg9v5h\",\".menu.svelte-1xg9v5h{display:flex;margin-top:43px;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;margin-right:-500px;transform-origin:bottom right;transform:rotate(-90deg) translate(0, -500px)}.menu-item.svelte-1xg9v5h{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1xg9v5h:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1xg9v5h:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1xg9v5h{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1xg9v5h:hover,.menu-item.svelte-1xg9v5h:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1xg9v5h\"),W(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&W(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1xg9v5h\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),W(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&W(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),W(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&W(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&W(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),W(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&W(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Wt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Xt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Yt,Xt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),W(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&W(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&W(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),W(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&W(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Wt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),W(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&W(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Wn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Xn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),W(t,\"current\",e[7]==e[0].currentPlayer),W(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&W(t,\"current\",e[7]==e[0].currentPlayer),6&o&&W(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Yn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Xn(Wn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Wn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Xn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Yn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){if(t&&(\"object\"==typeof t||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return pr(e)}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t,{ToggleVisibility:c}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager),\"ToggleVisibility\"in e&&n(3,c=e.ToggleVisibility)}),[s,r,i,c]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2,ToggleVisibility:3},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Wr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Xr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Yr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Yr,Xr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),W(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&W(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Wr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),W(t,\"clickable\",e[1].length>0),W(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&W(t,\"clickable\",e[1].length>0),1&l&&W(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),W(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&W(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[6]=t[n][0],r[7]=t[n][1],r[8]=t,r[9]=n,r}function Bl(e){let t,n,r,l;function o(){e[5].call(t,e[6])}return{c(){G(t=M(\"input\"),\"id\",n=e[3](e[6])),G(t,\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(n,a){q(n,t,a),t.checked=e[1][e[6]],r||(l=[R(t,\"change\",o),R(t,\"change\",e[2])],r=!0)},p(r,l){e=r,1&l&&n!==(n=e[3](e[6]))&&G(t,\"id\",n),3&l&&(t.checked=e[1][e[6]])},d(e){e&&I(t),r=!1,c(l)}}}function Rl(e){let t,n,r,l,o,a,s,i,u,d=e[1][e[6]]+\"\";function f(){e[4].call(l,e[6])}return{c(){t=M(\"span\"),n=N(d),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"id\",o=e[3](e[6])),G(l,\"type\",\"range\"),G(l,\"min\",a=e[7].range.min),G(l,\"max\",s=e[7].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[6]]),i||(u=[R(l,\"change\",f),R(l,\"input\",f),R(l,\"change\",e[2])],i=!0)},p(t,r){e=t,3&r&&d!==(d=e[1][e[6]]+\"\")&&F(n,d),1&r&&o!==(o=e[3](e[6]))&&G(l,\"id\",o),1&r&&a!==(a=e[7].range.min)&&G(l,\"min\",a),1&r&&s!==(s=e[7].range.max)&&G(l,\"max\",s),3&r&&H(l,e[1][e[6]])},d(e){e&&I(t),e&&I(r),e&&I(l),i=!1,c(u)}}}function Kl(e){let t,n,r,l,o,a,s=e[6]+\"\";function i(e,t){return e[7].range?Rl:\"boolean\"==typeof e[7].value?Bl:void 0}let c=i(e),u=c&&c(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),o=V(),u&&u.c(),a=V(),G(n,\"for\",l=e[3](e[6])),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),u&&u.m(t,null),A(t,a)},p(e,o){1&o&&s!==(s=e[6]+\"\")&&F(r,s),1&o&&l!==(l=e[3](e[6]))&&G(n,\"for\",l),c===(c=i(e))&&u?u.p(e,o):(u&&u.d(1),(u=c&&c(e))&&(u.c(),u.m(t,a)))},d(e){e&&I(t),u&&u.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(15&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},e=>\"ai-option-\"+e,function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Xl(Hl(e,E,c));let z=j&&Yl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[17].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[17]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Xl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Yl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Xl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Yl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"for\",\"ai-option-debug\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"id\",\"ai-option-debug\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[18]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Wl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t,{ToggleVisibility:a}=t;const{secondaryPane:s}=de(\"secondaryPane\"),i={MCTS:r.M,Random:r.R};let c=!1,u=null,d=0,f=null;const p=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,d=e),n(2,u=e/t),f=r,c&&f&&s.set({component:jl,metadata:f})};let m,g,v,$;function y(){l.overrideGameState(null),s.set(null),n(1,c=!1)}return l.game.ai&&(m=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})).setOpt(\"async\",!0),ie(y),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager),\"ToggleVisibility\"in e&&n(16,a=e.ToggleVisibility)}),[l,c,u,d,g,v,$,m,i,function(){c&&f?s.set({component:jl,metadata:f}):s.set(null)},function(){const e=i[g];n(7,m=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:p})),m.setOpt(\"async\",!0),n(5,v=null),f=null,s.set(null),n(3,d=0)},async function(){n(5,v=null),f=null,n(3,d=0);const e=await(0,r.S)(l,m);e&&(n(5,v=e.payload.type),n(6,$=e.payload.args))},function(e=1e4,t=100){return n(5,v=null),f=null,n(3,d=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,m);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,v=null),f=null,n(3,d=0),y()},function(e){27==e.keyCode&&y()},o,a,function(){g=U(this),n(4,g),n(8,i)},function(){c=this.checked,n(1,c)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15,ToggleVisibility:16},Fl)}}function oo(e){z(e,\"svelte-8ymctk\",\".debug-panel.svelte-8ymctk.svelte-8ymctk{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-8ymctk.svelte-8ymctk{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-8ymctk.svelte-8ymctk{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-8ymctk.svelte-8ymctk:hover,.visibility-toggle.svelte-8ymctk.svelte-8ymctk:focus{background:#eee}.opener.svelte-8ymctk.svelte-8ymctk{right:10px}.closer.svelte-8ymctk.svelte-8ymctk{left:-326px}@keyframes svelte-8ymctk-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-8ymctk.svelte-8ymctk{display:flex;height:100%;animation:svelte-8ymctk-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-8ymctk .icon.svelte-8ymctk{animation-direction:reverse}.pane.svelte-8ymctk.svelte-8ymctk{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-8ymctk.svelte-8ymctk{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-8ymctk button,.debug-panel.svelte-8ymctk select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-8ymctk select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-8ymctk section{margin-bottom:20px}.debug-panel.svelte-8ymctk .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u=e[10]&&io(e);(r=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var d=e[6][e[2]].component;function f(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}d&&(a=new d(f(e)));let p=e[5]&&co(e);return{c(){t=M(\"div\"),u&&u.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"div\"),a&&Be(a.$$.fragment),s=V(),p&&p.c(),G(o,\"class\",\"pane svelte-8ymctk\"),G(o,\"role\",\"region\"),G(o,\"aria-label\",e[2]),G(o,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-8ymctk\")},m(i,d){q(i,t,d),u&&u.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),a&&Re(a,o,null),e[16](o),A(t,s),p&&p.m(t,null),c=!0},p(n,l){(e=n)[10]&&u.p(e,l);const s={};4&l&&(s.pane=e[2]),r.$set(s);const i={};if(16&l&&(i.client=e[4]),1&l&&(i.clientManager=e[0]),d!==(d=e[6][e[2]].component)){if(a){_e();const e=a;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}d?(Be((a=new d(f(e))).$$.fragment),Ce(a.$$.fragment,1),Re(a,o,null)):a=null}else d&&a.$set(i);(!c||4&l)&&G(o,\"aria-label\",e[2]),e[5]?p?(p.p(e,l),32&l&&Ce(p,1)):((p=co(e)).c(),Ce(p,1),p.m(t,null)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se())},i(n){c||(Ce(u),Ce(r.$$.fragment,n),a&&Ce(a.$$.fragment,n),Ce(p),be(()=>{i||(i=De(t,We,{x:400,...e[12]},!0)),i.run(1)}),c=!0)},o(n){qe(u),qe(r.$$.fragment,n),a&&qe(a.$$.fragment,n),qe(p),i||(i=De(t,We,{x:400,...e[12]},!1)),i.run(0),c=!1},d(n){n&&I(t),u&&u.d(),Ke(r),a&&Ke(a),e[16](null),p&&p.d(),n&&i&&i.end()}}}function so(e){let t,n,r=e[10]&&uo(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,t){e[10]&&r.p(e,t)},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function io(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle closer svelte-8ymctk\"),G(t,\"title\",\"Hide Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function co(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-8ymctk\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function uo(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-8ymctk\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-8ymctk\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[14],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[13],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function fo(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-8ymctk\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[11]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function po(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(15,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,h=!h)}const y=o.client.debugOpt;let h=!y||!y.collapseOnLoad;const b=!y||!y.hideToggleButton;const x={duration:150,easing:Ze},[w,k]=Xe(x);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{32768&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,h,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,b,function(e){\".\"!=e.key?h&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},x,w,k,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class mo extends Le{constructor(e){super(),Je(this,e,po,fo,d,{clientManager:0},oo)}}exports.D=mo;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"flatted\":\"O5av\",\"./ai-3099ce9a.js\":\"pO2S\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"Wibm\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"./reducer-07c7b307.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.t)(n,{game:r}),n=(0,e.m)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.q)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\"}],\"zA0v\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class t{constructor({transportDataCallback:t,gameName:a,playerID:s,matchID:e,credentials:n,numPlayers:i}){this.connectionStatusCallback=(()=>{}),this.isConnected=!1,this.transportDataCallback=t,this.gameName=a||\"default\",this.playerID=s||null,this.matchID=e||\"default\",this.credentials=n,this.numPlayers=i||2}subscribeToConnectionStatus(t){this.connectionStatusCallback=t}setConnectionStatus(t){this.isConnected=t,this.connectionStatusCallback()}notifyClient(t){this.transportDataCallback(t)}}exports.T=t;\n},{}],\"FkTq\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid/non-secure\"),e=require(\"./Debug-fd09b8bc.js\"),s=require(\"redux\"),i=require(\"./turn-order-0b7dce3d.js\"),r=require(\"./reducer-07c7b307.js\"),a=require(\"./initialize-9ac1bbf5.js\"),n=require(\"./transport-ce07b771.js\");class h extends n.T{connect(){}disconnect(){}sendAction(){}sendChatMessage(){}requestSync(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const c=t=>new h(t);class l{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const u=new l;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const c of e)h[c]=((...e)=>{const h=i.A[t](c,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:l,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g||\"default\",this.credentials=d,this.multiplayer=l,this.debugOpt=n,this.manager=u,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==l}),this.initialState=null,l||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.u)(this.initialState))}),this.undo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.w)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.p||this.transport.sendAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.o:case i.h:case i.R:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.l:this.log=[];break;case i.P:case i.k:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.j:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),l||(l=c),this.transport=l({transportDataCallback:t=>this.receiveTransportData(t),gameKey:e,game:this.game,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.sendChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})})}receiveMatchData(t){this.matchData=t,this.notifySubscribers()}receiveChatMessage(t){this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()}receiveTransportData(t){const[e]=t.args;if(e===this.matchID)switch(t.type){case\"sync\":{const[,e]=t.args,s=(0,i.s)(e);this.receiveMatchData(e.filteredMetadata),this.store.dispatch(s);break}case\"update\":{const[,e,s]=t.args,r=this.store.getState();if(e._stateID>=r._stateID){const t=(0,i.z)(e,s);this.store.dispatch(t)}break}case\"patch\":{const[,e,s,r,a]=t.args,n=this.store.getState()._stateID;if(e!==n)break;const h=(0,i.y)(e,s,r,a);this.store.dispatch(h),this.store.getState()._stateID===n&&this.transport.requestSync();break}case\"matchData\":{const[,e]=t.args;this.receiveMatchData(e);break}case\"chat\":{const[,e]=t.args;this.receiveChatMessage(e);break}}}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribeToConnectionStatus(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.x)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\"}],\"mOPV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const e=(e,t)=>{if(!e||\"string\"!=typeof e)throw new Error(`Expected ${t} string, got \"${e}\".`)},t=t=>e(t,\"game name\"),s=t=>e(t,\"match ID\"),r=(e,t)=>{if(!e)throw new Error(`Expected body, got “${e}”.`);for(const s in t){const r=t[s],a=Array.isArray(r)?r:[r],n=e[s];if(!a.includes(typeof n)){const e=a.join(\"|\");throw new TypeError(`Expected body.${s} to be of type ${e}, got “${n}”.`)}}};class a extends Error{constructor(e,t){super(e),this.details=t}}exports.a=a;class n{constructor({server:e=\"\"}={}){this.server=e.replace(/\\/$/,\"\")}async request(e,t){const s=await fetch(this.server+e,t);if(!s.ok){let e;try{e=await s.clone().json()}catch{try{e=await s.text()}catch(r){e=r.message}}throw new a(`HTTP status ${s.status}`,e)}return s.json()}async post(e,t){let s={method:\"post\",body:JSON.stringify(t.body),headers:{\"Content-Type\":\"application/json\"}};return t.init&&(s={...s,...t.init,headers:{...s.headers,...t.init.headers}}),this.request(e,s)}async listGames(e){return this.request(\"/games\",e)}async listMatches(e,s,r){t(e);let a=\"\";if(s){const e=[],{isGameover:t,updatedBefore:r,updatedAfter:n}=s;void 0!==t&&e.push(`isGameover=${t}`),r&&e.push(`updatedBefore=${r}`),n&&e.push(`updatedAfter=${n}`),e.length>0&&(a=\"?\"+e.join(\"&\"))}return this.request(`/games/${e}${a}`,r)}async getMatch(e,r,a){return t(e),s(r),this.request(`/games/${e}/${r}`,a)}async createMatch(e,s,a){return t(e),r(s,{numPlayers:\"number\"}),this.post(`/games/${e}/create`,{body:s,init:a})}async joinMatch(e,a,n,i){return t(e),s(a),r(n,{playerID:[\"string\",\"undefined\"],playerName:\"string\"}),this.post(`/games/${e}/${a}/join`,{body:n,init:i})}async leaveMatch(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/leave`,{body:n,init:i})}async updatePlayer(e,a,n,i){t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${e}/${a}/update`,{body:n,init:i})}async playAgain(e,a,n,i){return t(e),s(a),r(n,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${e}/${a}/playAgain`,{body:n,init:i})}}exports.L=n;\n},{}],\"L8uO\":[function(require,module,exports) {\n\"use strict\";var e=require(\"object-assign\"),r=\"function\"==typeof Symbol&&Symbol.for,t=r?Symbol.for(\"react.element\"):60103,n=r?Symbol.for(\"react.portal\"):60106,o=r?Symbol.for(\"react.fragment\"):60107,u=r?Symbol.for(\"react.strict_mode\"):60108,f=r?Symbol.for(\"react.profiler\"):60114,c=r?Symbol.for(\"react.provider\"):60109,l=r?Symbol.for(\"react.context\"):60110,i=r?Symbol.for(\"react.forward_ref\"):60112,s=r?Symbol.for(\"react.suspense\"):60113,a=r?Symbol.for(\"react.memo\"):60115,p=r?Symbol.for(\"react.lazy\"):60116,y=\"function\"==typeof Symbol&&Symbol.iterator;function d(e){for(var r=\"https://reactjs.org/docs/error-decoder.html?invariant=\"+e,t=1;t<arguments.length;t++)r+=\"&args[]=\"+encodeURIComponent(arguments[t]);return\"Minified React error #\"+e+\"; visit \"+r+\" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function m(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}function x(){}function b(e,r,t){this.props=e,this.context=r,this.refs=h,this.updater=t||v}m.prototype.isReactComponent={},m.prototype.setState=function(e,r){if(\"object\"!=typeof e&&\"function\"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,r,\"setState\")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,\"forceUpdate\")},x.prototype=m.prototype;var S=b.prototype=new x;S.constructor=b,e(S,m.prototype),S.isPureReactComponent=!0;var _={current:null},k=Object.prototype.hasOwnProperty,$={key:!0,ref:!0,__self:!0,__source:!0};function g(e,r,n){var o,u={},f=null,c=null;if(null!=r)for(o in void 0!==r.ref&&(c=r.ref),void 0!==r.key&&(f=\"\"+r.key),r)k.call(r,o)&&!$.hasOwnProperty(o)&&(u[o]=r[o]);var l=arguments.length-2;if(1===l)u.children=n;else if(1<l){for(var i=Array(l),s=0;s<l;s++)i[s]=arguments[s+2];u.children=i}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===u[o]&&(u[o]=l[o]);return{$$typeof:t,type:e,key:f,ref:c,props:u,_owner:_.current}}function w(e,r){return{$$typeof:t,type:e.type,key:r,ref:e.ref,props:e.props,_owner:e._owner}}function C(e){return\"object\"==typeof e&&null!==e&&e.$$typeof===t}function E(e){var r={\"=\":\"=0\",\":\":\"=2\"};return\"$\"+(\"\"+e).replace(/[=:]/g,function(e){return r[e]})}var R=/\\/+/g,P=[];function j(e,r,t,n){if(P.length){var o=P.pop();return o.result=e,o.keyPrefix=r,o.func=t,o.context=n,o.count=0,o}return{result:e,keyPrefix:r,func:t,context:n,count:0}}function O(e){e.result=null,e.keyPrefix=null,e.func=null,e.context=null,e.count=0,10>P.length&&P.push(e)}function A(e,r,o,u){var f=typeof e;\"undefined\"!==f&&\"boolean\"!==f||(e=null);var c=!1;if(null===e)c=!0;else switch(f){case\"string\":case\"number\":c=!0;break;case\"object\":switch(e.$$typeof){case t:case n:c=!0}}if(c)return o(u,e,\"\"===r?\".\"+U(e,0):r),1;if(c=0,r=\"\"===r?\".\":r+\":\",Array.isArray(e))for(var l=0;l<e.length;l++){var i=r+U(f=e[l],l);c+=A(f,i,o,u)}else if(null===e||\"object\"!=typeof e?i=null:i=\"function\"==typeof(i=y&&e[y]||e[\"@@iterator\"])?i:null,\"function\"==typeof i)for(e=i.call(e),l=0;!(f=e.next()).done;)c+=A(f=f.value,i=r+U(f,l++),o,u);else if(\"object\"===f)throw o=\"\"+e,Error(d(31,\"[object Object]\"===o?\"object with keys {\"+Object.keys(e).join(\", \")+\"}\":o,\"\"));return c}function I(e,r,t){return null==e?0:A(e,\"\",r,t)}function U(e,r){return\"object\"==typeof e&&null!==e&&null!=e.key?E(e.key):r.toString(36)}function q(e,r){e.func.call(e.context,r,e.count++)}function F(e,r,t){var n=e.result,o=e.keyPrefix;e=e.func.call(e.context,r,e.count++),Array.isArray(e)?L(e,n,t,function(e){return e}):null!=e&&(C(e)&&(e=w(e,o+(!e.key||r&&r.key===e.key?\"\":(\"\"+e.key).replace(R,\"$&/\")+\"/\")+t)),n.push(e))}function L(e,r,t,n,o){var u=\"\";null!=t&&(u=(\"\"+t).replace(R,\"$&/\")+\"/\"),I(e,F,r=j(r,u,n,o)),O(r)}var M={current:null};function D(){var e=M.current;if(null===e)throw Error(d(321));return e}var V={ReactCurrentDispatcher:M,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:_,IsSomeRendererActing:{current:!1},assign:e};exports.Children={map:function(e,r,t){if(null==e)return e;var n=[];return L(e,n,null,r,t),n},forEach:function(e,r,t){if(null==e)return e;I(e,q,r=j(null,null,r,t)),O(r)},count:function(e){return I(e,function(){return null},null)},toArray:function(e){var r=[];return L(e,r,null,function(e){return e}),r},only:function(e){if(!C(e))throw Error(d(143));return e}},exports.Component=m,exports.Fragment=o,exports.Profiler=f,exports.PureComponent=b,exports.StrictMode=u,exports.Suspense=s,exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,exports.cloneElement=function(r,n,o){if(null==r)throw Error(d(267,r));var u=e({},r.props),f=r.key,c=r.ref,l=r._owner;if(null!=n){if(void 0!==n.ref&&(c=n.ref,l=_.current),void 0!==n.key&&(f=\"\"+n.key),r.type&&r.type.defaultProps)var i=r.type.defaultProps;for(s in n)k.call(n,s)&&!$.hasOwnProperty(s)&&(u[s]=void 0===n[s]&&void 0!==i?i[s]:n[s])}var s=arguments.length-2;if(1===s)u.children=o;else if(1<s){i=Array(s);for(var a=0;a<s;a++)i[a]=arguments[a+2];u.children=i}return{$$typeof:t,type:r.type,key:f,ref:c,props:u,_owner:l}},exports.createContext=function(e,r){return void 0===r&&(r=null),(e={$$typeof:l,_calculateChangedBits:r,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:c,_context:e},e.Consumer=e},exports.createElement=g,exports.createFactory=function(e){var r=g.bind(null,e);return r.type=e,r},exports.createRef=function(){return{current:null}},exports.forwardRef=function(e){return{$$typeof:i,render:e}},exports.isValidElement=C,exports.lazy=function(e){return{$$typeof:p,_ctor:e,_status:-1,_result:null}},exports.memo=function(e,r){return{$$typeof:a,type:e,compare:void 0===r?null:r}},exports.useCallback=function(e,r){return D().useCallback(e,r)},exports.useContext=function(e,r){return D().useContext(e,r)},exports.useDebugValue=function(){},exports.useEffect=function(e,r){return D().useEffect(e,r)},exports.useImperativeHandle=function(e,r,t){return D().useImperativeHandle(e,r,t)},exports.useLayoutEffect=function(e,r){return D().useLayoutEffect(e,r)},exports.useMemo=function(e,r){return D().useMemo(e,r)},exports.useReducer=function(e,r,t){return D().useReducer(e,r,t)},exports.useRef=function(e){return D().useRef(e)},exports.useState=function(e){return D().useState(e)},exports.version=\"16.14.0\";\n},{\"object-assign\":\"J4Nk\"}],\"SAdv\":[function(require,module,exports) {\n\"use strict\";module.exports=require(\"./cjs/react.production.min.js\");\n},{\"./cjs/react.production.min.js\":\"L8uO\"}],\"PB2Y\":[function(require,module,exports) {\n\"use strict\";var _=\"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED\";module.exports=_;\n},{}],\"cTRg\":[function(require,module,exports) {\n\"use strict\";var e=require(\"./lib/ReactPropTypesSecret\");function r(){}function t(){}t.resetWarningCache=r,module.exports=function(){function n(r,t,n,o,a,p){if(p!==e){var c=new Error(\"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types\");throw c.name=\"Invariant Violation\",c}}function o(){return n}n.isRequired=n;var a={array:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:o,element:n,elementType:n,instanceOf:o,node:n,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:t,resetWarningCache:r};return a.PropTypes=a,a};\n},{\"./lib/ReactPropTypesSecret\":\"PB2Y\"}],\"yu5W\":[function(require,module,exports) {\nvar r,e;module.exports=require(\"./factoryWithThrowingShims\")();\n},{\"./factoryWithThrowingShims\":\"cTRg\"}],\"KAZ5\":[function(require,module,exports) {\n\"use strict\";exports.parse=n,exports.serialize=o;var e=decodeURIComponent,t=encodeURIComponent,r=/; */,i=/^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;function n(t,i){if(\"string\"!=typeof t)throw new TypeError(\"argument str must be a string\");for(var n={},o=i||{},s=t.split(r),p=o.decode||e,f=0;f<s.length;f++){var u=s[f],m=u.indexOf(\"=\");if(!(m<0)){var c=u.substr(0,m).trim(),l=u.substr(++m,u.length).trim();'\"'==l[0]&&(l=l.slice(1,-1)),null==n[c]&&(n[c]=a(l,p))}}return n}function o(e,r,n){var o=n||{},a=o.encode||t;if(\"function\"!=typeof a)throw new TypeError(\"option encode is invalid\");if(!i.test(e))throw new TypeError(\"argument name is invalid\");var s=a(r);if(s&&!i.test(s))throw new TypeError(\"argument val is invalid\");var p=e+\"=\"+s;if(null!=o.maxAge){var f=o.maxAge-0;if(isNaN(f))throw new Error(\"maxAge should be a Number\");p+=\"; Max-Age=\"+Math.floor(f)}if(o.domain){if(!i.test(o.domain))throw new TypeError(\"option domain is invalid\");p+=\"; Domain=\"+o.domain}if(o.path){if(!i.test(o.path))throw new TypeError(\"option path is invalid\");p+=\"; Path=\"+o.path}if(o.expires){if(\"function\"!=typeof o.expires.toUTCString)throw new TypeError(\"option expires is invalid\");p+=\"; Expires=\"+o.expires.toUTCString()}if(o.httpOnly&&(p+=\"; HttpOnly\"),o.secure&&(p+=\"; Secure\"),o.sameSite)switch(\"string\"==typeof o.sameSite?o.sameSite.toLowerCase():o.sameSite){case!0:p+=\"; SameSite=Strict\";break;case\"lax\":p+=\"; SameSite=Lax\";break;case\"strict\":p+=\"; SameSite=Strict\";break;default:throw new TypeError(\"option sameSite is invalid\")}return p}function a(e,t){try{return t(e)}catch(r){return e}}\n},{}],\"kpSY\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");Object.defineProperty(exports,\"__esModule\",{value:!0});var o=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e};exports.load=f,exports.loadAll=l,exports.select=p,exports.save=y,exports.remove=v,exports.setRawCookie=k,exports.plugToRequest=m;var t=require(\"cookie\"),r=u(t),n=require(\"object-assign\"),i=u(n);function u(e){return e&&e.__esModule?e:{default:e}}var c=\"undefined\"==typeof document||void 0!==e&&e.env&&!1,a={},s=void 0;function d(){return s&&!s.headersSent}function f(e,o){var t=c?a:r.default.parse(document.cookie),n=t&&t[e];if(void 0===o&&(o=!n||\"{\"!==n[0]&&\"[\"!==n[0]),!o)try{n=JSON.parse(n)}catch(i){}return n}function l(e){var o=c?a:r.default.parse(document.cookie);if(void 0===e&&(e=!o||\"{\"!==o[0]&&\"[\"!==o[0]),!e)try{o=JSON.parse(o)}catch(t){}return o}function p(e){var o=c?a:r.default.parse(document.cookie);return o?e?Object.keys(o).reduce(function(t,r){if(!e.test(r))return t;var n={};return n[r]=o[r],(0,i.default)({},t,n)},{}):o:{}}function y(e,t,n){a[e]=t,\"object\"===(void 0===t?\"undefined\":o(t))&&(a[e]=JSON.stringify(t)),c||(document.cookie=r.default.serialize(e,a[e],n)),d()&&s.cookie&&s.cookie(e,t,n)}function v(e,o){delete a[e],o=void 0===o?{}:\"string\"==typeof o?{path:o}:(0,i.default)({},o),\"undefined\"!=typeof document&&(o.expires=new Date(1970,1,1,0,0,1),o.maxAge=0,document.cookie=r.default.serialize(e,\"\",o)),d()&&s.clearCookie&&s.clearCookie(e,o)}function k(e){a=e?r.default.parse(e):{}}function m(e,o){return e.cookie?a=e.cookie:e.cookies?a=e.cookies:e.headers&&e.headers.cookie?k(e.headers.cookie):a={},s=o,function(){s=null,a={}}}exports.default={setRawCookie:k,load:f,loadAll:l,select:p,save:y,remove:v,plugToRequest:m};\n},{\"cookie\":\"KAZ5\",\"object-assign\":\"J4Nk\",\"process\":\"pBGv\"}],\"pSNY\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=a,exports.c=exports.S=exports.A=void 0;var e,t=require(\"./initialize-9ac1bbf5.js\");function a(t){return t.type()===e.SYNC}!function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class s{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=s;class n{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=n;const o=({game:e,unlisted:t,setupData:a,numPlayers:s})=>{const n={gameName:e.name,unlisted:!!t,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==a&&(n.setupData=a);for(let o=0;o<s;o++)n.players[o]={id:o};return n},r=({game:e,numPlayers:a,setupData:s,unlisted:n})=>{a&&\"number\"==typeof a||(a=2);const r=e.validateSetupData&&e.validateSetupData(s,a);return void 0!==r?{setupDataError:r}:{metadata:o({game:e,numPlayers:a,setupData:s,unlisted:n}),initialState:(0,t.I)({game:e,numPlayers:a,setupData:s})}};exports.c=r;\n},{\"./initialize-9ac1bbf5.js\":\"Wibm\"}],\"gTRl\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0b7dce3d.js\"),e=require(\"./reducer-07c7b307.js\"),r=require(\"./util-b1699aa1.js\");const s=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),i=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class o{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(s,o,n,c){if(!s||!s.payload)return{error:\"missing action or action payload\"};let l;if((0,r.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(n,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:c,credentials:s.payload.credentials,metadata:l})))return{error:\"unauthorized action\"}}const d=i(s),h=n;let u;if((0,r.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${c}]`+` - action[${d.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),y=(0,t.createStore)(p,u,g);if(d.type==a.h||d.type==a.R){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===c;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[c]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${c}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,c))return void(0,a.e)(`player not active - playerID=[${c}]`+` - action[${d.payload.type}]`);const m=d.type==a.M?this.game.flow.getMove(u.ctx,d.payload.type,c):null;if(d.type==a.M&&!m)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${c}]`+` - action[${d.payload.type}]`);if(u._stateID!==o&&!(m&&(0,e.I)(m)&&m.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${o}], expected=[${u._stateID}]`+` - playerID=[${c}] - action[${d.payload.type}]`);const I=y.getState();y.dispatch(d),u=y.getState(),this.subscribeCallback({state:u,action:d,matchID:n}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[n,o,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[n,u]});const{deltalog:f,...P}=u;let A;if(!l||void 0!==l.gameover&&null!==l.gameover||(A={...l,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,r.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,i=2){const o=t,n={state:!0,metadata:!0,log:!0,initialState:!0},c=(0,r.i)(this.storageAPI)?this.storageAPI.fetch(o,n):await this.storageAPI.fetch(o,n);let{state:l,initialState:d,log:h,metadata:u}=c;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:u})))return{error:\"unauthorized\"}}if(void 0===l){const a=(0,r.c)({game:this.game,unlisted:!0,numPlayers:i,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};d=l=a.initialState,u=a.metadata,this.subscribeCallback({state:l,matchID:t}),(0,r.i)(this.storageAPI)?this.storageAPI.createMatch(o,{initialState:d,metadata:u}):await this.storageAPI.createMatch(o,{initialState:d,metadata:u})}const p={state:l,log:h,filteredMetadata:u?s(u):void 0,initialState:d};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,p]})}async onConnectionChange(t,e,i,o){const n=t;if(null==e)return;let c;if((0,r.i)(this.storageAPI)?({metadata:c}=this.storageAPI.fetch(n,{metadata:!0})):({metadata:c}=await this.storageAPI.fetch(n,{metadata:!0})),void 0===c)return(0,a.e)(`metadata not found for matchID=[${n}]`),{error:\"metadata not found\"};if(void 0===c.players[e])return(0,a.e)(`Player not in the match, matchID=[${n}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:i,metadata:c})))return{error:\"unauthorized\"}}c.players[e].isConnected=o;const l=s(c);this.transportAPI.sendAll({type:\"matchData\",args:[t,l]}),(0,r.i)(this.storageAPI)?this.storageAPI.setMetadata(n,c):await this.storageAPI.setMetadata(n,c)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=o;\n},{\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"./reducer-07c7b307.js\":\"iEGk\",\"./util-b1699aa1.js\":\"pSNY\"}],\"AbzV\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.g=void 0;var e=require(\"./turn-order-0b7dce3d.js\"),t=require(\"rfc6902\");const r=(t,r,a)=>({...a,G:t.playerView(a.G,a.ctx,r),plugins:(0,e.x)(a,{playerID:r,game:t}),deltalog:void 0,_undo:[],_redo:[]}),a=e=>(a,s)=>{switch(s.type){case\"patch\":{const[c,n,l,u]=s.args,d=o(u.deltalog,a),p=r(e,a,u),i=u._stateID,g=r(e,a,l);return{type:\"patch\",args:[c,n,i,(0,t.createPatch)(g,p),d]}}case\"update\":{const[t,c]=s.args,n=o(c.deltalog,a);return{type:\"update\",args:[t,r(e,a,c),n]}}case\"sync\":{const[t,c]=s.args,n=r(e,a,c.state),l=o(c.log,a);return{type:\"sync\",args:[t,{...c,state:n,log:l}]}}default:return s}};function o(e,t){return void 0===e?e:e.map(e=>{if(null!==t&&+t==+e.action.payload.playerID)return e;if(!0!==e.redact)return e;const r={...e.action.payload,args:null},a={...e,action:{...e.action,payload:r}},{redact:o,...s}=a;return s})}exports.g=a;\n},{\"./turn-order-0b7dce3d.js\":\"MZmr\",\"rfc6902\":\"B6py\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"UzxM\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=p,exports.S=g;var t=require(\"./transport-ce07b771.js\"),e=require(\"./util-b1699aa1.js\"),s=require(\"./master-be1abdd0.js\"),i=require(\"./filter-player-view-c30cdfbf.js\"),a=n(require(\"socket.io-client\"));function n(t){return t&&t.__esModule?t:{default:t}}class r extends e.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class c extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends r{constructor(t=\"bgio\"){super();const e=e=>new c(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}function h(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class l extends s.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const n={},c={};if(t&&t.ai&&e)for(const i in e){const s=e[i];c[i]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const l=({playerID:t,...e})=>{const s=n[t];void 0!==s&&s(u(t,e))},u=(0,i.g)(t),d={send:l,sendAll:t=>{for(const e in n)l({playerID:e,...t})}};super(t,a?new o(s):new r,d),this.connect=((t,e)=>{n[t]=e}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const i=h(t,c);null!==i&&setTimeout(async()=>{const e=await c[i].play(t,i);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class u extends t.T{constructor({master:t,...e}){super(e),this.master=t}sendChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}sendAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}requestSync(){this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}connect(){this.setConnectionStatus(!0),this.master.connect(this.playerID,t=>this.notifyClient(t)),this.requestSync()}disconnect(){this.setConnectionStatus(!1)}updateMatchID(t){this.matchID=t,this.connect()}updatePlayerID(t){this.playerID=t,this.connect()}updateCredentials(t){this.credentials=t,this.connect()}}const d=new Map;function p({bots:t,persist:e,storageKey:s}={}){return i=>{const{gameKey:a,game:n}=i;let r;const c=d.get(a);return c&&c.bots===t&&c.storageKey===s&&c.persist===e&&(r=c.master),r||(r=new l({game:n,bots:t,persist:e,storageKey:s}),d.set(a,{master:r,bots:t,persist:e,storageKey:s})),new u({master:r,...i})}}const m=a.default;class y extends t.T{constructor({socket:t,socketOpts:e,server:s,...i}){super(i),this.server=s,this.socket=t,this.socketOpts=e}sendAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}sendChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=m(t+this.gameName,this.socketOpts)}else this.socket=m(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(t,e,s,i,a)=>{this.notifyClient({type:\"patch\",args:[t,e,s,i,a]})}),this.socket.on(\"update\",(t,e,s)=>{this.notifyClient({type:\"update\",args:[t,e,s]})}),this.socket.on(\"sync\",(t,e)=>{this.notifyClient({type:\"sync\",args:[t,e]})}),this.socket.on(\"matchData\",(t,e)=>{this.notifyClient({type:\"matchData\",args:[t,e]})}),this.socket.on(\"chat\",(t,e)=>{this.notifyClient({type:\"chat\",args:[t,e]})}),this.socket.on(\"connect\",()=>{this.requestSync(),this.setConnectionStatus(!0)}),this.socket.on(\"disconnect\",()=>{this.setConnectionStatus(!1)})}disconnect(){this.socket.close(),this.socket=null,this.setConnectionStatus(!1)}requestSync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}updateMatchID(t){this.matchID=t,this.requestSync()}updatePlayerID(t){this.playerID=t,this.requestSync()}updateCredentials(t){this.credentials=t,this.requestSync()}}function g({server:t,socketOpts:e}={}){return s=>new y({server:t,socketOpts:e,...s})}\n},{\"./transport-ce07b771.js\":\"zA0v\",\"./util-b1699aa1.js\":\"pSNY\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"PUvW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Client=o,exports.Lobby=void 0,require(\"nanoid/non-secure\"),require(\"./Debug-fd09b8bc.js\"),require(\"redux\"),require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"./initialize-9ac1bbf5.js\"),require(\"./transport-ce07b771.js\");var e=require(\"./client-fa36c03a.js\");require(\"flatted\"),require(\"setimmediate\");var t=require(\"./ai-3099ce9a.js\"),a=require(\"./client-5f57c3f2.js\"),s=c(require(\"react\")),r=c(require(\"prop-types\")),n=c(require(\"react-cookies\"));require(\"./util-b1699aa1.js\");var i,l=require(\"./socketio-e4fb268a.js\");function c(e){return e&&e.__esModule?e:{default:e}}function o(t){var a;const{game:n,numPlayers:i,board:l,multiplayer:c,enhancer:o}=t;let{loading:h,debug:m}=t;if(void 0===h){h=(()=>s.default.createElement(\"div\",{className:\"bgio-loading\"},\"connecting...\"))}return(a=class extends s.default.Component{constructor(t){super(t),void 0===m&&(m=t.debug),this.client=(0,e.C)({game:n,debug:m,numPlayers:i,multiplayer:c,matchID:t.matchID,playerID:t.playerID,credentials:t.credentials,enhancer:o})}componentDidMount(){this.unsubscribe=this.client.subscribe(()=>this.forceUpdate()),this.client.start()}componentWillUnmount(){this.client.stop(),this.unsubscribe()}componentDidUpdate(e){this.props.matchID!=e.matchID&&this.client.updateMatchID(this.props.matchID),this.props.playerID!=e.playerID&&this.client.updatePlayerID(this.props.playerID),this.props.credentials!=e.credentials&&this.client.updateCredentials(this.props.credentials)}render(){const e=this.client.getState();if(null===e)return s.default.createElement(h);let t=null;return l&&(t=s.default.createElement(l,{...e,...this.props,isMultiplayer:!!c,moves:this.client.moves,events:this.client.events,matchID:this.client.matchID,playerID:this.client.playerID,reset:this.client.reset,undo:this.client.undo,redo:this.client.redo,log:this.client.log,matchData:this.client.matchData,sendChatMessage:this.client.sendChatMessage,chatMessages:this.client.chatMessages})),s.default.createElement(\"div\",{className:\"bgio-client\"},t)}}).propTypes={matchID:r.default.string,playerID:r.default.string,credentials:r.default.string,debug:r.default.any},a.defaultProps={matchID:\"default\",playerID:null,credentials:null,debug:!0},a}require(\"./master-be1abdd0.js\"),require(\"./filter-player-view-c30cdfbf.js\"),require(\"socket.io-client\");class h{constructor({server:e,gameComponents:t,playerName:s,playerCredentials:r}){this.client=new a.L({server:e}),this.gameComponents=t,this.playerName=s||\"Visitor\",this.playerCredentials=r,this.matches=[]}async refresh(){try{this.matches=[];const t=await this.client.listGames();for(const e of t){if(!this._getGameComponents(e))continue;const{matches:t}=await this.client.listMatches(e);this.matches.push(...t)}}catch(e){throw new Error(\"failed to retrieve list of matches (\"+e+\")\")}}_getMatchInstance(e){for(const t of this.matches)if(t.matchID===e)return t}_getGameComponents(e){for(const t of this.gameComponents)if(t.game.name===e)return t}_findPlayer(e){for(const t of this.matches)if(t.players.some(t=>t.name===e))return t}async join(e,t,a){try{let r=this._findPlayer(this.playerName);if(r)throw new Error(\"player has already joined \"+r.matchID);if(!(r=this._getMatchInstance(t)))throw new Error(\"game instance \"+t+\" not found\");const n=await this.client.joinMatch(e,t,{playerID:a,playerName:this.playerName});r.players[Number.parseInt(a)].name=this.playerName,this.playerCredentials=n.playerCredentials}catch(s){throw new Error(\"failed to join match \"+t+\" (\"+s+\")\")}}async leave(e,t){try{const s=this._getMatchInstance(t);if(!s)throw new Error(\"match instance not found\");for(const a of s.players)if(a.name===this.playerName)return await this.client.leaveMatch(e,t,{playerID:a.id.toString(),credentials:this.playerCredentials}),delete a.name,void delete this.playerCredentials;throw new Error(\"player not found in match\")}catch(a){throw new Error(\"failed to leave match \"+t+\" (\"+a+\")\")}}async disconnect(){const e=this._findPlayer(this.playerName);e&&await this.leave(e.gameName,e.matchID),this.matches=[],this.playerName=\"Visitor\"}async create(e,t){try{const s=this._getGameComponents(e);if(!s)throw new Error(\"game not found\");if(t<s.game.minPlayers||t>s.game.maxPlayers)throw new Error(\"invalid number of players \"+t);await this.client.createMatch(e,{numPlayers:t})}catch(a){throw new Error(\"failed to create match for \"+e+\" (\"+a+\")\")}}}function m(e){return new h(e)}class u extends s.default.Component{constructor(){super(...arguments),this.state={playerName:this.props.playerName,nameErrorMsg:\"\"},this.onClickEnter=(()=>{\"\"!==this.state.playerName&&this.props.onEnter(this.state.playerName)}),this.onKeyPress=(e=>{\"Enter\"===e.key&&this.onClickEnter()}),this.onChangePlayerName=(e=>{const t=e.target.value.trim();this.setState({playerName:t,nameErrorMsg:t.length>0?\"\":\"empty player name\"})})}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"p\",{className:\"phase-title\"},\"Choose a player name:\"),s.default.createElement(\"input\",{type:\"text\",value:this.state.playerName,onChange:this.onChangePlayerName,onKeyPress:this.onKeyPress}),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{className:\"buttons\",onClick:this.onClickEnter},\"Enter\")),s.default.createElement(\"br\",null),s.default.createElement(\"span\",{className:\"error-msg\"},this.state.nameErrorMsg,s.default.createElement(\"br\",null)))}}u.defaultProps={playerName:\"\"};class p extends s.default.Component{constructor(){super(...arguments),this._createSeat=(e=>e.name||\"[free]\"),this._createButtonJoin=((e,t)=>s.default.createElement(\"button\",{key:\"button-join-\"+e.matchID,onClick:()=>this.props.onClickJoin(e.gameName,e.matchID,\"\"+t)},\"Join\")),this._createButtonLeave=(e=>s.default.createElement(\"button\",{key:\"button-leave-\"+e.matchID,onClick:()=>this.props.onClickLeave(e.gameName,e.matchID)},\"Leave\")),this._createButtonPlay=((e,t)=>s.default.createElement(\"button\",{key:\"button-play-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,playerID:\"\"+t,numPlayers:e.players.length})},\"Play\")),this._createButtonSpectate=(e=>s.default.createElement(\"button\",{key:\"button-spectate-\"+e.matchID,onClick:()=>this.props.onClickPlay(e.gameName,{matchID:e.matchID,numPlayers:e.players.length})},\"Spectate\")),this._createInstanceButtons=(e=>{const t=e.players.find(e=>e.name===this.props.playerName),a=e.players.find(e=>!e.name);return t&&a?this._createButtonLeave(e):a?this._createButtonJoin(e,a.id):t?s.default.createElement(\"div\",null,[this._createButtonPlay(e,t.id),this._createButtonLeave(e)]):this._createButtonSpectate(e)})}render(){const e=this.props.match;let t=\"OPEN\";return e.players.some(e=>!e.name)||(t=\"RUNNING\"),s.default.createElement(\"tr\",{key:\"line-\"+e.matchID},s.default.createElement(\"td\",{key:\"cell-name-\"+e.matchID},e.gameName),s.default.createElement(\"td\",{key:\"cell-status-\"+e.matchID},t),s.default.createElement(\"td\",{key:\"cell-seats-\"+e.matchID},e.players.map(e=>this._createSeat(e)).join(\", \")),s.default.createElement(\"td\",{key:\"cell-buttons-\"+e.matchID},this._createInstanceButtons(e)))}}class d extends s.default.Component{constructor(e){super(e),this.state={selectedGame:0,numPlayers:2},this._createGameNameOption=((e,t)=>s.default.createElement(\"option\",{key:\"name-option-\"+t,value:t},e.game.name)),this._createNumPlayersOption=(e=>s.default.createElement(\"option\",{key:\"num-option-\"+e,value:e},e)),this._createNumPlayersRange=(e=>Array.from({length:e.maxPlayers+1}).map((e,t)=>t).slice(e.minPlayers)),this.onChangeNumPlayers=(e=>{this.setState({numPlayers:Number.parseInt(e.target.value)})}),this.onChangeSelectedGame=(e=>{const t=Number.parseInt(e.target.value);this.setState({selectedGame:t,numPlayers:this.props.games[t].game.minPlayers})}),this.onClickCreate=(()=>{this.props.createMatch(this.props.games[this.state.selectedGame].game.name,this.state.numPlayers)});for(const t of e.games){const e=t.game;e.minPlayers||(e.minPlayers=1),e.maxPlayers||(e.maxPlayers=4),console.assert(e.maxPlayers>=e.minPlayers)}this.state={selectedGame:0,numPlayers:e.games[0].game.minPlayers}}render(){return s.default.createElement(\"div\",null,s.default.createElement(\"select\",{value:this.state.selectedGame,onChange:e=>this.onChangeSelectedGame(e)},this.props.games.map((e,t)=>this._createGameNameOption(e,t))),s.default.createElement(\"span\",null,\"Players:\"),s.default.createElement(\"select\",{value:this.state.numPlayers,onChange:this.onChangeNumPlayers},this._createNumPlayersRange(this.props.games[this.state.selectedGame].game).map(e=>this._createNumPlayersOption(e))),s.default.createElement(\"span\",{className:\"buttons\"},s.default.createElement(\"button\",{onClick:this.onClickCreate},\"Create\")))}}!function(e){e.ENTER=\"enter\",e.PLAY=\"play\",e.LIST=\"list\"}(i||(i={}));class y extends s.default.Component{constructor(e){super(e),this.state={phase:i.ENTER,playerName:\"Visitor\",runningMatch:null,errorMsg:\"\",credentialStore:{}},this._createConnection=(e=>{const t=this.state.playerName;this.connection=m({server:e.lobbyServer,gameComponents:e.gameComponents,playerName:t,playerCredentials:this.state.credentialStore[t]})}),this._updateCredentials=((e,t)=>{this.setState(a=>{const s=Object.assign({},a.credentialStore);return s[e]=t,{credentialStore:s}})}),this._updateConnection=(async()=>{await this.connection.refresh(),this.forceUpdate()}),this._enterLobby=(e=>{this._startRefreshInterval(),this.setState({playerName:e,phase:i.LIST})}),this._exitLobby=(async()=>{this._clearRefreshInterval(),await this.connection.disconnect(),this.setState({phase:i.ENTER,errorMsg:\"\"})}),this._createMatch=(async(e,t)=>{try{await this.connection.create(e,t),await this.connection.refresh(),this.setState({})}catch(a){this.setState({errorMsg:a.message})}}),this._joinMatch=(async(e,t,a)=>{try{await this.connection.join(e,t,a),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(s){this.setState({errorMsg:s.message})}}),this._leaveMatch=(async(e,t)=>{try{await this.connection.leave(e,t),await this.connection.refresh(),this._updateCredentials(this.connection.playerName,this.connection.playerCredentials)}catch(a){this.setState({errorMsg:a.message})}}),this._startMatch=((e,a)=>{const s=this.connection._getGameComponents(e);if(!s)return void this.setState({errorMsg:\"game \"+e+\" not supported\"});let r=void 0;if(a.numPlayers>1&&(r=this.props.gameServer?(0,l.S)({server:this.props.gameServer}):(0,l.S)()),1==a.numPlayers){const e=s.game.maxPlayers,a={};for(let s=1;s<e;s++)a[s+\"\"]=t.M;r=(0,l.L)({bots:a})}const n={app:this.props.clientFactory({game:s.game,board:s.board,debug:this.props.debug,multiplayer:r}),matchID:a.matchID,playerID:a.numPlayers>1?a.playerID:\"0\",credentials:this.connection.playerCredentials};this._clearRefreshInterval(),this.setState({phase:i.PLAY,runningMatch:n})}),this._exitMatch=(()=>{this._startRefreshInterval(),this.setState({phase:i.LIST,runningMatch:null})}),this._getPhaseVisibility=(e=>this.state.phase!==e?\"hidden\":\"phase\"),this.renderMatches=((e,t)=>e.map(e=>{const{matchID:a,gameName:r,players:n}=e;return s.default.createElement(p,{key:\"instance-\"+a,match:{matchID:a,gameName:r,players:Object.values(n)},playerName:t,onClickJoin:this._joinMatch,onClickLeave:this._leaveMatch,onClickPlay:this._startMatch})})),this._createConnection(this.props)}componentDidMount(){const e=n.default.load(\"lobbyState\")||{};e.phase&&e.phase===i.PLAY&&(e.phase=i.LIST),e.phase&&e.phase!==i.ENTER&&this._startRefreshInterval(),this.setState({phase:e.phase||i.ENTER,playerName:e.playerName||\"Visitor\",credentialStore:e.credentialStore||{}})}componentDidUpdate(e,t){const a=this.state.playerName,s=this.state.credentialStore[a];if(t.phase!==this.state.phase||t.credentialStore[a]!==s||t.playerName!==a){this._createConnection(this.props),this._updateConnection();const e={phase:this.state.phase,playerName:a,credentialStore:this.state.credentialStore};n.default.save(\"lobbyState\",e,{path:\"/\"})}e.refreshInterval!==this.props.refreshInterval&&this._startRefreshInterval()}componentWillUnmount(){this._clearRefreshInterval()}_startRefreshInterval(){this._clearRefreshInterval(),this._currentInterval=setInterval(this._updateConnection,this.props.refreshInterval)}_clearRefreshInterval(){clearInterval(this._currentInterval)}render(){const{gameComponents:e,renderer:t}=this.props,{errorMsg:a,playerName:r,phase:n,runningMatch:l}=this.state;return t?t({errorMsg:a,gameComponents:e,matches:this.connection.matches,phase:n,playerName:r,runningMatch:l,handleEnterLobby:this._enterLobby,handleExitLobby:this._exitLobby,handleCreateMatch:this._createMatch,handleJoinMatch:this._joinMatch,handleLeaveMatch:this._leaveMatch,handleExitMatch:this._exitMatch,handleRefreshMatches:this._updateConnection,handleStartMatch:this._startMatch}):s.default.createElement(\"div\",{id:\"lobby-view\",style:{padding:50}},s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.ENTER)},s.default.createElement(u,{key:r,playerName:r,onEnter:this._enterLobby})),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.LIST)},s.default.createElement(\"p\",null,\"Welcome, \",r),s.default.createElement(\"div\",{className:\"phase-title\",id:\"match-creation\"},s.default.createElement(\"span\",null,\"Create a match:\"),s.default.createElement(d,{games:e,createMatch:this._createMatch})),s.default.createElement(\"p\",{className:\"phase-title\"},\"Join a match:\"),s.default.createElement(\"div\",{id:\"instances\"},s.default.createElement(\"table\",null,s.default.createElement(\"tbody\",null,this.renderMatches(this.connection.matches,r))),s.default.createElement(\"span\",{className:\"error-msg\"},a,s.default.createElement(\"br\",null))),s.default.createElement(\"p\",{className:\"phase-title\"},\"Matches that become empty are automatically deleted.\")),s.default.createElement(\"div\",{className:this._getPhaseVisibility(i.PLAY)},l&&s.default.createElement(l.app,{matchID:l.matchID,playerID:l.playerID,credentials:l.credentials}),s.default.createElement(\"div\",{className:\"buttons\",id:\"match-exit\"},s.default.createElement(\"button\",{onClick:this._exitMatch},\"Exit match\"))),s.default.createElement(\"div\",{className:\"buttons\",id:\"lobby-exit\"},s.default.createElement(\"button\",{onClick:this._exitLobby},\"Exit lobby\")))}}exports.Lobby=y,y.propTypes={gameComponents:r.default.array.isRequired,lobbyServer:r.default.string,gameServer:r.default.string,debug:r.default.bool,clientFactory:r.default.func,refreshInterval:r.default.number},y.defaultProps={debug:!1,clientFactory:o,refreshInterval:2e3};\n},{\"nanoid/non-secure\":\"zm2Q\",\"./Debug-fd09b8bc.js\":\"uvSB\",\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\",\"./client-fa36c03a.js\":\"FkTq\",\"flatted\":\"O5av\",\"setimmediate\":\"lU15\",\"./ai-3099ce9a.js\":\"pO2S\",\"./client-5f57c3f2.js\":\"mOPV\",\"react\":\"SAdv\",\"prop-types\":\"yu5W\",\"react-cookies\":\"kpSY\",\"./util-b1699aa1.js\":\"pSNY\",\"./socketio-e4fb268a.js\":\"UzxM\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"Q5yd\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Local\",{enumerable:!0,get:function(){return e.L}}),Object.defineProperty(exports,\"SocketIO\",{enumerable:!0,get:function(){return e.S}}),require(\"redux\"),require(\"./turn-order-0b7dce3d.js\"),require(\"immer\"),require(\"./plugin-random-087f861e.js\"),require(\"lodash.isplainobject\"),require(\"./reducer-07c7b307.js\"),require(\"rfc6902\"),require(\"./initialize-9ac1bbf5.js\"),require(\"./transport-ce07b771.js\"),require(\"./util-b1699aa1.js\");var e=require(\"./socketio-e4fb268a.js\");require(\"./master-be1abdd0.js\"),require(\"./filter-player-view-c30cdfbf.js\"),require(\"socket.io-client\");\n},{\"redux\":\"OV4J\",\"./turn-order-0b7dce3d.js\":\"MZmr\",\"immer\":\"VB7z\",\"./plugin-random-087f861e.js\":\"Sn21\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-07c7b307.js\":\"iEGk\",\"rfc6902\":\"B6py\",\"./initialize-9ac1bbf5.js\":\"Wibm\",\"./transport-ce07b771.js\":\"zA0v\",\"./util-b1699aa1.js\":\"pSNY\",\"./socketio-e4fb268a.js\":\"UzxM\",\"./master-be1abdd0.js\":\"gTRl\",\"./filter-player-view-c30cdfbf.js\":\"AbzV\",\"socket.io-client\":\"x518\"}],\"ChrO\":[function(require,module,exports) {\n\"use strict\";var e=n(require(\"react\")),t=n(require(\"react-dom\")),l=require(\"boardgame.io/react\"),r=require(\"boardgame.io/multiplayer\");function n(e){return e&&e.__esModule?e:{default:e}}function a(e){const t=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]];for(let l of t){const t=e[l[0]];let r=t;for(let n of l)if(e[n]!=t){r=null;break}if(null!=r)return!0}return!1}const u={setup:()=>({cells:Array(9).fill(null)}),moves:{clickCell(e,t,l){const r=[...e.cells];return null===r[l]&&(r[l]=t.currentPlayer),{...e,cells:r}}},turn:{minMoves:1,maxMoves:1},endIf:(e,t)=>a(e.cells)?{winner:t.currentPlayer}:0==e.cells.filter(e=>null===e).length?{draw:!0}:void 0};function c({G:t,ctx:l,moves:r,isActive:n,playerID:a}){const u=e=>n&&null==t.cells[e],c=e=>{u(e)&&r.clickCell(e)};let i=\"\";l.gameover&&(i=void 0!==l.gameover.winner?e.default.createElement(\"div\",{id:\"winner\"},\"Winner: \",l.gameover.winner):e.default.createElement(\"div\",{id:\"winner\"},\"Draw!\"));const o=e=>({border:\"1px solid #555\",width:\"3.125rem\",height:\"3.125rem\",lineHeight:\"3.125rem\",textAlign:\"center\",fontFamily:\"monospace\",fontSize:\"1.25rem\",fontWeight:\"bold\",background:e?\"#eeffe9\":\"transparent\",padding:\"0\",boxSizing:\"border-box\"});let d=[];for(let f=0;f<3;f++){let l=[];for(let r=0;r<3;r++){const n=3*f+r;l.push(e.default.createElement(\"td\",{key:n},u(n)?e.default.createElement(\"button\",{style:o(!0),onClick:()=>c(n)}):e.default.createElement(\"div\",{style:o(!1)},t.cells[n])))}d.push(e.default.createElement(\"tr\",{key:f},l))}return e.default.createElement(\"div\",null,e.default.createElement(\"p\",{style:{display:\"flex\",justifyContent:\"space-between\",flexWrap:\"wrap\"}},e.default.createElement(\"span\",null,\"Player \",a),n&&e.default.createElement(\"span\",null,\"Your turn!\")),e.default.createElement(\"table\",{id:\"board\"},e.default.createElement(\"tbody\",null,d)),e.default.createElement(\"p\",null,i))}var i=(0,l.Client)({board:c,game:u,debug:!1,multiplayer:(0,r.Local)()});const o=()=>e.default.createElement(\"div\",{style:{display:\"flex\",justifyContent:\"space-around\",gap:\"1.25rem\"}},e.default.createElement(i,{playerID:\"0\"}),e.default.createElement(i,{playerID:\"1\"}));t.default.render(e.default.createElement(o,null),document.getElementById(\"app\"));\n},{\"react\":\"n8MK\",\"react-dom\":\"NKHc\",\"boardgame.io/react\":\"PUvW\",\"boardgame.io/multiplayer\":\"Q5yd\"}]},{},[\"ChrO\"], null)"
  },
  {
    "path": "docs/documentation/snippets/phases-1/index.html",
    "content": "<!DOCTYPE html><html><link rel=\"stylesheet\" href=\"/documentation/snippets/phases-1.490dcd4c.css\"><body> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/phases-1.0d4500d6.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/phases-1.0d4500d6.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"YkLP\":[function(require,module,exports) {\nvar global = arguments[3];\nvar t=arguments[3];function e(){}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.action_destroyer=M,exports.add_attribute=mn,exports.add_classes=gn,exports.add_flush_callback=Se,exports.add_location=s,exports.add_render_callback=Ee,exports.add_resize_listener=Pt,exports.add_transform=re,exports.afterUpdate=ue,exports.append=J,exports.append_dev=Cn,exports.append_empty_stylesheet=V,exports.append_hydration=Z,exports.append_hydration_dev=Dn,exports.append_styles=K,exports.assign=o,exports.attr=xt,exports.attr_dev=qn,exports.attribute_to_object=Yt,exports.beforeUpdate=ce,exports.bind=yn,exports.blank_object=c,exports.bubble=xe,exports.check_outros=He,exports.children=wt,exports.claim_component=$n,exports.claim_element=St,exports.claim_html_tag=At,exports.claim_space=Dt,exports.claim_text=Ct,exports.clear_loops=B,exports.component_subscribe=g,exports.compute_rest_props=E,exports.compute_slots=S,exports.createEventDispatcher=pe,exports.create_animation=ne,exports.create_bidirectional_transition=We,exports.create_component=bn,exports.create_in_transition=Ie,exports.create_out_transition=ze,exports.create_slot=y,exports.create_ssr_component=xn,exports.custom_event=zt,exports.dataset_dev=Ln,exports.debug=fn,exports.destroy_block=Je,exports.destroy_component=Fn,exports.destroy_each=ot,exports.detach=nt,exports.detach_after_dev=Nn,exports.detach_before_dev=jn,exports.detach_between_dev=Tn,exports.detach_dev=Mn,exports.dispatch_dev=Sn,exports.each=an,exports.element=rt,exports.element_is=st,exports.empty=at,exports.end_hydrating=G,exports.escape=cn,exports.escape_attribute_value=ln,exports.escape_object=un,exports.exclude_internal_props=k,exports.fix_and_destroy_block=Qe,exports.fix_and_outro_and_destroy_block=Ve,exports.fix_position=oe,exports.flush=Oe,exports.getAllContexts=_e,exports.getContext=fe,exports.get_all_dirty_from_scope=w,exports.get_binding_group_value=$t,exports.get_current_component=ie,exports.get_custom_elements_slots=Jt,exports.get_root_for_style=Q,exports.get_slot_changes=$,exports.get_spread_object=en,exports.get_spread_update=tn,exports.get_store_value=m,exports.group_outros=qe,exports.handle_promise=Ge,exports.hasContext=he,exports.init=kn,exports.insert=tt,exports.insert_dev=On,exports.insert_hydration=et,exports.insert_hydration_dev=An,exports.is_crossorigin=Bt,exports.is_empty=_,exports.is_function=u,exports.is_promise=r,exports.listen=pt,exports.listen_dev=Rn,exports.loop=P,exports.loop_guard=Gn,exports.mount_component=vn,exports.noop=e,exports.not_equal=f,exports.null_to_empty=D,exports.object_without_properties=it,exports.onDestroy=ae,exports.onMount=le,exports.once=C,exports.outro_and_destroy_block=Ke,exports.prevent_default=dt,exports.prop_dev=Hn,exports.query_selector_all=Wt,exports.run=i,exports.run_all=l,exports.safe_not_equal=a,exports.schedule_update=we,exports.select_multiple_value=Lt,exports.select_option=Rt,exports.select_options=qt,exports.select_value=Ht,exports.self=_t,exports.setContext=de,exports.set_attributes=mt,exports.set_current_component=se,exports.set_custom_element_data=yt,exports.set_data=Mt,exports.set_data_dev=Bn,exports.set_input_type=jt,exports.set_input_value=Tt,exports.set_now=R,exports.set_raf=q,exports.set_store_value=O,exports.set_style=Nt,exports.set_svg_attributes=gt,exports.space=ut,exports.spread=rn,exports.src_url_equal=d,exports.start_hydrating=W,exports.stop_propagation=ft,exports.subscribe=x,exports.svg_element=ct,exports.text=lt,exports.tick=ke,exports.time_ranges_to_array=Ft,exports.to_number=vt,exports.toggle_class=It,exports.transition_in=Le,exports.transition_out=Be,exports.trusted=ht,exports.update_await_block_branch=Ue,exports.update_keyed_each=Xe,exports.update_slot=F,exports.update_slot_base=v,exports.validate_component=dn,exports.validate_each_argument=Pn,exports.validate_each_keys=Ze,exports.validate_slots=In,exports.validate_store=h,exports.xlink_attr=bt,exports.raf=exports.now=exports.missing_component=exports.is_client=exports.invalid_attribute_name_character=exports.intros=exports.identity=exports.has_prop=exports.globals=exports.escaped=exports.dirty_components=exports.current_component=exports.binding_callbacks=exports.SvelteElement=exports.SvelteComponentTyped=exports.SvelteComponentDev=exports.SvelteComponent=exports.HtmlTagHydration=exports.HtmlTag=void 0;const n=t=>t;function o(t,e){for(const n in e)t[n]=e[n];return t}function r(t){return t&&\"object\"==typeof t&&\"function\"==typeof t.then}function s(t,e,n,o,r){t.__svelte_meta={loc:{file:e,line:n,column:o,char:r}}}function i(t){return t()}function c(){return Object.create(null)}function l(t){t.forEach(i)}function u(t){return\"function\"==typeof t}function a(t,e){return t!=t?e==e:t!==e||t&&\"object\"==typeof t||\"function\"==typeof t}let p;function d(t,e){return p||(p=document.createElement(\"a\")),p.href=e,t===p.href}function f(t,e){return t!=t?e==e:t!==e}function _(t){return 0===Object.keys(t).length}function h(t,e){if(null!=t&&\"function\"!=typeof t.subscribe)throw new Error(`'${e}' is not a store with a 'subscribe' method`)}function x(t,...n){if(null==t)return e;const o=t.subscribe(...n);return o.unsubscribe?()=>o.unsubscribe():o}function m(t){let e;return x(t,t=>e=t)(),e}function g(t,e,n){t.$$.on_destroy.push(x(e,n))}function y(t,e,n,o){if(t){const r=b(t,e,n,o);return t[0](r)}}function b(t,e,n,r){return t[1]&&r?o(n.ctx.slice(),t[1](r(e))):n.ctx}function $(t,e,n,o){if(t[2]&&o){const r=t[2](o(n));if(void 0===e.dirty)return r;if(\"object\"==typeof r){const t=[],n=Math.max(e.dirty.length,r.length);for(let o=0;o<n;o+=1)t[o]=e.dirty[o]|r[o];return t}return e.dirty|r}return e.dirty}function v(t,e,n,o,r,s){if(r){const i=b(e,n,o,s);t.p(i,r)}}function F(t,e,n,o,r,s,i){v(t,e,n,o,$(e,o,r,s),i)}function w(t){if(t.ctx.length>32){const e=[],n=t.ctx.length/32;for(let t=0;t<n;t++)e[t]=-1;return e}return-1}function k(t){const e={};for(const n in t)\"$\"!==n[0]&&(e[n]=t[n]);return e}function E(t,e){const n={};e=new Set(e);for(const o in t)e.has(o)||\"$\"===o[0]||(n[o]=t[o]);return n}function S(t){const e={};for(const n in t)e[n]=!0;return e}function C(t){let e=!1;return function(...n){e||(e=!0,t.call(this,...n))}}function D(t){return null==t?\"\":t}function O(t,e,n){return t.set(n),e}exports.identity=n;const A=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);function M(t){return t&&u(t.destroy)?t.destroy:e}exports.has_prop=A;const T=\"undefined\"!=typeof window;exports.is_client=T;let j=T?()=>window.performance.now():()=>Date.now();exports.now=j;let N=T?t=>requestAnimationFrame(t):e;function R(t){exports.now=j=t}function q(t){exports.raf=N=t}exports.raf=N;const H=new Set;function L(t){H.forEach(e=>{e.c(t)||(H.delete(e),e.f())}),0!==H.size&&N(L)}function B(){H.clear()}function P(t){let e;return 0===H.size&&N(L),{promise:new Promise(n=>{H.add(e={c:t,f:n})}),abort(){H.delete(e)}}}let I,z=!1;function W(){z=!0}function G(){z=!1}function U(t,e,n,o){for(;t<e;){const r=t+(e-t>>1);n(r)<=o?t=r+1:e=r}return t}function Y(t){if(t.hydrate_init)return;t.hydrate_init=!0;let e=t.childNodes;if(\"HEAD\"===t.nodeName){const t=[];for(let n=0;n<e.length;n++){const o=e[n];void 0!==o.claim_order&&t.push(o)}e=t}const n=new Int32Array(e.length+1),o=new Int32Array(e.length);n[0]=-1;let r=0;for(let l=0;l<e.length;l++){const t=e[l].claim_order,s=(r>0&&e[n[r]].claim_order<=t?r+1:U(1,r,t=>e[n[t]].claim_order,t))-1;o[l]=n[s]+1;const i=s+1;n[i]=l,r=Math.max(i,r)}const s=[],i=[];let c=e.length-1;for(let l=n[r]+1;0!=l;l=o[l-1]){for(s.push(e[l-1]);c>=l;c--)i.push(e[c]);c--}for(;c>=0;c--)i.push(e[c]);s.reverse(),i.sort((t,e)=>t.claim_order-e.claim_order);for(let l=0,u=0;l<i.length;l++){for(;u<s.length&&i[l].claim_order>=s[u].claim_order;)u++;const e=u<s.length?s[u]:null;t.insertBefore(i[l],e)}}function J(t,e){t.appendChild(e)}function K(t,e,n){const o=Q(t);if(!o.getElementById(e)){const t=rt(\"style\");t.id=e,t.textContent=n,X(o,t)}}function Q(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e.host?e:document}function V(t){const e=rt(\"style\");return X(Q(t),e),e}function X(t,e){J(t.head||t,e)}function Z(t,e){if(z){for(Y(t),(void 0===t.actual_end_child||null!==t.actual_end_child&&t.actual_end_child.parentElement!==t)&&(t.actual_end_child=t.firstChild);null!==t.actual_end_child&&void 0===t.actual_end_child.claim_order;)t.actual_end_child=t.actual_end_child.nextSibling;e!==t.actual_end_child?void 0===e.claim_order&&e.parentNode===t||t.insertBefore(e,t.actual_end_child):t.actual_end_child=e.nextSibling}else e.parentNode!==t&&t.appendChild(e)}function tt(t,e,n){t.insertBefore(e,n||null)}function et(t,e,n){z&&!n?Z(t,e):e.parentNode===t&&e.nextSibling==n||t.insertBefore(e,n||null)}function nt(t){t.parentNode.removeChild(t)}function ot(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function rt(t){return document.createElement(t)}function st(t,e){return document.createElement(t,{is:e})}function it(t,e){const n={};for(const o in t)A(t,o)&&-1===e.indexOf(o)&&(n[o]=t[o]);return n}function ct(t){return document.createElementNS(\"http://www.w3.org/2000/svg\",t)}function lt(t){return document.createTextNode(t)}function ut(){return lt(\" \")}function at(){return lt(\"\")}function pt(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function dt(t){return function(e){return e.preventDefault(),t.call(this,e)}}function ft(t){return function(e){return e.stopPropagation(),t.call(this,e)}}function _t(t){return function(e){e.target===this&&t.call(this,e)}}function ht(t){return function(e){e.isTrusted&&t.call(this,e)}}function xt(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function mt(t,e){const n=Object.getOwnPropertyDescriptors(t.__proto__);for(const o in e)null==e[o]?t.removeAttribute(o):\"style\"===o?t.style.cssText=e[o]:\"__value\"===o?t.value=t[o]=e[o]:n[o]&&n[o].set?t[o]=e[o]:xt(t,o,e[o])}function gt(t,e){for(const n in e)xt(t,n,e[n])}function yt(t,e,n){e in t?t[e]=\"boolean\"==typeof t[e]&&\"\"===n||n:xt(t,e,n)}function bt(t,e,n){t.setAttributeNS(\"http://www.w3.org/1999/xlink\",e,n)}function $t(t,e,n){const o=new Set;for(let r=0;r<t.length;r+=1)t[r].checked&&o.add(t[r].__value);return n||o.delete(e),Array.from(o)}function vt(t){return\"\"===t?null:+t}function Ft(t){const e=[];for(let n=0;n<t.length;n+=1)e.push({start:t.start(n),end:t.end(n)});return e}function wt(t){return Array.from(t.childNodes)}function kt(t){void 0===t.claim_info&&(t.claim_info={last_index:0,total_claimed:0})}function Et(t,e,n,o,r=!1){kt(t);const s=(()=>{for(let o=t.claim_info.last_index;o<t.length;o++){const s=t[o];if(e(s)){const e=n(s);return void 0===e?t.splice(o,1):t[o]=e,r||(t.claim_info.last_index=o),s}}for(let o=t.claim_info.last_index-1;o>=0;o--){const s=t[o];if(e(s)){const e=n(s);return void 0===e?t.splice(o,1):t[o]=e,r?void 0===e&&t.claim_info.last_index--:t.claim_info.last_index=o,s}}return o()})();return s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1,s}function St(t,e,n,o){return Et(t,t=>t.nodeName===e,t=>{const e=[];for(let o=0;o<t.attributes.length;o++){const r=t.attributes[o];n[r.name]||e.push(r.name)}e.forEach(e=>t.removeAttribute(e))},()=>o?ct(e):rt(e))}function Ct(t,e){return Et(t,t=>3===t.nodeType,t=>{const n=\"\"+e;if(t.data.startsWith(n)){if(t.data.length!==n.length)return t.splitText(n.length)}else t.data=n},()=>lt(e),!0)}function Dt(t){return Ct(t,\" \")}function Ot(t,e,n){for(let o=n;o<t.length;o+=1){const n=t[o];if(8===n.nodeType&&n.textContent.trim()===e)return o}return t.length}function At(t){const e=Ot(t,\"HTML_TAG_START\",0),n=Ot(t,\"HTML_TAG_END\",e);if(e===n)return new Ut;kt(t);const o=t.splice(e,n+1);nt(o[0]),nt(o[o.length-1]);const r=o.slice(1,o.length-1);for(const s of r)s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1;return new Ut(r)}function Mt(t,e){e=\"\"+e,t.wholeText!==e&&(t.data=e)}function Tt(t,e){t.value=null==e?\"\":e}function jt(t,e){try{t.type=e}catch(n){}}function Nt(t,e,n,o){t.style.setProperty(e,n,o?\"important\":\"\")}function Rt(t,e){for(let n=0;n<t.options.length;n+=1){const o=t.options[n];if(o.__value===e)return void(o.selected=!0)}}function qt(t,e){for(let n=0;n<t.options.length;n+=1){const o=t.options[n];o.selected=~e.indexOf(o.__value)}}function Ht(t){const e=t.querySelector(\":checked\")||t.options[0];return e&&e.__value}function Lt(t){return[].map.call(t.querySelectorAll(\":checked\"),t=>t.__value)}function Bt(){if(void 0===I){I=!1;try{\"undefined\"!=typeof window&&window.parent&&window.parent.document}catch(t){I=!0}}return I}function Pt(t,e){\"static\"===getComputedStyle(t).position&&(t.style.position=\"relative\");const n=rt(\"iframe\");n.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),n.setAttribute(\"aria-hidden\",\"true\"),n.tabIndex=-1;const o=Bt();let r;return o?(n.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",r=pt(window,\"message\",t=>{t.source===n.contentWindow&&e()})):(n.src=\"about:blank\",n.onload=(()=>{r=pt(n.contentWindow,\"resize\",e)})),J(t,n),()=>{o?r():r&&n.contentWindow&&r(),nt(n)}}function It(t,e,n){t.classList[n?\"add\":\"remove\"](e)}function zt(t,e,n=!1){const o=document.createEvent(\"CustomEvent\");return o.initCustomEvent(t,n,!1,e),o}function Wt(t,e=document.body){return Array.from(e.querySelectorAll(t))}class Gt{constructor(){this.e=this.n=null}c(t){this.h(t)}m(t,e,n=null){this.e||(this.e=rt(e.nodeName),this.t=e,this.c(t)),this.i(n)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let e=0;e<this.n.length;e+=1)tt(this.t,this.n[e],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(nt)}}exports.HtmlTag=Gt;class Ut extends Gt{constructor(t){super(),this.e=this.n=null,this.l=t}c(t){this.l?this.n=this.l:super.c(t)}i(t){for(let e=0;e<this.n.length;e+=1)et(this.t,this.n[e],t)}}function Yt(t){const e={};for(const n of t)e[n.name]=n.value;return e}function Jt(t){const e={};return t.childNodes.forEach(t=>{e[t.slot||\"default\"]=!0}),e}exports.HtmlTagHydration=Ut;const Kt=new Set;let Qt,Vt=0;function Xt(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}function Zt(t,e,n,o,r,s,i,c=0){const l=16.666/o;let u=\"{\\n\";for(let x=0;x<=1;x+=l){const t=e+(n-e)*s(x);u+=100*x+`%{${i(t,1-t)}}\\n`}const a=u+`100% {${i(n,1-n)}}\\n}`,p=`__svelte_${Xt(a)}_${c}`,d=Q(t);Kt.add(d);const f=d.__svelte_stylesheet||(d.__svelte_stylesheet=V(t).sheet),_=d.__svelte_rules||(d.__svelte_rules={});_[p]||(_[p]=!0,f.insertRule(`@keyframes ${p} ${a}`,f.cssRules.length));const h=t.style.animation||\"\";return t.style.animation=`${h?`${h}, `:\"\"}${p} ${o}ms linear ${r}ms 1 both`,Vt+=1,p}function te(t,e){const n=(t.style.animation||\"\").split(\", \"),o=n.filter(e?t=>t.indexOf(e)<0:t=>-1===t.indexOf(\"__svelte\")),r=n.length-o.length;r&&(t.style.animation=o.join(\", \"),(Vt-=r)||ee())}function ee(){N(()=>{Vt||(Kt.forEach(t=>{const e=t.__svelte_stylesheet;let n=e.cssRules.length;for(;n--;)e.deleteRule(n);t.__svelte_rules={}}),Kt.clear())})}function ne(t,o,r,s){if(!o)return e;const i=t.getBoundingClientRect();if(o.left===i.left&&o.right===i.right&&o.top===i.top&&o.bottom===i.bottom)return e;const{delay:c=0,duration:l=300,easing:u=n,start:a=j()+c,end:p=a+l,tick:d=e,css:f}=r(t,{from:o,to:i},s);let _,h=!0,x=!1;function m(){f&&te(t,_),h=!1}return P(t=>{if(!x&&t>=a&&(x=!0),x&&t>=p&&(d(1,0),m()),!h)return!1;if(x){const e=0+1*u((t-a)/l);d(e,1-e)}return!0}),f&&(_=Zt(t,0,1,l,c,u,f)),c||(x=!0),d(0,1),m}function oe(t){const e=getComputedStyle(t);if(\"absolute\"!==e.position&&\"fixed\"!==e.position){const{width:n,height:o}=e,r=t.getBoundingClientRect();t.style.position=\"absolute\",t.style.width=n,t.style.height=o,re(t,r)}}function re(t,e){const n=t.getBoundingClientRect();if(e.left!==n.left||e.top!==n.top){const o=getComputedStyle(t),r=\"none\"===o.transform?\"\":o.transform;t.style.transform=`${r} translate(${e.left-n.left}px, ${e.top-n.top}px)`}}function se(t){exports.current_component=Qt=t}function ie(){if(!Qt)throw new Error(\"Function called outside component initialization\");return Qt}function ce(t){ie().$$.before_update.push(t)}function le(t){ie().$$.on_mount.push(t)}function ue(t){ie().$$.after_update.push(t)}function ae(t){ie().$$.on_destroy.push(t)}function pe(){const t=ie();return(e,n)=>{const o=t.$$.callbacks[e];if(o){const r=zt(e,n);o.slice().forEach(e=>{e.call(t,r)})}}}function de(t,e){ie().$$.context.set(t,e)}function fe(t){return ie().$$.context.get(t)}function _e(){return ie().$$.context}function he(t){return ie().$$.context.has(t)}function xe(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(t=>t.call(this,e))}exports.current_component=Qt;const me=[];exports.dirty_components=me;const ge={enabled:!1};exports.intros=ge;const ye=[];exports.binding_callbacks=ye;const be=[],$e=[],ve=Promise.resolve();let Fe=!1;function we(){Fe||(Fe=!0,ve.then(Oe))}function ke(){return we(),ve}function Ee(t){be.push(t)}function Se(t){$e.push(t)}let Ce=!1;const De=new Set;function Oe(){if(!Ce){Ce=!0;do{for(let t=0;t<me.length;t+=1){const e=me[t];se(e),Ae(e.$$)}for(se(null),me.length=0;ye.length;)ye.pop()();for(let t=0;t<be.length;t+=1){const e=be[t];De.has(e)||(De.add(e),e())}be.length=0}while(me.length);for(;$e.length;)$e.pop()();Fe=!1,Ce=!1,De.clear()}}function Ae(t){if(null!==t.fragment){t.update(),l(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Ee)}}let Me;function Te(){return Me||(Me=Promise.resolve()).then(()=>{Me=null}),Me}function je(t,e,n){t.dispatchEvent(zt(`${e?\"intro\":\"outro\"}${n}`))}const Ne=new Set;let Re;function qe(){Re={r:0,c:[],p:Re}}function He(){Re.r||l(Re.c),Re=Re.p}function Le(t,e){t&&t.i&&(Ne.delete(t),t.i(e))}function Be(t,e,n,o){if(t&&t.o){if(Ne.has(t))return;Ne.add(t),Re.c.push(()=>{Ne.delete(t),o&&(n&&t.d(1),o())}),t.o(e)}}const Pe={duration:0};function Ie(t,o,r){let s,i,c=o(t,r),l=!1,a=0;function p(){s&&te(t,s)}function d(){const{delay:o=0,duration:r=300,easing:u=n,tick:d=e,css:f}=c||Pe;f&&(s=Zt(t,0,1,r,o,u,f,a++)),d(0,1);const _=j()+o,h=_+r;i&&i.abort(),l=!0,Ee(()=>je(t,!0,\"start\")),i=P(e=>{if(l){if(e>=h)return d(1,0),je(t,!0,\"end\"),p(),l=!1;if(e>=_){const t=u((e-_)/r);d(t,1-t)}}return l})}let f=!1;return{start(){f||(f=!0,te(t),u(c)?(c=c(),Te().then(d)):d())},invalidate(){f=!1},end(){l&&(p(),l=!1)}}}function ze(t,o,r){let s,i=o(t,r),c=!0;const a=Re;function p(){const{delay:o=0,duration:r=300,easing:u=n,tick:p=e,css:d}=i||Pe;d&&(s=Zt(t,1,0,r,o,u,d));const f=j()+o,_=f+r;Ee(()=>je(t,!1,\"start\")),P(e=>{if(c){if(e>=_)return p(0,1),je(t,!1,\"end\"),--a.r||l(a.c),!1;if(e>=f){const t=u((e-f)/r);p(1-t,t)}}return c})}return a.r+=1,u(i)?Te().then(()=>{i=i(),p()}):p(),{end(e){e&&i.tick&&i.tick(1,0),c&&(s&&te(t,s),c=!1)}}}function We(t,o,r,s){let i=o(t,r),c=s?0:1,a=null,p=null,d=null;function f(){d&&te(t,d)}function _(t,e){const n=t.b-c;return e*=Math.abs(n),{a:c,b:t.b,d:n,duration:e,start:t.start,end:t.start+e,group:t.group}}function h(o){const{delay:r=0,duration:s=300,easing:u=n,tick:h=e,css:x}=i||Pe,m={start:j()+r,b:o};o||(m.group=Re,Re.r+=1),a||p?p=m:(x&&(f(),d=Zt(t,c,o,s,r,u,x)),o&&h(0,1),a=_(m,s),Ee(()=>je(t,o,\"start\")),P(e=>{if(p&&e>p.start&&(a=_(p,s),p=null,je(t,a.b,\"start\"),x&&(f(),d=Zt(t,c,a.b,a.duration,0,u,i.css))),a)if(e>=a.end)h(c=a.b,1-c),je(t,a.b,\"end\"),p||(a.b?f():--a.group.r||l(a.group.c)),a=null;else if(e>=a.start){const t=e-a.start;c=a.a+a.d*u(t/a.duration),h(c,1-c)}return!(!a&&!p)}))}return{run(t){u(i)?Te().then(()=>{i=i(),h(t)}):h(t)},end(){f(),a=p=null}}}function Ge(t,e){const n=e.token={};function o(t,o,r,s){if(e.token!==n)return;e.resolved=s;let i=e.ctx;void 0!==r&&((i=i.slice())[r]=s);const c=t&&(e.current=t)(i);let l=!1;e.block&&(e.blocks?e.blocks.forEach((t,n)=>{n!==o&&t&&(qe(),Be(t,1,1,()=>{e.blocks[n]===t&&(e.blocks[n]=null)}),He())}):e.block.d(1),c.c(),Le(c,1),c.m(e.mount(),e.anchor),l=!0),e.block=c,e.blocks&&(e.blocks[o]=c),l&&Oe()}if(r(t)){const n=ie();if(t.then(t=>{se(n),o(e.then,1,e.value,t),se(null)},t=>{if(se(n),o(e.catch,2,e.error,t),se(null),!e.hasCatch)throw t}),e.current!==e.pending)return o(e.pending,0),!0}else{if(e.current!==e.then)return o(e.then,1,e.value,t),!0;e.resolved=t}}function Ue(t,e,n){const o=e.slice(),{resolved:r}=t;t.current===t.then&&(o[t.value]=r),t.current===t.catch&&(o[t.error]=r),t.block.p(o,n)}const Ye=\"undefined\"!=typeof window?window:\"undefined\"!=typeof globalThis?globalThis:t;function Je(t,e){t.d(1),e.delete(t.key)}function Ke(t,e){Be(t,1,1,()=>{e.delete(t.key)})}function Qe(t,e){t.f(),Je(t,e)}function Ve(t,e){t.f(),Ke(t,e)}function Xe(t,e,n,o,r,s,i,c,l,u,a,p){let d=t.length,f=s.length,_=d;const h={};for(;_--;)h[t[_].key]=_;const x=[],m=new Map,g=new Map;for(_=f;_--;){const t=p(r,s,_),c=n(t);let l=i.get(c);l?o&&l.p(t,e):(l=u(c,t)).c(),m.set(c,x[_]=l),c in h&&g.set(c,Math.abs(_-h[c]))}const y=new Set,b=new Set;function $(t){Le(t,1),t.m(c,a),i.set(t.key,t),a=t.first,f--}for(;d&&f;){const e=x[f-1],n=t[d-1],o=e.key,r=n.key;e===n?(a=e.first,d--,f--):m.has(r)?!i.has(o)||y.has(o)?$(e):b.has(r)?d--:g.get(o)>g.get(r)?(b.add(o),$(e)):(y.add(r),d--):(l(n,i),d--)}for(;d--;){const e=t[d];m.has(e.key)||l(e,i)}for(;f;)$(x[f-1]);return x}function Ze(t,e,n,o){const r=new Set;for(let s=0;s<e.length;s++){const i=o(n(t,e,s));if(r.has(i))throw new Error(\"Cannot have duplicate keys in a keyed each\");r.add(i)}}function tn(t,e){const n={},o={},r={$$scope:1};let s=t.length;for(;s--;){const i=t[s],c=e[s];if(c){for(const t in i)t in c||(o[t]=1);for(const t in c)r[t]||(n[t]=c[t],r[t]=1);t[s]=c}else for(const t in i)r[t]=1}for(const i in o)i in n||(n[i]=void 0);return n}function en(t){return\"object\"==typeof t&&null!==t?t:{}}exports.globals=Ye;const nn=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),on=/[\\s'\">\\/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function rn(t,e){const n=Object.assign({},...t);e&&(null==n.class?n.class=e:n.class+=\" \"+e);let o=\"\";return Object.keys(n).forEach(t=>{if(on.test(t))return;const e=n[t];!0===e?o+=\" \"+t:nn.has(t.toLowerCase())?e&&(o+=\" \"+t):null!=e&&(o+=` ${t}=\"${e}\"`)}),o}exports.invalid_attribute_name_character=on;const sn={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function cn(t){return String(t).replace(/[\"'&<>]/g,t=>sn[t])}function ln(t){return\"string\"==typeof t?cn(t):t}function un(t){const e={};for(const n in t)e[n]=ln(t[n]);return e}function an(t,e){let n=\"\";for(let o=0;o<t.length;o+=1)n+=e(t[o],o);return n}exports.escaped=sn;const pn={$$render:()=>\"\"};function dn(t,e){if(!t||!t.$$render)throw\"svelte:component\"===e&&(e+=\" this={...}\"),new Error(`<${e}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return t}function fn(t,e,n,o){return console.log(`{@debug} ${t?t+\" \":\"\"}(${e}:${n})`),console.log(o),\"\"}let _n,hn;function xn(t){function e(e,n,o,r,s){const i=Qt;se({$$:{on_destroy:_n,context:new Map(i?i.$$.context:s||[]),on_mount:[],before_update:[],after_update:[],callbacks:c()}});const l=t(e,n,o,r);return se(i),l}return{render:(t={},{$$slots:n={},context:o=new Map}={})=>{_n=[];const r={title:\"\",head:\"\",css:new Set},s=e(r,t,{},n,o);return l(_n),{html:s,css:{code:Array.from(r.css).map(t=>t.code).join(\"\\n\"),map:null},head:r.title+r.head}},$$render:e}}function mn(t,e,n){return null==e||n&&!e?\"\":` ${t}${!0===e?\"\":`=${\"string\"==typeof e?JSON.stringify(cn(e)):`\"${e}\"`}`}`}function gn(t){return t?` class=\"${t}\"`:\"\"}function yn(t,e,n){const o=t.$$.props[e];void 0!==o&&(t.$$.bound[o]=n,n(t.$$.ctx[o]))}function bn(t){t&&t.c()}function $n(t,e){t&&t.l(e)}function vn(t,e,n,o){const{fragment:r,on_mount:s,on_destroy:c,after_update:a}=t.$$;r&&r.m(e,n),o||Ee(()=>{const e=s.map(i).filter(u);c?c.push(...e):l(e),t.$$.on_mount=[]}),a.forEach(Ee)}function Fn(t,e){const n=t.$$;null!==n.fragment&&(l(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function wn(t,e){-1===t.$$.dirty[0]&&(me.push(t),we(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function kn(t,n,o,r,s,i,u,a=[-1]){const p=Qt;se(t);const d=t.$$={fragment:null,ctx:null,props:i,update:e,not_equal:s,bound:c(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:n.context||[]),callbacks:c(),dirty:a,skip_bound:!1,root:n.target||p.$$.root};u&&u(d.root);let f=!1;if(d.ctx=o?o(t,n.props||{},(e,n,...o)=>{const r=o.length?o[0]:n;return d.ctx&&s(d.ctx[e],d.ctx[e]=r)&&(!d.skip_bound&&d.bound[e]&&d.bound[e](r),f&&wn(t,e)),n}):[],d.update(),f=!0,l(d.before_update),d.fragment=!!r&&r(d.ctx),n.target){if(n.hydrate){W();const t=wt(n.target);d.fragment&&d.fragment.l(t),t.forEach(nt)}else d.fragment&&d.fragment.c();n.intro&&Le(t.$$.fragment),vn(t,n.target,n.anchor,n.customElement),G(),Oe()}se(p)}exports.missing_component=pn,exports.SvelteElement=hn,\"function\"==typeof HTMLElement&&(exports.SvelteElement=hn=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(i).filter(u);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){l(this.$$.on_disconnect)}$destroy(){Fn(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class En{$destroy(){Fn(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Sn(t,e){document.dispatchEvent(zt(t,Object.assign({version:\"3.41.0\"},e),!0))}function Cn(t,e){Sn(\"SvelteDOMInsert\",{target:t,node:e}),J(t,e)}function Dn(t,e){Sn(\"SvelteDOMInsert\",{target:t,node:e}),Z(t,e)}function On(t,e,n){Sn(\"SvelteDOMInsert\",{target:t,node:e,anchor:n}),tt(t,e,n)}function An(t,e,n){Sn(\"SvelteDOMInsert\",{target:t,node:e,anchor:n}),et(t,e,n)}function Mn(t){Sn(\"SvelteDOMRemove\",{node:t}),nt(t)}function Tn(t,e){for(;t.nextSibling&&t.nextSibling!==e;)Mn(t.nextSibling)}function jn(t){for(;t.previousSibling;)Mn(t.previousSibling)}function Nn(t){for(;t.nextSibling;)Mn(t.nextSibling)}function Rn(t,e,n,o,r,s){const i=!0===o?[\"capture\"]:o?Array.from(Object.keys(o)):[];r&&i.push(\"preventDefault\"),s&&i.push(\"stopPropagation\"),Sn(\"SvelteDOMAddEventListener\",{node:t,event:e,handler:n,modifiers:i});const c=pt(t,e,n,o);return()=>{Sn(\"SvelteDOMRemoveEventListener\",{node:t,event:e,handler:n,modifiers:i}),c()}}function qn(t,e,n){xt(t,e,n),null==n?Sn(\"SvelteDOMRemoveAttribute\",{node:t,attribute:e}):Sn(\"SvelteDOMSetAttribute\",{node:t,attribute:e,value:n})}function Hn(t,e,n){t[e]=n,Sn(\"SvelteDOMSetProperty\",{node:t,property:e,value:n})}function Ln(t,e,n){t.dataset[e]=n,Sn(\"SvelteDOMSetDataset\",{node:t,property:e,value:n})}function Bn(t,e){e=\"\"+e,t.wholeText!==e&&(Sn(\"SvelteDOMSetData\",{node:t,data:e}),t.data=e)}function Pn(t){if(\"string\"!=typeof t&&!(t&&\"object\"==typeof t&&\"length\"in t)){let e=\"{#each} only iterates over array-like objects.\";throw\"function\"==typeof Symbol&&t&&Symbol.iterator in t&&(e+=\" You can use a spread to convert this iterable into an array.\"),new Error(e)}}function In(t,e,n){for(const o of Object.keys(e))~n.indexOf(o)||console.warn(`<${t}> received an unexpected slot \"${o}\".`)}exports.SvelteComponent=En;class zn extends En{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=(()=>{console.warn(\"Component was already destroyed\")})}$capture_state(){}$inject_state(){}}exports.SvelteComponentDev=zn;class Wn extends zn{constructor(t){super(t)}}function Gn(t){const e=Date.now();return()=>{if(Date.now()-e>t)throw new Error(\"Infinite loop detected\")}}exports.SvelteComponentTyped=Wn;\n},{}],\"UTAW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.urlAlphabet=void 0;let e=\"ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW\";exports.urlAlphabet=e;\n},{}],\"b767\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"urlAlphabet\",{enumerable:!0,get:function(){return e.urlAlphabet}}),exports.random=exports.customRandom=exports.customAlphabet=exports.nanoid=void 0;var e=require(\"./url-alphabet/index.js\");let t=e=>crypto.getRandomValues(new Uint8Array(e));exports.random=t;let r=(e,t,r)=>{let o=(2<<Math.log(e.length-1)/Math.LN2)-1,n=-~(1.6*o*t/e.length);return()=>{let l=\"\";for(;;){let a=r(n),p=n;for(;p--;)if((l+=e[a[p]&o]||\"\").length===t)return l}}};exports.customRandom=r;let o=(e,o)=>r(e,o,t);exports.customAlphabet=o;let n=(e=21)=>{let t=\"\",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let o=63&r[e];t+=o<36?o.toString(36):o<62?(o-26).toString(36).toUpperCase():o<63?\"_\":\"-\"}return t};exports.nanoid=n;\n},{\"./url-alphabet/index.js\":\"UTAW\"}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"Tr4D\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ie,exports.S=se,exports.U=le,exports.b=ne,exports.e=$,exports.i=V,exports.y=D,exports.z=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.c=exports.a=exports.T=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=r(require(\"immer\")),t=r(require(\"lodash.isplainobject\"));function r(e){return e&&e.__esModule?e:{default:e}}const s=\"MAKE_MOVE\";exports.M=s;const n=\"GAME_EVENT\";exports.d=n;const a=\"REDO\";exports.m=a;const o=\"RESET\";exports.R=o;const i=\"SYNC\";exports.k=i;const l=\"UNDO\";exports.l=l;const p=\"UPDATE\";exports.j=p;const c=\"PATCH\";exports.o=c;const u=\"PLUGIN\";exports.P=u;const d=\"STRIP_TRANSIENTS\";exports.c=d;const h=(e,t,r,n)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:n}});exports.x=h;const y=(e,t,r,s)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:s}});exports.g=y;const g=(e,t,r,s)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:s},automatic:!0}),v=e=>({type:i,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=v;const f=(e,t,r,s)=>({type:c,prevStateID:e,stateID:t,patch:r,deltalog:s,clientOnly:!0});exports.C=f;const x=(e,t)=>({type:p,state:e,deltalog:t,clientOnly:!0});exports.B=x;const m=e=>({type:o,state:e,clientOnly:!0});exports.t=m;const E=(e,t)=>({type:l,payload:{type:null,args:null,playerID:e,credentials:t}});exports.u=E;const O=(e,t)=>({type:a,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=O;const P=(e,t,r,s)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:s}}),_=()=>({type:d});exports.q=_;var N=Object.freeze({makeMove:h,gameEvent:y,automaticGameEvent:g,sync:v,patch:f,update:x,reset:m,undo:E,redo:O,plugin:P,stripTransients:_});exports.A=N;const M=\"INVALID_MOVE\";exports.h=M;const T={name:\"plugin-immer\",fnWrap:t=>(r,s,...n)=>{let a=!1;const o=(0,e.default)(r,e=>{const r=t(e,s,...n);if(r!==M)return r;a=!0});return a?M:o}};class A{constructor(e){const t=I();this.c=1,this.s0=t(\" \"),this.s1=t(\" \"),this.s2=t(\" \"),this.s0-=t(e),this.s0<0&&(this.s0+=1),this.s1-=t(e),this.s1<0&&(this.s1+=1),this.s2-=t(e),this.s2<0&&(this.s2+=1)}next(){const e=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=e-(this.c=Math.trunc(e))}}function I(){let e=4022871197;return function(t){const r=t.toString();for(let s=0;s<r.length;s++){let t=.02519603282416938*(e+=r.charCodeAt(s));t-=e=t>>>0,e=(t*=e)>>>0,e+=4294967296*(t-=e)}return 2.3283064365386963e-10*(e>>>0)}}function S(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function D(e,t){const r=new A(e),s=r.next.bind(r);return t&&S(t,r),s.state=(()=>S(r,{})),s}class L{constructor(e){this.state=e||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const e=this.state,t=D(e.prngstate?\"\":e.seed,e.prngstate),r=t();return this.state={...e,prngstate:t.state()},r}api(){const e=this._random.bind(this),t={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},r={};for(const s in t){const n=t[s];r[s]=(t=>void 0===t?Math.floor(e()*n)+1:Array.from({length:t}).map(()=>Math.floor(e()*n)+1))}return{...r,Die:function(t=6,r){return void 0===r?Math.floor(e()*t)+1:Array.from({length:r}).map(()=>Math.floor(e()*t)+1)},Number:()=>e(),Shuffle:t=>{const r=[...t];let s=t.length,n=0;const a=Array.from({length:s});for(;s;){const t=Math.trunc(s*e());a[n++]=r[t],r[t]=r[--s]}return a},_private:this}}}const b={name:\"random\",noClient:({api:e})=>e._private.isUsed(),flush:({api:e})=>e._private.getState(),api:({data:e})=>{return new L(e).api()},setup:({game:e})=>{let{seed:t}=e;return void 0===t&&(t=L.seed()),{seed:t}},playerView:()=>void 0};var U,G;exports.G=U,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(U||(exports.G=U={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(G||(G={}));class w{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let s=0;s<this.dispatch.length;s++){const t=this.dispatch[s],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,G.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,G.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case U.TURN_ON_END:case U.PHASE_ON_END:return r(t.error,G.StageEventInOnEnd);case U.PHASE_ON_BEGIN:return r(t.error,G.StageEventInPhaseBegin);case U.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,G.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===U.TURN_ON_END||t.calledFrom===U.PHASE_ON_END)return r(t.error,G.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===U.PHASE_ON_END)return r(t.error,G.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const a=g(t.type,t.args,this.playerID);e=this.flow.processEvent(e,a)}return e}}const R={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,s,...n)=>{const a=s.events;return a&&a._private.updateTurnContext(s,t),r=e(r,s,...n),a&&a._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new w(e.flow,t,r).api()},k={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function C(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,t.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!C(e[t]))return!1;return!0}const B={name:\"plugin-serializable\",fnWrap:e=>(t,r,...s)=>{const n=e(t,r,...s);return n}},F=!0,H=()=>{},j=(...e)=>console.error(...e);function V(e){H(`INFO: ${e}`)}function $(e){j(\"ERROR:\",e)}const W=[T,b,k,B],q=[...W,R],z=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}},a=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[s]:{...n,data:a}}}}),e);exports.n=z;const K=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=K;const Y=(e,t,r)=>[...W,...r,R].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=Y;const J=(e,t)=>([...q,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const s=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[s]:{data:n}}}}),e);exports.r=J;const Q=(e,t)=>([...q,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}},a=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[s]:{...n,api:a}}}}),e);exports.f=Q;const X=(e,t)=>([...W,...t.game.plugins,R].reverse().forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}};if(r.flush){const s=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}else if(r.dangerouslyFlushRawState){const a=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[s].data;e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}}),e),Z=(e,t)=>[...q,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const s=r.name,n=e.plugins[s];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=Z;const ee=(e,t)=>{return[...q,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:s}=r,n=e.plugins[s],a=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!a&&{plugin:s,message:a}}).find(e=>e)||!1},te=(e,t)=>{const r=X(e,t),s=ee(r,t);if(!s)return[r];const{plugin:n,message:a}=s;return $(`${n} plugin declared action invalid:\\n${a}`),[e,s]};exports.p=te;const re=({G:e,ctx:t,plugins:r={}},{game:s,playerID:n})=>([...q,...s.plugins].forEach(({name:a,playerView:o})=>{if(!o)return;const{data:i}=r[a]||{data:{}},l=o({G:e,ctx:t,game:s,data:i,playerID:n});r={...r,[a]:{data:l}}}),r);function se(e,t){let r={},s=[],n=null,a={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=ce.NULL),r=e}else{if(t.next&&(n=t.next),t.revert&&(s=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMoveLimit:e._activePlayersMoveLimit,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&ae(r,a,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let s=0;s<e.playOrder.length;s++){const n=e.playOrder[s];n!==e.currentPlayer&&ae(r,a,n,t.others)}if(void 0!==t.all)for(let s=0;s<e.playOrder.length;s++){ae(r,a,e.playOrder[s],t.all)}if(t.value)for(const e in t.value)ae(r,a,e,t.value[e]);if(t.moveLimit)for(const e in r)void 0===a[e]&&(a[e]=t.moveLimit)}0===Object.keys(r).length&&(r=null),0===Object.keys(a).length&&(a=null);const o={};for(const i in r)o[i]=0;return{...e,activePlayers:r,_activePlayersMoveLimit:a,_activePlayersNumMoves:o,_prevActivePlayers:s,_nextActivePlayers:n}}function ne(e){let{activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n,_nextActivePlayers:a}=e;if(t&&0===Object.keys(t).length)if(a)e=se(e,a),({activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n}=e);else if(n.length>0){const e=n.length-1;({activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s}=n[e]),n=n.slice(0,e)}else t=null,r=null;return{...e,activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n}}function ae(e,t,r,s){\"object\"==typeof s&&s!==ce.NULL||(s={stage:s}),void 0!==s.stage&&(e[r]=s.stage,s.moveLimit&&(t[r]=s.moveLimit))}function oe(e,t){return e[t]+\"\"}function ie(e,t){let{G:r,ctx:s}=e;const{numPlayers:n}=s,a=K(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,a));const l=o.first(r,a),p=typeof l;\"number\"!==p&&$(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=oe(i,l);return s=se(s={...s,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function le(e,t,r,s){const n=r.order;let{G:a,ctx:o}=e,i=o.playOrderPos,l=!1;if(s&&!0!==s)\"object\"!=typeof s&&$(`invalid argument to endTurn: ${s}`),Object.keys(s).forEach(e=>{switch(e){case\"remove\":t=oe(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(s.next),t=s.next;break;default:$(`invalid argument to endTurn: ${e}`)}});else{const r=K(e),s=n.next(a,r),p=typeof s;void 0!==s&&\"number\"!==p&&$(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${s}”.`),void 0===s?l=!0:(i=s,t=oe(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.w=re;const pe={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=pe;const ce={NULL:null};exports.a=ce;const ue={ALL:{all:ce.NULL},ALL_ONCE:{all:ce.NULL,moveLimit:1},OTHERS:{others:ce.NULL},OTHERS_ONCE:{others:ce.NULL,moveLimit:1}};exports.z=ue;\n},{\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)o=((e=o)||{})[n=this.tokens[r]];return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"b133\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=m,exports.I=s,exports.P=i,exports.T=void 0;var e,t,n=require(\"./turn-order-0d61594c.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:i,plugins:s}){void 0===e&&(e={}),void 0===i&&(i={}),void 0===s&&(s=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const u={...t};\"\"in u&&(0,n.e)(\"cannot specify phase with empty name\"),u[\"\"]={};const c={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,s);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const T in u){const e=u[T];if(!0===e.start&&(d=T),void 0!==e.moves)for(const t of Object.keys(e.moves))c[T+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={});for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){c[T+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?u[e.phase]:u[\"\"]}function m(e){return e}function g(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:i,...s}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const u=[];if(e=o(e,{...s,arg:i,next:u}),o===b)break;const c=G(e);if(c){t.push({fn:b,arg:c,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([m,D,M].includes(o)){const n=w(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...u)}}return e}function h(e,{next:t}){return t.push({fn:x}),e}function x(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.S)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const i=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:i,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:i}=e;if(t&&t.next){if(!(t.next in u))return(0,n.e)(\"invalid phase: \"+t.next),e;i={...i,phase:t.next}}else i={...i,phase:o.wrapped.next(e)||null};return e={...e,ctx:i},a.push({fn:x}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:i}=e;const s=y(i),{endPhase:u,ctx:c}=(0,n.U)(e,a,s.turn,t);return i=c,e={...e,G:o,ctx:i},u?r.push({fn:N,turn:i.turn,phase:i.phase}):r.push({fn:I,currentPlayer:i.currentPlayer}),e}function D(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.a.NULL||(t={stage:t}),\"object\"!=typeof t)return e;let{ctx:r}=e,{activePlayers:o,_activePlayersMoveLimit:i,_activePlayersNumMoves:s}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,s[a]=0,t.moveLimit&&(null===i&&(i={}),i[a]=t.moveLimit)),r={...r,activePlayers:o,_activePlayersMoveLimit:i,_activePlayersNumMoves:s},{...e,ctx:r}}function M(e,{arg:t}){return{...e,ctx:(0,n.S)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function w(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.moveLimit&&n>=t.turn.moveLimit)||t.turn.wrapped.endIf(e)}function b(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:i,turn:s}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:i}),null===i)return e;const u=y(e.ctx).wrapped.onEnd(e),c={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:s,phase:i};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:u,ctx:c,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:i,playerID:s}){if(r!==e.ctx.turn)return e;const{currentPlayer:u,numMoves:c,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=c||0;if(!o&&p.turn.moveLimit&&v<p.turn.moveLimit)return(0,n.i)(`cannot end turn before making ${p.turn.moveLimit} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:u});let m={...e.ctx,activePlayers:null};if(t&&t.remove){s=s||u;const t=m.playOrder.filter(e=>e!=s),n=m.playOrderPos>t.length-1?0:m.playOrderPos;if(m={...m,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const g=(0,n.g)(\"endTurn\",t),{_stateID:h}=e,x={action:g,_stateID:h,turn:d,phase:l};i&&(x.automatic=!0);const I=[...e.deltalog||[],x];return{...e,G:f,ctx:m,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:i,_stateID:s}=e,{activePlayers:u,_activePlayersMoveLimit:c,phase:l,turn:d}=i;const p=null!==u&&o in u;if(!t&&p){const e=y(i).turn.stages[u[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:D,arg:t,playerID:o}),!p)return e;delete(u={...u})[o],c&&delete(c={...c})[o],i=(0,n.b)({...i,activePlayers:u,_activePlayersMoveLimit:c});const v={action:(0,n.g)(\"endStage\",t),_stateID:s,turn:d,phase:l};r&&(v.automatic=!0);const f=[...e.deltalog||[],v];return{...e,ctx:i,deltalog:f}}function S(t,a,r){const o=y(t),i=o.turn.stages,{activePlayers:s}=t;if(s&&void 0!==s[r]&&s[r]!==n.a.NULL&&void 0!==i[s[r]]&&void 0!==i[s[r]].moves){const e=i[s[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const L={endStage:function(e,t){return g(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return g(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return g(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return g(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return g(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return g(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return g(e,[{fn:b,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return g(e,[{fn:M,arg:n}])}},U=[];return!1!==i.endTurn&&U.push(\"endTurn\"),!1!==i.pass&&U.push(\"pass\"),!1!==i.endPhase&&U.push(\"endPhase\"),!1!==i.setPhase&&U.push(\"setPhase\"),!1!==i.endGame&&U.push(\"endGame\"),!1!==i.setActivePlayers&&U.push(\"setActivePlayers\"),!1!==i.endStage&&U.push(\"endStage\"),!1!==i.setStage&&U.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>g(e,[{fn:h}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:L,eventNames:Object.keys(L),enabledEventNames:U,moveMap:c,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{ctx:r}=e,{currentPlayer:o,activePlayers:i,_activePlayersMoveLimit:s}=r,u=S(r,a,n),c=!u||\"function\"==typeof u||!0!==u.noLimit;let{numMoves:l,_activePlayersNumMoves:d}=r;c&&(n===o&&l++,i&&d[n]++),e={...e,ctx:{...r,numMoves:l,_activePlayersNumMoves:d}},s&&d[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const p=y(r).turn.wrapped.onMove(e);return g(e={...e,G:p},[{fn:m}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof L[n]?e:L[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function i(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(s(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),i={...(0,n.E)(a),playerID:r.playerID};let s=[];return void 0!==r.args&&(s=Array.isArray(r.args)?r.args:[r.args]),t(a.G,i,...s)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function s(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const u=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,c=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,i]=(0,n.p)(e,r);return i?[o,f(a,t.PluginActionInvalid,i)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.c:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.q)()),{...r,transients:t}):r}}};function m({game:r,isClient:o}){return r=i(r),(i=null,s)=>{let[y]=v(i);switch(s.type){case n.c:return y;case n.d:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(u(s)&&!r.flow.isPlayerActive(y.G,y.ctx,s.payload.playerID))return(0,n.e)(`disallowed event: ${s.payload.type}`),f(y,t.InactivePlayer);y=(0,n.f)(y,{game:r,isClient:!1,playerID:s.payload.playerID});let e,a=r.flow.processEvent(y,s);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:s}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,s.payload.type,s.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${s.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(u(s)&&!r.flow.isPlayerActive(y.G,y.ctx,s.payload.playerID))return(0,n.e)(`disallowed move: ${s.payload.type}`),f(y,t.InactivePlayer);y=(0,n.f)(y,{game:r,isClient:o,playerID:s.payload.playerID});const i=r.processMove(y,s.payload);if(i===n.h)return(0,n.e)(`invalid move: ${s.payload.type} args: ${s.payload.args}`),f(y,t.InvalidMove);const c={...y,G:i};if(o&&(0,n.N)(c,{game:r}))return y;if(y=c,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,s,a),y=r.flow.processMove(y,s.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:s}),{...y,_stateID:y._stateID+1})}case n.R:case n.j:case n.k:return s.state;case n.l:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:i,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(u(s)&&s.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!c(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,s),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...i]}}case n.m:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const i=a[0];return u(s)&&s.payload.playerID!==i.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,s),{...y,G:i.G,ctx:i.ctx,plugins:i.plugins,_stateID:o+1,_undo:[...e,i],_redo:a.slice(1)})}case n.P:return(0,n.n)(y,s,{game:r});case n.o:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,s.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(s.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"vgbL\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=n,exports.a=o,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0d61594c.js\"),e=require(\"./reducer-77828ca8.js\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:a}){this._opts[t]={range:e,value:a}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,a,s){return this.enumerateFn(e,a,s).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.x)(e.move,e.args,s):\"event\"in e?(0,t.g)(e.event,e.args,s):void 0)}random(e){let a;if(void 0!==this.seed){const e=this.prngstate?\"\":this.seed,s=(0,t.y)(e,this.prngstate);a=s(),this.prngstate=s.state()}else a=Math.random();if(e){if(Array.isArray(e)){return e[Math.floor(a*e.length)]}return Math.floor(a*e)}return a}}exports.B=a;const s=25;class r extends a{constructor({enumerate:t,seed:a,objectives:s,game:r,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:a}),void 0===s&&(s=(()=>({}))),this.objectives=s,this.iterationCallback=o||(()=>{}),this.reducer=(0,e.C)({game:r}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:a,playerID:s}){const{G:r,ctx:i}=t;let n=[],o=[];if(void 0!==s)n=this.enumerate(r,i,s),o=this.objectives(r,i,s);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(r,i,c)),o.push(this.objectives(r,i,c));else n=this.enumerate(r,i,i.currentPlayer),o=this.objectives(r,i,i.currentPlayer);return{state:t,parent:a,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,a=0;for(const s of t.children){const r=s.visits+Number.EPSILON,i=s.value/r+Math.sqrt(2*Math.log(t.visits)/r);(null==e||i>a)&&(a=i,e=s)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const a=this.random(e.length),s=e[a];t.actions.splice(a,1);const r=this.reducer(t.state,s),i=this.createNode({state:r,parentAction:s,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let a=0;a<e&&void 0===t.ctx.gameover;a++){const{G:e,ctx:a}=t;let s=a.currentPlayer;a.activePlayers&&(s=Object.keys(a.activePlayers)[0]);const r=this.enumerate(e,a,s),i=this.objectives(e,a,s),n=Object.keys(i).reduce((t,s)=>{const r=i[s];return r.checker(e,a)?t+r.weight:t},0);if(n>0)return{score:n};if(!r||0===r.length)return;const o=this.random(r.length);t=this.reducer(t,r[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const a=this.createNode({state:t,playerID:e});let r=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(r=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of a.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:a}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<r;t++){const t=this.select(a),e=this.expand(t),s=this.playout(e);this.backpropagate(e,s),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:r,metadata:a})};if(this.iterationCounter=0,this.getOpt(\"async\")){const a=()=>{this.iterationCounter<r?(e(),setTimeout(a,0)):t(i())};a()}else{for(;this.iterationCounter<r;)e();t(i())}})}}exports.M=r;class i extends a{play({G:t,ctx:e},a){const s=this.enumerate(t,e,a);return Promise.resolve({action:this.random(s)})}}async function n(t,e){const a=t.store.getState();let s=a.ctx.currentPlayer;a.ctx.activePlayers&&(s=Object.keys(a.ctx.activePlayers)[0]);const{action:r,metadata:i}=await e.play(a,s);if(r){const e={...r,payload:{...r.payload,metadata:i}};return t.store.dispatch(e),e}}async function o({game:t,bots:s,state:r,depth:i}){void 0===i&&(i=1e4);const n=(0,e.C)({game:t});let o=null,c=0;for(;void 0===r.ctx.gameover&&c<i;){let t=r.ctx.currentPlayer;r.ctx.activePlayers&&(t=Object.keys(r.ctx.activePlayers)[0]);const e=s instanceof a?s:s[t],i=await e.play(r,t);if(!i.action)break;o=i.metadata,r=n(r,i.action),c++}return{state:r,metadata:o}}exports.R=i;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\"}],\"odqP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0d61594c.js\"),t=require(\"./reducer-77828ca8.js\"),n=require(\"flatted\"),r=require(\"./ai-f28cab02.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function X(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Y(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const W=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);W.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(W.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),W.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=Y(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(Y(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function Xe(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Ye(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function We(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},We)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1scv1e1\",\".menu.svelte-1scv1e1{display:flex;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;transform-origin:top right;transform:rotate(-90deg) /* 2 */ translateY(-27px) /* 3 */ translateX(-70px)}.menu-item.svelte-1scv1e1{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1scv1e1:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1scv1e1:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1scv1e1{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1scv1e1:hover,.menu-item.svelte-1scv1e1:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1scv1e1\"),X(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&X(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1scv1e1\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),X(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&X(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),X(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&X(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),X(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&X(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),X(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&X(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Xt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Yt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Wt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Wt,Yt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),X(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&X(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&X(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&X(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Xt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),X(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&X(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),X(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&X(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Xn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Yn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),X(t,\"current\",e[7]==e[0].currentPlayer),X(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&X(t,\"current\",e[7]==e[0].currentPlayer),6&o&&X(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Wn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Yn(Xn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Xn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Yn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Wn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){return!t||\"object\"!=typeof t&&\"function\"!=typeof t?pr(e):t}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager)}),[s,r,i]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Xr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Yr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Wr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Wr,Yr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),X(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&X(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Xr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),X(t,\"clickable\",e[1].length>0),X(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&X(t,\"clickable\",e[1].length>0),1&l&&X(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),X(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&X(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[5]=t[n][0],r[6]=t[n][1],r[7]=t,r[8]=n,r}function Bl(e){let t,n,r,l,o,a,s,i,u=e[1][e[5]]+\"\";function d(){e[3].call(l,e[5])}return{c(){t=M(\"span\"),n=N(u),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"type\",\"range\"),G(l,\"min\",o=e[6].range.min),G(l,\"max\",a=e[6].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[5]]),s||(i=[R(l,\"change\",d),R(l,\"input\",d),R(l,\"change\",e[2])],s=!0)},p(t,r){e=t,3&r&&u!==(u=e[1][e[5]]+\"\")&&F(n,u),1&r&&o!==(o=e[6].range.min)&&G(l,\"min\",o),1&r&&a!==(a=e[6].range.max)&&G(l,\"max\",a),3&r&&H(l,e[1][e[5]])},d(e){e&&I(t),e&&I(r),e&&I(l),s=!1,c(i)}}}function Rl(e){let t,n,r;function l(){e[4].call(t,e[5])}return{c(){G(t=M(\"input\"),\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(o,a){q(o,t,a),t.checked=e[1][e[5]],n||(r=[R(t,\"change\",l),R(t,\"change\",e[2])],n=!0)},p(n,r){e=n,3&r&&(t.checked=e[1][e[5]])},d(e){e&&I(t),n=!1,c(r)}}}function Kl(e){let t,n,r,l,o,a,s=e[5]+\"\",i=e[6].range&&Bl(e),c=\"boolean\"==typeof e[6].value&&Rl(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),l=V(),i&&i.c(),o=V(),c&&c.c(),a=V(),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,s){q(e,t,s),A(t,n),A(n,r),A(t,l),i&&i.m(t,null),A(t,o),c&&c.m(t,null),A(t,a)},p(e,n){1&n&&s!==(s=e[5]+\"\")&&F(r,s),e[6].range?i?i.p(e,n):((i=Bl(e)).c(),i.m(t,o)):i&&(i.d(1),i=null),\"boolean\"==typeof e[6].value?c?c.p(e,n):((c=Rl(e)).c(),c.m(t,a)):c&&(c.d(1),c=null)},d(e){e&&I(t),i&&i.d(),c&&c.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Xl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Yl(Hl(e,E,c));let z=j&&Wl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[16].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[16]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Yl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Wl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Yl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[17]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Xl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t;const{secondaryPane:a}=de(\"secondaryPane\"),s={MCTS:r.M,Random:r.R};let i=!1,c=null,u=0,d=null;const f=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,u=e),n(2,c=e/t),d=r,i&&d&&a.set({component:jl,metadata:d})};let p,m,g,v;function $(){l.overrideGameState(null),a.set(null),n(1,i=!1)}return l.game.ai&&(p=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:f})).setOpt(\"async\",!0),ie($),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager)}),[l,i,c,u,m,g,v,p,s,function(){i&&d?a.set({component:jl,metadata:d}):a.set(null)},function(){const e=s[m];n(7,p=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:f})),p.setOpt(\"async\",!0),n(5,g=null),d=null,a.set(null),n(3,u=0)},async function(){n(5,g=null),d=null,n(3,u=0);const e=await(0,r.S)(l,p);e&&(n(5,g=e.payload.type),n(6,v=e.payload.args))},function(e=1e4,t=100){return n(5,g=null),d=null,n(3,u=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,p);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,g=null),d=null,n(3,u=0),$()},function(e){27==e.keyCode&&$()},o,function(){m=U(this),n(4,m),n(8,s)},function(){i=this.checked,n(1,i)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15},Fl)}}function oo(e){z(e,\"svelte-18rjbx9\",\".debug-panel.svelte-18rjbx9.svelte-18rjbx9{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-18rjbx9.svelte-18rjbx9{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9:hover,.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9:focus{background:#eee}.opener.svelte-18rjbx9.svelte-18rjbx9{right:10px}.closer.svelte-18rjbx9.svelte-18rjbx9{left:175px}@keyframes svelte-18rjbx9-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-18rjbx9.svelte-18rjbx9{display:flex;height:100%;animation:svelte-18rjbx9-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-18rjbx9 .icon.svelte-18rjbx9{animation-direction:reverse}.pane.svelte-18rjbx9.svelte-18rjbx9{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-18rjbx9.svelte-18rjbx9{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-18rjbx9 button,.debug-panel.svelte-18rjbx9 select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-18rjbx9 select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-18rjbx9 section{margin-bottom:20px}.debug-panel.svelte-18rjbx9 .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v;l=new at({}),(i=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var $=e[6][e[2]].component;function y(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}$&&(d=new $(y(e)));let h=e[5]&&io(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=M(\"span\"),Be(l.$$.fragment),s=V(),Be(i.$$.fragment),c=V(),u=M(\"div\"),d&&Be(d.$$.fragment),f=V(),h&&h.c(),G(r,\"class\",\"icon svelte-18rjbx9\"),G(r,\"aria-hidden\",\"true\"),G(n,\"class\",\"visibility-toggle closer svelte-18rjbx9\"),G(n,\"title\",\"Hide Debug Panel\"),G(u,\"class\",\"pane svelte-18rjbx9\"),G(u,\"role\",\"region\"),G(u,\"aria-label\",e[2]),G(u,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-18rjbx9\")},m(o,a){q(o,t,a),A(t,n),A(n,r),Re(l,r,null),A(t,s),Re(i,t,null),A(t,c),A(t,u),d&&Re(d,u,null),e[15](u),A(t,f),h&&h.m(t,null),m=!0,g||(v=R(n,\"click\",e[9]),g=!0)},p(n,r){e=n;const l={};4&r&&(l.pane=e[2]),i.$set(l);const o={};if(16&r&&(o.client=e[4]),1&r&&(o.clientManager=e[0]),$!==($=e[6][e[2]].component)){if(d){_e();const e=d;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}$?(Be((d=new $(y(e))).$$.fragment),Ce(d.$$.fragment,1),Re(d,u,null)):d=null}else $&&d.$set(o);(!m||4&r)&&G(u,\"aria-label\",e[2]),e[5]?h?(h.p(e,r),32&r&&Ce(h,1)):((h=io(e)).c(),Ce(h,1),h.m(t,null)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se())},i(r){m||(Ce(l.$$.fragment,r),be(()=>{a&&a.end(1),(o=Te(n,e[13],{key:\"toggle\"})).start()}),Ce(i.$$.fragment,r),d&&Ce(d.$$.fragment,r),Ce(h),be(()=>{p||(p=De(t,Xe,{x:400,...e[11]},!0)),p.run(1)}),m=!0)},o(r){qe(l.$$.fragment,r),o&&o.invalidate(),a=Me(n,e[12],{key:\"toggle\"}),qe(i.$$.fragment,r),d&&qe(d.$$.fragment,r),qe(h),p||(p=De(t,Xe,{x:400,...e[11]},!1)),p.run(0),m=!1},d(n){n&&I(t),Ke(l),n&&a&&a.end(),Ke(i),d&&Ke(d),e[15](null),h&&h.d(),n&&p&&p.end(),g=!1,v()}}}function so(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-18rjbx9\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-18rjbx9\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[13],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[12],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function io(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-18rjbx9\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function co(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-18rjbx9\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[10]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function uo(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(14,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,y=!y)}let y=!0;const h={duration:150,easing:Ze},[b,x]=Ye(h);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{16384&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,y,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,function(e){\".\"!=e.key?y&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},h,b,x,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class fo extends Le{constructor(e){super(),Je(this,e,uo,co,d,{clientManager:0},oo)}}exports.D=fo;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"flatted\":\"O5av\",\"./ai-f28cab02.js\":\"vgbL\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"azvt\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0d61594c.js\"),t=require(\"./reducer-77828ca8.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.r)(n,{game:r}),n=(0,e.f)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.p)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\"}],\"KLsr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class e{constructor({store:e,gameName:t,playerID:s,matchID:a,credentials:r,numPlayers:l}){this.store=e,this.gameName=t||\"default\",this.playerID=s||null,this.matchID=a||\"default\",this.credentials=r,this.numPlayers=l||2}}exports.T=e;\n},{}],\"yBCo\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid\"),e=require(\"./Debug-a4f4cad1.js\"),s=require(\"redux\"),i=require(\"./turn-order-0d61594c.js\"),r=require(\"./reducer-77828ca8.js\"),a=require(\"./initialize-68f0dc41.js\"),n=require(\"./transport-0079de87.js\");class h extends n.T{connect(){}disconnect(){}onAction(){}onChatMessage(){}subscribe(){}subscribeChatMessage(){}subscribeMatchData(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const l=t=>new h(t);class u{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const c=new u;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const l of e)h[l]=((...e)=>{const h=i.A[t](l,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:u,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g,this.credentials=d,this.multiplayer=u,this.debugOpt=n,this.manager=c,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==u}),this.initialState=null,u||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.t)(this.initialState))}),this.undo=(()=>{const t=(0,i.u)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.c||this.transport.onAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.d:case i.l:case i.m:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.R:this.log=[];break;case i.o:case i.j:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.k:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),u||(u=l),this.transport=u({gameKey:e,game:this.game,store:this.store,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.transport.subscribeMatchData(t=>{this.matchData=t,this.notifySubscribers()}),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.onChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})}),this.transport.subscribeChatMessage(t=>{this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()})}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribe(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.w)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid\":\"b767\",\"./Debug-a4f4cad1.js\":\"odqP\",\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\"}],\"hK59\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const t=(t,e)=>{if(!t||\"string\"!=typeof t)throw new Error(`Expected ${e} string, got \"${t}\".`)},e=e=>t(e,\"game name\"),s=e=>t(e,\"match ID\"),r=(t,e)=>{if(!t)throw new Error(`Expected body, got “${t}”.`);for(const s in e){const r=e[s],a=t[s];if(typeof a!==r)throw new TypeError(`Expected body.${s} to be of type ${r}, got “${a}”.`)}};class a extends Error{constructor(t,e){super(t),this.details=e}}exports.a=a;class i{constructor({server:t=\"\"}={}){this.server=t.replace(/\\/$/,\"\")}async request(t,e){const s=await fetch(this.server+t,e);if(!s.ok){let t;try{t=await s.json()}catch{try{t=await s.text()}catch(r){t=r.message}}throw new a(`HTTP status ${s.status}`,t)}return s.json()}async post(t,e){let s={method:\"post\",body:JSON.stringify(e.body),headers:{\"Content-Type\":\"application/json\"}};return e.init&&(s={...s,...e.init,headers:{...s.headers,...e.init.headers}}),this.request(t,s)}async listGames(t){return this.request(\"/games\",t)}async listMatches(t,s,r){e(t);let a=\"\";if(s){const t=[],{isGameover:e,updatedBefore:r,updatedAfter:i}=s;void 0!==e&&t.push(`isGameover=${e}`),r&&t.push(`updatedBefore=${r}`),i&&t.push(`updatedAfter=${i}`),t.length>0&&(a=\"?\"+t.join(\"&\"))}return this.request(`/games/${t}${a}`,r)}async getMatch(t,r,a){return e(t),s(r),this.request(`/games/${t}/${r}`,a)}async createMatch(t,s,a){return e(t),r(s,{numPlayers:\"number\"}),this.post(`/games/${t}/create`,{body:s,init:a})}async joinMatch(t,a,i,n){return e(t),s(a),r(i,{playerID:\"string\",playerName:\"string\"}),this.post(`/games/${t}/${a}/join`,{body:i,init:n})}async leaveMatch(t,a,i,n){e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${t}/${a}/leave`,{body:i,init:n})}async updatePlayer(t,a,i,n){e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${t}/${a}/update`,{body:i,init:n})}async playAgain(t,a,i,n){return e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${t}/${a}/playAgain`,{body:i,init:n})}}exports.L=i;\n},{}],\"iSKo\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Client\",{enumerable:!0,get:function(){return e.C}}),Object.defineProperty(exports,\"LobbyClient\",{enumerable:!0,get:function(){return r.L}}),Object.defineProperty(exports,\"LobbyClientError\",{enumerable:!0,get:function(){return r.a}}),require(\"nanoid\"),require(\"./Debug-a4f4cad1.js\"),require(\"redux\"),require(\"./turn-order-0d61594c.js\"),require(\"immer\"),require(\"lodash.isplainobject\"),require(\"./reducer-77828ca8.js\"),require(\"rfc6902\"),require(\"./initialize-68f0dc41.js\"),require(\"./transport-0079de87.js\");var e=require(\"./client-1535506e.js\");require(\"flatted\"),require(\"./ai-f28cab02.js\");var r=require(\"./client-99609c4d.js\");\n},{\"nanoid\":\"b767\",\"./Debug-a4f4cad1.js\":\"odqP\",\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-77828ca8.js\":\"b133\",\"rfc6902\":\"B6py\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\",\"./client-1535506e.js\":\"yBCo\",\"flatted\":\"O5av\",\"./ai-f28cab02.js\":\"vgbL\",\"./client-99609c4d.js\":\"hK59\"}],\"VAT5\":[function(require,module,exports) {\n\"use strict\";var e;function t(t){return t.type()===e.SYNC}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=t,exports.S=exports.A=void 0,function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class a{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=a;class s{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=s;\n},{}],\"pSJp\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0d61594c.js\"),e=require(\"./reducer-77828ca8.js\"),r=require(\"./initialize-68f0dc41.js\"),s=require(\"./base-13e38c3e.js\");const i=({game:t,unlisted:a,setupData:e,numPlayers:r})=>{const s={gameName:t.name,unlisted:!!a,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==e&&(s.setupData=e);for(let i=0;i<r;i++)s.players[i]={id:i};return s},o=({game:t,numPlayers:a,setupData:e,unlisted:s})=>{a&&\"number\"==typeof a||(a=2);const o=t.validateSetupData&&t.validateSetupData(e,a);return void 0!==o?{setupDataError:o}:{metadata:i({game:t,numPlayers:a,setupData:e,unlisted:s}),initialState:(0,r.I)({game:t,numPlayers:a,setupData:e})}},n=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),l=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class d{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(r,i,o,n){if(!r||!r.payload)return{error:\"missing action or action payload\"};let d;if((0,s.i)(this.storageAPI)?({metadata:d}=this.storageAPI.fetch(o,{metadata:!0})):({metadata:d}=await this.storageAPI.fetch(o,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:n,credentials:r.payload.credentials,metadata:d})))return{error:\"unauthorized action\"}}const c=l(r),h=o;let u;if((0,s.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${n}]`+` - action[${c.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),m=(0,t.createStore)(p,u,g);if(c.type==a.l||c.type==a.m){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===n;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[n]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${n}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,n))return void(0,a.e)(`player not active - playerID=[${n}]`+` - action[${c.payload.type}]`);const y=c.type==a.M?this.game.flow.getMove(u.ctx,c.payload.type,n):null;if(c.type==a.M&&!y)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${n}]`+` - action[${c.payload.type}]`);if(u._stateID!==i&&!(y&&(0,e.I)(y)&&y.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${i}], expected=[${u._stateID}]`+` - playerID=[${n}] - action[${c.payload.type}]`);const I=m.getState();m.dispatch(c),u=m.getState(),this.subscribeCallback({state:u,action:c,matchID:o}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[o,i,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[o,u]});const{deltalog:f,...P}=u;let A;if(!d||\"gameover\"in d||(A={...d,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,s.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,r=2){const i=t,l={state:!0,metadata:!0,log:!0,initialState:!0},d=(0,s.i)(this.storageAPI)?this.storageAPI.fetch(i,l):await this.storageAPI.fetch(i,l);let{state:c,initialState:h,log:u,metadata:p}=d;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:p})))return{error:\"unauthorized\"}}if(void 0===c){const a=o({game:this.game,unlisted:!0,numPlayers:r,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};h=c=a.initialState,p=a.metadata,this.subscribeCallback({state:c,matchID:t}),(0,s.i)(this.storageAPI)?this.storageAPI.createMatch(i,{initialState:h,metadata:p}):await this.storageAPI.createMatch(i,{initialState:h,metadata:p})}const g={state:c,log:u,filteredMetadata:p?n(p):void 0,initialState:h};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,g]})}async onConnectionChange(t,e,r,i){const o=t;if(null==e)return;let l;if((0,s.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(o,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(o,{metadata:!0})),void 0===l)return(0,a.e)(`metadata not found for matchID=[${o}]`),{error:\"metadata not found\"};if(void 0===l.players[e])return(0,a.e)(`Player not in the match, matchID=[${o}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:r,metadata:l})))return{error:\"unauthorized\"}}l.players[e].isConnected=i;const d=n(l);this.transportAPI.sendAll({type:\"matchData\",args:[t,d]}),(0,s.i)(this.storageAPI)?this.storageAPI.setMetadata(o,l):await this.storageAPI.setMetadata(o,l)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=d;\n},{\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"./initialize-68f0dc41.js\":\"azvt\",\"./base-13e38c3e.js\":\"VAT5\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"a3MF\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=f,exports.S=I;var t=require(\"./turn-order-0d61594c.js\"),e=require(\"rfc6902\"),s=require(\"./transport-0079de87.js\"),a=require(\"./base-13e38c3e.js\"),i=require(\"./master-cf52dceb.js\"),c=r(require(\"socket.io-client\"));function r(t){return t&&t.__esModule?t:{default:t}}class n extends a.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class h extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends n{constructor(t=\"bgio\"){super();const e=e=>new h(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}const l=(e,s,a)=>({...a,G:e.playerView(a.G,a.ctx,s),plugins:(0,t.w)(a,{playerID:s,game:e}),deltalog:void 0,_undo:[],_redo:[]}),d=t=>(s,a)=>{switch(a.type){case\"patch\":{const[i,c,r,n]=a.args,h=u(n.deltalog,s),o=l(t,s,n),d=n._stateID,p=l(t,s,r);return{type:\"patch\",args:[i,c,d,(0,e.createPatch)(p,o),h]}}case\"update\":{const[e,i]=a.args,c=u(i.deltalog,s);return{type:\"update\",args:[e,l(t,s,i),c]}}case\"sync\":{const[e,i]=a.args,c=l(t,s,i.state),r=u(i.log,s);return{type:\"sync\",args:[e,{...i,state:c,log:r}]}}default:return a}};function u(t,e){return void 0===t?t:t.map(t=>{if(null!==e&&+e==+t.action.payload.playerID)return t;if(!0!==t.redact)return t;const s={...t.action.payload,args:null},a={...t,action:{...t.action,payload:s}},{redact:i,...c}=a;return c})}function p(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class m extends i.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const i={},c={};if(t&&t.ai&&e)for(const n in e){const s=e[n];c[n]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const r=({playerID:t,...e})=>{const s=i[t];void 0!==s&&s(h(t,e))},h=d(t),l={send:r,sendAll:t=>{for(const e in i)r({playerID:e,...t})}};super(t,a?new o(s):new n,l),this.connect=((t,e,s)=>{i[e]=s}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const a=p(t,c);null!==a&&setTimeout(async()=>{const e=await c[a].play(t,a);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class g extends s.T{constructor({master:t,...e}){super(e),this.master=t,this.isConnected=!0}onChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}async onUpdate(e,s,a){const i=this.store.getState();if(e==this.matchID&&s._stateID>=i._stateID){const e=(0,t.B)(s,a);this.store.dispatch(e)}}onSync(e,s){if(e==this.matchID){const e=(0,t.s)(s);this.store.dispatch(e)}}onAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}connect(){this.master.connect(this.matchID,this.playerID,t=>{switch(t.type){case\"sync\":return this.onSync(...t.args);case\"update\":return this.onUpdate(...t.args);case\"chat\":return this.chatMessageCallback(t.args[1])}}),this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}disconnect(){}subscribe(){}subscribeMatchData(){}subscribeChatMessage(t){this.chatMessageCallback=t}resetAndSync(){const e=(0,t.t)(null);this.store.dispatch(e),this.connect()}updateMatchID(t){this.matchID=t,this.resetAndSync()}updatePlayerID(t){this.playerID=t,this.resetAndSync()}updateCredentials(t){this.credentials=t,this.resetAndSync()}}const y=new Map;function f({bots:t,persist:e,storageKey:s}={}){return a=>{const{gameKey:i,game:c}=a;let r;const n=y.get(i);return n&&n.bots===t&&n.storageKey===s&&n.persist===e&&(r=n.master),r||(r=new m({game:c,bots:t,persist:e,storageKey:s}),y.set(i,{master:r,bots:t,persist:e,storageKey:s})),new g({master:r,...a})}}const D=c.default;class k extends s.T{constructor({socket:t,socketOpts:e,server:s,...a}={}){super(a),this.server=s,this.socket=t,this.socketOpts=e,this.isConnected=!1,this.callback=(()=>{}),this.matchDataCallback=(()=>{}),this.chatMessageCallback=(()=>{})}onAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}onChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=D(t+this.gameName,this.socketOpts)}else this.socket=D(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(e,s,a,i,c)=>{const r=this.store.getState()._stateID;if(e===this.matchID&&s===r){const e=(0,t.C)(s,a,i,c);this.store.dispatch(e),this.store.getState()._stateID===r&&this.sync()}}),this.socket.on(\"update\",(e,s,a)=>{const i=this.store.getState();if(e==this.matchID&&s._stateID>=i._stateID){const e=(0,t.B)(s,a);this.store.dispatch(e)}}),this.socket.on(\"sync\",(e,s)=>{if(e==this.matchID){const e=(0,t.s)(s);this.matchDataCallback(s.filteredMetadata),this.store.dispatch(e)}}),this.socket.on(\"matchData\",(t,e)=>{t==this.matchID&&this.matchDataCallback(e)}),this.socket.on(\"chat\",(t,e)=>{t===this.matchID&&this.chatMessageCallback(e)}),this.socket.on(\"connect\",()=>{this.sync(),this.isConnected=!0,this.callback()}),this.socket.on(\"disconnect\",()=>{this.isConnected=!1,this.callback()})}disconnect(){this.socket.close(),this.socket=null,this.isConnected=!1,this.callback()}subscribe(t){this.callback=t}subscribeMatchData(t){this.matchDataCallback=t}subscribeChatMessage(t){this.chatMessageCallback=t}sync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}resetAndSync(){const e=(0,t.t)(null);this.store.dispatch(e),this.sync()}updateMatchID(t){this.matchID=t,this.resetAndSync()}updatePlayerID(t){this.playerID=t,this.resetAndSync()}updateCredentials(t){this.credentials=t,this.resetAndSync()}}function I({server:t,socketOpts:e}={}){return s=>new k({server:t,socketOpts:e,...s})}\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"rfc6902\":\"B6py\",\"./transport-0079de87.js\":\"KLsr\",\"./base-13e38c3e.js\":\"VAT5\",\"./master-cf52dceb.js\":\"pSJp\",\"socket.io-client\":\"x518\"}],\"Q5yd\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Local\",{enumerable:!0,get:function(){return e.L}}),Object.defineProperty(exports,\"SocketIO\",{enumerable:!0,get:function(){return e.S}}),require(\"redux\"),require(\"./turn-order-0d61594c.js\"),require(\"immer\"),require(\"lodash.isplainobject\"),require(\"./reducer-77828ca8.js\"),require(\"rfc6902\"),require(\"./initialize-68f0dc41.js\"),require(\"./transport-0079de87.js\"),require(\"./base-13e38c3e.js\");var e=require(\"./socketio-b981ab77.js\");require(\"./master-cf52dceb.js\"),require(\"socket.io-client\");\n},{\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-77828ca8.js\":\"b133\",\"rfc6902\":\"B6py\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\",\"./base-13e38c3e.js\":\"VAT5\",\"./socketio-b981ab77.js\":\"a3MF\",\"./master-cf52dceb.js\":\"pSJp\",\"socket.io-client\":\"x518\"}],\"pFAM\":[function(require,module,exports) {\n\"use strict\";function e(e,r){e.deck--,e.hand[r.currentPlayer]++}function r(e,r){e.deck++,e.hand[r.currentPlayer]--}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;const t={setup:e=>({deck:6,hand:Array(e.numPlayers).fill(0)}),moves:{DrawCard:e,PlayCard:r},turn:{moveLimit:1}};var a=t;exports.default=a;\n},{}],\"z6aW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=require(\"svelte/internal\"),t=require(\"boardgame.io/client\"),a=require(\"boardgame.io/multiplayer\"),n=l(require(\"./game\"));function l(e){return e&&e.__esModule?e:{default:e}}function d(t){(0,e.append_styles)(t,\"svelte-1b6u8ju\",\".deck.svelte-1b6u8ju.svelte-1b6u8ju{font-family:monospace;width:40px;height:60px;margin-left:auto;margin-right:auto;border:1px solid #ddd;padding:20px;text-align:center;border-radius:5px;margin-bottom:50px}.client.svelte-1b6u8ju.svelte-1b6u8ju{border-radius:5px;width:100px;border:1px solid #ddd;background:#fafafa;opacity:.8}.client.active.svelte-1b6u8ju.svelte-1b6u8ju{box-shadow:0 0 5px #aaa;background:#fff;opacity:1}.client.svelte-1b6u8ju li.svelte-1b6u8ju{font-family:monospace;list-style:none;padding:5px;height:30px;line-height:30px;text-align:center}\")}function p(t){let a,n,l,d,p,r,s,i,u,o,c,m,v,b,x,f,g,y=t[1].G.hand[t[0]]+\"\";return{c(){a=(0,e.element)(\"div\"),n=(0,e.element)(\"li\"),l=(0,e.element)(\"strong\"),d=(0,e.text)(\"Player \"),p=(0,e.text)(t[0]),r=(0,e.space)(),s=(0,e.element)(\"li\"),i=(0,e.text)(y),u=(0,e.text)(\" cards\"),o=(0,e.space)(),c=(0,e.element)(\"li\"),(m=(0,e.element)(\"button\")).textContent=\"Draw Card\",v=(0,e.space)(),b=(0,e.element)(\"li\"),(x=(0,e.element)(\"button\")).textContent=\"Play Card\",(0,e.attr)(n,\"class\",\"svelte-1b6u8ju\"),(0,e.attr)(s,\"class\",\"svelte-1b6u8ju\"),(0,e.attr)(c,\"class\",\"svelte-1b6u8ju\"),(0,e.attr)(b,\"class\",\"svelte-1b6u8ju\"),(0,e.attr)(a,\"class\",\"client svelte-1b6u8ju\"),(0,e.toggle_class)(a,\"active\",t[1].isActive)},m(y,h){(0,e.insert)(y,a,h),(0,e.append)(a,n),(0,e.append)(n,l),(0,e.append)(l,d),(0,e.append)(l,p),(0,e.append)(a,r),(0,e.append)(a,s),(0,e.append)(s,i),(0,e.append)(s,u),(0,e.append)(a,o),(0,e.append)(a,c),(0,e.append)(c,m),(0,e.append)(a,v),(0,e.append)(a,b),(0,e.append)(b,x),f||(g=[(0,e.listen)(m,\"click\",t[2].moves.DrawCard),(0,e.listen)(x,\"click\",t[2].moves.PlayCard)],f=!0)},p(t,n){1&n&&(0,e.set_data)(p,t[0]),3&n&&y!==(y=t[1].G.hand[t[0]]+\"\")&&(0,e.set_data)(i,y),2&n&&(0,e.toggle_class)(a,\"active\",t[1].isActive)},d(t){t&&(0,e.detach)(a),f=!1,(0,e.run_all)(g)}}}function r(t){let a,n,l,d,p,r=t[1].G.deck+\"\";return{c(){a=(0,e.element)(\"div\"),n=(0,e.element)(\"div\"),l=(0,e.text)(r),d=(0,e.space)(),(p=(0,e.element)(\"div\")).textContent=\"cards\",(0,e.attr)(a,\"class\",\"deck svelte-1b6u8ju\")},m(t,r){(0,e.insert)(t,a,r),(0,e.append)(a,n),(0,e.append)(n,l),(0,e.append)(a,d),(0,e.append)(a,p)},p(t,a){2&a&&r!==(r=t[1].G.deck+\"\")&&(0,e.set_data)(l,r)},d(t){t&&(0,e.detach)(a)}}}function s(t){let a;function n(e,t){return e[0]?p:r}let l=n(t),d=l(t);return{c(){d.c(),a=(0,e.empty)()},m(t,n){d.m(t,n),(0,e.insert)(t,a,n)},p(e,[t]){l===(l=n(e))&&d?d.p(e,t):(d.d(1),(d=l(e))&&(d.c(),d.m(a.parentNode,a)))},i:e.noop,o:e.noop,d(t){d.d(t),t&&(0,e.detach)(a)}}}function i(l,d,p){let r,{playerID:s=null}=d;const i=(0,t.Client)({game:n.default,matchID:\"default\",playerID:s,debug:!1,numPlayers:3,multiplayer:(0,a.Local)()});return(0,e.component_subscribe)(l,i,e=>p(1,r=e)),i.start(),l.$$set=(e=>{\"playerID\"in e&&p(0,s=e.playerID)}),[s,r,i]}class u extends e.SvelteComponent{constructor(t){super(),(0,e.init)(this,t,i,s,e.safe_not_equal,{playerID:0},d)}}var o=u;exports.default=o;\n},{\"svelte/internal\":\"YkLP\",\"boardgame.io/client\":\"iSKo\",\"boardgame.io/multiplayer\":\"Q5yd\",\"./game\":\"pFAM\"}],\"kyn9\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=require(\"svelte/internal\"),t=n(require(\"./Player.svelte\"));function n(e){return e&&e.__esModule?e:{default:e}}function o(t){(0,e.append_styles)(t,\"svelte-1ohivkv\",\"#board.svelte-1ohivkv{width:100%}.container.svelte-1ohivkv{display:flex;flex-direction:row;justify-content:space-evenly}\")}function r(n){let o,r,a,i,s,l,p,c,u,d,m;return a=new t.default({}),l=new t.default({props:{playerID:\"0\"}}),c=new t.default({props:{playerID:\"1\"}}),d=new t.default({props:{playerID:\"2\"}}),{c(){o=(0,e.element)(\"div\"),r=(0,e.element)(\"div\"),(0,e.create_component)(a.$$.fragment),i=(0,e.space)(),s=(0,e.element)(\"div\"),(0,e.create_component)(l.$$.fragment),p=(0,e.space)(),(0,e.create_component)(c.$$.fragment),u=(0,e.space)(),(0,e.create_component)(d.$$.fragment),(0,e.attr)(r,\"id\",\"board\"),(0,e.attr)(r,\"class\",\"svelte-1ohivkv\"),(0,e.attr)(s,\"class\",\"container svelte-1ohivkv\")},m(t,n){(0,e.insert)(t,o,n),(0,e.append)(o,r),(0,e.mount_component)(a,r,null),(0,e.append)(o,i),(0,e.append)(o,s),(0,e.mount_component)(l,s,null),(0,e.append)(s,p),(0,e.mount_component)(c,s,null),(0,e.append)(s,u),(0,e.mount_component)(d,s,null),m=!0},p:e.noop,i(t){m||((0,e.transition_in)(a.$$.fragment,t),(0,e.transition_in)(l.$$.fragment,t),(0,e.transition_in)(c.$$.fragment,t),(0,e.transition_in)(d.$$.fragment,t),m=!0)},o(t){(0,e.transition_out)(a.$$.fragment,t),(0,e.transition_out)(l.$$.fragment,t),(0,e.transition_out)(c.$$.fragment,t),(0,e.transition_out)(d.$$.fragment,t),m=!1},d(t){t&&(0,e.detach)(o),(0,e.destroy_component)(a),(0,e.destroy_component)(l),(0,e.destroy_component)(c),(0,e.destroy_component)(d)}}}class a extends e.SvelteComponent{constructor(t){super(),(0,e.init)(this,t,null,r,e.safe_not_equal,{},o)}}var i=a;exports.default=i;\n},{\"svelte/internal\":\"YkLP\",\"./Player.svelte\":\"z6aW\"}],\"D7hl\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=t(require(\"./App.svelte\"));function t(e){return e&&e.__esModule?e:{default:e}}const r=new e.default({target:document.getElementById(\"app\"),props:{name:\"world\"}});var o=r;exports.default=o;\n},{\"./App.svelte\":\"kyn9\"}]},{},[\"D7hl\"], null)"
  },
  {
    "path": "docs/documentation/snippets/phases-1.490dcd4c.css",
    "content": ".deck.svelte-1b6u8ju.svelte-1b6u8ju{font-family:monospace;width:40px;height:60px;margin-left:auto;margin-right:auto;border:1px solid #ddd;padding:20px;text-align:center;border-radius:5px;margin-bottom:50px}.client.svelte-1b6u8ju.svelte-1b6u8ju{border-radius:5px;width:100px;border:1px solid #ddd;background:#fafafa;opacity:.8}.client.active.svelte-1b6u8ju.svelte-1b6u8ju{box-shadow:0 0 5px #aaa;background:#fff;opacity:1}.client.svelte-1b6u8ju li.svelte-1b6u8ju{font-family:monospace;list-style:none;padding:5px;height:30px;line-height:30px;text-align:center}#board.svelte-1ohivkv{width:100%}.container.svelte-1ohivkv{display:flex;flex-direction:row;justify-content:space-evenly}"
  },
  {
    "path": "docs/documentation/snippets/phases-2/index.html",
    "content": "<!DOCTYPE html><html><link rel=\"stylesheet\" href=\"/documentation/snippets/phases-2.fa21cb61.css\"><body> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/phases-2.a59f38ac.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/phases-2.a59f38ac.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"YkLP\":[function(require,module,exports) {\nvar global = arguments[3];\nvar t=arguments[3];function e(){}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.action_destroyer=M,exports.add_attribute=mn,exports.add_classes=gn,exports.add_flush_callback=Se,exports.add_location=s,exports.add_render_callback=Ee,exports.add_resize_listener=Pt,exports.add_transform=re,exports.afterUpdate=ue,exports.append=J,exports.append_dev=Cn,exports.append_empty_stylesheet=V,exports.append_hydration=Z,exports.append_hydration_dev=Dn,exports.append_styles=K,exports.assign=o,exports.attr=xt,exports.attr_dev=qn,exports.attribute_to_object=Yt,exports.beforeUpdate=ce,exports.bind=yn,exports.blank_object=c,exports.bubble=xe,exports.check_outros=He,exports.children=wt,exports.claim_component=$n,exports.claim_element=St,exports.claim_html_tag=At,exports.claim_space=Dt,exports.claim_text=Ct,exports.clear_loops=B,exports.component_subscribe=g,exports.compute_rest_props=E,exports.compute_slots=S,exports.createEventDispatcher=pe,exports.create_animation=ne,exports.create_bidirectional_transition=We,exports.create_component=bn,exports.create_in_transition=Ie,exports.create_out_transition=ze,exports.create_slot=y,exports.create_ssr_component=xn,exports.custom_event=zt,exports.dataset_dev=Ln,exports.debug=fn,exports.destroy_block=Je,exports.destroy_component=Fn,exports.destroy_each=ot,exports.detach=nt,exports.detach_after_dev=Nn,exports.detach_before_dev=jn,exports.detach_between_dev=Tn,exports.detach_dev=Mn,exports.dispatch_dev=Sn,exports.each=an,exports.element=rt,exports.element_is=st,exports.empty=at,exports.end_hydrating=G,exports.escape=cn,exports.escape_attribute_value=ln,exports.escape_object=un,exports.exclude_internal_props=k,exports.fix_and_destroy_block=Qe,exports.fix_and_outro_and_destroy_block=Ve,exports.fix_position=oe,exports.flush=Oe,exports.getAllContexts=_e,exports.getContext=fe,exports.get_all_dirty_from_scope=w,exports.get_binding_group_value=$t,exports.get_current_component=ie,exports.get_custom_elements_slots=Jt,exports.get_root_for_style=Q,exports.get_slot_changes=$,exports.get_spread_object=en,exports.get_spread_update=tn,exports.get_store_value=m,exports.group_outros=qe,exports.handle_promise=Ge,exports.hasContext=he,exports.init=kn,exports.insert=tt,exports.insert_dev=On,exports.insert_hydration=et,exports.insert_hydration_dev=An,exports.is_crossorigin=Bt,exports.is_empty=_,exports.is_function=u,exports.is_promise=r,exports.listen=pt,exports.listen_dev=Rn,exports.loop=P,exports.loop_guard=Gn,exports.mount_component=vn,exports.noop=e,exports.not_equal=f,exports.null_to_empty=D,exports.object_without_properties=it,exports.onDestroy=ae,exports.onMount=le,exports.once=C,exports.outro_and_destroy_block=Ke,exports.prevent_default=dt,exports.prop_dev=Hn,exports.query_selector_all=Wt,exports.run=i,exports.run_all=l,exports.safe_not_equal=a,exports.schedule_update=we,exports.select_multiple_value=Lt,exports.select_option=Rt,exports.select_options=qt,exports.select_value=Ht,exports.self=_t,exports.setContext=de,exports.set_attributes=mt,exports.set_current_component=se,exports.set_custom_element_data=yt,exports.set_data=Mt,exports.set_data_dev=Bn,exports.set_input_type=jt,exports.set_input_value=Tt,exports.set_now=R,exports.set_raf=q,exports.set_store_value=O,exports.set_style=Nt,exports.set_svg_attributes=gt,exports.space=ut,exports.spread=rn,exports.src_url_equal=d,exports.start_hydrating=W,exports.stop_propagation=ft,exports.subscribe=x,exports.svg_element=ct,exports.text=lt,exports.tick=ke,exports.time_ranges_to_array=Ft,exports.to_number=vt,exports.toggle_class=It,exports.transition_in=Le,exports.transition_out=Be,exports.trusted=ht,exports.update_await_block_branch=Ue,exports.update_keyed_each=Xe,exports.update_slot=F,exports.update_slot_base=v,exports.validate_component=dn,exports.validate_each_argument=Pn,exports.validate_each_keys=Ze,exports.validate_slots=In,exports.validate_store=h,exports.xlink_attr=bt,exports.raf=exports.now=exports.missing_component=exports.is_client=exports.invalid_attribute_name_character=exports.intros=exports.identity=exports.has_prop=exports.globals=exports.escaped=exports.dirty_components=exports.current_component=exports.binding_callbacks=exports.SvelteElement=exports.SvelteComponentTyped=exports.SvelteComponentDev=exports.SvelteComponent=exports.HtmlTagHydration=exports.HtmlTag=void 0;const n=t=>t;function o(t,e){for(const n in e)t[n]=e[n];return t}function r(t){return t&&\"object\"==typeof t&&\"function\"==typeof t.then}function s(t,e,n,o,r){t.__svelte_meta={loc:{file:e,line:n,column:o,char:r}}}function i(t){return t()}function c(){return Object.create(null)}function l(t){t.forEach(i)}function u(t){return\"function\"==typeof t}function a(t,e){return t!=t?e==e:t!==e||t&&\"object\"==typeof t||\"function\"==typeof t}let p;function d(t,e){return p||(p=document.createElement(\"a\")),p.href=e,t===p.href}function f(t,e){return t!=t?e==e:t!==e}function _(t){return 0===Object.keys(t).length}function h(t,e){if(null!=t&&\"function\"!=typeof t.subscribe)throw new Error(`'${e}' is not a store with a 'subscribe' method`)}function x(t,...n){if(null==t)return e;const o=t.subscribe(...n);return o.unsubscribe?()=>o.unsubscribe():o}function m(t){let e;return x(t,t=>e=t)(),e}function g(t,e,n){t.$$.on_destroy.push(x(e,n))}function y(t,e,n,o){if(t){const r=b(t,e,n,o);return t[0](r)}}function b(t,e,n,r){return t[1]&&r?o(n.ctx.slice(),t[1](r(e))):n.ctx}function $(t,e,n,o){if(t[2]&&o){const r=t[2](o(n));if(void 0===e.dirty)return r;if(\"object\"==typeof r){const t=[],n=Math.max(e.dirty.length,r.length);for(let o=0;o<n;o+=1)t[o]=e.dirty[o]|r[o];return t}return e.dirty|r}return e.dirty}function v(t,e,n,o,r,s){if(r){const i=b(e,n,o,s);t.p(i,r)}}function F(t,e,n,o,r,s,i){v(t,e,n,o,$(e,o,r,s),i)}function w(t){if(t.ctx.length>32){const e=[],n=t.ctx.length/32;for(let t=0;t<n;t++)e[t]=-1;return e}return-1}function k(t){const e={};for(const n in t)\"$\"!==n[0]&&(e[n]=t[n]);return e}function E(t,e){const n={};e=new Set(e);for(const o in t)e.has(o)||\"$\"===o[0]||(n[o]=t[o]);return n}function S(t){const e={};for(const n in t)e[n]=!0;return e}function C(t){let e=!1;return function(...n){e||(e=!0,t.call(this,...n))}}function D(t){return null==t?\"\":t}function O(t,e,n){return t.set(n),e}exports.identity=n;const A=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);function M(t){return t&&u(t.destroy)?t.destroy:e}exports.has_prop=A;const T=\"undefined\"!=typeof window;exports.is_client=T;let j=T?()=>window.performance.now():()=>Date.now();exports.now=j;let N=T?t=>requestAnimationFrame(t):e;function R(t){exports.now=j=t}function q(t){exports.raf=N=t}exports.raf=N;const H=new Set;function L(t){H.forEach(e=>{e.c(t)||(H.delete(e),e.f())}),0!==H.size&&N(L)}function B(){H.clear()}function P(t){let e;return 0===H.size&&N(L),{promise:new Promise(n=>{H.add(e={c:t,f:n})}),abort(){H.delete(e)}}}let I,z=!1;function W(){z=!0}function G(){z=!1}function U(t,e,n,o){for(;t<e;){const r=t+(e-t>>1);n(r)<=o?t=r+1:e=r}return t}function Y(t){if(t.hydrate_init)return;t.hydrate_init=!0;let e=t.childNodes;if(\"HEAD\"===t.nodeName){const t=[];for(let n=0;n<e.length;n++){const o=e[n];void 0!==o.claim_order&&t.push(o)}e=t}const n=new Int32Array(e.length+1),o=new Int32Array(e.length);n[0]=-1;let r=0;for(let l=0;l<e.length;l++){const t=e[l].claim_order,s=(r>0&&e[n[r]].claim_order<=t?r+1:U(1,r,t=>e[n[t]].claim_order,t))-1;o[l]=n[s]+1;const i=s+1;n[i]=l,r=Math.max(i,r)}const s=[],i=[];let c=e.length-1;for(let l=n[r]+1;0!=l;l=o[l-1]){for(s.push(e[l-1]);c>=l;c--)i.push(e[c]);c--}for(;c>=0;c--)i.push(e[c]);s.reverse(),i.sort((t,e)=>t.claim_order-e.claim_order);for(let l=0,u=0;l<i.length;l++){for(;u<s.length&&i[l].claim_order>=s[u].claim_order;)u++;const e=u<s.length?s[u]:null;t.insertBefore(i[l],e)}}function J(t,e){t.appendChild(e)}function K(t,e,n){const o=Q(t);if(!o.getElementById(e)){const t=rt(\"style\");t.id=e,t.textContent=n,X(o,t)}}function Q(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e.host?e:document}function V(t){const e=rt(\"style\");return X(Q(t),e),e}function X(t,e){J(t.head||t,e)}function Z(t,e){if(z){for(Y(t),(void 0===t.actual_end_child||null!==t.actual_end_child&&t.actual_end_child.parentElement!==t)&&(t.actual_end_child=t.firstChild);null!==t.actual_end_child&&void 0===t.actual_end_child.claim_order;)t.actual_end_child=t.actual_end_child.nextSibling;e!==t.actual_end_child?void 0===e.claim_order&&e.parentNode===t||t.insertBefore(e,t.actual_end_child):t.actual_end_child=e.nextSibling}else e.parentNode!==t&&t.appendChild(e)}function tt(t,e,n){t.insertBefore(e,n||null)}function et(t,e,n){z&&!n?Z(t,e):e.parentNode===t&&e.nextSibling==n||t.insertBefore(e,n||null)}function nt(t){t.parentNode.removeChild(t)}function ot(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function rt(t){return document.createElement(t)}function st(t,e){return document.createElement(t,{is:e})}function it(t,e){const n={};for(const o in t)A(t,o)&&-1===e.indexOf(o)&&(n[o]=t[o]);return n}function ct(t){return document.createElementNS(\"http://www.w3.org/2000/svg\",t)}function lt(t){return document.createTextNode(t)}function ut(){return lt(\" \")}function at(){return lt(\"\")}function pt(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function dt(t){return function(e){return e.preventDefault(),t.call(this,e)}}function ft(t){return function(e){return e.stopPropagation(),t.call(this,e)}}function _t(t){return function(e){e.target===this&&t.call(this,e)}}function ht(t){return function(e){e.isTrusted&&t.call(this,e)}}function xt(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function mt(t,e){const n=Object.getOwnPropertyDescriptors(t.__proto__);for(const o in e)null==e[o]?t.removeAttribute(o):\"style\"===o?t.style.cssText=e[o]:\"__value\"===o?t.value=t[o]=e[o]:n[o]&&n[o].set?t[o]=e[o]:xt(t,o,e[o])}function gt(t,e){for(const n in e)xt(t,n,e[n])}function yt(t,e,n){e in t?t[e]=\"boolean\"==typeof t[e]&&\"\"===n||n:xt(t,e,n)}function bt(t,e,n){t.setAttributeNS(\"http://www.w3.org/1999/xlink\",e,n)}function $t(t,e,n){const o=new Set;for(let r=0;r<t.length;r+=1)t[r].checked&&o.add(t[r].__value);return n||o.delete(e),Array.from(o)}function vt(t){return\"\"===t?null:+t}function Ft(t){const e=[];for(let n=0;n<t.length;n+=1)e.push({start:t.start(n),end:t.end(n)});return e}function wt(t){return Array.from(t.childNodes)}function kt(t){void 0===t.claim_info&&(t.claim_info={last_index:0,total_claimed:0})}function Et(t,e,n,o,r=!1){kt(t);const s=(()=>{for(let o=t.claim_info.last_index;o<t.length;o++){const s=t[o];if(e(s)){const e=n(s);return void 0===e?t.splice(o,1):t[o]=e,r||(t.claim_info.last_index=o),s}}for(let o=t.claim_info.last_index-1;o>=0;o--){const s=t[o];if(e(s)){const e=n(s);return void 0===e?t.splice(o,1):t[o]=e,r?void 0===e&&t.claim_info.last_index--:t.claim_info.last_index=o,s}}return o()})();return s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1,s}function St(t,e,n,o){return Et(t,t=>t.nodeName===e,t=>{const e=[];for(let o=0;o<t.attributes.length;o++){const r=t.attributes[o];n[r.name]||e.push(r.name)}e.forEach(e=>t.removeAttribute(e))},()=>o?ct(e):rt(e))}function Ct(t,e){return Et(t,t=>3===t.nodeType,t=>{const n=\"\"+e;if(t.data.startsWith(n)){if(t.data.length!==n.length)return t.splitText(n.length)}else t.data=n},()=>lt(e),!0)}function Dt(t){return Ct(t,\" \")}function Ot(t,e,n){for(let o=n;o<t.length;o+=1){const n=t[o];if(8===n.nodeType&&n.textContent.trim()===e)return o}return t.length}function At(t){const e=Ot(t,\"HTML_TAG_START\",0),n=Ot(t,\"HTML_TAG_END\",e);if(e===n)return new Ut;kt(t);const o=t.splice(e,n+1);nt(o[0]),nt(o[o.length-1]);const r=o.slice(1,o.length-1);for(const s of r)s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1;return new Ut(r)}function Mt(t,e){e=\"\"+e,t.wholeText!==e&&(t.data=e)}function Tt(t,e){t.value=null==e?\"\":e}function jt(t,e){try{t.type=e}catch(n){}}function Nt(t,e,n,o){t.style.setProperty(e,n,o?\"important\":\"\")}function Rt(t,e){for(let n=0;n<t.options.length;n+=1){const o=t.options[n];if(o.__value===e)return void(o.selected=!0)}}function qt(t,e){for(let n=0;n<t.options.length;n+=1){const o=t.options[n];o.selected=~e.indexOf(o.__value)}}function Ht(t){const e=t.querySelector(\":checked\")||t.options[0];return e&&e.__value}function Lt(t){return[].map.call(t.querySelectorAll(\":checked\"),t=>t.__value)}function Bt(){if(void 0===I){I=!1;try{\"undefined\"!=typeof window&&window.parent&&window.parent.document}catch(t){I=!0}}return I}function Pt(t,e){\"static\"===getComputedStyle(t).position&&(t.style.position=\"relative\");const n=rt(\"iframe\");n.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),n.setAttribute(\"aria-hidden\",\"true\"),n.tabIndex=-1;const o=Bt();let r;return o?(n.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",r=pt(window,\"message\",t=>{t.source===n.contentWindow&&e()})):(n.src=\"about:blank\",n.onload=(()=>{r=pt(n.contentWindow,\"resize\",e)})),J(t,n),()=>{o?r():r&&n.contentWindow&&r(),nt(n)}}function It(t,e,n){t.classList[n?\"add\":\"remove\"](e)}function zt(t,e,n=!1){const o=document.createEvent(\"CustomEvent\");return o.initCustomEvent(t,n,!1,e),o}function Wt(t,e=document.body){return Array.from(e.querySelectorAll(t))}class Gt{constructor(){this.e=this.n=null}c(t){this.h(t)}m(t,e,n=null){this.e||(this.e=rt(e.nodeName),this.t=e,this.c(t)),this.i(n)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let e=0;e<this.n.length;e+=1)tt(this.t,this.n[e],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(nt)}}exports.HtmlTag=Gt;class Ut extends Gt{constructor(t){super(),this.e=this.n=null,this.l=t}c(t){this.l?this.n=this.l:super.c(t)}i(t){for(let e=0;e<this.n.length;e+=1)et(this.t,this.n[e],t)}}function Yt(t){const e={};for(const n of t)e[n.name]=n.value;return e}function Jt(t){const e={};return t.childNodes.forEach(t=>{e[t.slot||\"default\"]=!0}),e}exports.HtmlTagHydration=Ut;const Kt=new Set;let Qt,Vt=0;function Xt(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}function Zt(t,e,n,o,r,s,i,c=0){const l=16.666/o;let u=\"{\\n\";for(let x=0;x<=1;x+=l){const t=e+(n-e)*s(x);u+=100*x+`%{${i(t,1-t)}}\\n`}const a=u+`100% {${i(n,1-n)}}\\n}`,p=`__svelte_${Xt(a)}_${c}`,d=Q(t);Kt.add(d);const f=d.__svelte_stylesheet||(d.__svelte_stylesheet=V(t).sheet),_=d.__svelte_rules||(d.__svelte_rules={});_[p]||(_[p]=!0,f.insertRule(`@keyframes ${p} ${a}`,f.cssRules.length));const h=t.style.animation||\"\";return t.style.animation=`${h?`${h}, `:\"\"}${p} ${o}ms linear ${r}ms 1 both`,Vt+=1,p}function te(t,e){const n=(t.style.animation||\"\").split(\", \"),o=n.filter(e?t=>t.indexOf(e)<0:t=>-1===t.indexOf(\"__svelte\")),r=n.length-o.length;r&&(t.style.animation=o.join(\", \"),(Vt-=r)||ee())}function ee(){N(()=>{Vt||(Kt.forEach(t=>{const e=t.__svelte_stylesheet;let n=e.cssRules.length;for(;n--;)e.deleteRule(n);t.__svelte_rules={}}),Kt.clear())})}function ne(t,o,r,s){if(!o)return e;const i=t.getBoundingClientRect();if(o.left===i.left&&o.right===i.right&&o.top===i.top&&o.bottom===i.bottom)return e;const{delay:c=0,duration:l=300,easing:u=n,start:a=j()+c,end:p=a+l,tick:d=e,css:f}=r(t,{from:o,to:i},s);let _,h=!0,x=!1;function m(){f&&te(t,_),h=!1}return P(t=>{if(!x&&t>=a&&(x=!0),x&&t>=p&&(d(1,0),m()),!h)return!1;if(x){const e=0+1*u((t-a)/l);d(e,1-e)}return!0}),f&&(_=Zt(t,0,1,l,c,u,f)),c||(x=!0),d(0,1),m}function oe(t){const e=getComputedStyle(t);if(\"absolute\"!==e.position&&\"fixed\"!==e.position){const{width:n,height:o}=e,r=t.getBoundingClientRect();t.style.position=\"absolute\",t.style.width=n,t.style.height=o,re(t,r)}}function re(t,e){const n=t.getBoundingClientRect();if(e.left!==n.left||e.top!==n.top){const o=getComputedStyle(t),r=\"none\"===o.transform?\"\":o.transform;t.style.transform=`${r} translate(${e.left-n.left}px, ${e.top-n.top}px)`}}function se(t){exports.current_component=Qt=t}function ie(){if(!Qt)throw new Error(\"Function called outside component initialization\");return Qt}function ce(t){ie().$$.before_update.push(t)}function le(t){ie().$$.on_mount.push(t)}function ue(t){ie().$$.after_update.push(t)}function ae(t){ie().$$.on_destroy.push(t)}function pe(){const t=ie();return(e,n)=>{const o=t.$$.callbacks[e];if(o){const r=zt(e,n);o.slice().forEach(e=>{e.call(t,r)})}}}function de(t,e){ie().$$.context.set(t,e)}function fe(t){return ie().$$.context.get(t)}function _e(){return ie().$$.context}function he(t){return ie().$$.context.has(t)}function xe(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(t=>t.call(this,e))}exports.current_component=Qt;const me=[];exports.dirty_components=me;const ge={enabled:!1};exports.intros=ge;const ye=[];exports.binding_callbacks=ye;const be=[],$e=[],ve=Promise.resolve();let Fe=!1;function we(){Fe||(Fe=!0,ve.then(Oe))}function ke(){return we(),ve}function Ee(t){be.push(t)}function Se(t){$e.push(t)}let Ce=!1;const De=new Set;function Oe(){if(!Ce){Ce=!0;do{for(let t=0;t<me.length;t+=1){const e=me[t];se(e),Ae(e.$$)}for(se(null),me.length=0;ye.length;)ye.pop()();for(let t=0;t<be.length;t+=1){const e=be[t];De.has(e)||(De.add(e),e())}be.length=0}while(me.length);for(;$e.length;)$e.pop()();Fe=!1,Ce=!1,De.clear()}}function Ae(t){if(null!==t.fragment){t.update(),l(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Ee)}}let Me;function Te(){return Me||(Me=Promise.resolve()).then(()=>{Me=null}),Me}function je(t,e,n){t.dispatchEvent(zt(`${e?\"intro\":\"outro\"}${n}`))}const Ne=new Set;let Re;function qe(){Re={r:0,c:[],p:Re}}function He(){Re.r||l(Re.c),Re=Re.p}function Le(t,e){t&&t.i&&(Ne.delete(t),t.i(e))}function Be(t,e,n,o){if(t&&t.o){if(Ne.has(t))return;Ne.add(t),Re.c.push(()=>{Ne.delete(t),o&&(n&&t.d(1),o())}),t.o(e)}}const Pe={duration:0};function Ie(t,o,r){let s,i,c=o(t,r),l=!1,a=0;function p(){s&&te(t,s)}function d(){const{delay:o=0,duration:r=300,easing:u=n,tick:d=e,css:f}=c||Pe;f&&(s=Zt(t,0,1,r,o,u,f,a++)),d(0,1);const _=j()+o,h=_+r;i&&i.abort(),l=!0,Ee(()=>je(t,!0,\"start\")),i=P(e=>{if(l){if(e>=h)return d(1,0),je(t,!0,\"end\"),p(),l=!1;if(e>=_){const t=u((e-_)/r);d(t,1-t)}}return l})}let f=!1;return{start(){f||(f=!0,te(t),u(c)?(c=c(),Te().then(d)):d())},invalidate(){f=!1},end(){l&&(p(),l=!1)}}}function ze(t,o,r){let s,i=o(t,r),c=!0;const a=Re;function p(){const{delay:o=0,duration:r=300,easing:u=n,tick:p=e,css:d}=i||Pe;d&&(s=Zt(t,1,0,r,o,u,d));const f=j()+o,_=f+r;Ee(()=>je(t,!1,\"start\")),P(e=>{if(c){if(e>=_)return p(0,1),je(t,!1,\"end\"),--a.r||l(a.c),!1;if(e>=f){const t=u((e-f)/r);p(1-t,t)}}return c})}return a.r+=1,u(i)?Te().then(()=>{i=i(),p()}):p(),{end(e){e&&i.tick&&i.tick(1,0),c&&(s&&te(t,s),c=!1)}}}function We(t,o,r,s){let i=o(t,r),c=s?0:1,a=null,p=null,d=null;function f(){d&&te(t,d)}function _(t,e){const n=t.b-c;return e*=Math.abs(n),{a:c,b:t.b,d:n,duration:e,start:t.start,end:t.start+e,group:t.group}}function h(o){const{delay:r=0,duration:s=300,easing:u=n,tick:h=e,css:x}=i||Pe,m={start:j()+r,b:o};o||(m.group=Re,Re.r+=1),a||p?p=m:(x&&(f(),d=Zt(t,c,o,s,r,u,x)),o&&h(0,1),a=_(m,s),Ee(()=>je(t,o,\"start\")),P(e=>{if(p&&e>p.start&&(a=_(p,s),p=null,je(t,a.b,\"start\"),x&&(f(),d=Zt(t,c,a.b,a.duration,0,u,i.css))),a)if(e>=a.end)h(c=a.b,1-c),je(t,a.b,\"end\"),p||(a.b?f():--a.group.r||l(a.group.c)),a=null;else if(e>=a.start){const t=e-a.start;c=a.a+a.d*u(t/a.duration),h(c,1-c)}return!(!a&&!p)}))}return{run(t){u(i)?Te().then(()=>{i=i(),h(t)}):h(t)},end(){f(),a=p=null}}}function Ge(t,e){const n=e.token={};function o(t,o,r,s){if(e.token!==n)return;e.resolved=s;let i=e.ctx;void 0!==r&&((i=i.slice())[r]=s);const c=t&&(e.current=t)(i);let l=!1;e.block&&(e.blocks?e.blocks.forEach((t,n)=>{n!==o&&t&&(qe(),Be(t,1,1,()=>{e.blocks[n]===t&&(e.blocks[n]=null)}),He())}):e.block.d(1),c.c(),Le(c,1),c.m(e.mount(),e.anchor),l=!0),e.block=c,e.blocks&&(e.blocks[o]=c),l&&Oe()}if(r(t)){const n=ie();if(t.then(t=>{se(n),o(e.then,1,e.value,t),se(null)},t=>{if(se(n),o(e.catch,2,e.error,t),se(null),!e.hasCatch)throw t}),e.current!==e.pending)return o(e.pending,0),!0}else{if(e.current!==e.then)return o(e.then,1,e.value,t),!0;e.resolved=t}}function Ue(t,e,n){const o=e.slice(),{resolved:r}=t;t.current===t.then&&(o[t.value]=r),t.current===t.catch&&(o[t.error]=r),t.block.p(o,n)}const Ye=\"undefined\"!=typeof window?window:\"undefined\"!=typeof globalThis?globalThis:t;function Je(t,e){t.d(1),e.delete(t.key)}function Ke(t,e){Be(t,1,1,()=>{e.delete(t.key)})}function Qe(t,e){t.f(),Je(t,e)}function Ve(t,e){t.f(),Ke(t,e)}function Xe(t,e,n,o,r,s,i,c,l,u,a,p){let d=t.length,f=s.length,_=d;const h={};for(;_--;)h[t[_].key]=_;const x=[],m=new Map,g=new Map;for(_=f;_--;){const t=p(r,s,_),c=n(t);let l=i.get(c);l?o&&l.p(t,e):(l=u(c,t)).c(),m.set(c,x[_]=l),c in h&&g.set(c,Math.abs(_-h[c]))}const y=new Set,b=new Set;function $(t){Le(t,1),t.m(c,a),i.set(t.key,t),a=t.first,f--}for(;d&&f;){const e=x[f-1],n=t[d-1],o=e.key,r=n.key;e===n?(a=e.first,d--,f--):m.has(r)?!i.has(o)||y.has(o)?$(e):b.has(r)?d--:g.get(o)>g.get(r)?(b.add(o),$(e)):(y.add(r),d--):(l(n,i),d--)}for(;d--;){const e=t[d];m.has(e.key)||l(e,i)}for(;f;)$(x[f-1]);return x}function Ze(t,e,n,o){const r=new Set;for(let s=0;s<e.length;s++){const i=o(n(t,e,s));if(r.has(i))throw new Error(\"Cannot have duplicate keys in a keyed each\");r.add(i)}}function tn(t,e){const n={},o={},r={$$scope:1};let s=t.length;for(;s--;){const i=t[s],c=e[s];if(c){for(const t in i)t in c||(o[t]=1);for(const t in c)r[t]||(n[t]=c[t],r[t]=1);t[s]=c}else for(const t in i)r[t]=1}for(const i in o)i in n||(n[i]=void 0);return n}function en(t){return\"object\"==typeof t&&null!==t?t:{}}exports.globals=Ye;const nn=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),on=/[\\s'\">\\/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function rn(t,e){const n=Object.assign({},...t);e&&(null==n.class?n.class=e:n.class+=\" \"+e);let o=\"\";return Object.keys(n).forEach(t=>{if(on.test(t))return;const e=n[t];!0===e?o+=\" \"+t:nn.has(t.toLowerCase())?e&&(o+=\" \"+t):null!=e&&(o+=` ${t}=\"${e}\"`)}),o}exports.invalid_attribute_name_character=on;const sn={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function cn(t){return String(t).replace(/[\"'&<>]/g,t=>sn[t])}function ln(t){return\"string\"==typeof t?cn(t):t}function un(t){const e={};for(const n in t)e[n]=ln(t[n]);return e}function an(t,e){let n=\"\";for(let o=0;o<t.length;o+=1)n+=e(t[o],o);return n}exports.escaped=sn;const pn={$$render:()=>\"\"};function dn(t,e){if(!t||!t.$$render)throw\"svelte:component\"===e&&(e+=\" this={...}\"),new Error(`<${e}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return t}function fn(t,e,n,o){return console.log(`{@debug} ${t?t+\" \":\"\"}(${e}:${n})`),console.log(o),\"\"}let _n,hn;function xn(t){function e(e,n,o,r,s){const i=Qt;se({$$:{on_destroy:_n,context:new Map(i?i.$$.context:s||[]),on_mount:[],before_update:[],after_update:[],callbacks:c()}});const l=t(e,n,o,r);return se(i),l}return{render:(t={},{$$slots:n={},context:o=new Map}={})=>{_n=[];const r={title:\"\",head:\"\",css:new Set},s=e(r,t,{},n,o);return l(_n),{html:s,css:{code:Array.from(r.css).map(t=>t.code).join(\"\\n\"),map:null},head:r.title+r.head}},$$render:e}}function mn(t,e,n){return null==e||n&&!e?\"\":` ${t}${!0===e?\"\":`=${\"string\"==typeof e?JSON.stringify(cn(e)):`\"${e}\"`}`}`}function gn(t){return t?` class=\"${t}\"`:\"\"}function yn(t,e,n){const o=t.$$.props[e];void 0!==o&&(t.$$.bound[o]=n,n(t.$$.ctx[o]))}function bn(t){t&&t.c()}function $n(t,e){t&&t.l(e)}function vn(t,e,n,o){const{fragment:r,on_mount:s,on_destroy:c,after_update:a}=t.$$;r&&r.m(e,n),o||Ee(()=>{const e=s.map(i).filter(u);c?c.push(...e):l(e),t.$$.on_mount=[]}),a.forEach(Ee)}function Fn(t,e){const n=t.$$;null!==n.fragment&&(l(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function wn(t,e){-1===t.$$.dirty[0]&&(me.push(t),we(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function kn(t,n,o,r,s,i,u,a=[-1]){const p=Qt;se(t);const d=t.$$={fragment:null,ctx:null,props:i,update:e,not_equal:s,bound:c(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:n.context||[]),callbacks:c(),dirty:a,skip_bound:!1,root:n.target||p.$$.root};u&&u(d.root);let f=!1;if(d.ctx=o?o(t,n.props||{},(e,n,...o)=>{const r=o.length?o[0]:n;return d.ctx&&s(d.ctx[e],d.ctx[e]=r)&&(!d.skip_bound&&d.bound[e]&&d.bound[e](r),f&&wn(t,e)),n}):[],d.update(),f=!0,l(d.before_update),d.fragment=!!r&&r(d.ctx),n.target){if(n.hydrate){W();const t=wt(n.target);d.fragment&&d.fragment.l(t),t.forEach(nt)}else d.fragment&&d.fragment.c();n.intro&&Le(t.$$.fragment),vn(t,n.target,n.anchor,n.customElement),G(),Oe()}se(p)}exports.missing_component=pn,exports.SvelteElement=hn,\"function\"==typeof HTMLElement&&(exports.SvelteElement=hn=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(i).filter(u);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){l(this.$$.on_disconnect)}$destroy(){Fn(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class En{$destroy(){Fn(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Sn(t,e){document.dispatchEvent(zt(t,Object.assign({version:\"3.41.0\"},e),!0))}function Cn(t,e){Sn(\"SvelteDOMInsert\",{target:t,node:e}),J(t,e)}function Dn(t,e){Sn(\"SvelteDOMInsert\",{target:t,node:e}),Z(t,e)}function On(t,e,n){Sn(\"SvelteDOMInsert\",{target:t,node:e,anchor:n}),tt(t,e,n)}function An(t,e,n){Sn(\"SvelteDOMInsert\",{target:t,node:e,anchor:n}),et(t,e,n)}function Mn(t){Sn(\"SvelteDOMRemove\",{node:t}),nt(t)}function Tn(t,e){for(;t.nextSibling&&t.nextSibling!==e;)Mn(t.nextSibling)}function jn(t){for(;t.previousSibling;)Mn(t.previousSibling)}function Nn(t){for(;t.nextSibling;)Mn(t.nextSibling)}function Rn(t,e,n,o,r,s){const i=!0===o?[\"capture\"]:o?Array.from(Object.keys(o)):[];r&&i.push(\"preventDefault\"),s&&i.push(\"stopPropagation\"),Sn(\"SvelteDOMAddEventListener\",{node:t,event:e,handler:n,modifiers:i});const c=pt(t,e,n,o);return()=>{Sn(\"SvelteDOMRemoveEventListener\",{node:t,event:e,handler:n,modifiers:i}),c()}}function qn(t,e,n){xt(t,e,n),null==n?Sn(\"SvelteDOMRemoveAttribute\",{node:t,attribute:e}):Sn(\"SvelteDOMSetAttribute\",{node:t,attribute:e,value:n})}function Hn(t,e,n){t[e]=n,Sn(\"SvelteDOMSetProperty\",{node:t,property:e,value:n})}function Ln(t,e,n){t.dataset[e]=n,Sn(\"SvelteDOMSetDataset\",{node:t,property:e,value:n})}function Bn(t,e){e=\"\"+e,t.wholeText!==e&&(Sn(\"SvelteDOMSetData\",{node:t,data:e}),t.data=e)}function Pn(t){if(\"string\"!=typeof t&&!(t&&\"object\"==typeof t&&\"length\"in t)){let e=\"{#each} only iterates over array-like objects.\";throw\"function\"==typeof Symbol&&t&&Symbol.iterator in t&&(e+=\" You can use a spread to convert this iterable into an array.\"),new Error(e)}}function In(t,e,n){for(const o of Object.keys(e))~n.indexOf(o)||console.warn(`<${t}> received an unexpected slot \"${o}\".`)}exports.SvelteComponent=En;class zn extends En{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=(()=>{console.warn(\"Component was already destroyed\")})}$capture_state(){}$inject_state(){}}exports.SvelteComponentDev=zn;class Wn extends zn{constructor(t){super(t)}}function Gn(t){const e=Date.now();return()=>{if(Date.now()-e>t)throw new Error(\"Infinite loop detected\")}}exports.SvelteComponentTyped=Wn;\n},{}],\"UTAW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.urlAlphabet=void 0;let e=\"ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW\";exports.urlAlphabet=e;\n},{}],\"b767\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"urlAlphabet\",{enumerable:!0,get:function(){return e.urlAlphabet}}),exports.random=exports.customRandom=exports.customAlphabet=exports.nanoid=void 0;var e=require(\"./url-alphabet/index.js\");let t=e=>crypto.getRandomValues(new Uint8Array(e));exports.random=t;let r=(e,t,r)=>{let o=(2<<Math.log(e.length-1)/Math.LN2)-1,n=-~(1.6*o*t/e.length);return()=>{let l=\"\";for(;;){let a=r(n),p=n;for(;p--;)if((l+=e[a[p]&o]||\"\").length===t)return l}}};exports.customRandom=r;let o=(e,o)=>r(e,o,t);exports.customAlphabet=o;let n=(e=21)=>{let t=\"\",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let o=63&r[e];t+=o<36?o.toString(36):o<62?(o-26).toString(36).toUpperCase():o<63?\"_\":\"-\"}return t};exports.nanoid=n;\n},{\"./url-alphabet/index.js\":\"UTAW\"}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"Tr4D\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ie,exports.S=se,exports.U=le,exports.b=ne,exports.e=$,exports.i=V,exports.y=D,exports.z=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.c=exports.a=exports.T=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=r(require(\"immer\")),t=r(require(\"lodash.isplainobject\"));function r(e){return e&&e.__esModule?e:{default:e}}const s=\"MAKE_MOVE\";exports.M=s;const n=\"GAME_EVENT\";exports.d=n;const a=\"REDO\";exports.m=a;const o=\"RESET\";exports.R=o;const i=\"SYNC\";exports.k=i;const l=\"UNDO\";exports.l=l;const p=\"UPDATE\";exports.j=p;const c=\"PATCH\";exports.o=c;const u=\"PLUGIN\";exports.P=u;const d=\"STRIP_TRANSIENTS\";exports.c=d;const h=(e,t,r,n)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:n}});exports.x=h;const y=(e,t,r,s)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:s}});exports.g=y;const g=(e,t,r,s)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:s},automatic:!0}),v=e=>({type:i,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=v;const f=(e,t,r,s)=>({type:c,prevStateID:e,stateID:t,patch:r,deltalog:s,clientOnly:!0});exports.C=f;const x=(e,t)=>({type:p,state:e,deltalog:t,clientOnly:!0});exports.B=x;const m=e=>({type:o,state:e,clientOnly:!0});exports.t=m;const E=(e,t)=>({type:l,payload:{type:null,args:null,playerID:e,credentials:t}});exports.u=E;const O=(e,t)=>({type:a,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=O;const P=(e,t,r,s)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:s}}),_=()=>({type:d});exports.q=_;var N=Object.freeze({makeMove:h,gameEvent:y,automaticGameEvent:g,sync:v,patch:f,update:x,reset:m,undo:E,redo:O,plugin:P,stripTransients:_});exports.A=N;const M=\"INVALID_MOVE\";exports.h=M;const T={name:\"plugin-immer\",fnWrap:t=>(r,s,...n)=>{let a=!1;const o=(0,e.default)(r,e=>{const r=t(e,s,...n);if(r!==M)return r;a=!0});return a?M:o}};class A{constructor(e){const t=I();this.c=1,this.s0=t(\" \"),this.s1=t(\" \"),this.s2=t(\" \"),this.s0-=t(e),this.s0<0&&(this.s0+=1),this.s1-=t(e),this.s1<0&&(this.s1+=1),this.s2-=t(e),this.s2<0&&(this.s2+=1)}next(){const e=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=e-(this.c=Math.trunc(e))}}function I(){let e=4022871197;return function(t){const r=t.toString();for(let s=0;s<r.length;s++){let t=.02519603282416938*(e+=r.charCodeAt(s));t-=e=t>>>0,e=(t*=e)>>>0,e+=4294967296*(t-=e)}return 2.3283064365386963e-10*(e>>>0)}}function S(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function D(e,t){const r=new A(e),s=r.next.bind(r);return t&&S(t,r),s.state=(()=>S(r,{})),s}class L{constructor(e){this.state=e||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const e=this.state,t=D(e.prngstate?\"\":e.seed,e.prngstate),r=t();return this.state={...e,prngstate:t.state()},r}api(){const e=this._random.bind(this),t={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},r={};for(const s in t){const n=t[s];r[s]=(t=>void 0===t?Math.floor(e()*n)+1:Array.from({length:t}).map(()=>Math.floor(e()*n)+1))}return{...r,Die:function(t=6,r){return void 0===r?Math.floor(e()*t)+1:Array.from({length:r}).map(()=>Math.floor(e()*t)+1)},Number:()=>e(),Shuffle:t=>{const r=[...t];let s=t.length,n=0;const a=Array.from({length:s});for(;s;){const t=Math.trunc(s*e());a[n++]=r[t],r[t]=r[--s]}return a},_private:this}}}const b={name:\"random\",noClient:({api:e})=>e._private.isUsed(),flush:({api:e})=>e._private.getState(),api:({data:e})=>{return new L(e).api()},setup:({game:e})=>{let{seed:t}=e;return void 0===t&&(t=L.seed()),{seed:t}},playerView:()=>void 0};var U,G;exports.G=U,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(U||(exports.G=U={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(G||(G={}));class w{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let s=0;s<this.dispatch.length;s++){const t=this.dispatch[s],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,G.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,G.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case U.TURN_ON_END:case U.PHASE_ON_END:return r(t.error,G.StageEventInOnEnd);case U.PHASE_ON_BEGIN:return r(t.error,G.StageEventInPhaseBegin);case U.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,G.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===U.TURN_ON_END||t.calledFrom===U.PHASE_ON_END)return r(t.error,G.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===U.PHASE_ON_END)return r(t.error,G.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const a=g(t.type,t.args,this.playerID);e=this.flow.processEvent(e,a)}return e}}const R={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,s,...n)=>{const a=s.events;return a&&a._private.updateTurnContext(s,t),r=e(r,s,...n),a&&a._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new w(e.flow,t,r).api()},k={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function C(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,t.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!C(e[t]))return!1;return!0}const B={name:\"plugin-serializable\",fnWrap:e=>(t,r,...s)=>{const n=e(t,r,...s);return n}},F=!0,H=()=>{},j=(...e)=>console.error(...e);function V(e){H(`INFO: ${e}`)}function $(e){j(\"ERROR:\",e)}const W=[T,b,k,B],q=[...W,R],z=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}},a=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[s]:{...n,data:a}}}}),e);exports.n=z;const K=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=K;const Y=(e,t,r)=>[...W,...r,R].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=Y;const J=(e,t)=>([...q,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const s=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[s]:{data:n}}}}),e);exports.r=J;const Q=(e,t)=>([...q,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}},a=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[s]:{...n,api:a}}}}),e);exports.f=Q;const X=(e,t)=>([...W,...t.game.plugins,R].reverse().forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}};if(r.flush){const s=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}else if(r.dangerouslyFlushRawState){const a=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[s].data;e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}}),e),Z=(e,t)=>[...q,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const s=r.name,n=e.plugins[s];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=Z;const ee=(e,t)=>{return[...q,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:s}=r,n=e.plugins[s],a=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!a&&{plugin:s,message:a}}).find(e=>e)||!1},te=(e,t)=>{const r=X(e,t),s=ee(r,t);if(!s)return[r];const{plugin:n,message:a}=s;return $(`${n} plugin declared action invalid:\\n${a}`),[e,s]};exports.p=te;const re=({G:e,ctx:t,plugins:r={}},{game:s,playerID:n})=>([...q,...s.plugins].forEach(({name:a,playerView:o})=>{if(!o)return;const{data:i}=r[a]||{data:{}},l=o({G:e,ctx:t,game:s,data:i,playerID:n});r={...r,[a]:{data:l}}}),r);function se(e,t){let r={},s=[],n=null,a={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=ce.NULL),r=e}else{if(t.next&&(n=t.next),t.revert&&(s=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMoveLimit:e._activePlayersMoveLimit,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&ae(r,a,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let s=0;s<e.playOrder.length;s++){const n=e.playOrder[s];n!==e.currentPlayer&&ae(r,a,n,t.others)}if(void 0!==t.all)for(let s=0;s<e.playOrder.length;s++){ae(r,a,e.playOrder[s],t.all)}if(t.value)for(const e in t.value)ae(r,a,e,t.value[e]);if(t.moveLimit)for(const e in r)void 0===a[e]&&(a[e]=t.moveLimit)}0===Object.keys(r).length&&(r=null),0===Object.keys(a).length&&(a=null);const o={};for(const i in r)o[i]=0;return{...e,activePlayers:r,_activePlayersMoveLimit:a,_activePlayersNumMoves:o,_prevActivePlayers:s,_nextActivePlayers:n}}function ne(e){let{activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n,_nextActivePlayers:a}=e;if(t&&0===Object.keys(t).length)if(a)e=se(e,a),({activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n}=e);else if(n.length>0){const e=n.length-1;({activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s}=n[e]),n=n.slice(0,e)}else t=null,r=null;return{...e,activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n}}function ae(e,t,r,s){\"object\"==typeof s&&s!==ce.NULL||(s={stage:s}),void 0!==s.stage&&(e[r]=s.stage,s.moveLimit&&(t[r]=s.moveLimit))}function oe(e,t){return e[t]+\"\"}function ie(e,t){let{G:r,ctx:s}=e;const{numPlayers:n}=s,a=K(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,a));const l=o.first(r,a),p=typeof l;\"number\"!==p&&$(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=oe(i,l);return s=se(s={...s,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function le(e,t,r,s){const n=r.order;let{G:a,ctx:o}=e,i=o.playOrderPos,l=!1;if(s&&!0!==s)\"object\"!=typeof s&&$(`invalid argument to endTurn: ${s}`),Object.keys(s).forEach(e=>{switch(e){case\"remove\":t=oe(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(s.next),t=s.next;break;default:$(`invalid argument to endTurn: ${e}`)}});else{const r=K(e),s=n.next(a,r),p=typeof s;void 0!==s&&\"number\"!==p&&$(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${s}”.`),void 0===s?l=!0:(i=s,t=oe(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.w=re;const pe={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=pe;const ce={NULL:null};exports.a=ce;const ue={ALL:{all:ce.NULL},ALL_ONCE:{all:ce.NULL,moveLimit:1},OTHERS:{others:ce.NULL},OTHERS_ONCE:{others:ce.NULL,moveLimit:1}};exports.z=ue;\n},{\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)o=((e=o)||{})[n=this.tokens[r]];return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"b133\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=m,exports.I=s,exports.P=i,exports.T=void 0;var e,t,n=require(\"./turn-order-0d61594c.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:i,plugins:s}){void 0===e&&(e={}),void 0===i&&(i={}),void 0===s&&(s=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const u={...t};\"\"in u&&(0,n.e)(\"cannot specify phase with empty name\"),u[\"\"]={};const c={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,s);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const T in u){const e=u[T];if(!0===e.start&&(d=T),void 0!==e.moves)for(const t of Object.keys(e.moves))c[T+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={});for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){c[T+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?u[e.phase]:u[\"\"]}function m(e){return e}function g(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:i,...s}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const u=[];if(e=o(e,{...s,arg:i,next:u}),o===b)break;const c=G(e);if(c){t.push({fn:b,arg:c,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([m,D,M].includes(o)){const n=w(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...u)}}return e}function h(e,{next:t}){return t.push({fn:x}),e}function x(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.S)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const i=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:i,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:i}=e;if(t&&t.next){if(!(t.next in u))return(0,n.e)(\"invalid phase: \"+t.next),e;i={...i,phase:t.next}}else i={...i,phase:o.wrapped.next(e)||null};return e={...e,ctx:i},a.push({fn:x}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:i}=e;const s=y(i),{endPhase:u,ctx:c}=(0,n.U)(e,a,s.turn,t);return i=c,e={...e,G:o,ctx:i},u?r.push({fn:N,turn:i.turn,phase:i.phase}):r.push({fn:I,currentPlayer:i.currentPlayer}),e}function D(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.a.NULL||(t={stage:t}),\"object\"!=typeof t)return e;let{ctx:r}=e,{activePlayers:o,_activePlayersMoveLimit:i,_activePlayersNumMoves:s}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,s[a]=0,t.moveLimit&&(null===i&&(i={}),i[a]=t.moveLimit)),r={...r,activePlayers:o,_activePlayersMoveLimit:i,_activePlayersNumMoves:s},{...e,ctx:r}}function M(e,{arg:t}){return{...e,ctx:(0,n.S)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function w(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.moveLimit&&n>=t.turn.moveLimit)||t.turn.wrapped.endIf(e)}function b(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:i,turn:s}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:i}),null===i)return e;const u=y(e.ctx).wrapped.onEnd(e),c={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:s,phase:i};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:u,ctx:c,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:i,playerID:s}){if(r!==e.ctx.turn)return e;const{currentPlayer:u,numMoves:c,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=c||0;if(!o&&p.turn.moveLimit&&v<p.turn.moveLimit)return(0,n.i)(`cannot end turn before making ${p.turn.moveLimit} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:u});let m={...e.ctx,activePlayers:null};if(t&&t.remove){s=s||u;const t=m.playOrder.filter(e=>e!=s),n=m.playOrderPos>t.length-1?0:m.playOrderPos;if(m={...m,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const g=(0,n.g)(\"endTurn\",t),{_stateID:h}=e,x={action:g,_stateID:h,turn:d,phase:l};i&&(x.automatic=!0);const I=[...e.deltalog||[],x];return{...e,G:f,ctx:m,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:i,_stateID:s}=e,{activePlayers:u,_activePlayersMoveLimit:c,phase:l,turn:d}=i;const p=null!==u&&o in u;if(!t&&p){const e=y(i).turn.stages[u[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:D,arg:t,playerID:o}),!p)return e;delete(u={...u})[o],c&&delete(c={...c})[o],i=(0,n.b)({...i,activePlayers:u,_activePlayersMoveLimit:c});const v={action:(0,n.g)(\"endStage\",t),_stateID:s,turn:d,phase:l};r&&(v.automatic=!0);const f=[...e.deltalog||[],v];return{...e,ctx:i,deltalog:f}}function S(t,a,r){const o=y(t),i=o.turn.stages,{activePlayers:s}=t;if(s&&void 0!==s[r]&&s[r]!==n.a.NULL&&void 0!==i[s[r]]&&void 0!==i[s[r]].moves){const e=i[s[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const L={endStage:function(e,t){return g(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return g(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return g(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return g(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return g(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return g(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return g(e,[{fn:b,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return g(e,[{fn:M,arg:n}])}},U=[];return!1!==i.endTurn&&U.push(\"endTurn\"),!1!==i.pass&&U.push(\"pass\"),!1!==i.endPhase&&U.push(\"endPhase\"),!1!==i.setPhase&&U.push(\"setPhase\"),!1!==i.endGame&&U.push(\"endGame\"),!1!==i.setActivePlayers&&U.push(\"setActivePlayers\"),!1!==i.endStage&&U.push(\"endStage\"),!1!==i.setStage&&U.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>g(e,[{fn:h}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:L,eventNames:Object.keys(L),enabledEventNames:U,moveMap:c,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{ctx:r}=e,{currentPlayer:o,activePlayers:i,_activePlayersMoveLimit:s}=r,u=S(r,a,n),c=!u||\"function\"==typeof u||!0!==u.noLimit;let{numMoves:l,_activePlayersNumMoves:d}=r;c&&(n===o&&l++,i&&d[n]++),e={...e,ctx:{...r,numMoves:l,_activePlayersNumMoves:d}},s&&d[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const p=y(r).turn.wrapped.onMove(e);return g(e={...e,G:p},[{fn:m}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof L[n]?e:L[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function i(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(s(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),i={...(0,n.E)(a),playerID:r.playerID};let s=[];return void 0!==r.args&&(s=Array.isArray(r.args)?r.args:[r.args]),t(a.G,i,...s)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function s(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const u=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,c=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,i]=(0,n.p)(e,r);return i?[o,f(a,t.PluginActionInvalid,i)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.c:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.q)()),{...r,transients:t}):r}}};function m({game:r,isClient:o}){return r=i(r),(i=null,s)=>{let[y]=v(i);switch(s.type){case n.c:return y;case n.d:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(u(s)&&!r.flow.isPlayerActive(y.G,y.ctx,s.payload.playerID))return(0,n.e)(`disallowed event: ${s.payload.type}`),f(y,t.InactivePlayer);y=(0,n.f)(y,{game:r,isClient:!1,playerID:s.payload.playerID});let e,a=r.flow.processEvent(y,s);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:s}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,s.payload.type,s.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${s.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(u(s)&&!r.flow.isPlayerActive(y.G,y.ctx,s.payload.playerID))return(0,n.e)(`disallowed move: ${s.payload.type}`),f(y,t.InactivePlayer);y=(0,n.f)(y,{game:r,isClient:o,playerID:s.payload.playerID});const i=r.processMove(y,s.payload);if(i===n.h)return(0,n.e)(`invalid move: ${s.payload.type} args: ${s.payload.args}`),f(y,t.InvalidMove);const c={...y,G:i};if(o&&(0,n.N)(c,{game:r}))return y;if(y=c,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,s,a),y=r.flow.processMove(y,s.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:s}),{...y,_stateID:y._stateID+1})}case n.R:case n.j:case n.k:return s.state;case n.l:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:i,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(u(s)&&s.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!c(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,s),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...i]}}case n.m:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const i=a[0];return u(s)&&s.payload.playerID!==i.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,s),{...y,G:i.G,ctx:i.ctx,plugins:i.plugins,_stateID:o+1,_undo:[...e,i],_redo:a.slice(1)})}case n.P:return(0,n.n)(y,s,{game:r});case n.o:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,s.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(s.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"vgbL\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=n,exports.a=o,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0d61594c.js\"),e=require(\"./reducer-77828ca8.js\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:a}){this._opts[t]={range:e,value:a}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,a,s){return this.enumerateFn(e,a,s).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.x)(e.move,e.args,s):\"event\"in e?(0,t.g)(e.event,e.args,s):void 0)}random(e){let a;if(void 0!==this.seed){const e=this.prngstate?\"\":this.seed,s=(0,t.y)(e,this.prngstate);a=s(),this.prngstate=s.state()}else a=Math.random();if(e){if(Array.isArray(e)){return e[Math.floor(a*e.length)]}return Math.floor(a*e)}return a}}exports.B=a;const s=25;class r extends a{constructor({enumerate:t,seed:a,objectives:s,game:r,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:a}),void 0===s&&(s=(()=>({}))),this.objectives=s,this.iterationCallback=o||(()=>{}),this.reducer=(0,e.C)({game:r}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:a,playerID:s}){const{G:r,ctx:i}=t;let n=[],o=[];if(void 0!==s)n=this.enumerate(r,i,s),o=this.objectives(r,i,s);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(r,i,c)),o.push(this.objectives(r,i,c));else n=this.enumerate(r,i,i.currentPlayer),o=this.objectives(r,i,i.currentPlayer);return{state:t,parent:a,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,a=0;for(const s of t.children){const r=s.visits+Number.EPSILON,i=s.value/r+Math.sqrt(2*Math.log(t.visits)/r);(null==e||i>a)&&(a=i,e=s)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const a=this.random(e.length),s=e[a];t.actions.splice(a,1);const r=this.reducer(t.state,s),i=this.createNode({state:r,parentAction:s,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let a=0;a<e&&void 0===t.ctx.gameover;a++){const{G:e,ctx:a}=t;let s=a.currentPlayer;a.activePlayers&&(s=Object.keys(a.activePlayers)[0]);const r=this.enumerate(e,a,s),i=this.objectives(e,a,s),n=Object.keys(i).reduce((t,s)=>{const r=i[s];return r.checker(e,a)?t+r.weight:t},0);if(n>0)return{score:n};if(!r||0===r.length)return;const o=this.random(r.length);t=this.reducer(t,r[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const a=this.createNode({state:t,playerID:e});let r=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(r=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of a.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:a}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<r;t++){const t=this.select(a),e=this.expand(t),s=this.playout(e);this.backpropagate(e,s),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:r,metadata:a})};if(this.iterationCounter=0,this.getOpt(\"async\")){const a=()=>{this.iterationCounter<r?(e(),setTimeout(a,0)):t(i())};a()}else{for(;this.iterationCounter<r;)e();t(i())}})}}exports.M=r;class i extends a{play({G:t,ctx:e},a){const s=this.enumerate(t,e,a);return Promise.resolve({action:this.random(s)})}}async function n(t,e){const a=t.store.getState();let s=a.ctx.currentPlayer;a.ctx.activePlayers&&(s=Object.keys(a.ctx.activePlayers)[0]);const{action:r,metadata:i}=await e.play(a,s);if(r){const e={...r,payload:{...r.payload,metadata:i}};return t.store.dispatch(e),e}}async function o({game:t,bots:s,state:r,depth:i}){void 0===i&&(i=1e4);const n=(0,e.C)({game:t});let o=null,c=0;for(;void 0===r.ctx.gameover&&c<i;){let t=r.ctx.currentPlayer;r.ctx.activePlayers&&(t=Object.keys(r.ctx.activePlayers)[0]);const e=s instanceof a?s:s[t],i=await e.play(r,t);if(!i.action)break;o=i.metadata,r=n(r,i.action),c++}return{state:r,metadata:o}}exports.R=i;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\"}],\"odqP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0d61594c.js\"),t=require(\"./reducer-77828ca8.js\"),n=require(\"flatted\"),r=require(\"./ai-f28cab02.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function X(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Y(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const W=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);W.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(W.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),W.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=Y(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(Y(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function Xe(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Ye(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function We(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},We)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1scv1e1\",\".menu.svelte-1scv1e1{display:flex;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;transform-origin:top right;transform:rotate(-90deg) /* 2 */ translateY(-27px) /* 3 */ translateX(-70px)}.menu-item.svelte-1scv1e1{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1scv1e1:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1scv1e1:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1scv1e1{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1scv1e1:hover,.menu-item.svelte-1scv1e1:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1scv1e1\"),X(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&X(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1scv1e1\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),X(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&X(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),X(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&X(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),X(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&X(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),X(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&X(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Xt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Yt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Wt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Wt,Yt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),X(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&X(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&X(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&X(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Xt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),X(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&X(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),X(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&X(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Xn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Yn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),X(t,\"current\",e[7]==e[0].currentPlayer),X(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&X(t,\"current\",e[7]==e[0].currentPlayer),6&o&&X(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Wn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Yn(Xn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Xn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Yn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Wn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){return!t||\"object\"!=typeof t&&\"function\"!=typeof t?pr(e):t}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager)}),[s,r,i]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Xr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Yr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Wr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Wr,Yr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),X(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&X(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Xr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),X(t,\"clickable\",e[1].length>0),X(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&X(t,\"clickable\",e[1].length>0),1&l&&X(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),X(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&X(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[5]=t[n][0],r[6]=t[n][1],r[7]=t,r[8]=n,r}function Bl(e){let t,n,r,l,o,a,s,i,u=e[1][e[5]]+\"\";function d(){e[3].call(l,e[5])}return{c(){t=M(\"span\"),n=N(u),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"type\",\"range\"),G(l,\"min\",o=e[6].range.min),G(l,\"max\",a=e[6].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[5]]),s||(i=[R(l,\"change\",d),R(l,\"input\",d),R(l,\"change\",e[2])],s=!0)},p(t,r){e=t,3&r&&u!==(u=e[1][e[5]]+\"\")&&F(n,u),1&r&&o!==(o=e[6].range.min)&&G(l,\"min\",o),1&r&&a!==(a=e[6].range.max)&&G(l,\"max\",a),3&r&&H(l,e[1][e[5]])},d(e){e&&I(t),e&&I(r),e&&I(l),s=!1,c(i)}}}function Rl(e){let t,n,r;function l(){e[4].call(t,e[5])}return{c(){G(t=M(\"input\"),\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(o,a){q(o,t,a),t.checked=e[1][e[5]],n||(r=[R(t,\"change\",l),R(t,\"change\",e[2])],n=!0)},p(n,r){e=n,3&r&&(t.checked=e[1][e[5]])},d(e){e&&I(t),n=!1,c(r)}}}function Kl(e){let t,n,r,l,o,a,s=e[5]+\"\",i=e[6].range&&Bl(e),c=\"boolean\"==typeof e[6].value&&Rl(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),l=V(),i&&i.c(),o=V(),c&&c.c(),a=V(),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,s){q(e,t,s),A(t,n),A(n,r),A(t,l),i&&i.m(t,null),A(t,o),c&&c.m(t,null),A(t,a)},p(e,n){1&n&&s!==(s=e[5]+\"\")&&F(r,s),e[6].range?i?i.p(e,n):((i=Bl(e)).c(),i.m(t,o)):i&&(i.d(1),i=null),\"boolean\"==typeof e[6].value?c?c.p(e,n):((c=Rl(e)).c(),c.m(t,a)):c&&(c.d(1),c=null)},d(e){e&&I(t),i&&i.d(),c&&c.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Xl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Yl(Hl(e,E,c));let z=j&&Wl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[16].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[16]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Yl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Wl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Yl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[17]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Xl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t;const{secondaryPane:a}=de(\"secondaryPane\"),s={MCTS:r.M,Random:r.R};let i=!1,c=null,u=0,d=null;const f=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,u=e),n(2,c=e/t),d=r,i&&d&&a.set({component:jl,metadata:d})};let p,m,g,v;function $(){l.overrideGameState(null),a.set(null),n(1,i=!1)}return l.game.ai&&(p=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:f})).setOpt(\"async\",!0),ie($),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager)}),[l,i,c,u,m,g,v,p,s,function(){i&&d?a.set({component:jl,metadata:d}):a.set(null)},function(){const e=s[m];n(7,p=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:f})),p.setOpt(\"async\",!0),n(5,g=null),d=null,a.set(null),n(3,u=0)},async function(){n(5,g=null),d=null,n(3,u=0);const e=await(0,r.S)(l,p);e&&(n(5,g=e.payload.type),n(6,v=e.payload.args))},function(e=1e4,t=100){return n(5,g=null),d=null,n(3,u=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,p);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,g=null),d=null,n(3,u=0),$()},function(e){27==e.keyCode&&$()},o,function(){m=U(this),n(4,m),n(8,s)},function(){i=this.checked,n(1,i)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15},Fl)}}function oo(e){z(e,\"svelte-18rjbx9\",\".debug-panel.svelte-18rjbx9.svelte-18rjbx9{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-18rjbx9.svelte-18rjbx9{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9:hover,.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9:focus{background:#eee}.opener.svelte-18rjbx9.svelte-18rjbx9{right:10px}.closer.svelte-18rjbx9.svelte-18rjbx9{left:175px}@keyframes svelte-18rjbx9-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-18rjbx9.svelte-18rjbx9{display:flex;height:100%;animation:svelte-18rjbx9-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-18rjbx9 .icon.svelte-18rjbx9{animation-direction:reverse}.pane.svelte-18rjbx9.svelte-18rjbx9{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-18rjbx9.svelte-18rjbx9{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-18rjbx9 button,.debug-panel.svelte-18rjbx9 select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-18rjbx9 select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-18rjbx9 section{margin-bottom:20px}.debug-panel.svelte-18rjbx9 .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v;l=new at({}),(i=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var $=e[6][e[2]].component;function y(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}$&&(d=new $(y(e)));let h=e[5]&&io(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=M(\"span\"),Be(l.$$.fragment),s=V(),Be(i.$$.fragment),c=V(),u=M(\"div\"),d&&Be(d.$$.fragment),f=V(),h&&h.c(),G(r,\"class\",\"icon svelte-18rjbx9\"),G(r,\"aria-hidden\",\"true\"),G(n,\"class\",\"visibility-toggle closer svelte-18rjbx9\"),G(n,\"title\",\"Hide Debug Panel\"),G(u,\"class\",\"pane svelte-18rjbx9\"),G(u,\"role\",\"region\"),G(u,\"aria-label\",e[2]),G(u,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-18rjbx9\")},m(o,a){q(o,t,a),A(t,n),A(n,r),Re(l,r,null),A(t,s),Re(i,t,null),A(t,c),A(t,u),d&&Re(d,u,null),e[15](u),A(t,f),h&&h.m(t,null),m=!0,g||(v=R(n,\"click\",e[9]),g=!0)},p(n,r){e=n;const l={};4&r&&(l.pane=e[2]),i.$set(l);const o={};if(16&r&&(o.client=e[4]),1&r&&(o.clientManager=e[0]),$!==($=e[6][e[2]].component)){if(d){_e();const e=d;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}$?(Be((d=new $(y(e))).$$.fragment),Ce(d.$$.fragment,1),Re(d,u,null)):d=null}else $&&d.$set(o);(!m||4&r)&&G(u,\"aria-label\",e[2]),e[5]?h?(h.p(e,r),32&r&&Ce(h,1)):((h=io(e)).c(),Ce(h,1),h.m(t,null)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se())},i(r){m||(Ce(l.$$.fragment,r),be(()=>{a&&a.end(1),(o=Te(n,e[13],{key:\"toggle\"})).start()}),Ce(i.$$.fragment,r),d&&Ce(d.$$.fragment,r),Ce(h),be(()=>{p||(p=De(t,Xe,{x:400,...e[11]},!0)),p.run(1)}),m=!0)},o(r){qe(l.$$.fragment,r),o&&o.invalidate(),a=Me(n,e[12],{key:\"toggle\"}),qe(i.$$.fragment,r),d&&qe(d.$$.fragment,r),qe(h),p||(p=De(t,Xe,{x:400,...e[11]},!1)),p.run(0),m=!1},d(n){n&&I(t),Ke(l),n&&a&&a.end(),Ke(i),d&&Ke(d),e[15](null),h&&h.d(),n&&p&&p.end(),g=!1,v()}}}function so(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-18rjbx9\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-18rjbx9\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[13],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[12],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function io(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-18rjbx9\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function co(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-18rjbx9\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[10]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function uo(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(14,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,y=!y)}let y=!0;const h={duration:150,easing:Ze},[b,x]=Ye(h);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{16384&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,y,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,function(e){\".\"!=e.key?y&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},h,b,x,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class fo extends Le{constructor(e){super(),Je(this,e,uo,co,d,{clientManager:0},oo)}}exports.D=fo;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"flatted\":\"O5av\",\"./ai-f28cab02.js\":\"vgbL\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"azvt\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0d61594c.js\"),t=require(\"./reducer-77828ca8.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.r)(n,{game:r}),n=(0,e.f)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.p)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\"}],\"KLsr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class e{constructor({store:e,gameName:t,playerID:s,matchID:a,credentials:r,numPlayers:l}){this.store=e,this.gameName=t||\"default\",this.playerID=s||null,this.matchID=a||\"default\",this.credentials=r,this.numPlayers=l||2}}exports.T=e;\n},{}],\"yBCo\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid\"),e=require(\"./Debug-a4f4cad1.js\"),s=require(\"redux\"),i=require(\"./turn-order-0d61594c.js\"),r=require(\"./reducer-77828ca8.js\"),a=require(\"./initialize-68f0dc41.js\"),n=require(\"./transport-0079de87.js\");class h extends n.T{connect(){}disconnect(){}onAction(){}onChatMessage(){}subscribe(){}subscribeChatMessage(){}subscribeMatchData(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const l=t=>new h(t);class u{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const c=new u;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const l of e)h[l]=((...e)=>{const h=i.A[t](l,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:u,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g,this.credentials=d,this.multiplayer=u,this.debugOpt=n,this.manager=c,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==u}),this.initialState=null,u||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.t)(this.initialState))}),this.undo=(()=>{const t=(0,i.u)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.c||this.transport.onAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.d:case i.l:case i.m:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.R:this.log=[];break;case i.o:case i.j:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.k:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),u||(u=l),this.transport=u({gameKey:e,game:this.game,store:this.store,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.transport.subscribeMatchData(t=>{this.matchData=t,this.notifySubscribers()}),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.onChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})}),this.transport.subscribeChatMessage(t=>{this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()})}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribe(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.w)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid\":\"b767\",\"./Debug-a4f4cad1.js\":\"odqP\",\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\"}],\"hK59\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const t=(t,e)=>{if(!t||\"string\"!=typeof t)throw new Error(`Expected ${e} string, got \"${t}\".`)},e=e=>t(e,\"game name\"),s=e=>t(e,\"match ID\"),r=(t,e)=>{if(!t)throw new Error(`Expected body, got “${t}”.`);for(const s in e){const r=e[s],a=t[s];if(typeof a!==r)throw new TypeError(`Expected body.${s} to be of type ${r}, got “${a}”.`)}};class a extends Error{constructor(t,e){super(t),this.details=e}}exports.a=a;class i{constructor({server:t=\"\"}={}){this.server=t.replace(/\\/$/,\"\")}async request(t,e){const s=await fetch(this.server+t,e);if(!s.ok){let t;try{t=await s.json()}catch{try{t=await s.text()}catch(r){t=r.message}}throw new a(`HTTP status ${s.status}`,t)}return s.json()}async post(t,e){let s={method:\"post\",body:JSON.stringify(e.body),headers:{\"Content-Type\":\"application/json\"}};return e.init&&(s={...s,...e.init,headers:{...s.headers,...e.init.headers}}),this.request(t,s)}async listGames(t){return this.request(\"/games\",t)}async listMatches(t,s,r){e(t);let a=\"\";if(s){const t=[],{isGameover:e,updatedBefore:r,updatedAfter:i}=s;void 0!==e&&t.push(`isGameover=${e}`),r&&t.push(`updatedBefore=${r}`),i&&t.push(`updatedAfter=${i}`),t.length>0&&(a=\"?\"+t.join(\"&\"))}return this.request(`/games/${t}${a}`,r)}async getMatch(t,r,a){return e(t),s(r),this.request(`/games/${t}/${r}`,a)}async createMatch(t,s,a){return e(t),r(s,{numPlayers:\"number\"}),this.post(`/games/${t}/create`,{body:s,init:a})}async joinMatch(t,a,i,n){return e(t),s(a),r(i,{playerID:\"string\",playerName:\"string\"}),this.post(`/games/${t}/${a}/join`,{body:i,init:n})}async leaveMatch(t,a,i,n){e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${t}/${a}/leave`,{body:i,init:n})}async updatePlayer(t,a,i,n){e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${t}/${a}/update`,{body:i,init:n})}async playAgain(t,a,i,n){return e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${t}/${a}/playAgain`,{body:i,init:n})}}exports.L=i;\n},{}],\"iSKo\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Client\",{enumerable:!0,get:function(){return e.C}}),Object.defineProperty(exports,\"LobbyClient\",{enumerable:!0,get:function(){return r.L}}),Object.defineProperty(exports,\"LobbyClientError\",{enumerable:!0,get:function(){return r.a}}),require(\"nanoid\"),require(\"./Debug-a4f4cad1.js\"),require(\"redux\"),require(\"./turn-order-0d61594c.js\"),require(\"immer\"),require(\"lodash.isplainobject\"),require(\"./reducer-77828ca8.js\"),require(\"rfc6902\"),require(\"./initialize-68f0dc41.js\"),require(\"./transport-0079de87.js\");var e=require(\"./client-1535506e.js\");require(\"flatted\"),require(\"./ai-f28cab02.js\");var r=require(\"./client-99609c4d.js\");\n},{\"nanoid\":\"b767\",\"./Debug-a4f4cad1.js\":\"odqP\",\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-77828ca8.js\":\"b133\",\"rfc6902\":\"B6py\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\",\"./client-1535506e.js\":\"yBCo\",\"flatted\":\"O5av\",\"./ai-f28cab02.js\":\"vgbL\",\"./client-99609c4d.js\":\"hK59\"}],\"VAT5\":[function(require,module,exports) {\n\"use strict\";var e;function t(t){return t.type()===e.SYNC}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=t,exports.S=exports.A=void 0,function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class a{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=a;class s{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=s;\n},{}],\"pSJp\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0d61594c.js\"),e=require(\"./reducer-77828ca8.js\"),r=require(\"./initialize-68f0dc41.js\"),s=require(\"./base-13e38c3e.js\");const i=({game:t,unlisted:a,setupData:e,numPlayers:r})=>{const s={gameName:t.name,unlisted:!!a,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==e&&(s.setupData=e);for(let i=0;i<r;i++)s.players[i]={id:i};return s},o=({game:t,numPlayers:a,setupData:e,unlisted:s})=>{a&&\"number\"==typeof a||(a=2);const o=t.validateSetupData&&t.validateSetupData(e,a);return void 0!==o?{setupDataError:o}:{metadata:i({game:t,numPlayers:a,setupData:e,unlisted:s}),initialState:(0,r.I)({game:t,numPlayers:a,setupData:e})}},n=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),l=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class d{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(r,i,o,n){if(!r||!r.payload)return{error:\"missing action or action payload\"};let d;if((0,s.i)(this.storageAPI)?({metadata:d}=this.storageAPI.fetch(o,{metadata:!0})):({metadata:d}=await this.storageAPI.fetch(o,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:n,credentials:r.payload.credentials,metadata:d})))return{error:\"unauthorized action\"}}const c=l(r),h=o;let u;if((0,s.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${n}]`+` - action[${c.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),m=(0,t.createStore)(p,u,g);if(c.type==a.l||c.type==a.m){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===n;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[n]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${n}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,n))return void(0,a.e)(`player not active - playerID=[${n}]`+` - action[${c.payload.type}]`);const y=c.type==a.M?this.game.flow.getMove(u.ctx,c.payload.type,n):null;if(c.type==a.M&&!y)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${n}]`+` - action[${c.payload.type}]`);if(u._stateID!==i&&!(y&&(0,e.I)(y)&&y.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${i}], expected=[${u._stateID}]`+` - playerID=[${n}] - action[${c.payload.type}]`);const I=m.getState();m.dispatch(c),u=m.getState(),this.subscribeCallback({state:u,action:c,matchID:o}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[o,i,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[o,u]});const{deltalog:f,...P}=u;let A;if(!d||\"gameover\"in d||(A={...d,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,s.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,r=2){const i=t,l={state:!0,metadata:!0,log:!0,initialState:!0},d=(0,s.i)(this.storageAPI)?this.storageAPI.fetch(i,l):await this.storageAPI.fetch(i,l);let{state:c,initialState:h,log:u,metadata:p}=d;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:p})))return{error:\"unauthorized\"}}if(void 0===c){const a=o({game:this.game,unlisted:!0,numPlayers:r,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};h=c=a.initialState,p=a.metadata,this.subscribeCallback({state:c,matchID:t}),(0,s.i)(this.storageAPI)?this.storageAPI.createMatch(i,{initialState:h,metadata:p}):await this.storageAPI.createMatch(i,{initialState:h,metadata:p})}const g={state:c,log:u,filteredMetadata:p?n(p):void 0,initialState:h};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,g]})}async onConnectionChange(t,e,r,i){const o=t;if(null==e)return;let l;if((0,s.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(o,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(o,{metadata:!0})),void 0===l)return(0,a.e)(`metadata not found for matchID=[${o}]`),{error:\"metadata not found\"};if(void 0===l.players[e])return(0,a.e)(`Player not in the match, matchID=[${o}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:r,metadata:l})))return{error:\"unauthorized\"}}l.players[e].isConnected=i;const d=n(l);this.transportAPI.sendAll({type:\"matchData\",args:[t,d]}),(0,s.i)(this.storageAPI)?this.storageAPI.setMetadata(o,l):await this.storageAPI.setMetadata(o,l)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=d;\n},{\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"./initialize-68f0dc41.js\":\"azvt\",\"./base-13e38c3e.js\":\"VAT5\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"a3MF\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=f,exports.S=I;var t=require(\"./turn-order-0d61594c.js\"),e=require(\"rfc6902\"),s=require(\"./transport-0079de87.js\"),a=require(\"./base-13e38c3e.js\"),i=require(\"./master-cf52dceb.js\"),c=r(require(\"socket.io-client\"));function r(t){return t&&t.__esModule?t:{default:t}}class n extends a.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class h extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends n{constructor(t=\"bgio\"){super();const e=e=>new h(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}const l=(e,s,a)=>({...a,G:e.playerView(a.G,a.ctx,s),plugins:(0,t.w)(a,{playerID:s,game:e}),deltalog:void 0,_undo:[],_redo:[]}),d=t=>(s,a)=>{switch(a.type){case\"patch\":{const[i,c,r,n]=a.args,h=u(n.deltalog,s),o=l(t,s,n),d=n._stateID,p=l(t,s,r);return{type:\"patch\",args:[i,c,d,(0,e.createPatch)(p,o),h]}}case\"update\":{const[e,i]=a.args,c=u(i.deltalog,s);return{type:\"update\",args:[e,l(t,s,i),c]}}case\"sync\":{const[e,i]=a.args,c=l(t,s,i.state),r=u(i.log,s);return{type:\"sync\",args:[e,{...i,state:c,log:r}]}}default:return a}};function u(t,e){return void 0===t?t:t.map(t=>{if(null!==e&&+e==+t.action.payload.playerID)return t;if(!0!==t.redact)return t;const s={...t.action.payload,args:null},a={...t,action:{...t.action,payload:s}},{redact:i,...c}=a;return c})}function p(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class m extends i.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const i={},c={};if(t&&t.ai&&e)for(const n in e){const s=e[n];c[n]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const r=({playerID:t,...e})=>{const s=i[t];void 0!==s&&s(h(t,e))},h=d(t),l={send:r,sendAll:t=>{for(const e in i)r({playerID:e,...t})}};super(t,a?new o(s):new n,l),this.connect=((t,e,s)=>{i[e]=s}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const a=p(t,c);null!==a&&setTimeout(async()=>{const e=await c[a].play(t,a);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class g extends s.T{constructor({master:t,...e}){super(e),this.master=t,this.isConnected=!0}onChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}async onUpdate(e,s,a){const i=this.store.getState();if(e==this.matchID&&s._stateID>=i._stateID){const e=(0,t.B)(s,a);this.store.dispatch(e)}}onSync(e,s){if(e==this.matchID){const e=(0,t.s)(s);this.store.dispatch(e)}}onAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}connect(){this.master.connect(this.matchID,this.playerID,t=>{switch(t.type){case\"sync\":return this.onSync(...t.args);case\"update\":return this.onUpdate(...t.args);case\"chat\":return this.chatMessageCallback(t.args[1])}}),this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}disconnect(){}subscribe(){}subscribeMatchData(){}subscribeChatMessage(t){this.chatMessageCallback=t}resetAndSync(){const e=(0,t.t)(null);this.store.dispatch(e),this.connect()}updateMatchID(t){this.matchID=t,this.resetAndSync()}updatePlayerID(t){this.playerID=t,this.resetAndSync()}updateCredentials(t){this.credentials=t,this.resetAndSync()}}const y=new Map;function f({bots:t,persist:e,storageKey:s}={}){return a=>{const{gameKey:i,game:c}=a;let r;const n=y.get(i);return n&&n.bots===t&&n.storageKey===s&&n.persist===e&&(r=n.master),r||(r=new m({game:c,bots:t,persist:e,storageKey:s}),y.set(i,{master:r,bots:t,persist:e,storageKey:s})),new g({master:r,...a})}}const D=c.default;class k extends s.T{constructor({socket:t,socketOpts:e,server:s,...a}={}){super(a),this.server=s,this.socket=t,this.socketOpts=e,this.isConnected=!1,this.callback=(()=>{}),this.matchDataCallback=(()=>{}),this.chatMessageCallback=(()=>{})}onAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}onChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=D(t+this.gameName,this.socketOpts)}else this.socket=D(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(e,s,a,i,c)=>{const r=this.store.getState()._stateID;if(e===this.matchID&&s===r){const e=(0,t.C)(s,a,i,c);this.store.dispatch(e),this.store.getState()._stateID===r&&this.sync()}}),this.socket.on(\"update\",(e,s,a)=>{const i=this.store.getState();if(e==this.matchID&&s._stateID>=i._stateID){const e=(0,t.B)(s,a);this.store.dispatch(e)}}),this.socket.on(\"sync\",(e,s)=>{if(e==this.matchID){const e=(0,t.s)(s);this.matchDataCallback(s.filteredMetadata),this.store.dispatch(e)}}),this.socket.on(\"matchData\",(t,e)=>{t==this.matchID&&this.matchDataCallback(e)}),this.socket.on(\"chat\",(t,e)=>{t===this.matchID&&this.chatMessageCallback(e)}),this.socket.on(\"connect\",()=>{this.sync(),this.isConnected=!0,this.callback()}),this.socket.on(\"disconnect\",()=>{this.isConnected=!1,this.callback()})}disconnect(){this.socket.close(),this.socket=null,this.isConnected=!1,this.callback()}subscribe(t){this.callback=t}subscribeMatchData(t){this.matchDataCallback=t}subscribeChatMessage(t){this.chatMessageCallback=t}sync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}resetAndSync(){const e=(0,t.t)(null);this.store.dispatch(e),this.sync()}updateMatchID(t){this.matchID=t,this.resetAndSync()}updatePlayerID(t){this.playerID=t,this.resetAndSync()}updateCredentials(t){this.credentials=t,this.resetAndSync()}}function I({server:t,socketOpts:e}={}){return s=>new k({server:t,socketOpts:e,...s})}\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"rfc6902\":\"B6py\",\"./transport-0079de87.js\":\"KLsr\",\"./base-13e38c3e.js\":\"VAT5\",\"./master-cf52dceb.js\":\"pSJp\",\"socket.io-client\":\"x518\"}],\"Q5yd\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Local\",{enumerable:!0,get:function(){return e.L}}),Object.defineProperty(exports,\"SocketIO\",{enumerable:!0,get:function(){return e.S}}),require(\"redux\"),require(\"./turn-order-0d61594c.js\"),require(\"immer\"),require(\"lodash.isplainobject\"),require(\"./reducer-77828ca8.js\"),require(\"rfc6902\"),require(\"./initialize-68f0dc41.js\"),require(\"./transport-0079de87.js\"),require(\"./base-13e38c3e.js\");var e=require(\"./socketio-b981ab77.js\");require(\"./master-cf52dceb.js\"),require(\"socket.io-client\");\n},{\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-77828ca8.js\":\"b133\",\"rfc6902\":\"B6py\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\",\"./base-13e38c3e.js\":\"VAT5\",\"./socketio-b981ab77.js\":\"a3MF\",\"./master-cf52dceb.js\":\"pSJp\",\"socket.io-client\":\"x518\"}],\"jx3b\":[function(require,module,exports) {\n\"use strict\";function e(e,r){e.deck--,e.hand[r.currentPlayer]++}function r(e,r){e.deck++,e.hand[r.currentPlayer]--}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;const a={setup:e=>({deck:6,hand:Array(e.numPlayers).fill(0)}),phases:{draw:{moves:{DrawCard:e},endIf:e=>e.deck<=0,next:\"play\",start:!0},play:{moves:{PlayCard:r},endIf:e=>e.deck>=6}},turn:{moveLimit:1}};var t=a;exports.default=t;\n},{}],\"iGH7\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=require(\"svelte/internal\"),t=require(\"boardgame.io/client\"),a=require(\"boardgame.io/multiplayer\"),n=s(require(\"./game\"));function s(e){return e&&e.__esModule?e:{default:e}}function l(t){(0,e.append_styles)(t,\"svelte-shmgoi\",\".phase.svelte-shmgoi.svelte-shmgoi{font-size:1.2em;margin-top:20px;color:#aaa}.deck.svelte-shmgoi.svelte-shmgoi{font-family:monospace;width:40px;height:60px;margin-left:auto;margin-right:auto;border:1px solid #ddd;padding:20px;text-align:center;border-radius:5px;margin-bottom:50px}.client.svelte-shmgoi.svelte-shmgoi{border-radius:5px;width:100px;border:1px solid #ddd;background:#fafafa;opacity:.8}.client.active.svelte-shmgoi.svelte-shmgoi{box-shadow:0 0 5px #aaa;background:#fff;opacity:1}.client.svelte-shmgoi li.svelte-shmgoi{list-style:none;padding:5px;height:30px;line-height:30px;text-align:center;font-family:monospace}\")}function i(t){let a,n,s,l,i,p,d,o,r,c,m,u,g,h,v,x,f,y=t[1].G.hand[t[0]]+\"\";return{c(){a=(0,e.element)(\"div\"),n=(0,e.element)(\"li\"),s=(0,e.element)(\"strong\"),l=(0,e.text)(\"Player \"),i=(0,e.text)(t[0]),p=(0,e.space)(),d=(0,e.element)(\"li\"),o=(0,e.text)(y),r=(0,e.text)(\" cards\"),c=(0,e.space)(),m=(0,e.element)(\"li\"),(u=(0,e.element)(\"button\")).textContent=\"Draw Card\",g=(0,e.space)(),h=(0,e.element)(\"li\"),(v=(0,e.element)(\"button\")).textContent=\"Play Card\",(0,e.attr)(n,\"class\",\"svelte-shmgoi\"),(0,e.attr)(d,\"class\",\"svelte-shmgoi\"),(0,e.attr)(m,\"class\",\"svelte-shmgoi\"),(0,e.attr)(h,\"class\",\"svelte-shmgoi\"),(0,e.attr)(a,\"class\",\"client svelte-shmgoi\"),(0,e.toggle_class)(a,\"active\",t[1].isActive)},m(y,b){(0,e.insert)(y,a,b),(0,e.append)(a,n),(0,e.append)(n,s),(0,e.append)(s,l),(0,e.append)(s,i),(0,e.append)(a,p),(0,e.append)(a,d),(0,e.append)(d,o),(0,e.append)(d,r),(0,e.append)(a,c),(0,e.append)(a,m),(0,e.append)(m,u),(0,e.append)(a,g),(0,e.append)(a,h),(0,e.append)(h,v),x||(f=[(0,e.listen)(u,\"click\",t[2].moves.DrawCard),(0,e.listen)(v,\"click\",t[2].moves.PlayCard)],x=!0)},p(t,n){1&n&&(0,e.set_data)(i,t[0]),3&n&&y!==(y=t[1].G.hand[t[0]]+\"\")&&(0,e.set_data)(o,y),2&n&&(0,e.toggle_class)(a,\"active\",t[1].isActive)},d(t){t&&(0,e.detach)(a),x=!1,(0,e.run_all)(f)}}}function p(t){let a,n,s,l,i,p,d,o,r=t[1].G.deck+\"\",c=t[1].ctx.phase+\"\";return{c(){a=(0,e.element)(\"div\"),n=(0,e.element)(\"div\"),s=(0,e.text)(r),l=(0,e.space)(),(i=(0,e.element)(\"div\")).textContent=\"cards\",p=(0,e.space)(),d=(0,e.element)(\"div\"),o=(0,e.text)(c),(0,e.attr)(d,\"class\",\"phase svelte-shmgoi\"),(0,e.attr)(a,\"class\",\"deck svelte-shmgoi\")},m(t,r){(0,e.insert)(t,a,r),(0,e.append)(a,n),(0,e.append)(n,s),(0,e.append)(a,l),(0,e.append)(a,i),(0,e.append)(a,p),(0,e.append)(a,d),(0,e.append)(d,o)},p(t,a){2&a&&r!==(r=t[1].G.deck+\"\")&&(0,e.set_data)(s,r),2&a&&c!==(c=t[1].ctx.phase+\"\")&&(0,e.set_data)(o,c)},d(t){t&&(0,e.detach)(a)}}}function d(t){let a;function n(e,t){return e[0]?i:p}let s=n(t),l=s(t);return{c(){l.c(),a=(0,e.empty)()},m(t,n){l.m(t,n),(0,e.insert)(t,a,n)},p(e,[t]){s===(s=n(e))&&l?l.p(e,t):(l.d(1),(l=s(e))&&(l.c(),l.m(a.parentNode,a)))},i:e.noop,o:e.noop,d(t){l.d(t),t&&(0,e.detach)(a)}}}function o(s,l,i){let p,{playerID:d=null}=l;const o=(0,t.Client)({game:n.default,matchID:\"default\",playerID:d,debug:!1,numPlayers:3,multiplayer:(0,a.Local)()});return(0,e.component_subscribe)(s,o,e=>i(1,p=e)),o.start(),s.$$set=(e=>{\"playerID\"in e&&i(0,d=e.playerID)}),[d,p,o]}class r extends e.SvelteComponent{constructor(t){super(),(0,e.init)(this,t,o,d,e.safe_not_equal,{playerID:0},l)}}var c=r;exports.default=c;\n},{\"svelte/internal\":\"YkLP\",\"boardgame.io/client\":\"iSKo\",\"boardgame.io/multiplayer\":\"Q5yd\",\"./game\":\"jx3b\"}],\"QdjF\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=require(\"svelte/internal\"),t=n(require(\"./Player.svelte\"));function n(e){return e&&e.__esModule?e:{default:e}}function o(t){(0,e.append_styles)(t,\"svelte-1ohivkv\",\"#board.svelte-1ohivkv{width:100%}.container.svelte-1ohivkv{display:flex;flex-direction:row;justify-content:space-evenly}\")}function r(n){let o,r,a,i,s,l,p,c,u,d,m;return a=new t.default({}),l=new t.default({props:{playerID:\"0\"}}),c=new t.default({props:{playerID:\"1\"}}),d=new t.default({props:{playerID:\"2\"}}),{c(){o=(0,e.element)(\"div\"),r=(0,e.element)(\"div\"),(0,e.create_component)(a.$$.fragment),i=(0,e.space)(),s=(0,e.element)(\"div\"),(0,e.create_component)(l.$$.fragment),p=(0,e.space)(),(0,e.create_component)(c.$$.fragment),u=(0,e.space)(),(0,e.create_component)(d.$$.fragment),(0,e.attr)(r,\"id\",\"board\"),(0,e.attr)(r,\"class\",\"svelte-1ohivkv\"),(0,e.attr)(s,\"class\",\"container svelte-1ohivkv\")},m(t,n){(0,e.insert)(t,o,n),(0,e.append)(o,r),(0,e.mount_component)(a,r,null),(0,e.append)(o,i),(0,e.append)(o,s),(0,e.mount_component)(l,s,null),(0,e.append)(s,p),(0,e.mount_component)(c,s,null),(0,e.append)(s,u),(0,e.mount_component)(d,s,null),m=!0},p:e.noop,i(t){m||((0,e.transition_in)(a.$$.fragment,t),(0,e.transition_in)(l.$$.fragment,t),(0,e.transition_in)(c.$$.fragment,t),(0,e.transition_in)(d.$$.fragment,t),m=!0)},o(t){(0,e.transition_out)(a.$$.fragment,t),(0,e.transition_out)(l.$$.fragment,t),(0,e.transition_out)(c.$$.fragment,t),(0,e.transition_out)(d.$$.fragment,t),m=!1},d(t){t&&(0,e.detach)(o),(0,e.destroy_component)(a),(0,e.destroy_component)(l),(0,e.destroy_component)(c),(0,e.destroy_component)(d)}}}class a extends e.SvelteComponent{constructor(t){super(),(0,e.init)(this,t,null,r,e.safe_not_equal,{},o)}}var i=a;exports.default=i;\n},{\"svelte/internal\":\"YkLP\",\"./Player.svelte\":\"iGH7\"}],\"QHMI\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=t(require(\"./App.svelte\"));function t(e){return e&&e.__esModule?e:{default:e}}const r=new e.default({target:document.getElementById(\"app\"),props:{name:\"world\"}});var o=r;exports.default=o;\n},{\"./App.svelte\":\"QdjF\"}]},{},[\"QHMI\"], null)"
  },
  {
    "path": "docs/documentation/snippets/phases-2.fa21cb61.css",
    "content": ".phase.svelte-shmgoi.svelte-shmgoi{font-size:1.2em;margin-top:20px;color:#aaa}.deck.svelte-shmgoi.svelte-shmgoi{font-family:monospace;width:40px;height:60px;margin-left:auto;margin-right:auto;border:1px solid #ddd;padding:20px;text-align:center;border-radius:5px;margin-bottom:50px}.client.svelte-shmgoi.svelte-shmgoi{border-radius:5px;width:100px;border:1px solid #ddd;background:#fafafa;opacity:.8}.client.active.svelte-shmgoi.svelte-shmgoi{box-shadow:0 0 5px #aaa;background:#fff;opacity:1}.client.svelte-shmgoi li.svelte-shmgoi{list-style:none;padding:5px;height:30px;line-height:30px;text-align:center;font-family:monospace}#board.svelte-1ohivkv{width:100%}.container.svelte-1ohivkv{display:flex;flex-direction:row;justify-content:space-evenly}"
  },
  {
    "path": "docs/documentation/snippets/stages-1/index.html",
    "content": "<!DOCTYPE html><html><link rel=\"stylesheet\" href=\"/documentation/snippets/stages-1.bcf7ab84.css\"><body> <div id=\"app\"></div> <script type=\"text/javascript\" src=\"/documentation/snippets/stages-1.1524ef02.js\"></script> </body></html>"
  },
  {
    "path": "docs/documentation/snippets/stages-1.1524ef02.js",
    "content": "parcelRequire=function(e,r,t,n){var i,o=\"function\"==typeof parcelRequire&&parcelRequire,u=\"function\"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i=\"function\"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&\"string\"==typeof t)return u(t);var c=new Error(\"Cannot find module '\"+t+\"'\");throw c.code=\"MODULE_NOT_FOUND\",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=l:\"function\"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({\"YkLP\":[function(require,module,exports) {\nvar global = arguments[3];\nvar t=arguments[3];function e(){}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.action_destroyer=M,exports.add_attribute=mn,exports.add_classes=gn,exports.add_flush_callback=Se,exports.add_location=s,exports.add_render_callback=Ee,exports.add_resize_listener=Pt,exports.add_transform=re,exports.afterUpdate=ue,exports.append=J,exports.append_dev=Cn,exports.append_empty_stylesheet=V,exports.append_hydration=Z,exports.append_hydration_dev=Dn,exports.append_styles=K,exports.assign=o,exports.attr=xt,exports.attr_dev=qn,exports.attribute_to_object=Yt,exports.beforeUpdate=ce,exports.bind=yn,exports.blank_object=c,exports.bubble=xe,exports.check_outros=He,exports.children=wt,exports.claim_component=$n,exports.claim_element=St,exports.claim_html_tag=At,exports.claim_space=Dt,exports.claim_text=Ct,exports.clear_loops=B,exports.component_subscribe=g,exports.compute_rest_props=E,exports.compute_slots=S,exports.createEventDispatcher=pe,exports.create_animation=ne,exports.create_bidirectional_transition=We,exports.create_component=bn,exports.create_in_transition=Ie,exports.create_out_transition=ze,exports.create_slot=y,exports.create_ssr_component=xn,exports.custom_event=zt,exports.dataset_dev=Ln,exports.debug=fn,exports.destroy_block=Je,exports.destroy_component=Fn,exports.destroy_each=ot,exports.detach=nt,exports.detach_after_dev=Nn,exports.detach_before_dev=jn,exports.detach_between_dev=Tn,exports.detach_dev=Mn,exports.dispatch_dev=Sn,exports.each=an,exports.element=rt,exports.element_is=st,exports.empty=at,exports.end_hydrating=G,exports.escape=cn,exports.escape_attribute_value=ln,exports.escape_object=un,exports.exclude_internal_props=k,exports.fix_and_destroy_block=Qe,exports.fix_and_outro_and_destroy_block=Ve,exports.fix_position=oe,exports.flush=Oe,exports.getAllContexts=_e,exports.getContext=fe,exports.get_all_dirty_from_scope=w,exports.get_binding_group_value=$t,exports.get_current_component=ie,exports.get_custom_elements_slots=Jt,exports.get_root_for_style=Q,exports.get_slot_changes=$,exports.get_spread_object=en,exports.get_spread_update=tn,exports.get_store_value=m,exports.group_outros=qe,exports.handle_promise=Ge,exports.hasContext=he,exports.init=kn,exports.insert=tt,exports.insert_dev=On,exports.insert_hydration=et,exports.insert_hydration_dev=An,exports.is_crossorigin=Bt,exports.is_empty=_,exports.is_function=u,exports.is_promise=r,exports.listen=pt,exports.listen_dev=Rn,exports.loop=P,exports.loop_guard=Gn,exports.mount_component=vn,exports.noop=e,exports.not_equal=f,exports.null_to_empty=D,exports.object_without_properties=it,exports.onDestroy=ae,exports.onMount=le,exports.once=C,exports.outro_and_destroy_block=Ke,exports.prevent_default=dt,exports.prop_dev=Hn,exports.query_selector_all=Wt,exports.run=i,exports.run_all=l,exports.safe_not_equal=a,exports.schedule_update=we,exports.select_multiple_value=Lt,exports.select_option=Rt,exports.select_options=qt,exports.select_value=Ht,exports.self=_t,exports.setContext=de,exports.set_attributes=mt,exports.set_current_component=se,exports.set_custom_element_data=yt,exports.set_data=Mt,exports.set_data_dev=Bn,exports.set_input_type=jt,exports.set_input_value=Tt,exports.set_now=R,exports.set_raf=q,exports.set_store_value=O,exports.set_style=Nt,exports.set_svg_attributes=gt,exports.space=ut,exports.spread=rn,exports.src_url_equal=d,exports.start_hydrating=W,exports.stop_propagation=ft,exports.subscribe=x,exports.svg_element=ct,exports.text=lt,exports.tick=ke,exports.time_ranges_to_array=Ft,exports.to_number=vt,exports.toggle_class=It,exports.transition_in=Le,exports.transition_out=Be,exports.trusted=ht,exports.update_await_block_branch=Ue,exports.update_keyed_each=Xe,exports.update_slot=F,exports.update_slot_base=v,exports.validate_component=dn,exports.validate_each_argument=Pn,exports.validate_each_keys=Ze,exports.validate_slots=In,exports.validate_store=h,exports.xlink_attr=bt,exports.raf=exports.now=exports.missing_component=exports.is_client=exports.invalid_attribute_name_character=exports.intros=exports.identity=exports.has_prop=exports.globals=exports.escaped=exports.dirty_components=exports.current_component=exports.binding_callbacks=exports.SvelteElement=exports.SvelteComponentTyped=exports.SvelteComponentDev=exports.SvelteComponent=exports.HtmlTagHydration=exports.HtmlTag=void 0;const n=t=>t;function o(t,e){for(const n in e)t[n]=e[n];return t}function r(t){return t&&\"object\"==typeof t&&\"function\"==typeof t.then}function s(t,e,n,o,r){t.__svelte_meta={loc:{file:e,line:n,column:o,char:r}}}function i(t){return t()}function c(){return Object.create(null)}function l(t){t.forEach(i)}function u(t){return\"function\"==typeof t}function a(t,e){return t!=t?e==e:t!==e||t&&\"object\"==typeof t||\"function\"==typeof t}let p;function d(t,e){return p||(p=document.createElement(\"a\")),p.href=e,t===p.href}function f(t,e){return t!=t?e==e:t!==e}function _(t){return 0===Object.keys(t).length}function h(t,e){if(null!=t&&\"function\"!=typeof t.subscribe)throw new Error(`'${e}' is not a store with a 'subscribe' method`)}function x(t,...n){if(null==t)return e;const o=t.subscribe(...n);return o.unsubscribe?()=>o.unsubscribe():o}function m(t){let e;return x(t,t=>e=t)(),e}function g(t,e,n){t.$$.on_destroy.push(x(e,n))}function y(t,e,n,o){if(t){const r=b(t,e,n,o);return t[0](r)}}function b(t,e,n,r){return t[1]&&r?o(n.ctx.slice(),t[1](r(e))):n.ctx}function $(t,e,n,o){if(t[2]&&o){const r=t[2](o(n));if(void 0===e.dirty)return r;if(\"object\"==typeof r){const t=[],n=Math.max(e.dirty.length,r.length);for(let o=0;o<n;o+=1)t[o]=e.dirty[o]|r[o];return t}return e.dirty|r}return e.dirty}function v(t,e,n,o,r,s){if(r){const i=b(e,n,o,s);t.p(i,r)}}function F(t,e,n,o,r,s,i){v(t,e,n,o,$(e,o,r,s),i)}function w(t){if(t.ctx.length>32){const e=[],n=t.ctx.length/32;for(let t=0;t<n;t++)e[t]=-1;return e}return-1}function k(t){const e={};for(const n in t)\"$\"!==n[0]&&(e[n]=t[n]);return e}function E(t,e){const n={};e=new Set(e);for(const o in t)e.has(o)||\"$\"===o[0]||(n[o]=t[o]);return n}function S(t){const e={};for(const n in t)e[n]=!0;return e}function C(t){let e=!1;return function(...n){e||(e=!0,t.call(this,...n))}}function D(t){return null==t?\"\":t}function O(t,e,n){return t.set(n),e}exports.identity=n;const A=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);function M(t){return t&&u(t.destroy)?t.destroy:e}exports.has_prop=A;const T=\"undefined\"!=typeof window;exports.is_client=T;let j=T?()=>window.performance.now():()=>Date.now();exports.now=j;let N=T?t=>requestAnimationFrame(t):e;function R(t){exports.now=j=t}function q(t){exports.raf=N=t}exports.raf=N;const H=new Set;function L(t){H.forEach(e=>{e.c(t)||(H.delete(e),e.f())}),0!==H.size&&N(L)}function B(){H.clear()}function P(t){let e;return 0===H.size&&N(L),{promise:new Promise(n=>{H.add(e={c:t,f:n})}),abort(){H.delete(e)}}}let I,z=!1;function W(){z=!0}function G(){z=!1}function U(t,e,n,o){for(;t<e;){const r=t+(e-t>>1);n(r)<=o?t=r+1:e=r}return t}function Y(t){if(t.hydrate_init)return;t.hydrate_init=!0;let e=t.childNodes;if(\"HEAD\"===t.nodeName){const t=[];for(let n=0;n<e.length;n++){const o=e[n];void 0!==o.claim_order&&t.push(o)}e=t}const n=new Int32Array(e.length+1),o=new Int32Array(e.length);n[0]=-1;let r=0;for(let l=0;l<e.length;l++){const t=e[l].claim_order,s=(r>0&&e[n[r]].claim_order<=t?r+1:U(1,r,t=>e[n[t]].claim_order,t))-1;o[l]=n[s]+1;const i=s+1;n[i]=l,r=Math.max(i,r)}const s=[],i=[];let c=e.length-1;for(let l=n[r]+1;0!=l;l=o[l-1]){for(s.push(e[l-1]);c>=l;c--)i.push(e[c]);c--}for(;c>=0;c--)i.push(e[c]);s.reverse(),i.sort((t,e)=>t.claim_order-e.claim_order);for(let l=0,u=0;l<i.length;l++){for(;u<s.length&&i[l].claim_order>=s[u].claim_order;)u++;const e=u<s.length?s[u]:null;t.insertBefore(i[l],e)}}function J(t,e){t.appendChild(e)}function K(t,e,n){const o=Q(t);if(!o.getElementById(e)){const t=rt(\"style\");t.id=e,t.textContent=n,X(o,t)}}function Q(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e.host?e:document}function V(t){const e=rt(\"style\");return X(Q(t),e),e}function X(t,e){J(t.head||t,e)}function Z(t,e){if(z){for(Y(t),(void 0===t.actual_end_child||null!==t.actual_end_child&&t.actual_end_child.parentElement!==t)&&(t.actual_end_child=t.firstChild);null!==t.actual_end_child&&void 0===t.actual_end_child.claim_order;)t.actual_end_child=t.actual_end_child.nextSibling;e!==t.actual_end_child?void 0===e.claim_order&&e.parentNode===t||t.insertBefore(e,t.actual_end_child):t.actual_end_child=e.nextSibling}else e.parentNode!==t&&t.appendChild(e)}function tt(t,e,n){t.insertBefore(e,n||null)}function et(t,e,n){z&&!n?Z(t,e):e.parentNode===t&&e.nextSibling==n||t.insertBefore(e,n||null)}function nt(t){t.parentNode.removeChild(t)}function ot(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function rt(t){return document.createElement(t)}function st(t,e){return document.createElement(t,{is:e})}function it(t,e){const n={};for(const o in t)A(t,o)&&-1===e.indexOf(o)&&(n[o]=t[o]);return n}function ct(t){return document.createElementNS(\"http://www.w3.org/2000/svg\",t)}function lt(t){return document.createTextNode(t)}function ut(){return lt(\" \")}function at(){return lt(\"\")}function pt(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function dt(t){return function(e){return e.preventDefault(),t.call(this,e)}}function ft(t){return function(e){return e.stopPropagation(),t.call(this,e)}}function _t(t){return function(e){e.target===this&&t.call(this,e)}}function ht(t){return function(e){e.isTrusted&&t.call(this,e)}}function xt(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function mt(t,e){const n=Object.getOwnPropertyDescriptors(t.__proto__);for(const o in e)null==e[o]?t.removeAttribute(o):\"style\"===o?t.style.cssText=e[o]:\"__value\"===o?t.value=t[o]=e[o]:n[o]&&n[o].set?t[o]=e[o]:xt(t,o,e[o])}function gt(t,e){for(const n in e)xt(t,n,e[n])}function yt(t,e,n){e in t?t[e]=\"boolean\"==typeof t[e]&&\"\"===n||n:xt(t,e,n)}function bt(t,e,n){t.setAttributeNS(\"http://www.w3.org/1999/xlink\",e,n)}function $t(t,e,n){const o=new Set;for(let r=0;r<t.length;r+=1)t[r].checked&&o.add(t[r].__value);return n||o.delete(e),Array.from(o)}function vt(t){return\"\"===t?null:+t}function Ft(t){const e=[];for(let n=0;n<t.length;n+=1)e.push({start:t.start(n),end:t.end(n)});return e}function wt(t){return Array.from(t.childNodes)}function kt(t){void 0===t.claim_info&&(t.claim_info={last_index:0,total_claimed:0})}function Et(t,e,n,o,r=!1){kt(t);const s=(()=>{for(let o=t.claim_info.last_index;o<t.length;o++){const s=t[o];if(e(s)){const e=n(s);return void 0===e?t.splice(o,1):t[o]=e,r||(t.claim_info.last_index=o),s}}for(let o=t.claim_info.last_index-1;o>=0;o--){const s=t[o];if(e(s)){const e=n(s);return void 0===e?t.splice(o,1):t[o]=e,r?void 0===e&&t.claim_info.last_index--:t.claim_info.last_index=o,s}}return o()})();return s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1,s}function St(t,e,n,o){return Et(t,t=>t.nodeName===e,t=>{const e=[];for(let o=0;o<t.attributes.length;o++){const r=t.attributes[o];n[r.name]||e.push(r.name)}e.forEach(e=>t.removeAttribute(e))},()=>o?ct(e):rt(e))}function Ct(t,e){return Et(t,t=>3===t.nodeType,t=>{const n=\"\"+e;if(t.data.startsWith(n)){if(t.data.length!==n.length)return t.splitText(n.length)}else t.data=n},()=>lt(e),!0)}function Dt(t){return Ct(t,\" \")}function Ot(t,e,n){for(let o=n;o<t.length;o+=1){const n=t[o];if(8===n.nodeType&&n.textContent.trim()===e)return o}return t.length}function At(t){const e=Ot(t,\"HTML_TAG_START\",0),n=Ot(t,\"HTML_TAG_END\",e);if(e===n)return new Ut;kt(t);const o=t.splice(e,n+1);nt(o[0]),nt(o[o.length-1]);const r=o.slice(1,o.length-1);for(const s of r)s.claim_order=t.claim_info.total_claimed,t.claim_info.total_claimed+=1;return new Ut(r)}function Mt(t,e){e=\"\"+e,t.wholeText!==e&&(t.data=e)}function Tt(t,e){t.value=null==e?\"\":e}function jt(t,e){try{t.type=e}catch(n){}}function Nt(t,e,n,o){t.style.setProperty(e,n,o?\"important\":\"\")}function Rt(t,e){for(let n=0;n<t.options.length;n+=1){const o=t.options[n];if(o.__value===e)return void(o.selected=!0)}}function qt(t,e){for(let n=0;n<t.options.length;n+=1){const o=t.options[n];o.selected=~e.indexOf(o.__value)}}function Ht(t){const e=t.querySelector(\":checked\")||t.options[0];return e&&e.__value}function Lt(t){return[].map.call(t.querySelectorAll(\":checked\"),t=>t.__value)}function Bt(){if(void 0===I){I=!1;try{\"undefined\"!=typeof window&&window.parent&&window.parent.document}catch(t){I=!0}}return I}function Pt(t,e){\"static\"===getComputedStyle(t).position&&(t.style.position=\"relative\");const n=rt(\"iframe\");n.setAttribute(\"style\",\"display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;\"),n.setAttribute(\"aria-hidden\",\"true\"),n.tabIndex=-1;const o=Bt();let r;return o?(n.src=\"data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\\/script>\",r=pt(window,\"message\",t=>{t.source===n.contentWindow&&e()})):(n.src=\"about:blank\",n.onload=(()=>{r=pt(n.contentWindow,\"resize\",e)})),J(t,n),()=>{o?r():r&&n.contentWindow&&r(),nt(n)}}function It(t,e,n){t.classList[n?\"add\":\"remove\"](e)}function zt(t,e,n=!1){const o=document.createEvent(\"CustomEvent\");return o.initCustomEvent(t,n,!1,e),o}function Wt(t,e=document.body){return Array.from(e.querySelectorAll(t))}class Gt{constructor(){this.e=this.n=null}c(t){this.h(t)}m(t,e,n=null){this.e||(this.e=rt(e.nodeName),this.t=e,this.c(t)),this.i(n)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let e=0;e<this.n.length;e+=1)tt(this.t,this.n[e],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(nt)}}exports.HtmlTag=Gt;class Ut extends Gt{constructor(t){super(),this.e=this.n=null,this.l=t}c(t){this.l?this.n=this.l:super.c(t)}i(t){for(let e=0;e<this.n.length;e+=1)et(this.t,this.n[e],t)}}function Yt(t){const e={};for(const n of t)e[n.name]=n.value;return e}function Jt(t){const e={};return t.childNodes.forEach(t=>{e[t.slot||\"default\"]=!0}),e}exports.HtmlTagHydration=Ut;const Kt=new Set;let Qt,Vt=0;function Xt(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}function Zt(t,e,n,o,r,s,i,c=0){const l=16.666/o;let u=\"{\\n\";for(let x=0;x<=1;x+=l){const t=e+(n-e)*s(x);u+=100*x+`%{${i(t,1-t)}}\\n`}const a=u+`100% {${i(n,1-n)}}\\n}`,p=`__svelte_${Xt(a)}_${c}`,d=Q(t);Kt.add(d);const f=d.__svelte_stylesheet||(d.__svelte_stylesheet=V(t).sheet),_=d.__svelte_rules||(d.__svelte_rules={});_[p]||(_[p]=!0,f.insertRule(`@keyframes ${p} ${a}`,f.cssRules.length));const h=t.style.animation||\"\";return t.style.animation=`${h?`${h}, `:\"\"}${p} ${o}ms linear ${r}ms 1 both`,Vt+=1,p}function te(t,e){const n=(t.style.animation||\"\").split(\", \"),o=n.filter(e?t=>t.indexOf(e)<0:t=>-1===t.indexOf(\"__svelte\")),r=n.length-o.length;r&&(t.style.animation=o.join(\", \"),(Vt-=r)||ee())}function ee(){N(()=>{Vt||(Kt.forEach(t=>{const e=t.__svelte_stylesheet;let n=e.cssRules.length;for(;n--;)e.deleteRule(n);t.__svelte_rules={}}),Kt.clear())})}function ne(t,o,r,s){if(!o)return e;const i=t.getBoundingClientRect();if(o.left===i.left&&o.right===i.right&&o.top===i.top&&o.bottom===i.bottom)return e;const{delay:c=0,duration:l=300,easing:u=n,start:a=j()+c,end:p=a+l,tick:d=e,css:f}=r(t,{from:o,to:i},s);let _,h=!0,x=!1;function m(){f&&te(t,_),h=!1}return P(t=>{if(!x&&t>=a&&(x=!0),x&&t>=p&&(d(1,0),m()),!h)return!1;if(x){const e=0+1*u((t-a)/l);d(e,1-e)}return!0}),f&&(_=Zt(t,0,1,l,c,u,f)),c||(x=!0),d(0,1),m}function oe(t){const e=getComputedStyle(t);if(\"absolute\"!==e.position&&\"fixed\"!==e.position){const{width:n,height:o}=e,r=t.getBoundingClientRect();t.style.position=\"absolute\",t.style.width=n,t.style.height=o,re(t,r)}}function re(t,e){const n=t.getBoundingClientRect();if(e.left!==n.left||e.top!==n.top){const o=getComputedStyle(t),r=\"none\"===o.transform?\"\":o.transform;t.style.transform=`${r} translate(${e.left-n.left}px, ${e.top-n.top}px)`}}function se(t){exports.current_component=Qt=t}function ie(){if(!Qt)throw new Error(\"Function called outside component initialization\");return Qt}function ce(t){ie().$$.before_update.push(t)}function le(t){ie().$$.on_mount.push(t)}function ue(t){ie().$$.after_update.push(t)}function ae(t){ie().$$.on_destroy.push(t)}function pe(){const t=ie();return(e,n)=>{const o=t.$$.callbacks[e];if(o){const r=zt(e,n);o.slice().forEach(e=>{e.call(t,r)})}}}function de(t,e){ie().$$.context.set(t,e)}function fe(t){return ie().$$.context.get(t)}function _e(){return ie().$$.context}function he(t){return ie().$$.context.has(t)}function xe(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(t=>t.call(this,e))}exports.current_component=Qt;const me=[];exports.dirty_components=me;const ge={enabled:!1};exports.intros=ge;const ye=[];exports.binding_callbacks=ye;const be=[],$e=[],ve=Promise.resolve();let Fe=!1;function we(){Fe||(Fe=!0,ve.then(Oe))}function ke(){return we(),ve}function Ee(t){be.push(t)}function Se(t){$e.push(t)}let Ce=!1;const De=new Set;function Oe(){if(!Ce){Ce=!0;do{for(let t=0;t<me.length;t+=1){const e=me[t];se(e),Ae(e.$$)}for(se(null),me.length=0;ye.length;)ye.pop()();for(let t=0;t<be.length;t+=1){const e=be[t];De.has(e)||(De.add(e),e())}be.length=0}while(me.length);for(;$e.length;)$e.pop()();Fe=!1,Ce=!1,De.clear()}}function Ae(t){if(null!==t.fragment){t.update(),l(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Ee)}}let Me;function Te(){return Me||(Me=Promise.resolve()).then(()=>{Me=null}),Me}function je(t,e,n){t.dispatchEvent(zt(`${e?\"intro\":\"outro\"}${n}`))}const Ne=new Set;let Re;function qe(){Re={r:0,c:[],p:Re}}function He(){Re.r||l(Re.c),Re=Re.p}function Le(t,e){t&&t.i&&(Ne.delete(t),t.i(e))}function Be(t,e,n,o){if(t&&t.o){if(Ne.has(t))return;Ne.add(t),Re.c.push(()=>{Ne.delete(t),o&&(n&&t.d(1),o())}),t.o(e)}}const Pe={duration:0};function Ie(t,o,r){let s,i,c=o(t,r),l=!1,a=0;function p(){s&&te(t,s)}function d(){const{delay:o=0,duration:r=300,easing:u=n,tick:d=e,css:f}=c||Pe;f&&(s=Zt(t,0,1,r,o,u,f,a++)),d(0,1);const _=j()+o,h=_+r;i&&i.abort(),l=!0,Ee(()=>je(t,!0,\"start\")),i=P(e=>{if(l){if(e>=h)return d(1,0),je(t,!0,\"end\"),p(),l=!1;if(e>=_){const t=u((e-_)/r);d(t,1-t)}}return l})}let f=!1;return{start(){f||(f=!0,te(t),u(c)?(c=c(),Te().then(d)):d())},invalidate(){f=!1},end(){l&&(p(),l=!1)}}}function ze(t,o,r){let s,i=o(t,r),c=!0;const a=Re;function p(){const{delay:o=0,duration:r=300,easing:u=n,tick:p=e,css:d}=i||Pe;d&&(s=Zt(t,1,0,r,o,u,d));const f=j()+o,_=f+r;Ee(()=>je(t,!1,\"start\")),P(e=>{if(c){if(e>=_)return p(0,1),je(t,!1,\"end\"),--a.r||l(a.c),!1;if(e>=f){const t=u((e-f)/r);p(1-t,t)}}return c})}return a.r+=1,u(i)?Te().then(()=>{i=i(),p()}):p(),{end(e){e&&i.tick&&i.tick(1,0),c&&(s&&te(t,s),c=!1)}}}function We(t,o,r,s){let i=o(t,r),c=s?0:1,a=null,p=null,d=null;function f(){d&&te(t,d)}function _(t,e){const n=t.b-c;return e*=Math.abs(n),{a:c,b:t.b,d:n,duration:e,start:t.start,end:t.start+e,group:t.group}}function h(o){const{delay:r=0,duration:s=300,easing:u=n,tick:h=e,css:x}=i||Pe,m={start:j()+r,b:o};o||(m.group=Re,Re.r+=1),a||p?p=m:(x&&(f(),d=Zt(t,c,o,s,r,u,x)),o&&h(0,1),a=_(m,s),Ee(()=>je(t,o,\"start\")),P(e=>{if(p&&e>p.start&&(a=_(p,s),p=null,je(t,a.b,\"start\"),x&&(f(),d=Zt(t,c,a.b,a.duration,0,u,i.css))),a)if(e>=a.end)h(c=a.b,1-c),je(t,a.b,\"end\"),p||(a.b?f():--a.group.r||l(a.group.c)),a=null;else if(e>=a.start){const t=e-a.start;c=a.a+a.d*u(t/a.duration),h(c,1-c)}return!(!a&&!p)}))}return{run(t){u(i)?Te().then(()=>{i=i(),h(t)}):h(t)},end(){f(),a=p=null}}}function Ge(t,e){const n=e.token={};function o(t,o,r,s){if(e.token!==n)return;e.resolved=s;let i=e.ctx;void 0!==r&&((i=i.slice())[r]=s);const c=t&&(e.current=t)(i);let l=!1;e.block&&(e.blocks?e.blocks.forEach((t,n)=>{n!==o&&t&&(qe(),Be(t,1,1,()=>{e.blocks[n]===t&&(e.blocks[n]=null)}),He())}):e.block.d(1),c.c(),Le(c,1),c.m(e.mount(),e.anchor),l=!0),e.block=c,e.blocks&&(e.blocks[o]=c),l&&Oe()}if(r(t)){const n=ie();if(t.then(t=>{se(n),o(e.then,1,e.value,t),se(null)},t=>{if(se(n),o(e.catch,2,e.error,t),se(null),!e.hasCatch)throw t}),e.current!==e.pending)return o(e.pending,0),!0}else{if(e.current!==e.then)return o(e.then,1,e.value,t),!0;e.resolved=t}}function Ue(t,e,n){const o=e.slice(),{resolved:r}=t;t.current===t.then&&(o[t.value]=r),t.current===t.catch&&(o[t.error]=r),t.block.p(o,n)}const Ye=\"undefined\"!=typeof window?window:\"undefined\"!=typeof globalThis?globalThis:t;function Je(t,e){t.d(1),e.delete(t.key)}function Ke(t,e){Be(t,1,1,()=>{e.delete(t.key)})}function Qe(t,e){t.f(),Je(t,e)}function Ve(t,e){t.f(),Ke(t,e)}function Xe(t,e,n,o,r,s,i,c,l,u,a,p){let d=t.length,f=s.length,_=d;const h={};for(;_--;)h[t[_].key]=_;const x=[],m=new Map,g=new Map;for(_=f;_--;){const t=p(r,s,_),c=n(t);let l=i.get(c);l?o&&l.p(t,e):(l=u(c,t)).c(),m.set(c,x[_]=l),c in h&&g.set(c,Math.abs(_-h[c]))}const y=new Set,b=new Set;function $(t){Le(t,1),t.m(c,a),i.set(t.key,t),a=t.first,f--}for(;d&&f;){const e=x[f-1],n=t[d-1],o=e.key,r=n.key;e===n?(a=e.first,d--,f--):m.has(r)?!i.has(o)||y.has(o)?$(e):b.has(r)?d--:g.get(o)>g.get(r)?(b.add(o),$(e)):(y.add(r),d--):(l(n,i),d--)}for(;d--;){const e=t[d];m.has(e.key)||l(e,i)}for(;f;)$(x[f-1]);return x}function Ze(t,e,n,o){const r=new Set;for(let s=0;s<e.length;s++){const i=o(n(t,e,s));if(r.has(i))throw new Error(\"Cannot have duplicate keys in a keyed each\");r.add(i)}}function tn(t,e){const n={},o={},r={$$scope:1};let s=t.length;for(;s--;){const i=t[s],c=e[s];if(c){for(const t in i)t in c||(o[t]=1);for(const t in c)r[t]||(n[t]=c[t],r[t]=1);t[s]=c}else for(const t in i)r[t]=1}for(const i in o)i in n||(n[i]=void 0);return n}function en(t){return\"object\"==typeof t&&null!==t?t:{}}exports.globals=Ye;const nn=new Set([\"allowfullscreen\",\"allowpaymentrequest\",\"async\",\"autofocus\",\"autoplay\",\"checked\",\"controls\",\"default\",\"defer\",\"disabled\",\"formnovalidate\",\"hidden\",\"ismap\",\"loop\",\"multiple\",\"muted\",\"nomodule\",\"novalidate\",\"open\",\"playsinline\",\"readonly\",\"required\",\"reversed\",\"selected\"]),on=/[\\s'\">\\/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;function rn(t,e){const n=Object.assign({},...t);e&&(null==n.class?n.class=e:n.class+=\" \"+e);let o=\"\";return Object.keys(n).forEach(t=>{if(on.test(t))return;const e=n[t];!0===e?o+=\" \"+t:nn.has(t.toLowerCase())?e&&(o+=\" \"+t):null!=e&&(o+=` ${t}=\"${e}\"`)}),o}exports.invalid_attribute_name_character=on;const sn={'\"':\"&quot;\",\"'\":\"&#39;\",\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\"};function cn(t){return String(t).replace(/[\"'&<>]/g,t=>sn[t])}function ln(t){return\"string\"==typeof t?cn(t):t}function un(t){const e={};for(const n in t)e[n]=ln(t[n]);return e}function an(t,e){let n=\"\";for(let o=0;o<t.length;o+=1)n+=e(t[o],o);return n}exports.escaped=sn;const pn={$$render:()=>\"\"};function dn(t,e){if(!t||!t.$$render)throw\"svelte:component\"===e&&(e+=\" this={...}\"),new Error(`<${e}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);return t}function fn(t,e,n,o){return console.log(`{@debug} ${t?t+\" \":\"\"}(${e}:${n})`),console.log(o),\"\"}let _n,hn;function xn(t){function e(e,n,o,r,s){const i=Qt;se({$$:{on_destroy:_n,context:new Map(i?i.$$.context:s||[]),on_mount:[],before_update:[],after_update:[],callbacks:c()}});const l=t(e,n,o,r);return se(i),l}return{render:(t={},{$$slots:n={},context:o=new Map}={})=>{_n=[];const r={title:\"\",head:\"\",css:new Set},s=e(r,t,{},n,o);return l(_n),{html:s,css:{code:Array.from(r.css).map(t=>t.code).join(\"\\n\"),map:null},head:r.title+r.head}},$$render:e}}function mn(t,e,n){return null==e||n&&!e?\"\":` ${t}${!0===e?\"\":`=${\"string\"==typeof e?JSON.stringify(cn(e)):`\"${e}\"`}`}`}function gn(t){return t?` class=\"${t}\"`:\"\"}function yn(t,e,n){const o=t.$$.props[e];void 0!==o&&(t.$$.bound[o]=n,n(t.$$.ctx[o]))}function bn(t){t&&t.c()}function $n(t,e){t&&t.l(e)}function vn(t,e,n,o){const{fragment:r,on_mount:s,on_destroy:c,after_update:a}=t.$$;r&&r.m(e,n),o||Ee(()=>{const e=s.map(i).filter(u);c?c.push(...e):l(e),t.$$.on_mount=[]}),a.forEach(Ee)}function Fn(t,e){const n=t.$$;null!==n.fragment&&(l(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function wn(t,e){-1===t.$$.dirty[0]&&(me.push(t),we(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function kn(t,n,o,r,s,i,u,a=[-1]){const p=Qt;se(t);const d=t.$$={fragment:null,ctx:null,props:i,update:e,not_equal:s,bound:c(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:n.context||[]),callbacks:c(),dirty:a,skip_bound:!1,root:n.target||p.$$.root};u&&u(d.root);let f=!1;if(d.ctx=o?o(t,n.props||{},(e,n,...o)=>{const r=o.length?o[0]:n;return d.ctx&&s(d.ctx[e],d.ctx[e]=r)&&(!d.skip_bound&&d.bound[e]&&d.bound[e](r),f&&wn(t,e)),n}):[],d.update(),f=!0,l(d.before_update),d.fragment=!!r&&r(d.ctx),n.target){if(n.hydrate){W();const t=wt(n.target);d.fragment&&d.fragment.l(t),t.forEach(nt)}else d.fragment&&d.fragment.c();n.intro&&Le(t.$$.fragment),vn(t,n.target,n.anchor,n.customElement),G(),Oe()}se(p)}exports.missing_component=pn,exports.SvelteElement=hn,\"function\"==typeof HTMLElement&&(exports.SvelteElement=hn=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:\"open\"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(i).filter(u);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){l(this.$$.on_disconnect)}$destroy(){Fn(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class En{$destroy(){Fn(this,1),this.$destroy=e}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!_(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Sn(t,e){document.dispatchEvent(zt(t,Object.assign({version:\"3.41.0\"},e),!0))}function Cn(t,e){Sn(\"SvelteDOMInsert\",{target:t,node:e}),J(t,e)}function Dn(t,e){Sn(\"SvelteDOMInsert\",{target:t,node:e}),Z(t,e)}function On(t,e,n){Sn(\"SvelteDOMInsert\",{target:t,node:e,anchor:n}),tt(t,e,n)}function An(t,e,n){Sn(\"SvelteDOMInsert\",{target:t,node:e,anchor:n}),et(t,e,n)}function Mn(t){Sn(\"SvelteDOMRemove\",{node:t}),nt(t)}function Tn(t,e){for(;t.nextSibling&&t.nextSibling!==e;)Mn(t.nextSibling)}function jn(t){for(;t.previousSibling;)Mn(t.previousSibling)}function Nn(t){for(;t.nextSibling;)Mn(t.nextSibling)}function Rn(t,e,n,o,r,s){const i=!0===o?[\"capture\"]:o?Array.from(Object.keys(o)):[];r&&i.push(\"preventDefault\"),s&&i.push(\"stopPropagation\"),Sn(\"SvelteDOMAddEventListener\",{node:t,event:e,handler:n,modifiers:i});const c=pt(t,e,n,o);return()=>{Sn(\"SvelteDOMRemoveEventListener\",{node:t,event:e,handler:n,modifiers:i}),c()}}function qn(t,e,n){xt(t,e,n),null==n?Sn(\"SvelteDOMRemoveAttribute\",{node:t,attribute:e}):Sn(\"SvelteDOMSetAttribute\",{node:t,attribute:e,value:n})}function Hn(t,e,n){t[e]=n,Sn(\"SvelteDOMSetProperty\",{node:t,property:e,value:n})}function Ln(t,e,n){t.dataset[e]=n,Sn(\"SvelteDOMSetDataset\",{node:t,property:e,value:n})}function Bn(t,e){e=\"\"+e,t.wholeText!==e&&(Sn(\"SvelteDOMSetData\",{node:t,data:e}),t.data=e)}function Pn(t){if(\"string\"!=typeof t&&!(t&&\"object\"==typeof t&&\"length\"in t)){let e=\"{#each} only iterates over array-like objects.\";throw\"function\"==typeof Symbol&&t&&Symbol.iterator in t&&(e+=\" You can use a spread to convert this iterable into an array.\"),new Error(e)}}function In(t,e,n){for(const o of Object.keys(e))~n.indexOf(o)||console.warn(`<${t}> received an unexpected slot \"${o}\".`)}exports.SvelteComponent=En;class zn extends En{constructor(t){if(!t||!t.target&&!t.$$inline)throw new Error(\"'target' is a required option\");super()}$destroy(){super.$destroy(),this.$destroy=(()=>{console.warn(\"Component was already destroyed\")})}$capture_state(){}$inject_state(){}}exports.SvelteComponentDev=zn;class Wn extends zn{constructor(t){super(t)}}function Gn(t){const e=Date.now();return()=>{if(Date.now()-e>t)throw new Error(\"Infinite loop detected\")}}exports.SvelteComponentTyped=Wn;\n},{}],\"UTAW\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.urlAlphabet=void 0;let e=\"ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW\";exports.urlAlphabet=e;\n},{}],\"b767\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"urlAlphabet\",{enumerable:!0,get:function(){return e.urlAlphabet}}),exports.random=exports.customRandom=exports.customAlphabet=exports.nanoid=void 0;var e=require(\"./url-alphabet/index.js\");let t=e=>crypto.getRandomValues(new Uint8Array(e));exports.random=t;let r=(e,t,r)=>{let o=(2<<Math.log(e.length-1)/Math.LN2)-1,n=-~(1.6*o*t/e.length);return()=>{let l=\"\";for(;;){let a=r(n),p=n;for(;p--;)if((l+=e[a[p]&o]||\"\").length===t)return l}}};exports.customRandom=r;let o=(e,o)=>r(e,o,t);exports.customAlphabet=o;let n=(e=21)=>{let t=\"\",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let o=63&r[e];t+=o<36?o.toString(36):o<62?(o-26).toString(36).toUpperCase():o<63?\"_\":\"-\"}return t};exports.nanoid=n;\n},{\"./url-alphabet/index.js\":\"UTAW\"}],\"VB7z\":[function(require,module,exports) {\n\"use strict\";function e(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw Error(\"[Immer] minified error nr: \"+e+(r.length?\" \"+r.map(function(e){return\"'\"+e+\"'\"}).join(\",\"):\"\")+\". Find the full error at: https://bit.ly/3cXEKWf\")}function t(e){return!!e&&!!e[Q]}function r(e){return!!e&&(function(e){if(!e||\"object\"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,\"constructor\")&&t.constructor;return r===Object||\"function\"==typeof r&&Function.toString.call(r)===Z}(e)||Array.isArray(e)||!!e[L]||!!e.constructor[L]||s(e)||l(e))}function n(r){return t(r)||e(23,r),r[Q].t}function o(e,t,r){void 0===r&&(r=!1),0===i(e)?(r?Object.keys:ee)(e).forEach(function(n){r&&\"symbol\"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function i(e){var t=e[Q];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:s(e)?2:l(e)?3:0}function a(e,t){return 2===i(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function u(e,t){return 2===i(e)?e.get(t):e[t]}function c(e,t,r){var n=i(e);2===n?e.set(t,r):3===n?(e.delete(t),e.add(r)):e[t]=r}function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function s(e){return X&&e instanceof Map}function l(e){return q&&e instanceof Set}function p(e){return e.o||e.t}function h(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=te(e);delete t[Q];for(var r=ee(t),n=0;n<r.length;n++){var o=r[n],i=t[o];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[o]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function v(e,n){return void 0===n&&(n=!1),y(e)||t(e)||!r(e)?e:(i(e)>1&&(e.set=e.add=e.clear=e.delete=d),Object.freeze(e),n&&o(e,function(e,t){return v(t,!0)},!0),e)}function d(){e(2)}function y(e){return null==e||\"object\"!=typeof e||Object.isFrozen(e)}function b(t){var r=re[t];return r||e(18,t),r}function g(e,t){re[e]||(re[e]=t)}function m(){return J}function P(e,t){t&&(b(\"Patches\"),e.u=[],e.s=[],e.v=t)}function O(e){x(e),e.p.forEach(j),e.p=null}function x(e){e===J&&(J=e.l)}function w(e){return J={p:[],l:J,h:e,m:!0,_:0}}function j(e){var t=e[Q];0===t.i||1===t.i?t.j():t.O=!0}function A(t,n){n._=n.p.length;var o=n.p[0],i=void 0!==t&&t!==o;return n.h.g||b(\"ES5\").S(n,t,i),i?(o[Q].P&&(O(n),e(4)),r(t)&&(t=D(n,t),n.l||_(n,t)),n.u&&b(\"Patches\").M(o[Q],t,n.u,n.s)):t=D(n,o,[]),O(n),n.u&&n.v(n.u,n.s),t!==H?t:void 0}function D(e,t,r){if(y(t))return t;var n=t[Q];if(!n)return o(t,function(o,i){return S(e,n,t,o,i,r)},!0),t;if(n.A!==e)return t;if(!n.P)return _(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=h(n.k):n.o;o(3===n.i?new Set(i):i,function(t,o){return S(e,n,i,t,o,r)}),_(e,i,!1),r&&e.u&&b(\"Patches\").R(n,r,e.u,e.s)}return n.o}function S(e,n,o,i,u,f){if(t(u)){var s=D(e,u,f&&n&&3!==n.i&&!a(n.D,i)?f.concat(i):void 0);if(c(o,i,s),!t(s))return;e.m=!1}if(r(u)&&!y(u)){if(!e.h.F&&e._<1)return;D(e,u),n&&n.A.l||_(e,u)}}function _(e,t,r){void 0===r&&(r=!1),e.h.F&&e.m&&v(t,r)}function k(e,t){var r=e[Q];return(r?p(r):e)[t]}function I(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function z(e){e.P||(e.P=!0,e.l&&z(e.l))}function E(e){e.o||(e.o=h(e.t))}function M(e,t,r){var n=s(t)?b(\"MapSet\").N(t,r):l(t)?b(\"MapSet\").T(t,r):e.g?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:m(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=n,i=ne;r&&(o=[n],i=oe);var a=Proxy.revocable(o,i),u=a.revoke,c=a.proxy;return n.k=c,n.j=u,c}(t,r):b(\"ES5\").J(t,r);return(r?r.A:m()).p.push(n),n}function F(n){return t(n)||e(22,n),function e(t){if(!r(t))return t;var n,a=t[Q],f=i(t);if(a){if(!a.P&&(a.i<4||!b(\"ES5\").K(a)))return a.t;a.I=!0,n=R(t,f),a.I=!1}else n=R(t,f);return o(n,function(t,r){a&&u(a.t,t)===r||c(n,t,e(r))}),3===f?new Set(n):n}(n)}function R(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return h(e)}function C(){function e(e,t){var r=u[e];return r?r.enumerable=t:u[e]=r={configurable:!0,enumerable:t,get:function(){var t=this[Q];return ne.get(t,e)},set:function(t){var r=this[Q];ne.set(r,e,t)}},r}function r(e){for(var t=e.length-1;t>=0;t--){var r=e[t][Q];if(!r.P)switch(r.i){case 5:i(r)&&z(r);break;case 4:n(r)&&z(r)}}}function n(e){for(var t=e.t,r=e.k,n=ee(r),o=n.length-1;o>=0;o--){var i=n[o];if(i!==Q){var u=t[i];if(void 0===u&&!a(t,i))return!0;var c=r[i],s=c&&c[Q];if(s?s.t!==u:!f(c,u))return!0}}var l=!!t[Q];return n.length!==ee(t).length+(l?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var u={};g(\"ES5\",{J:function(t,r){var n=Array.isArray(t),o=function(t,r){if(t){for(var n=Array(r.length),o=0;o<r.length;o++)Object.defineProperty(n,\"\"+o,e(o,!0));return n}var i=te(r);delete i[Q];for(var a=ee(i),u=0;u<a.length;u++){var c=a[u];i[c]=e(c,t||!!i[c].enumerable)}return Object.create(Object.getPrototypeOf(r),i)}(n,t),i={i:n?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,Q,{value:i,writable:!0}),o},S:function(e,n,u){u?t(n)&&n[Q].A===e&&r(e.p):(e.u&&function e(t){if(t&&\"object\"==typeof t){var r=t[Q];if(r){var n=r.t,u=r.k,c=r.D,f=r.i;if(4===f)o(u,function(t){t!==Q&&(void 0!==n[t]||a(n,t)?c[t]||e(u[t]):(c[t]=!0,z(r)))}),o(n,function(e){void 0!==u[e]||a(u,e)||(c[e]=!1,z(r))});else if(5===f){if(i(r)&&(z(r),c.length=!0),u.length<n.length)for(var s=u.length;s<n.length;s++)c[s]=!1;else for(var l=n.length;l<u.length;l++)c[l]=!0;for(var p=Math.min(u.length,n.length),h=0;h<p;h++)void 0===c[h]&&e(u[h])}}}}(e.p[0]),r(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}function T(){function n(e){if(!r(e))return e;if(Array.isArray(e))return e.map(n);if(s(e))return new Map(Array.from(e.entries()).map(function(e){return[e[0],n(e[1])]}));if(l(e))return new Set(Array.from(e).map(n));var t=Object.create(Object.getPrototypeOf(e));for(var o in e)t[o]=n(e[o]);return a(e,L)&&(t[L]=e[L]),t}function c(e){return t(e)?n(e):e}var f=\"add\";g(\"Patches\",{$:function(t,r){return r.forEach(function(r){for(var o=r.path,a=r.op,c=t,s=0;s<o.length-1;s++){var l=i(c),p=o[s];0!==l&&1!==l||\"__proto__\"!==p&&\"constructor\"!==p||e(24),\"function\"==typeof c&&\"prototype\"===p&&e(24),\"object\"!=typeof(c=u(c,p))&&e(15,o.join(\"/\"))}var h=i(c),v=n(r.value),d=o[o.length-1];switch(a){case\"replace\":switch(h){case 2:return c.set(d,v);case 3:e(16);default:return c[d]=v}case f:switch(h){case 1:return c.splice(d,0,v);case 2:return c.set(d,v);case 3:return c.add(v);default:return c[d]=v}case\"remove\":switch(h){case 1:return c.splice(d,1);case 2:return c.delete(d);case 3:return c.delete(r.value);default:return delete c[d]}default:e(17,a)}}),t},R:function(e,t,r,n){switch(e.i){case 0:case 4:case 2:return function(e,t,r,n){var i=e.t,s=e.o;o(e.D,function(e,o){var l=u(i,e),p=u(s,e),h=o?a(i,e)?\"replace\":f:\"remove\";if(l!==p||\"replace\"!==h){var v=t.concat(e);r.push(\"remove\"===h?{op:h,path:v}:{op:h,path:v,value:p}),n.push(h===f?{op:\"remove\",path:v}:\"remove\"===h?{op:f,path:v,value:c(l)}:{op:\"replace\",path:v,value:c(l)})}})}(e,t,r,n);case 5:case 1:return function(e,t,r,n){var o=e.t,i=e.D,a=e.o;if(a.length<o.length){var u=[a,o];o=u[0],a=u[1];var s=[n,r];r=s[0],n=s[1]}for(var l=0;l<o.length;l++)if(i[l]&&a[l]!==o[l]){var p=t.concat([l]);r.push({op:\"replace\",path:p,value:c(a[l])}),n.push({op:\"replace\",path:p,value:c(o[l])})}for(var h=o.length;h<a.length;h++){var v=t.concat([h]);r.push({op:f,path:v,value:c(a[h])})}o.length<a.length&&n.push({op:\"replace\",path:t.concat([\"length\"]),value:o.length})}(e,t,r,n);case 3:return function(e,t,r,n){var o=e.t,i=e.o,a=0;o.forEach(function(e){if(!i.has(e)){var o=t.concat([a]);r.push({op:\"remove\",path:o,value:e}),n.unshift({op:f,path:o,value:e})}a++}),a=0,i.forEach(function(e){if(!o.has(e)){var i=t.concat([a]);r.push({op:f,path:i,value:e}),n.unshift({op:\"remove\",path:i,value:e})}a++})}(e,t,r,n)}},M:function(e,t,r,n){r.push({op:\"replace\",path:[],value:t===H?void 0:t}),n.push({op:\"replace\",path:[],value:e.t})}})}function K(){function t(e,t){function r(){this.constructor=e}u(e,t),e.prototype=(r.prototype=t.prototype,new r)}function n(e){e.o||(e.D=new Map,e.o=new Map(e.t))}function i(e){e.o||(e.o=new Set,e.t.forEach(function(t){if(r(t)){var n=M(e.A.h,t,e);e.p.set(t,n),e.o.add(n)}else e.o.add(t)}))}function a(t){t.O&&e(3,JSON.stringify(p(t)))}var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},c=function(){function e(e,t){return this[Q]={i:2,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,D:void 0,t:e,k:this,C:!1,O:!1},this}t(e,Map);var i=e.prototype;return Object.defineProperty(i,\"size\",{get:function(){return p(this[Q]).size}}),i.has=function(e){return p(this[Q]).has(e)},i.set=function(e,t){var r=this[Q];return a(r),p(r).has(e)&&p(r).get(e)===t||(n(r),z(r),r.D.set(e,!0),r.o.set(e,t),r.D.set(e,!0)),this},i.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),n(t),z(t),t.D.set(e,!1),t.o.delete(e),!0},i.clear=function(){var e=this[Q];a(e),p(e).size&&(n(e),z(e),e.D=new Map,o(e.t,function(t){e.D.set(t,!1)}),e.o.clear())},i.forEach=function(e,t){var r=this;p(this[Q]).forEach(function(n,o){e.call(t,r.get(o),o,r)})},i.get=function(e){var t=this[Q];a(t);var o=p(t).get(e);if(t.I||!r(o))return o;if(o!==t.t.get(e))return o;var i=M(t.A.h,o,t);return n(t),t.o.set(e,i),i},i.keys=function(){return p(this[Q]).keys()},i.values=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.values()},e.next=function(){var e=r.next();return e.done?e:{done:!1,value:t.get(e.value)}},e},i.entries=function(){var e,t=this,r=this.keys();return(e={})[V]=function(){return t.entries()},e.next=function(){var e=r.next();if(e.done)return e;var n=t.get(e.value);return{done:!1,value:[e.value,n]}},e},i[V]=function(){return this.entries()},e}(),f=function(){function e(e,t){return this[Q]={i:3,l:t,A:t?t.A:m(),P:!1,I:!1,o:void 0,t:e,k:this,p:new Map,O:!1,C:!1},this}t(e,Set);var r=e.prototype;return Object.defineProperty(r,\"size\",{get:function(){return p(this[Q]).size}}),r.has=function(e){var t=this[Q];return a(t),t.o?!!t.o.has(e)||!(!t.p.has(e)||!t.o.has(t.p.get(e))):t.t.has(e)},r.add=function(e){var t=this[Q];return a(t),this.has(e)||(i(t),z(t),t.o.add(e)),this},r.delete=function(e){if(!this.has(e))return!1;var t=this[Q];return a(t),i(t),z(t),t.o.delete(e)||!!t.p.has(e)&&t.o.delete(t.p.get(e))},r.clear=function(){var e=this[Q];a(e),p(e).size&&(i(e),z(e),e.o.clear())},r.values=function(){var e=this[Q];return a(e),i(e),e.o.values()},r.entries=function(){var e=this[Q];return a(e),i(e),e.o.entries()},r.keys=function(){return this.values()},r[V]=function(){return this.values()},r.forEach=function(e,t){for(var r=this.values(),n=r.next();!n.done;)e.call(t,n.value,n.value,this),n=r.next()},e}();g(\"MapSet\",{N:function(e,t){return new c(e,t)},T:function(e,t){return new f(e,t)}})}function U(){C(),K(),T()}function W(e){return e}function N(e){return e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.castDraft=W,exports.castImmutable=N,exports.current=F,exports.enableAllPlugins=U,exports.enableES5=C,exports.enableMapSet=K,exports.enablePatches=T,exports.freeze=v,exports.isDraft=t,exports.isDraftable=r,exports.original=n,exports.setUseProxies=exports.setAutoFreeze=exports.produceWithPatches=exports.produce=exports.nothing=exports.immerable=exports.finishDraft=exports.createDraft=exports.applyPatches=exports.Immer=exports.default=void 0;var $,J,G=\"undefined\"!=typeof Symbol&&\"symbol\"==typeof Symbol(\"x\"),X=\"undefined\"!=typeof Map,q=\"undefined\"!=typeof Set,B=\"undefined\"!=typeof Proxy&&void 0!==Proxy.revocable&&\"undefined\"!=typeof Reflect,H=G?Symbol.for(\"immer-nothing\"):(($={})[\"immer-nothing\"]=!0,$),L=G?Symbol.for(\"immer-draftable\"):\"__$immer_draftable\",Q=G?Symbol.for(\"immer-state\"):\"__$immer_state\",V=\"undefined\"!=typeof Symbol&&Symbol.iterator||\"@@iterator\",Y={0:\"Illegal state\",1:\"Immer drafts cannot have computed properties\",2:\"This object has been frozen and should not be mutated\",3:function(e){return\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \"+e},4:\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",5:\"Immer forbids circular references\",6:\"The first or second argument to `produce` must be a function\",7:\"The third argument to `produce` must be a function or undefined\",8:\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",9:\"First argument to `finishDraft` must be a draft returned by `createDraft`\",10:\"The given draft is already finalized\",11:\"Object.defineProperty() cannot be used on an Immer draft\",12:\"Object.setPrototypeOf() cannot be used on an Immer draft\",13:\"Immer only supports deleting array indices\",14:\"Immer only supports setting array indices and the 'length' property\",15:function(e){return\"Cannot apply patch, path doesn't resolve: \"+e},16:'Sets cannot have \"replace\" patches.',17:function(e){return\"Unsupported patch operation: \"+e},18:function(e){return\"The plugin for '\"+e+\"' has not been loaded into Immer. To enable the plugin, import and call `enable\"+e+\"()` when initializing your application.\"},20:\"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available\",21:function(e){return\"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '\"+e+\"'\"},22:function(e){return\"'current' expects a draft, got: \"+e},23:function(e){return\"'original' expects a draft, got: \"+e},24:\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"},Z=\"\"+Object.prototype.constructor,ee=\"undefined\"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,te=Object.getOwnPropertyDescriptors||function(e){var t={};return ee(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},re={},ne={get:function(e,t){if(t===Q)return e;var n=p(e);if(!a(n,t))return function(e,t,r){var n,o=I(t,r);return o?\"value\"in o?o.value:null===(n=o.get)||void 0===n?void 0:n.call(e.k):void 0}(e,n,t);var o=n[t];return e.I||!r(o)?o:o===k(e.t,t)?(E(e),e.o[t]=M(e.A.h,o,e)):o},has:function(e,t){return t in p(e)},ownKeys:function(e){return Reflect.ownKeys(p(e))},set:function(e,t,r){var n=I(p(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var o=k(p(e),t),i=null==o?void 0:o[Q];if(i&&i.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(f(r,o)&&(void 0!==r||a(e.t,t)))return!0;E(e),z(e)}return e.o[t]===r&&\"number\"!=typeof r&&(void 0!==r||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==k(e.t,t)||t in e.t?(e.D[t]=!1,E(e),z(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=p(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||\"length\"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){e(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){e(12)}},oe={};exports.immerable=L,exports.nothing=H,o(ne,function(e,t){oe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),oe.deleteProperty=function(e,t){return ne.deleteProperty.call(this,e[0],t)},oe.set=function(e,t,r){return ne.set.call(this,e[0],t,r,e[0])};var ie=function(){function n(t){var n=this;this.g=B,this.F=!0,this.produce=function(t,o,i){if(\"function\"==typeof t&&\"function\"!=typeof o){var a=o;o=t;var u=n;return function(e){var t=this;void 0===e&&(e=a);for(var r=arguments.length,n=Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return u.produce(e,function(e){var r;return(r=o).call.apply(r,[t,e].concat(n))})}}var c;if(\"function\"!=typeof o&&e(6),void 0!==i&&\"function\"!=typeof i&&e(7),r(t)){var f=w(n),s=M(n,t,void 0),l=!0;try{c=o(s),l=!1}finally{l?O(f):x(f)}return\"undefined\"!=typeof Promise&&c instanceof Promise?c.then(function(e){return P(f,i),A(e,f)},function(e){throw O(f),e}):(P(f,i),A(c,f))}if(!t||\"object\"!=typeof t){if((c=o(t))===H)return;return void 0===c&&(c=t),n.F&&v(c,!0),c}e(21,t)},this.produceWithPatches=function(e,t){return\"function\"==typeof e?function(t){for(var r=arguments.length,o=Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return n.produceWithPatches(t,function(t){return e.apply(void 0,[t].concat(o))})}:[n.produce(e,t,function(e,t){r=e,o=t}),r,o];var r,o},\"boolean\"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),\"boolean\"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var o=n.prototype;return o.createDraft=function(n){r(n)||e(8),t(n)&&(n=F(n));var o=w(this),i=M(this,n,void 0);return i[Q].C=!0,x(o),i},o.finishDraft=function(e,t){var r=e&&e[Q],n=r.A;return P(n,t),A(void 0,n)},o.setAutoFreeze=function(e){this.F=e},o.setUseProxies=function(t){t&&!B&&e(20),this.g=t},o.applyPatches=function(e,r){var n;for(n=r.length-1;n>=0;n--){var o=r[n];if(0===o.path.length&&\"replace\"===o.op){e=o.value;break}}var i=b(\"Patches\").$;return t(e)?i(e,r):this.produce(e,function(e){return i(e,r.slice(n+1))})},n}(),ae=new ie,ue=ae.produce,ce=ae.produceWithPatches.bind(ae),fe=ae.setAutoFreeze.bind(ae),se=ae.setUseProxies.bind(ae),le=ae.applyPatches.bind(ae),pe=ae.createDraft.bind(ae),he=ae.finishDraft.bind(ae);exports.finishDraft=he,exports.createDraft=pe,exports.applyPatches=le,exports.setUseProxies=se,exports.setAutoFreeze=fe,exports.produceWithPatches=ce,exports.produce=ue,exports.Immer=ie;var ve=ue;exports.default=ve;\n},{}],\"B6zW\":[function(require,module,exports) {\nvar t=\"[object Object]\";function n(t){var n=!1;if(null!=t&&\"function\"!=typeof t.toString)try{n=!!(t+\"\")}catch(r){}return n}function r(t,n){return function(r){return t(n(r))}}var o=Function.prototype,c=Object.prototype,e=o.toString,u=c.hasOwnProperty,f=e.call(Object),i=c.toString,l=r(Object.getPrototypeOf,Object);function a(t){return!!t&&\"object\"==typeof t}function p(r){if(!a(r)||i.call(r)!=t||n(r))return!1;var o=l(r);if(null===o)return!0;var c=u.call(o,\"constructor\")&&o.constructor;return\"function\"==typeof c&&c instanceof c&&e.call(c)==f}module.exports=p;\n},{}],\"Tr4D\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=ie,exports.S=se,exports.U=le,exports.b=ne,exports.e=$,exports.i=V,exports.y=D,exports.z=exports.x=exports.w=exports.v=exports.u=exports.t=exports.s=exports.r=exports.q=exports.p=exports.o=exports.n=exports.m=exports.l=exports.k=exports.j=exports.h=exports.g=exports.f=exports.d=exports.c=exports.a=exports.T=exports.R=exports.P=exports.N=exports.M=exports.G=exports.F=exports.E=exports.C=exports.B=exports.A=void 0;var e=r(require(\"immer\")),t=r(require(\"lodash.isplainobject\"));function r(e){return e&&e.__esModule?e:{default:e}}const s=\"MAKE_MOVE\";exports.M=s;const n=\"GAME_EVENT\";exports.d=n;const a=\"REDO\";exports.m=a;const o=\"RESET\";exports.R=o;const i=\"SYNC\";exports.k=i;const l=\"UNDO\";exports.l=l;const p=\"UPDATE\";exports.j=p;const c=\"PATCH\";exports.o=c;const u=\"PLUGIN\";exports.P=u;const d=\"STRIP_TRANSIENTS\";exports.c=d;const h=(e,t,r,n)=>({type:s,payload:{type:e,args:t,playerID:r,credentials:n}});exports.x=h;const y=(e,t,r,s)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:s}});exports.g=y;const g=(e,t,r,s)=>({type:n,payload:{type:e,args:t,playerID:r,credentials:s},automatic:!0}),v=e=>({type:i,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0});exports.s=v;const f=(e,t,r,s)=>({type:c,prevStateID:e,stateID:t,patch:r,deltalog:s,clientOnly:!0});exports.C=f;const x=(e,t)=>({type:p,state:e,deltalog:t,clientOnly:!0});exports.B=x;const m=e=>({type:o,state:e,clientOnly:!0});exports.t=m;const E=(e,t)=>({type:l,payload:{type:null,args:null,playerID:e,credentials:t}});exports.u=E;const O=(e,t)=>({type:a,payload:{type:null,args:null,playerID:e,credentials:t}});exports.v=O;const P=(e,t,r,s)=>({type:u,payload:{type:e,args:t,playerID:r,credentials:s}}),_=()=>({type:d});exports.q=_;var N=Object.freeze({makeMove:h,gameEvent:y,automaticGameEvent:g,sync:v,patch:f,update:x,reset:m,undo:E,redo:O,plugin:P,stripTransients:_});exports.A=N;const M=\"INVALID_MOVE\";exports.h=M;const T={name:\"plugin-immer\",fnWrap:t=>(r,s,...n)=>{let a=!1;const o=(0,e.default)(r,e=>{const r=t(e,s,...n);if(r!==M)return r;a=!0});return a?M:o}};class A{constructor(e){const t=I();this.c=1,this.s0=t(\" \"),this.s1=t(\" \"),this.s2=t(\" \"),this.s0-=t(e),this.s0<0&&(this.s0+=1),this.s1-=t(e),this.s1<0&&(this.s1+=1),this.s2-=t(e),this.s2<0&&(this.s2+=1)}next(){const e=2091639*this.s0+2.3283064365386963e-10*this.c;return this.s0=this.s1,this.s1=this.s2,this.s2=e-(this.c=Math.trunc(e))}}function I(){let e=4022871197;return function(t){const r=t.toString();for(let s=0;s<r.length;s++){let t=.02519603282416938*(e+=r.charCodeAt(s));t-=e=t>>>0,e=(t*=e)>>>0,e+=4294967296*(t-=e)}return 2.3283064365386963e-10*(e>>>0)}}function S(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function D(e,t){const r=new A(e),s=r.next.bind(r);return t&&S(t,r),s.state=(()=>S(r,{})),s}class L{constructor(e){this.state=e||{seed:\"0\"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;const e=this.state,t=D(e.prngstate?\"\":e.seed,e.prngstate),r=t();return this.state={...e,prngstate:t.state()},r}api(){const e=this._random.bind(this),t={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},r={};for(const s in t){const n=t[s];r[s]=(t=>void 0===t?Math.floor(e()*n)+1:Array.from({length:t}).map(()=>Math.floor(e()*n)+1))}return{...r,Die:function(t=6,r){return void 0===r?Math.floor(e()*t)+1:Array.from({length:r}).map(()=>Math.floor(e()*t)+1)},Number:()=>e(),Shuffle:t=>{const r=[...t];let s=t.length,n=0;const a=Array.from({length:s});for(;s;){const t=Math.trunc(s*e());a[n++]=r[t],r[t]=r[--s]}return a},_private:this}}}const b={name:\"random\",noClient:({api:e})=>e._private.isUsed(),flush:({api:e})=>e._private.getState(),api:({data:e})=>{return new L(e).api()},setup:({game:e})=>{let{seed:t}=e;return void 0===t&&(t=L.seed()),{seed:t}},playerView:()=>void 0};var U,G;exports.G=U,function(e){e.MOVE=\"MOVE\",e.GAME_ON_END=\"GAME_ON_END\",e.PHASE_ON_BEGIN=\"PHASE_ON_BEGIN\",e.PHASE_ON_END=\"PHASE_ON_END\",e.TURN_ON_BEGIN=\"TURN_ON_BEGIN\",e.TURN_ON_MOVE=\"TURN_ON_MOVE\",e.TURN_ON_END=\"TURN_ON_END\"}(U||(exports.G=U={})),function(e){e.CalledOutsideHook=\"Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.\",e.EndTurnInOnEnd=\"`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.\",e.MaxTurnEndings=\"Maximum number of turn endings exceeded for this update.\\nThis likely means game code is triggering an infinite loop.\",e.PhaseEventInOnEnd=\"`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\nIf you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.\",e.StageEventInOnEnd=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.\",e.StageEventInPhaseBegin=\"`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.\",e.StageEventInTurnBegin=\"`setStage` & `endStage` are disallowed in `turn.onBegin`.\\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead.\"}(G||(G={}));class w{constructor(e,t,r){this.flow=e,this.playerID=r,this.dispatch=[],this.initialTurn=t.turn,this.updateTurnContext(t,void 0),this.maxEndedTurnsPerAction=100*t.numPlayers}api(){const e={_private:this};for(const t of this.flow.eventNames)e[t]=((...e)=>{this.dispatch.push({type:t,args:e,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error(\"Events Plugin Error\")})});return e}isUsed(){return this.dispatch.length>0}updateTurnContext(e,t){this.currentPhase=e.phase,this.currentTurn=e.turn,this.currentMethod=t}unsetCurrentMethod(){this.currentMethod=void 0}update(e){const t=e,r=({stack:e},r)=>({...t,plugins:{...t.plugins,events:{...t.plugins.events,data:{error:r+\"\\n\"+e}}}});e:for(let s=0;s<this.dispatch.length;s++){const t=this.dispatch[s],n=t.turn!==e.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(t.error,G.MaxTurnEndings);if(void 0===t.calledFrom)return r(t.error,G.CalledOutsideHook);if(e.ctx.gameover)break e;switch(t.type){case\"endStage\":case\"setStage\":case\"setActivePlayers\":switch(t.calledFrom){case U.TURN_ON_END:case U.PHASE_ON_END:return r(t.error,G.StageEventInOnEnd);case U.PHASE_ON_BEGIN:return r(t.error,G.StageEventInPhaseBegin);case U.TURN_ON_BEGIN:if(\"setActivePlayers\"===t.type)break;return r(t.error,G.StageEventInTurnBegin)}if(n)continue e;break;case\"endTurn\":if(t.calledFrom===U.TURN_ON_END||t.calledFrom===U.PHASE_ON_END)return r(t.error,G.EndTurnInOnEnd);if(n)continue e;break;case\"endPhase\":case\"setPhase\":if(t.calledFrom===U.PHASE_ON_END)return r(t.error,G.PhaseEventInOnEnd);if(t.phase!==e.ctx.phase)continue e}const a=g(t.type,t.args,this.playerID);e=this.flow.processEvent(e,a)}return e}}const R={name:\"events\",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(r,s,...n)=>{const a=s.events;return a&&a._private.updateTurnContext(s,t),r=e(r,s,...n),a&&a._private.unsetCurrentMethod(),r},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:r})=>new w(e.flow,t,r).api()},k={name:\"log\",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};function C(e){if(null==e||\"boolean\"==typeof e||\"number\"==typeof e||\"string\"==typeof e)return!0;if(!(0,t.default)(e)&&!Array.isArray(e))return!1;for(const t in e)if(!C(e[t]))return!1;return!0}const B={name:\"plugin-serializable\",fnWrap:e=>(t,r,...s)=>{const n=e(t,r,...s);return n}},F=!0,H=()=>{},j=(...e)=>console.error(...e);function V(e){H(`INFO: ${e}`)}function $(e){j(\"ERROR:\",e)}const W=[T,b,k,B],q=[...W,R],z=(e,t,r)=>(r.game.plugins.filter(e=>void 0!==e.action).filter(e=>e.name===t.payload.type).forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}},a=r.action(n.data,t.payload);e={...e,plugins:{...e.plugins,[s]:{...n,data:a}}}}),e);exports.n=z;const K=e=>{const t={...e.ctx},r=e.plugins||{};return Object.entries(r).forEach(([e,{api:r}])=>{t[e]=r}),t};exports.E=K;const Y=(e,t,r)=>[...W,...r,R].filter(e=>void 0!==e.fnWrap).reduce((e,{fnWrap:r})=>r(e,t),e);exports.F=Y;const J=(e,t)=>([...q,...t.game.plugins].filter(e=>void 0!==e.setup).forEach(r=>{const s=r.name,n=r.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[s]:{data:n}}}}),e);exports.r=J;const Q=(e,t)=>([...q,...t.game.plugins].filter(e=>void 0!==e.api).forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}},a=r.api({G:e.G,ctx:e.ctx,data:n.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[s]:{...n,api:a}}}}),e);exports.f=Q;const X=(e,t)=>([...W,...t.game.plugins,R].reverse().forEach(r=>{const s=r.name,n=e.plugins[s]||{data:{}};if(r.flush){const s=r.flush({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data});e={...e,plugins:{...e.plugins,[r.name]:{data:s}}}}else if(r.dangerouslyFlushRawState){const a=(e=r.dangerouslyFlushRawState({state:e,game:t.game,api:n.api,data:n.data})).plugins[s].data;e={...e,plugins:{...e.plugins,[r.name]:{data:a}}}}}),e),Z=(e,t)=>[...q,...t.game.plugins].filter(e=>void 0!==e.noClient).map(r=>{const s=r.name,n=e.plugins[s];return!!n&&r.noClient({G:e.G,ctx:e.ctx,game:t.game,api:n.api,data:n.data})}).includes(!0);exports.N=Z;const ee=(e,t)=>{return[...q,...t.game.plugins].filter(e=>void 0!==e.isInvalid).map(r=>{const{name:s}=r,n=e.plugins[s],a=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:n&&n.data});return!!a&&{plugin:s,message:a}}).find(e=>e)||!1},te=(e,t)=>{const r=X(e,t),s=ee(r,t);if(!s)return[r];const{plugin:n,message:a}=s;return $(`${n} plugin declared action invalid:\\n${a}`),[e,s]};exports.p=te;const re=({G:e,ctx:t,plugins:r={}},{game:s,playerID:n})=>([...q,...s.plugins].forEach(({name:a,playerView:o})=>{if(!o)return;const{data:i}=r[a]||{data:{}},l=o({G:e,ctx:t,game:s,data:i,playerID:n});r={...r,[a]:{data:l}}}),r);function se(e,t){let r={},s=[],n=null,a={};if(Array.isArray(t)){const e={};t.forEach(t=>e[t]=ce.NULL),r=e}else{if(t.next&&(n=t.next),t.revert&&(s=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMoveLimit:e._activePlayersMoveLimit,_activePlayersNumMoves:e._activePlayersNumMoves}]),void 0!==t.currentPlayer&&ae(r,a,e.currentPlayer,t.currentPlayer),void 0!==t.others)for(let s=0;s<e.playOrder.length;s++){const n=e.playOrder[s];n!==e.currentPlayer&&ae(r,a,n,t.others)}if(void 0!==t.all)for(let s=0;s<e.playOrder.length;s++){ae(r,a,e.playOrder[s],t.all)}if(t.value)for(const e in t.value)ae(r,a,e,t.value[e]);if(t.moveLimit)for(const e in r)void 0===a[e]&&(a[e]=t.moveLimit)}0===Object.keys(r).length&&(r=null),0===Object.keys(a).length&&(a=null);const o={};for(const i in r)o[i]=0;return{...e,activePlayers:r,_activePlayersMoveLimit:a,_activePlayersNumMoves:o,_prevActivePlayers:s,_nextActivePlayers:n}}function ne(e){let{activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n,_nextActivePlayers:a}=e;if(t&&0===Object.keys(t).length)if(a)e=se(e,a),({activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n}=e);else if(n.length>0){const e=n.length-1;({activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s}=n[e]),n=n.slice(0,e)}else t=null,r=null;return{...e,activePlayers:t,_activePlayersMoveLimit:r,_activePlayersNumMoves:s,_prevActivePlayers:n}}function ae(e,t,r,s){\"object\"==typeof s&&s!==ce.NULL||(s={stage:s}),void 0!==s.stage&&(e[r]=s.stage,s.moveLimit&&(t[r]=s.moveLimit))}function oe(e,t){return e[t]+\"\"}function ie(e,t){let{G:r,ctx:s}=e;const{numPlayers:n}=s,a=K(e),o=t.order;let i=[...Array.from({length:n})].map((e,t)=>t+\"\");void 0!==o.playOrder&&(i=o.playOrder(r,a));const l=o.first(r,a),p=typeof l;\"number\"!==p&&$(`invalid value returned by turn.order.first — expected number got ${p} “${l}”.`);const c=oe(i,l);return s=se(s={...s,currentPlayer:c,playOrderPos:l,playOrder:i},t.activePlayers||{})}function le(e,t,r,s){const n=r.order;let{G:a,ctx:o}=e,i=o.playOrderPos,l=!1;if(s&&!0!==s)\"object\"!=typeof s&&$(`invalid argument to endTurn: ${s}`),Object.keys(s).forEach(e=>{switch(e){case\"remove\":t=oe(o.playOrder,i);break;case\"next\":i=o.playOrder.indexOf(s.next),t=s.next;break;default:$(`invalid argument to endTurn: ${e}`)}});else{const r=K(e),s=n.next(a,r),p=typeof s;void 0!==s&&\"number\"!==p&&$(`invalid value returned by turn.order.next — expected number or undefined got ${p} “${s}”.`),void 0===s?l=!0:(i=s,t=oe(o.playOrder,i))}return{endPhase:l,ctx:o={...o,playOrderPos:i,currentPlayer:t}}}exports.w=re;const pe={DEFAULT:{first:(e,t)=>0===t.turn?t.playOrderPos:(t.playOrderPos+1)%t.playOrder.length,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},RESET:{first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},CONTINUE:{first:(e,t)=>t.playOrderPos,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length},ONCE:{first:()=>0,next:(e,t)=>{if(t.playOrderPos<t.playOrder.length-1)return t.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:t=>t[e],first:()=>0,next:(e,t)=>(t.playOrderPos+1)%t.playOrder.length})};exports.T=pe;const ce={NULL:null};exports.a=ce;const ue={ALL:{all:ce.NULL},ALL_ONCE:{all:ce.NULL,moveLimit:1},OTHERS:{others:ce.NULL},OTHERS_ONCE:{others:ce.NULL,moveLimit:1}};exports.z=ue;\n},{\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\"}],\"Al58\":[function(require,module,exports) {\n\"use strict\";function t(t){return t.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}function e(t){return t.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Pointer=void 0;var n=function(){function n(t){void 0===t&&(t=[\"\"]),this.tokens=t}return n.fromJSON=function(e){var o=e.split(\"/\").map(t);if(\"\"!==o[0])throw new Error(\"Invalid JSON Pointer: \"+e);return new n(o)},n.prototype.toString=function(){return this.tokens.map(e).join(\"/\")},n.prototype.evaluate=function(t){for(var e=null,n=\"\",o=t,r=1,i=this.tokens.length;r<i;r++)o=((e=o)||{})[n=this.tokens[r]];return{parent:e,key:n,value:o}},n.prototype.get=function(t){return this.evaluate(t).value},n.prototype.set=function(t,e){for(var n=t,o=1,r=this.tokens.length-1,i=this.tokens[o];o<r;o++)n=(n||{})[i];n&&(n[this.tokens[this.tokens.length-1]]=e)},n.prototype.push=function(t){this.tokens.push(t)},n.prototype.add=function(t){return new n(this.tokens.concat(String(t)))},n}();exports.Pointer=n;\n},{}],\"HHTq\":[function(require,module,exports) {\n\"use strict\";function r(r){return void 0===r?\"undefined\":null===r?\"null\":Array.isArray(r)?\"array\":typeof r}function e(r){return null!=r&&\"object\"==typeof r}function t(r){if(!e(r))return r;if(r.constructor==Array){for(var o=r.length,n=new Array(o),p=0;p<o;p++)n[p]=t(r[p]);return n}if(r.constructor==Date)return new Date(+r);var s={};for(var u in r)exports.hasOwnProperty.call(r,u)&&(s[u]=t(r[u]));return s}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.clone=exports.objectType=exports.hasOwnProperty=void 0,exports.hasOwnProperty=Object.prototype.hasOwnProperty,exports.objectType=r,exports.clone=t;\n},{}],\"gukC\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var r=require(\"./pointer\"),e=require(\"./util\");function t(r){var e=r.op;return\"remove\"===e||\"replace\"===e||\"copy\"===e||\"move\"===e}function o(r,t){var o={};for(var n in r)e.hasOwnProperty.call(r,n)&&void 0!==r[n]&&(o[n]=1);for(var i in t)e.hasOwnProperty.call(t,i)&&void 0!==t[i]&&delete o[i];return Object.keys(o)}function n(r){for(var t=r.length,o={},n=0;n<t;n++){var i=r[n];for(var a in i)e.hasOwnProperty.call(i,a)&&void 0!==i[a]&&(o[a]=(o[a]||0)+1)}for(var a in o)o[a]<t&&delete o[a];return Object.keys(o)}function i(r){return\"add\"===r.op}function a(r){return\"remove\"===r.op}function p(r,e){return{operations:r.operations.concat(e),cost:r.cost+1}}function c(e,t,o,n){void 0===n&&(n=s);var c={\"0,0\":{operations:[],cost:0}};var u=isNaN(e.length)||e.length<=0?0:e.length,f=isNaN(t.length)||t.length<=0?0:t.length;return function o(i,a){var u=i+\",\"+a,s=c[u];if(void 0===s){if(i>0&&a>0&&!n(e[i-1],t[a-1],new r.Pointer).length)s=o(i-1,a-1);else{var f=[];if(i>0){var v=o(i-1,a),d={op:\"remove\",index:i-1};f.push(p(v,d))}if(a>0){var l=o(i,a-1),h={op:\"add\",index:i-1,value:t[a-1]};f.push(p(l,h))}if(i>0&&a>0){var x=o(i-1,a-1),g={op:\"replace\",index:i-1,original:e[i-1],value:t[a-1]};f.push(p(x,g))}s=f.sort(function(r,e){return r.cost-e.cost})[0]}c[u]=s}return s}(u,f).operations.reduce(function(r,e){var t=r[0],p=r[1];if(i(e)){var c=e.index+1+p,s=c<u+p?String(c):\"-\",f={op:e.op,path:o.add(s).toString(),value:e.value};return[t.concat(f),p+1]}if(a(e)){f={op:e.op,path:o.add(String(e.index+p)).toString()};return[t.concat(f),p-1]}var v=o.add(String(e.index+p)),d=n(e.original,e.value,v);return[t.concat.apply(t,d),p]},[[],0])[0]}function u(r,e,t,i){void 0===i&&(i=s);var a=[];return o(r,e).forEach(function(r){a.push({op:\"remove\",path:t.add(r).toString()})}),o(e,r).forEach(function(r){a.push({op:\"add\",path:t.add(r).toString(),value:e[r]})}),n([r,e]).forEach(function(o){a.push.apply(a,i(r[o],e[o],t.add(o)))}),a}function s(r,t,o,n){if(void 0===n&&(n=s),r===t)return[];var i=e.objectType(r),a=e.objectType(t);return\"array\"==i&&\"array\"==a?c(r,t,o,n):\"object\"==i&&\"object\"==a?u(r,t,o,n):[{op:\"replace\",path:o.toString(),value:t}]}exports.isDestructive=t,exports.subtract=o,exports.intersection=n,exports.diffArrays=c,exports.diffObjects=u,exports.diffAny=s;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\"}],\"datJ\":[function(require,module,exports) {\n\"use strict\";var r=this&&this.__extends||function(){var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])})(e,t)};return function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Class extends value \"+String(t)+\" is not a constructor or null\");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var e=require(\"./pointer\"),t=require(\"./util\"),n=require(\"./diff\"),o=function(e){function t(r){var t=e.call(this,\"Value required at path: \"+r)||this;return t.path=r,t.name=\"MissingError\",t}return r(t,e),t}(Error);exports.MissingError=o;var a=function(e){function t(r,t){var n=e.call(this,\"Test failed: \"+r+\" != \"+t)||this;return n.actual=r,n.expected=t,n.name=\"TestError\",n}return r(t,e),t}(Error);function i(r,e,t){if(Array.isArray(r))if(\"-\"==e)r.push(t);else{var n=parseInt(e,10);r.splice(n,0,t)}else r[e]=t}function u(r,e){if(Array.isArray(r)){var t=parseInt(e,10);r.splice(t,1)}else delete r[e]}function p(r,n){var a=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===a.parent?new o(n.path):(i(a.parent,a.key,t.clone(n.value)),null)}function l(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===n.value?new o(t.path):(u(n.parent,n.key),null)}function s(r,t){var n=e.Pointer.fromJSON(t.path).evaluate(r);if(null===n.parent)return new o(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new o(t.path)}else if(void 0===n.value)return new o(t.path);return n.parent[n.key]=t.value,null}function v(r,t){var n=e.Pointer.fromJSON(t.from).evaluate(r);if(void 0===n.value)return new o(t.from);var a=e.Pointer.fromJSON(t.path).evaluate(r);return void 0===a.parent?new o(t.path):(u(n.parent,n.key),i(a.parent,a.key,n.value),null)}function c(r,n){var a=e.Pointer.fromJSON(n.from).evaluate(r);if(void 0===a.value)return new o(n.from);var u=e.Pointer.fromJSON(n.path).evaluate(r);return void 0===u.parent?new o(n.path):(i(u.parent,u.key,t.clone(a.value)),null)}function f(r,t){var o=e.Pointer.fromJSON(t.path).evaluate(r);return n.diffAny(o.value,t.value,new e.Pointer).length?new a(o.value,t.value):null}exports.TestError=a,exports.add=p,exports.remove=l,exports.replace=s,exports.move=v,exports.copy=c,exports.test=f;var h=function(e){function t(r){var t=e.call(this,\"Invalid operation: \"+r.op)||this;return t.operation=r,t.name=\"InvalidOperationError\",t}return r(t,e),t}(Error);function y(r,e){switch(e.op){case\"add\":return p(r,e);case\"remove\":return l(r,e);case\"replace\":return s(r,e);case\"move\":return v(r,e);case\"copy\":return c(r,e);case\"test\":return f(r,e)}return new h(e)}exports.InvalidOperationError=h,exports.apply=y;\n},{\"./pointer\":\"Al58\",\"./util\":\"HHTq\",\"./diff\":\"gukC\"}],\"B6py\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.createTests=exports.createPatch=exports.applyPatch=void 0;var r=require(\"./pointer\"),e=require(\"./patch\"),t=require(\"./diff\");function n(r,t){return t.map(function(t){return e.apply(r,t)})}function a(r){return function e(n,a,i){var o=r(n,a,i);return Array.isArray(o)?o:t.diffAny(n,a,i,e)}}function i(e,n,i){var o=new r.Pointer;return(i?a(i):t.diffAny)(e,n,o)}function o(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:\"test\",path:t,value:n.value}}function u(r,e){var n=new Array;return e.filter(t.isDestructive).forEach(function(e){var t=o(r,e.path);if(t&&n.push(t),\"from\"in e){var a=o(r,e.from);a&&n.push(a)}}),n}exports.applyPatch=n,exports.createPatch=i,exports.createTests=u;\n},{\"./pointer\":\"Al58\",\"./patch\":\"datJ\",\"./diff\":\"gukC\"}],\"b133\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=m,exports.I=s,exports.P=i,exports.T=void 0;var e,t,n=require(\"./turn-order-0d61594c.js\"),a=require(\"rfc6902\");function r({moves:e,phases:t,endIf:a,onEnd:r,turn:o,events:i,plugins:s}){void 0===e&&(e={}),void 0===i&&(i={}),void 0===s&&(s=[]),void 0===t&&(t={}),a||(a=(()=>void 0)),r||(r=(e=>e)),o||(o={});const u={...t};\"\"in u&&(0,n.e)(\"cannot specify phase with empty name\"),u[\"\"]={};const c={},l=new Set;let d=null;Object.keys(e).forEach(e=>l.add(e));const p=(e,t)=>{const a=(0,n.F)(e,t,s);return e=>{const t=(0,n.E)(e);return a(e.G,t)}},v=e=>t=>{const a=(0,n.E)(t);return e(t.G,a)},f={onEnd:p(r,n.G.GAME_ON_END),endIf:v(a)};for(const T in u){const e=u[T];if(!0===e.start&&(d=T),void 0!==e.moves)for(const t of Object.keys(e.moves))c[T+\".\"+t]=e.moves[t],l.add(t);void 0===e.endIf&&(e.endIf=(()=>void 0)),void 0===e.onBegin&&(e.onBegin=(e=>e)),void 0===e.onEnd&&(e.onEnd=(e=>e)),void 0===e.turn&&(e.turn=o),void 0===e.turn.order&&(e.turn.order=n.T.DEFAULT),void 0===e.turn.onBegin&&(e.turn.onBegin=(e=>e)),void 0===e.turn.onEnd&&(e.turn.onEnd=(e=>e)),void 0===e.turn.endIf&&(e.turn.endIf=(()=>!1)),void 0===e.turn.onMove&&(e.turn.onMove=(e=>e)),void 0===e.turn.stages&&(e.turn.stages={});for(const t in e.turn.stages){const n=e.turn.stages[t].moves||{};for(const e of Object.keys(n)){c[T+\".\"+t+\".\"+e]=n[e],l.add(e)}}if(e.wrapped={onBegin:p(e.onBegin,n.G.PHASE_ON_BEGIN),onEnd:p(e.onEnd,n.G.PHASE_ON_END),endIf:v(e.endIf)},e.turn.wrapped={onMove:p(e.turn.onMove,n.G.TURN_ON_MOVE),onBegin:p(e.turn.onBegin,n.G.TURN_ON_BEGIN),onEnd:p(e.turn.onEnd,n.G.TURN_ON_END),endIf:v(e.turn.endIf)},\"function\"!=typeof e.next){const{next:t}=e;e.next=(()=>t||null)}e.wrapped.next=v(e.next)}function y(e){return e.phase?u[e.phase]:u[\"\"]}function m(e){return e}function g(e,t){const n=new Set,a=new Set;for(let r=0;r<t.length;r++){const{fn:o,arg:i,...s}=t[r];if(o===N){a.clear();const t=e.ctx.phase;if(n.has(t)){const t={...e.ctx,phase:null};return{...e,ctx:t}}n.add(t)}const u=[];if(e=o(e,{...s,arg:i,next:u}),o===b)break;const c=G(e);if(c){t.push({fn:b,arg:c,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}const l=E(e);if(l)t.push({fn:N,arg:l,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});else{if([m,D,M].includes(o)){const n=w(e);if(n){t.push({fn:A,arg:n,turn:e.ctx.turn,phase:e.ctx.phase,automatic:!0});continue}}t.push(...u)}}return e}function h(e,{next:t}){return t.push({fn:x}),e}function x(e,{next:t}){let{G:n,ctx:a}=e;return n=y(a).wrapped.onBegin(e),t.push({fn:I}),{...e,G:n,ctx:a}}function I(e,{currentPlayer:t}){let{ctx:a}=e;const r=y(a);t?(a={...a,currentPlayer:t},r.turn.activePlayers&&(a=(0,n.S)(a,r.turn.activePlayers))):a=(0,n.I)(e,r.turn);const o=a.turn+1;a={...a,turn:o,numMoves:0,_prevActivePlayers:[]};const i=r.turn.wrapped.onBegin({...e,ctx:a});return{...e,G:i,ctx:a,_undo:[],_redo:[]}}function P(e,{arg:t,next:a,phase:r}){const o=y({phase:r});let{ctx:i}=e;if(t&&t.next){if(!(t.next in u))return(0,n.e)(\"invalid phase: \"+t.next),e;i={...i,phase:t.next}}else i={...i,phase:o.wrapped.next(e)||null};return e={...e,ctx:i},a.push({fn:x}),e}function _(e,{arg:t,currentPlayer:a,next:r}){let{G:o,ctx:i}=e;const s=y(i),{endPhase:u,ctx:c}=(0,n.U)(e,a,s.turn,t);return i=c,e={...e,G:o,ctx:i},u?r.push({fn:N,turn:i.turn,phase:i.phase}):r.push({fn:I,currentPlayer:i.currentPlayer}),e}function D(e,{arg:t,playerID:a}){if(\"string\"!=typeof t&&t!==n.a.NULL||(t={stage:t}),\"object\"!=typeof t)return e;let{ctx:r}=e,{activePlayers:o,_activePlayersMoveLimit:i,_activePlayersNumMoves:s}=r;return void 0!==t.stage&&(null===o&&(o={}),o[a]=t.stage,s[a]=0,t.moveLimit&&(null===i&&(i={}),i[a]=t.moveLimit)),r={...r,activePlayers:o,_activePlayersMoveLimit:i,_activePlayersNumMoves:s},{...e,ctx:r}}function M(e,{arg:t}){return{...e,ctx:(0,n.S)(e.ctx,t)}}function G(e){return f.endIf(e)}function E(e){return y(e.ctx).wrapped.endIf(e)}function w(e){const t=y(e.ctx),n=e.ctx.numMoves||0;return!!(t.turn.moveLimit&&n>=t.turn.moveLimit)||t.turn.wrapped.endIf(e)}function b(e,{arg:t,phase:n}){e=N(e,{phase:n}),void 0===t&&(t=!0),e={...e,ctx:{...e.ctx,gameover:t}};const a=f.onEnd(e);return{...e,G:a}}function N(e,{arg:t,next:a,turn:r,automatic:o}){e=A(e,{turn:r,force:!0,automatic:!0});const{phase:i,turn:s}=e.ctx;if(a&&a.push({fn:P,arg:t,phase:i}),null===i)return e;const u=y(e.ctx).wrapped.onEnd(e),c={...e.ctx,phase:null},l=(0,n.g)(\"endPhase\",t),{_stateID:d}=e,p={action:l,_stateID:d,turn:s,phase:i};o&&(p.automatic=!0);const v=[...e.deltalog||[],p];return{...e,G:u,ctx:c,deltalog:v}}function A(e,{arg:t,next:a,turn:r,force:o,automatic:i,playerID:s}){if(r!==e.ctx.turn)return e;const{currentPlayer:u,numMoves:c,phase:l,turn:d}=e.ctx,p=y(e.ctx),v=c||0;if(!o&&p.turn.moveLimit&&v<p.turn.moveLimit)return(0,n.i)(`cannot end turn before making ${p.turn.moveLimit} moves`),e;const f=p.turn.wrapped.onEnd(e);a&&a.push({fn:_,arg:t,currentPlayer:u});let m={...e.ctx,activePlayers:null};if(t&&t.remove){s=s||u;const t=m.playOrder.filter(e=>e!=s),n=m.playOrderPos>t.length-1?0:m.playOrderPos;if(m={...m,playOrder:t,playOrderPos:n},0===t.length)return a.push({fn:N,turn:d,phase:l}),e}const g=(0,n.g)(\"endTurn\",t),{_stateID:h}=e,x={action:g,_stateID:h,turn:d,phase:l};i&&(x.automatic=!0);const I=[...e.deltalog||[],x];return{...e,G:f,ctx:m,deltalog:I,_undo:[],_redo:[]}}function O(e,{arg:t,next:a,automatic:r,playerID:o}){o=o||e.ctx.currentPlayer;let{ctx:i,_stateID:s}=e,{activePlayers:u,_activePlayersMoveLimit:c,phase:l,turn:d}=i;const p=null!==u&&o in u;if(!t&&p){const e=y(i).turn.stages[u[o]];e&&e.next&&(t=e.next)}if(a&&a.push({fn:D,arg:t,playerID:o}),!p)return e;delete(u={...u})[o],c&&delete(c={...c})[o],i=(0,n.b)({...i,activePlayers:u,_activePlayersMoveLimit:c});const v={action:(0,n.g)(\"endStage\",t),_stateID:s,turn:d,phase:l};r&&(v.automatic=!0);const f=[...e.deltalog||[],v];return{...e,ctx:i,deltalog:f}}function S(t,a,r){const o=y(t),i=o.turn.stages,{activePlayers:s}=t;if(s&&void 0!==s[r]&&s[r]!==n.a.NULL&&void 0!==i[s[r]]&&void 0!==i[s[r]].moves){const e=i[s[r]].moves;if(a in e)return e[a]}else if(o.moves){if(a in o.moves)return o.moves[a]}else if(a in e)return e[a];return null}const L={endStage:function(e,t){return g(e,[{fn:O,playerID:t}])},setStage:function(e,t,n){return g(e,[{fn:O,arg:n,playerID:t}])},endTurn:function(e,t,n){return g(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},pass:function(e,t,n){return g(e,[{fn:A,turn:e.ctx.turn,phase:e.ctx.phase,force:!0,arg:n}])},endPhase:function(e){return g(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn}])},setPhase:function(e,t,n){return g(e,[{fn:N,phase:e.ctx.phase,turn:e.ctx.turn,arg:{next:n}}])},endGame:function(e,t,n){return g(e,[{fn:b,turn:e.ctx.turn,phase:e.ctx.phase,arg:n}])},setActivePlayers:function(e,t,n){return g(e,[{fn:M,arg:n}])}},U=[];return!1!==i.endTurn&&U.push(\"endTurn\"),!1!==i.pass&&U.push(\"pass\"),!1!==i.endPhase&&U.push(\"endPhase\"),!1!==i.setPhase&&U.push(\"setPhase\"),!1!==i.endGame&&U.push(\"endGame\"),!1!==i.setActivePlayers&&U.push(\"setActivePlayers\"),!1!==i.endStage&&U.push(\"endStage\"),!1!==i.setStage&&U.push(\"setStage\"),{ctx:e=>({numPlayers:e,turn:0,currentPlayer:\"0\",playOrder:[...Array.from({length:e})].map((e,t)=>t+\"\"),playOrderPos:0,phase:d,activePlayers:null}),init:e=>g(e,[{fn:h}]),isPlayerActive:function(e,t,n){return t.activePlayers?n in t.activePlayers:t.currentPlayer===n},eventHandlers:L,eventNames:Object.keys(L),enabledEventNames:U,moveMap:c,moveNames:[...l.values()],processMove:function(e,t){const{playerID:n,type:a}=t,{ctx:r}=e,{currentPlayer:o,activePlayers:i,_activePlayersMoveLimit:s}=r,u=S(r,a,n),c=!u||\"function\"==typeof u||!0!==u.noLimit;let{numMoves:l,_activePlayersNumMoves:d}=r;c&&(n===o&&l++,i&&d[n]++),e={...e,ctx:{...r,numMoves:l,_activePlayersNumMoves:d}},s&&d[n]>=s[n]&&(e=O(e,{playerID:n,automatic:!0}));const p=y(r).turn.wrapped.onMove(e);return g(e={...e,G:p},[{fn:m}])},processEvent:function(e,t){const{type:n,playerID:a,args:r}=t.payload;return\"function\"!=typeof L[n]?e:L[n](e,a,...Array.isArray(r)?r:[r])},getMove:S}}function o(e){return void 0!==e.processMove}function i(e){if(o(e))return e;if(void 0===e.name&&(e.name=\"default\"),void 0===e.deltaState&&(e.deltaState=!1),void 0===e.disableUndo&&(e.disableUndo=!1),void 0===e.setup&&(e.setup=(()=>({}))),void 0===e.moves&&(e.moves={}),void 0===e.playerView&&(e.playerView=(e=>e)),void 0===e.plugins&&(e.plugins=[]),e.plugins.forEach(e=>{if(void 0===e.name)throw new Error(\"Plugin missing name attribute\");if(e.name.includes(\" \"))throw new Error(e.name+\": Plugin name must not include spaces\")}),e.name.includes(\" \"))throw new Error(e.name+\": Game name must not include spaces\");const t=r(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(e=>e.name),processMove:(a,r)=>{let o=t.getMove(a.ctx,r.type,r.playerID);if(s(o)&&(o=o.move),o instanceof Function){const t=(0,n.F)(o,n.G.MOVE,e.plugins),i={...(0,n.E)(a),playerID:r.playerID};let s=[];return void 0!==r.args&&(s=Array.isArray(r.args)?r.args:[r.args]),t(a.G,i,...s)}return(0,n.e)(`invalid move object: ${r.type}`),a.G}}}function s(e){return e instanceof Object&&void 0!==e.move}!function(e){e.UnauthorizedAction=\"update/unauthorized_action\",e.MatchNotFound=\"update/match_not_found\",e.PatchFailed=\"update/patch_failed\"}(e||(e={})),function(e){e.StaleStateId=\"action/stale_state_id\",e.UnavailableMove=\"action/unavailable_move\",e.InvalidMove=\"action/invalid_move\",e.InactivePlayer=\"action/inactive_player\",e.GameOver=\"action/gameover\",e.ActionDisabled=\"action/action_disabled\",e.ActionInvalid=\"action/action_invalid\",e.PluginActionInvalid=\"action/plugin_invalid\"}(t||(t={}));const u=e=>null!==e.payload.playerID&&void 0!==e.payload.playerID,c=(e,t,n)=>{return!function(e){return void 0!==e.undoable}(n)||(function(e){return e instanceof Function}(n.undoable)?n.undoable(e,t):n.undoable)};function l(e,t){if(t.game.disableUndo)return e;const n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return\"MAKE_MOVE\"===t.action.type&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function d(e,t,n){const a={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},r=e.plugins.log.data.metadata;return void 0!==r&&(a.metadata=r),\"object\"==typeof n&&!0===n.redact&&(a.redact=!0),{...e,deltalog:[a]}}function p(e,a,r){const[o,i]=(0,n.p)(e,r);return i?[o,f(a,t.PluginActionInvalid,i)]:[o]}function v(e){if(!e)return[null,void 0];const{transients:t,...n}=e;return[n,t]}function f(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}const y=e=>t=>a=>{const r=t(a);switch(a.type){case n.c:return r;default:{const[,t]=v(e.getState());return void 0!==t?(e.dispatch((0,n.q)()),{...r,transients:t}):r}}};function m({game:r,isClient:o}){return r=i(r),(i=null,s)=>{let[y]=v(i);switch(s.type){case n.c:return y;case n.d:{if(y={...y,deltalog:[]},o)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot call event after game end\"),f(y,t.GameOver);if(u(s)&&!r.flow.isPlayerActive(y.G,y.ctx,s.payload.playerID))return(0,n.e)(`disallowed event: ${s.payload.type}`),f(y,t.InactivePlayer);y=(0,n.f)(y,{game:r,isClient:!1,playerID:s.payload.playerID});let e,a=r.flow.processEvent(y,s);return[a,e]=p(a,y,{game:r,isClient:!1}),e?e:(a=l(a,{game:r,action:s}),{...a,_stateID:y._stateID+1})}case n.M:{const e=y={...y,deltalog:[]},a=r.flow.getMove(y.ctx,s.payload.type,s.payload.playerID||y.ctx.currentPlayer);if(null===a)return(0,n.e)(`disallowed move: ${s.payload.type}`),f(y,t.UnavailableMove);if(o&&!1===a.client)return y;if(void 0!==y.ctx.gameover)return(0,n.e)(\"cannot make move after game end\"),f(y,t.GameOver);if(u(s)&&!r.flow.isPlayerActive(y.G,y.ctx,s.payload.playerID))return(0,n.e)(`disallowed move: ${s.payload.type}`),f(y,t.InactivePlayer);y=(0,n.f)(y,{game:r,isClient:o,playerID:s.payload.playerID});const i=r.processMove(y,s.payload);if(i===n.h)return(0,n.e)(`invalid move: ${s.payload.type} args: ${s.payload.args}`),f(y,t.InvalidMove);const c={...y,G:i};if(o&&(0,n.N)(c,{game:r}))return y;if(y=c,o){let t;return[y,t]=p(y,e,{game:r,isClient:!0}),t||{...y,_stateID:y._stateID+1}}let v;return y=d(y,s,a),y=r.flow.processMove(y,s.payload),[y,v]=p(y,e,{game:r}),v?v:(y=l(y,{game:r,action:s}),{...y,_stateID:y._stateID+1})}case n.R:case n.j:case n.k:return s.state;case n.l:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Undo is not enabled\"),f(y,t.ActionDisabled);const{G:e,ctx:a,_undo:o,_redo:i,_stateID:l}=y;if(o.length<2)return(0,n.e)(\"No moves to undo\"),f(y,t.ActionInvalid);const p=o[o.length-1],v=o[o.length-2];if(u(s)&&s.payload.playerID!==p.playerID)return(0,n.e)(\"Cannot undo other players' moves\"),f(y,t.ActionInvalid);if(p.moveType){const o=r.flow.getMove(v.ctx,p.moveType,p.playerID);if(!c(e,a,o))return(0,n.e)(\"Move cannot be undone\"),f(y,t.ActionInvalid)}return y=d(y,s),{...y,G:v.G,ctx:v.ctx,plugins:v.plugins,_stateID:l+1,_undo:o.slice(0,-1),_redo:[p,...i]}}case n.m:{if(y={...y,deltalog:[]},r.disableUndo)return(0,n.e)(\"Redo is not enabled\"),f(y,t.ActionDisabled);const{_undo:e,_redo:a,_stateID:o}=y;if(0===a.length)return(0,n.e)(\"No moves to redo\"),f(y,t.ActionInvalid);const i=a[0];return u(s)&&s.payload.playerID!==i.playerID?((0,n.e)(\"Cannot redo other players' moves\"),f(y,t.ActionInvalid)):(y=d(y,s),{...y,G:i.G,ctx:i.ctx,plugins:i.plugins,_stateID:o+1,_undo:[...e,i],_redo:a.slice(1)})}case n.P:return(0,n.n)(y,s,{game:r});case n.o:{const t=y,r=JSON.parse(JSON.stringify(t)),o=(0,a.applyPatch)(r,s.patch);return o.some(e=>null!==e)?((0,n.e)(`Patch ${JSON.stringify(s.patch)} apply failed`),f(t,e.PatchFailed,o)):r}default:return y}}}exports.T=y;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"rfc6902\":\"B6py\"}],\"O5av\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.fromJSON=exports.toJSON=exports.stringify=exports.parse=void 0;const{parse:t,stringify:e}=JSON,{keys:s}=Object,n=String,o=\"string\",r={},c=\"object\",l=(t,e)=>e,p=t=>t instanceof n?n(t):t,i=(t,e)=>typeof e===o?new n(e):e,a=(t,e,o,l)=>{const p=[];for(let i=s(o),{length:a}=i,f=0;f<a;f++){const s=i[f],a=o[s];if(a instanceof n){const n=t[a];typeof n!==c||e.has(n)?o[s]=l.call(o,s,n):(e.add(n),o[s]=r,p.push({k:s,a:[t,e,n,l]}))}else o[s]!==r&&(o[s]=l.call(o,s,a))}for(let{length:s}=p,n=0;n<s;n++){const{k:t,a:e}=p[n];o[t]=l.call(o,t,a.apply(null,e))}return o},f=(t,e,s)=>{const o=n(e.push(s)-1);return t.set(s,o),o},u=(e,s)=>{const n=t(e,i).map(p),o=n[0],r=s||l,f=typeof o===c&&o?a(n,new Set,o,r):o;return r.call({\"\":f},\"\",f)};exports.parse=u;const y=(t,s,n)=>{const r=s&&typeof s===c?(t,e)=>\"\"===t||-1<s.indexOf(t)?e:void 0:s||l,p=new Map,i=[],a=[];let u=+f(p,i,r.call({\"\":t},\"\",t)),y=!u;for(;u<i.length;)y=!0,a[u]=e(i[u++],x,n);return\"[\"+a.join(\",\")+\"]\";function x(t,e){if(y)return y=!y,e;const s=r.call(this,t,e);switch(typeof s){case c:if(null===s)return s;case o:return p.get(s)||f(p,i,s)}return s}};exports.stringify=y;const x=e=>t(y(e));exports.toJSON=x;const g=t=>u(e(t));exports.fromJSON=g;\n},{}],\"vgbL\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.S=n,exports.a=o,exports.R=exports.M=exports.B=void 0;var t=require(\"./turn-order-0d61594c.js\"),e=require(\"./reducer-77828ca8.js\");class a{constructor({enumerate:t,seed:e}){this.enumerateFn=t,this.seed=e,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:e,initial:a}){this._opts[t]={range:e,value:a}}getOpt(t){return this._opts[t].value}setOpt(t,e){t in this._opts&&(this._opts[t].value=e)}opts(){return this._opts}enumerate(e,a,s){return this.enumerateFn(e,a,s).map(e=>\"payload\"in e?e:\"move\"in e?(0,t.x)(e.move,e.args,s):\"event\"in e?(0,t.g)(e.event,e.args,s):void 0)}random(e){let a;if(void 0!==this.seed){const e=this.prngstate?\"\":this.seed,s=(0,t.y)(e,this.prngstate);a=s(),this.prngstate=s.state()}else a=Math.random();if(e){if(Array.isArray(e)){return e[Math.floor(a*e.length)]}return Math.floor(a*e)}return a}}exports.B=a;const s=25;class r extends a{constructor({enumerate:t,seed:a,objectives:s,game:r,iterations:i,playoutDepth:n,iterationCallback:o}){super({enumerate:t,seed:a}),void 0===s&&(s=(()=>({}))),this.objectives=s,this.iterationCallback=o||(()=>{}),this.reducer=(0,e.C)({game:r}),this.iterations=i,this.playoutDepth=n,this.addOpt({key:\"async\",initial:!1}),this.addOpt({key:\"iterations\",initial:\"number\"==typeof i?i:1e3,range:{min:1,max:2e3}}),this.addOpt({key:\"playoutDepth\",initial:\"number\"==typeof n?n:50,range:{min:1,max:100}})}createNode({state:t,parentAction:e,parent:a,playerID:s}){const{G:r,ctx:i}=t;let n=[],o=[];if(void 0!==s)n=this.enumerate(r,i,s),o=this.objectives(r,i,s);else if(i.activePlayers)for(const c in i.activePlayers)n.push(...this.enumerate(r,i,c)),o.push(this.objectives(r,i,c));else n=this.enumerate(r,i,i.currentPlayer),o=this.objectives(r,i,i.currentPlayer);return{state:t,parent:a,parentAction:e,actions:n,objectives:o,children:[],visits:0,value:0}}select(t){if(t.actions.length>0)return t;if(0===t.children.length)return t;let e=null,a=0;for(const s of t.children){const r=s.visits+Number.EPSILON,i=s.value/r+Math.sqrt(2*Math.log(t.visits)/r);(null==e||i>a)&&(a=i,e=s)}return this.select(e)}expand(t){const e=t.actions;if(0===e.length||void 0!==t.state.ctx.gameover)return t;const a=this.random(e.length),s=e[a];t.actions.splice(a,1);const r=this.reducer(t.state,s),i=this.createNode({state:r,parentAction:s,parent:t});return t.children.push(i),i}playout({state:t}){let e=this.getOpt(\"playoutDepth\");\"function\"==typeof this.playoutDepth&&(e=this.playoutDepth(t.G,t.ctx));for(let a=0;a<e&&void 0===t.ctx.gameover;a++){const{G:e,ctx:a}=t;let s=a.currentPlayer;a.activePlayers&&(s=Object.keys(a.activePlayers)[0]);const r=this.enumerate(e,a,s),i=this.objectives(e,a,s),n=Object.keys(i).reduce((t,s)=>{const r=i[s];return r.checker(e,a)?t+r.weight:t},0);if(n>0)return{score:n};if(!r||0===r.length)return;const o=this.random(r.length);t=this.reducer(t,r[o])}return t.ctx.gameover}backpropagate(t,e={}){t.visits++,void 0!==e.score&&(t.value+=e.score),!0===e.draw&&(t.value+=.5),t.parentAction&&e.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,e)}play(t,e){const a=this.createNode({state:t,playerID:e});let r=this.getOpt(\"iterations\");\"function\"==typeof this.iterations&&(r=this.iterations(t.G,t.ctx));const i=()=>{let t=null;for(const e of a.children)(null==t||e.visits>t.visits)&&(t=e);return{action:t&&t.parentAction,metadata:a}};return new Promise(t=>{const e=()=>{for(let t=0;t<s&&this.iterationCounter<r;t++){const t=this.select(a),e=this.expand(t),s=this.playout(e);this.backpropagate(e,s),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:r,metadata:a})};if(this.iterationCounter=0,this.getOpt(\"async\")){const a=()=>{this.iterationCounter<r?(e(),setTimeout(a,0)):t(i())};a()}else{for(;this.iterationCounter<r;)e();t(i())}})}}exports.M=r;class i extends a{play({G:t,ctx:e},a){const s=this.enumerate(t,e,a);return Promise.resolve({action:this.random(s)})}}async function n(t,e){const a=t.store.getState();let s=a.ctx.currentPlayer;a.ctx.activePlayers&&(s=Object.keys(a.ctx.activePlayers)[0]);const{action:r,metadata:i}=await e.play(a,s);if(r){const e={...r,payload:{...r.payload,metadata:i}};return t.store.dispatch(e),e}}async function o({game:t,bots:s,state:r,depth:i}){void 0===i&&(i=1e4);const n=(0,e.C)({game:t});let o=null,c=0;for(;void 0===r.ctx.gameover&&c<i;){let t=r.ctx.currentPlayer;r.ctx.activePlayers&&(t=Object.keys(r.ctx.activePlayers)[0]);const e=s instanceof a?s:s[t],i=await e.play(r,t);if(!i.action)break;o=i.metadata,r=n(r,i.action),c++}return{state:r,metadata:o}}exports.R=i;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\"}],\"odqP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports._=sr,exports.a=gr,exports.b=or,exports.c=ar,exports.d=rr,exports.e=fr,exports.f=nr,exports.D=void 0;var e=require(\"./turn-order-0d61594c.js\"),t=require(\"./reducer-77828ca8.js\"),n=require(\"flatted\"),r=require(\"./ai-f28cab02.js\");function l(){}const o=e=>e;function a(e,t){for(const n in t)e[n]=t[n];return e}function s(e){return e()}function i(){return Object.create(null)}function c(e){e.forEach(s)}function u(e){return\"function\"==typeof e}function d(e,t){return e!=e?t==t:e!==t||e&&\"object\"==typeof e||\"function\"==typeof e}function f(e){return 0===Object.keys(e).length}function p(e,...t){if(null==e)return l;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function m(e,t,n){e.$$.on_destroy.push(p(t,n))}function g(e,t,n,r){if(e){const l=v(e,t,n,r);return e[0](l)}}function v(e,t,n,r){return e[1]&&r?a(n.ctx.slice(),e[1](r(t))):n.ctx}function $(e,t,n,r){if(e[2]&&r){const l=e[2](r(n));if(void 0===t.dirty)return l;if(\"object\"==typeof l){const e=[],n=Math.max(t.dirty.length,l.length);for(let r=0;r<n;r+=1)e[r]=t.dirty[r]|l[r];return e}return t.dirty|l}return t.dirty}function y(e,t,n,r,l,o){if(l){const a=v(t,n,r,o);e.p(a,l)}}function h(e){if(e.ctx.length>32){const t=[],n=e.ctx.length/32;for(let e=0;e<n;e++)t[e]=-1;return t}return-1}function b(e){const t={};for(const n in e)\"$\"!==n[0]&&(t[n]=e[n]);return t}function x(e){return null==e?\"\":e}const w=\"undefined\"!=typeof window;let k=w?()=>window.performance.now():()=>Date.now(),P=w?e=>requestAnimationFrame(e):l;const j=new Set;function E(e){j.forEach(t=>{t.c(e)||(j.delete(t),t.f())}),0!==j.size&&P(E)}function O(e){let t;return 0===j.size&&P(E),{promise:new Promise(n=>{j.add(t={c:e,f:n})}),abort(){j.delete(t)}}}function A(e,t){e.appendChild(t)}function z(e,t,n){const r=_(e);if(!r.getElementById(t)){const e=M(\"style\");e.id=t,e.textContent=n,C(r,e)}}function _(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t.host?t:document}function S(e){const t=M(\"style\");return C(_(e),t),t}function C(e,t){A(e.head||e,t)}function q(e,t,n){e.insertBefore(t,n||null)}function I(e){e.parentNode.removeChild(e)}function T(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function M(e){return document.createElement(e)}function D(e){return document.createElementNS(\"http://www.w3.org/2000/svg\",e)}function N(e){return document.createTextNode(e)}function V(){return N(\" \")}function B(){return N(\"\")}function R(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function K(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function G(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function J(e){return\"\"===e?null:+e}function L(e){return Array.from(e.childNodes)}function F(e,t){t=\"\"+t,e.wholeText!==t&&(e.data=t)}function H(e,t){e.value=null==t?\"\":t}function Z(e,t){for(let n=0;n<e.options.length;n+=1){const r=e.options[n];if(r.__value===t)return void(r.selected=!0)}}function U(e){const t=e.querySelector(\":checked\")||e.options[0];return t&&t.__value}function X(e,t,n){e.classList[n?\"add\":\"remove\"](t)}function Y(e,t,n=!1){const r=document.createEvent(\"CustomEvent\");return r.initCustomEvent(e,n,!1,t),r}const W=new Set;let Q,ee=0;function te(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ne(e,t,n,r,l,o,a,s=0){const i=16.666/r;let c=\"{\\n\";for(let v=0;v<=1;v+=i){const e=t+(n-t)*o(v);c+=100*v+`%{${a(e,1-e)}}\\n`}const u=c+`100% {${a(n,1-n)}}\\n}`,d=`__svelte_${te(u)}_${s}`,f=_(e);W.add(f);const p=f.__svelte_stylesheet||(f.__svelte_stylesheet=S(e).sheet),m=f.__svelte_rules||(f.__svelte_rules={});m[d]||(m[d]=!0,p.insertRule(`@keyframes ${d} ${u}`,p.cssRules.length));const g=e.style.animation||\"\";return e.style.animation=`${g?`${g}, `:\"\"}${d} ${r}ms linear ${l}ms 1 both`,ee+=1,d}function re(e,t){const n=(e.style.animation||\"\").split(\", \"),r=n.filter(t?e=>e.indexOf(t)<0:e=>-1===e.indexOf(\"__svelte\")),l=n.length-r.length;l&&(e.style.animation=r.join(\", \"),(ee-=l)||le())}function le(){P(()=>{ee||(W.forEach(e=>{const t=e.__svelte_stylesheet;let n=t.cssRules.length;for(;n--;)t.deleteRule(n);e.__svelte_rules={}}),W.clear())})}function oe(e){Q=e}function ae(){if(!Q)throw new Error(\"Function called outside component initialization\");return Q}function se(e){ae().$$.after_update.push(e)}function ie(e){ae().$$.on_destroy.push(e)}function ce(){const e=ae();return(t,n)=>{const r=e.$$.callbacks[t];if(r){const l=Y(t,n);r.slice().forEach(t=>{t.call(e,l)})}}}function ue(e,t){ae().$$.context.set(e,t)}function de(e){return ae().$$.context.get(e)}function fe(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const pe=[],me=[],ge=[],ve=[],$e=Promise.resolve();let ye=!1;function he(){ye||(ye=!0,$e.then(ke))}function be(e){ge.push(e)}let xe=!1;const we=new Set;function ke(){if(!xe){xe=!0;do{for(let e=0;e<pe.length;e+=1){const t=pe[e];oe(t),Pe(t.$$)}for(oe(null),pe.length=0;me.length;)me.pop()();for(let e=0;e<ge.length;e+=1){const t=ge[e];we.has(t)||(we.add(t),t())}ge.length=0}while(pe.length);for(;ve.length;)ve.pop()();ye=!1,xe=!1,we.clear()}}function Pe(e){if(null!==e.fragment){e.update(),c(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(be)}}let je;function Ee(){return je||(je=Promise.resolve()).then(()=>{je=null}),je}function Oe(e,t,n){e.dispatchEvent(Y(`${t?\"intro\":\"outro\"}${n}`))}const Ae=new Set;let ze;function _e(){ze={r:0,c:[],p:ze}}function Se(){ze.r||c(ze.c),ze=ze.p}function Ce(e,t){e&&e.i&&(Ae.delete(e),e.i(t))}function qe(e,t,n,r){if(e&&e.o){if(Ae.has(e))return;Ae.add(e),ze.c.push(()=>{Ae.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}}const Ie={duration:0};function Te(e,t,n){let r,a,s=t(e,n),i=!1,c=0;function d(){r&&re(e,r)}function f(){const{delay:t=0,duration:n=300,easing:u=o,tick:f=l,css:p}=s||Ie;p&&(r=ne(e,0,1,n,t,u,p,c++)),f(0,1);const m=k()+t,g=m+n;a&&a.abort(),i=!0,be(()=>Oe(e,!0,\"start\")),a=O(t=>{if(i){if(t>=g)return f(1,0),Oe(e,!0,\"end\"),d(),i=!1;if(t>=m){const e=u((t-m)/n);f(e,1-e)}}return i})}let p=!1;return{start(){p||(p=!0,re(e),u(s)?(s=s(),Ee().then(f)):f())},invalidate(){p=!1},end(){i&&(d(),i=!1)}}}function Me(e,t,n){let r,a=t(e,n),s=!0;const i=ze;function d(){const{delay:t=0,duration:n=300,easing:u=o,tick:d=l,css:f}=a||Ie;f&&(r=ne(e,1,0,n,t,u,f));const p=k()+t,m=p+n;be(()=>Oe(e,!1,\"start\")),O(t=>{if(s){if(t>=m)return d(0,1),Oe(e,!1,\"end\"),--i.r||c(i.c),!1;if(t>=p){const e=u((t-p)/n);d(1-e,e)}}return s})}return i.r+=1,u(a)?Ee().then(()=>{a=a(),d()}):d(),{end(t){t&&a.tick&&a.tick(1,0),s&&(r&&re(e,r),s=!1)}}}function De(e,t,n,r){let a=t(e,n),s=r?0:1,i=null,d=null,f=null;function p(){f&&re(e,f)}function m(e,t){const n=e.b-s;return t*=Math.abs(n),{a:s,b:e.b,d:n,duration:t,start:e.start,end:e.start+t,group:e.group}}function g(t){const{delay:n=0,duration:r=300,easing:u=o,tick:g=l,css:v}=a||Ie,$={start:k()+n,b:t};t||($.group=ze,ze.r+=1),i||d?d=$:(v&&(p(),f=ne(e,s,t,r,n,u,v)),t&&g(0,1),i=m($,r),be(()=>Oe(e,t,\"start\")),O(t=>{if(d&&t>d.start&&(i=m(d,r),d=null,Oe(e,i.b,\"start\"),v&&(p(),f=ne(e,s,i.b,i.duration,0,u,a.css))),i)if(t>=i.end)g(s=i.b,1-s),Oe(e,i.b,\"end\"),d||(i.b?p():--i.group.r||c(i.group.c)),i=null;else if(t>=i.start){const e=t-i.start;s=i.a+i.d*u(e/i.duration),g(s,1-s)}return!(!i&&!d)}))}return{run(e){u(a)?Ee().then(()=>{a=a(),g(e)}):g(e)},end(){p(),i=d=null}}}function Ne(e,t){const n={},r={},l={$$scope:1};let o=e.length;for(;o--;){const a=e[o],s=t[o];if(s){for(const e in a)e in s||(r[e]=1);for(const e in s)l[e]||(n[e]=s[e],l[e]=1);e[o]=s}else for(const e in a)l[e]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ve(e){return\"object\"==typeof e&&null!==e?e:{}}function Be(e){e&&e.c()}function Re(e,t,n,r){const{fragment:l,on_mount:o,on_destroy:a,after_update:i}=e.$$;l&&l.m(t,n),r||be(()=>{const t=o.map(s).filter(u);a?a.push(...t):c(t),e.$$.on_mount=[]}),i.forEach(be)}function Ke(e,t){const n=e.$$;null!==n.fragment&&(c(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ge(e,t){-1===e.$$.dirty[0]&&(pe.push(e),he(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,n,r,o,a,s,u=[-1]){const d=Q;oe(e);const f=e.$$={fragment:null,ctx:null,props:a,update:l,not_equal:o,bound:i(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:t.context||[]),callbacks:i(),dirty:u,skip_bound:!1,root:t.target||d.$$.root};s&&s(f.root);let p=!1;if(f.ctx=n?n(e,t.props||{},(t,n,...r)=>{const l=r.length?r[0]:n;return f.ctx&&o(f.ctx[t],f.ctx[t]=l)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](l),p&&Ge(e,t)),n}):[],f.update(),p=!0,c(f.before_update),f.fragment=!!r&&r(f.ctx),t.target){if(t.hydrate){const e=L(t.target);f.fragment&&f.fragment.l(e),e.forEach(I)}else f.fragment&&f.fragment.c();t.intro&&Ce(e.$$.fragment),Re(e,t.target,t.anchor,t.customElement),ke()}oe(d)}class Le{$destroy(){Ke(this,1),this.$destroy=l}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&!f(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Fe=[];function He(e,t=l){let n;const r=new Set;function o(t){if(d(e,t)&&(e=t,n)){const t=!Fe.length;for(const n of r)n[1](),Fe.push(n,e);if(t){for(let e=0;e<Fe.length;e+=2)Fe[e][0](Fe[e+1]);Fe.length=0}}}return{set:o,update:function(t){o(t(e))},subscribe:function(a,s=l){const i=[a,s];return r.add(i),1===r.size&&(n=t(o)||l),a(e),()=>{r.delete(i),0===r.size&&(n(),n=null)}}}}function Ze(e){const t=e-1;return t*t*t+1}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&\"function\"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)t.indexOf(r[l])<0&&Object.prototype.propertyIsEnumerable.call(e,r[l])&&(n[r[l]]=e[r[l]])}return n}function Xe(e,{delay:t=0,duration:n=400,easing:r=Ze,x:l=0,y:o=0,opacity:a=0}={}){const s=getComputedStyle(e),i=+s.opacity,c=\"none\"===s.transform?\"\":s.transform,u=i*(1-a);return{delay:t,duration:n,easing:r,css:(e,t)=>`\\n\\t\\t\\ttransform: ${c} translate(${(1-e)*l}px, ${(1-e)*o}px);\\n\\t\\t\\topacity: ${i-u*t}`}}function Ye(e){var{fallback:t}=e,n=Ue(e,[\"fallback\"]);const r=new Map,l=new Map;function o(e,r,l){return(o,s)=>(e.set(s.key,{rect:o.getBoundingClientRect()}),()=>{if(r.has(s.key)){const{rect:e}=r.get(s.key);return r.delete(s.key),function(e,t,r){const{delay:l=0,duration:o=(e=>30*Math.sqrt(e)),easing:s=Ze}=a(a({},n),r),i=t.getBoundingClientRect(),c=e.left-i.left,d=e.top-i.top,f=e.width/i.width,p=e.height/i.height,m=Math.sqrt(c*c+d*d),g=getComputedStyle(t),v=\"none\"===g.transform?\"\":g.transform,$=+g.opacity;return{delay:l,duration:u(o)?o(m):o,easing:s,css:(e,t)=>`\\n\\t\\t\\t\\topacity: ${e*$};\\n\\t\\t\\t\\ttransform-origin: top left;\\n\\t\\t\\t\\ttransform: ${v} translate(${t*c}px,${t*d}px) scale(${e+(1-e)*f}, ${e+(1-e)*p});\\n\\t\\t\\t`}}(e,o,s)}return e.delete(s.key),t&&t(o,s,l)})}return[o(l,r,!1),o(r,l,!0)]}function We(e){z(e,\"svelte-c8tyih\",\"svg.svelte-c8tyih{stroke:currentColor;fill:currentColor;stroke-width:0;width:100%;height:auto;max-height:100%}\")}function Qe(e){let t,n;return{c(){t=D(\"title\"),n=N(e[0])},m(e,r){q(e,t,r),A(t,n)},p(e,t){1&t&&F(n,e[0])},d(e){e&&I(t)}}}function et(e){let t,n,r,l=e[0]&&Qe(e);const o=e[3].default,a=g(o,e,e[2],null);return{c(){t=D(\"svg\"),l&&l.c(),n=B(),a&&a.c(),G(t,\"xmlns\",\"http://www.w3.org/2000/svg\"),G(t,\"viewBox\",e[1]),G(t,\"class\",\"svelte-c8tyih\")},m(e,o){q(e,t,o),l&&l.m(t,null),A(t,n),a&&a.m(t,null),r=!0},p(e,[s]){e[0]?l?l.p(e,s):((l=Qe(e)).c(),l.m(t,n)):l&&(l.d(1),l=null),a&&a.p&&(!r||4&s)&&y(a,o,e,e[2],r?$(o,e[2],s,null):h(e[2]),null),(!r||2&s)&&G(t,\"viewBox\",e[1])},i(e){r||(Ce(a,e),r=!0)},o(e){qe(a,e),r=!1},d(e){e&&I(t),l&&l.d(),a&&a.d(e)}}}function tt(e,t,n){let{$$slots:r={},$$scope:l}=t,{title:o=null}=t,{viewBox:a}=t;return e.$$set=(e=>{\"title\"in e&&n(0,o=e.title),\"viewBox\"in e&&n(1,a=e.viewBox),\"$$scope\"in e&&n(2,l=e.$$scope)}),[o,a,l,r]}class nt extends Le{constructor(e){super(),Je(this,e,tt,et,d,{title:0,viewBox:1},We)}}function rt(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function lt(e){let t,n;const r=[{viewBox:\"0 0 320 512\"},e[0]];let l={$$slots:{default:[rt]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ot(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class at extends Le{constructor(e){super(),Je(this,e,ot,lt,d,{})}}function st(e){z(e,\"svelte-1scv1e1\",\".menu.svelte-1scv1e1{display:flex;flex-direction:row-reverse;border:1px solid #ccc;border-radius:5px 5px 0 0;height:25px;line-height:25px;transform-origin:top right;transform:rotate(-90deg) /* 2 */ translateY(-27px) /* 3 */ translateX(-70px)}.menu-item.svelte-1scv1e1{line-height:25px;cursor:pointer;border:0;background:#fefefe;color:#555;padding-left:15px;padding-right:15px;text-align:center}.menu-item.svelte-1scv1e1:first-child{border-radius:0 5px 0 0}.menu-item.svelte-1scv1e1:last-child{border-radius:5px 0 0 0}.menu-item.active.svelte-1scv1e1{cursor:default;font-weight:bold;background:#ddd;color:#555}.menu-item.svelte-1scv1e1:hover,.menu-item.svelte-1scv1e1:focus{background:#eee;color:#555}\")}function it(e,t,n){const r=e.slice();return r[4]=t[n][0],r[5]=t[n][1].label,r}function ct(e){let t,n,r,l,o,a=e[5]+\"\";function s(){return e[3](e[4])}return{c(){t=M(\"button\"),n=N(a),r=V(),G(t,\"class\",\"menu-item svelte-1scv1e1\"),X(t,\"active\",e[0]==e[4])},m(e,a){q(e,t,a),A(t,n),A(t,r),l||(o=R(t,\"click\",s),l=!0)},p(r,l){e=r,2&l&&a!==(a=e[5]+\"\")&&F(n,a),3&l&&X(t,\"active\",e[0]==e[4])},d(e){e&&I(t),l=!1,o()}}}function ut(e){let t,n=Object.entries(e[1]),r=[];for(let l=0;l<n.length;l+=1)r[l]=ct(it(e,n,l));return{c(){t=M(\"nav\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"menu svelte-1scv1e1\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[1]),o=0;o<n.length;o+=1){const a=it(e,n,o);r[o]?r[o].p(a,l):(r[o]=ct(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function dt(e,t,n){let{pane:r}=t,{panes:l}=t;const o=ce();return e.$$set=(e=>{\"pane\"in e&&n(0,r=e.pane),\"panes\"in e&&n(1,l=e.panes)}),[r,l,o,e=>o(\"change\",e)]}class ft extends Le{constructor(e){super(),Je(this,e,dt,ut,d,{pane:0,panes:1},st)}}var pt={};function mt(e){z(e,\"svelte-1vyml86\",\".container.svelte-1vyml86{display:inline-block;cursor:pointer;transform:translate(calc(0px - var(--li-identation)), -50%);position:absolute;top:50%;padding-right:100%}.arrow.svelte-1vyml86{transform-origin:25% 50%;position:relative;line-height:1.1em;font-size:0.75em;margin-left:0;transition:150ms;color:var(--arrow-sign);user-select:none;font-family:'Courier New', Courier, monospace}.expanded.svelte-1vyml86{transform:rotateZ(90deg) translateX(-3px)}\")}function gt(e){let t,n,r,o;return{c(){t=M(\"div\"),(n=M(\"div\")).textContent=\"▶\",G(n,\"class\",\"arrow svelte-1vyml86\"),X(n,\"expanded\",e[0]),G(t,\"class\",\"container svelte-1vyml86\")},m(l,a){q(l,t,a),A(t,n),r||(o=R(t,\"click\",e[1]),r=!0)},p(e,[t]){1&t&&X(n,\"expanded\",e[0])},i:l,o:l,d(e){e&&I(t),r=!1,o()}}}function vt(e,t,n){let{expanded:r}=t;return e.$$set=(e=>{\"expanded\"in e&&n(0,r=e.expanded)}),[r,function(t){fe.call(this,e,t)}]}class $t extends Le{constructor(e){super(),Je(this,e,vt,gt,d,{expanded:0},mt)}}function yt(e){z(e,\"svelte-1vlbacg\",\"label.svelte-1vlbacg{display:inline-block;color:var(--label-color);padding:0}.spaced.svelte-1vlbacg{padding-right:var(--li-colon-space)}\")}function ht(e){let t,n,r,l,o,a;return{c(){t=M(\"label\"),n=M(\"span\"),r=N(e[0]),l=N(e[2]),G(t,\"class\",\"svelte-1vlbacg\"),X(t,\"spaced\",e[1])},m(s,i){q(s,t,i),A(t,n),A(n,r),A(n,l),o||(a=R(t,\"click\",e[5]),o=!0)},p(e,n){1&n&&F(r,e[0]),4&n&&F(l,e[2]),2&n&&X(t,\"spaced\",e[1])},d(e){e&&I(t),o=!1,a()}}}function bt(e){let t,n=e[3]&&e[0]&&ht(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[3]&&e[0]?n?n.p(e,r):((n=ht(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}function xt(e,t,n){let r,{key:l,isParentExpanded:o,isParentArray:a=!1,colon:s=\":\"}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(4,a=e.isParentArray),\"colon\"in e&&n(2,s=e.colon)}),e.$$.update=(()=>{19&e.$$.dirty&&n(3,r=o||!a||l!=+l)}),[l,o,s,r,a,function(t){fe.call(this,e,t)}]}class wt extends Le{constructor(e){super(),Je(this,e,xt,bt,d,{key:0,isParentExpanded:1,isParentArray:4,colon:2},yt)}}function kt(e){z(e,\"svelte-rwxv37\",\"label.svelte-rwxv37{display:inline-block}.indent.svelte-rwxv37{padding-left:var(--li-identation)}.collapse.svelte-rwxv37{--li-display:inline;display:inline;font-style:italic}.comma.svelte-rwxv37{margin-left:-0.5em;margin-right:0.5em}label.svelte-rwxv37{position:relative}\")}function Pt(e,t,n){const r=e.slice();return r[12]=t[n],r[20]=n,r}function jt(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[15]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Et(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Ot(e){let t,n,r,l,o,a=e[13],s=[];for(let u=0;u<a.length;u+=1)s[u]=zt(Pt(e,a,u));const i=e=>qe(s[e],1,1,()=>{s[e]=null});let c=e[13].length<e[7].length&&_t();return{c(){t=M(\"ul\");for(let e=0;e<s.length;e+=1)s[e].c();n=V(),c&&c.c(),G(t,\"class\",\"svelte-rwxv37\"),X(t,\"collapse\",!e[0])},m(a,i){q(a,t,i);for(let e=0;e<s.length;e+=1)s[e].m(t,null);A(t,n),c&&c.m(t,null),r=!0,l||(o=R(t,\"click\",e[16]),l=!0)},p(e,r){if(10129&r){let l;for(a=e[13],l=0;l<a.length;l+=1){const o=Pt(e,a,l);s[l]?(s[l].p(o,r),Ce(s[l],1)):(s[l]=zt(o),s[l].c(),Ce(s[l],1),s[l].m(t,n))}for(_e(),l=a.length;l<s.length;l+=1)i(l);Se()}e[13].length<e[7].length?c||((c=_t()).c(),c.m(t,null)):c&&(c.d(1),c=null),1&r&&X(t,\"collapse\",!e[0])},i(e){if(!r){for(let e=0;e<a.length;e+=1)Ce(s[e]);r=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);r=!1},d(e){e&&I(t),T(s,e),c&&c.d(),l=!1,o()}}}function At(e){let t;return{c(){(t=M(\"span\")).textContent=\",\",G(t,\"class\",\"comma svelte-rwxv37\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function zt(e){let t,n,r,l;t=new $n({props:{key:e[8](e[12]),isParentExpanded:e[0],isParentArray:e[4],value:e[0]?e[9](e[12]):e[10](e[12])}});let o=!e[0]&&e[20]<e[7].length-1&&At();return{c(){Be(t.$$.fragment),n=V(),o&&o.c(),r=B()},m(e,a){Re(t,e,a),q(e,n,a),o&&o.m(e,a),q(e,r,a),l=!0},p(e,n){const l={};8448&n&&(l.key=e[8](e[12])),1&n&&(l.isParentExpanded=e[0]),16&n&&(l.isParentArray=e[4]),9729&n&&(l.value=e[0]?e[9](e[12]):e[10](e[12])),t.$set(l),!e[0]&&e[20]<e[7].length-1?o||((o=At()).c(),o.m(r.parentNode,r)):o&&(o.d(1),o=null)},i(e){l||(Ce(t.$$.fragment,e),l=!0)},o(e){qe(t.$$.fragment,e),l=!1},d(e){Ke(t,e),e&&I(n),o&&o.d(e),e&&I(r)}}}function _t(e){let t;return{c(){(t=M(\"span\")).textContent=\"…\"},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function St(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h=e[11]&&e[2]&&jt(e);(l=new wt({props:{key:e[12],colon:e[14].colon,isParentExpanded:e[2],isParentArray:e[3]}})).$on(\"click\",e[15]);const b=[Ot,Et],x=[];function w(e,t){return e[2]?0:1}return d=w(e),f=x[d]=b[d](e),{c(){t=M(\"li\"),n=M(\"label\"),h&&h.c(),r=V(),Be(l.$$.fragment),o=V(),a=M(\"span\"),s=M(\"span\"),i=N(e[1]),c=N(e[5]),u=V(),f.c(),p=V(),m=M(\"span\"),g=N(e[6]),G(n,\"class\",\"svelte-rwxv37\"),G(t,\"class\",\"svelte-rwxv37\"),X(t,\"indent\",e[2])},m(f,b){q(f,t,b),A(t,n),h&&h.m(n,null),A(n,r),Re(l,n,null),A(n,o),A(n,a),A(a,s),A(s,i),A(a,c),A(t,u),x[d].m(t,null),A(t,p),A(t,m),A(m,g),v=!0,$||(y=R(a,\"click\",e[15]),$=!0)},p(e,[o]){e[11]&&e[2]?h?(h.p(e,o),2052&o&&Ce(h,1)):((h=jt(e)).c(),Ce(h,1),h.m(n,r)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se());const a={};4096&o&&(a.key=e[12]),4&o&&(a.isParentExpanded=e[2]),8&o&&(a.isParentArray=e[3]),l.$set(a),(!v||2&o)&&F(i,e[1]),(!v||32&o)&&F(c,e[5]);let s=d;(d=w(e))===s?x[d].p(e,o):(_e(),qe(x[s],1,1,()=>{x[s]=null}),Se(),(f=x[d])?f.p(e,o):(f=x[d]=b[d](e)).c(),Ce(f,1),f.m(t,p)),(!v||64&o)&&F(g,e[6]),4&o&&X(t,\"indent\",e[2])},i(e){v||(Ce(h),Ce(l.$$.fragment,e),Ce(f),v=!0)},o(e){qe(h),qe(l.$$.fragment,e),qe(f),v=!1},d(e){e&&I(t),h&&h.d(),Ke(l),x[d].d(),$=!1,y()}}}function Ct(e,t,n){let r,{key:l,keys:o,colon:a=\":\",label:s=\"\",isParentExpanded:i,isParentArray:c,isArray:u=!1,bracketOpen:d,bracketClose:f}=t,{previewKeys:p=o}=t,{getKey:m=(e=>e)}=t,{getValue:g=(e=>e)}=t,{getPreviewValue:v=g}=t,{expanded:$=!1,expandable:y=!0}=t;const h=de(pt);return ue(pt,{...h,colon:a}),e.$$set=(e=>{\"key\"in e&&n(12,l=e.key),\"keys\"in e&&n(17,o=e.keys),\"colon\"in e&&n(18,a=e.colon),\"label\"in e&&n(1,s=e.label),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray),\"isArray\"in e&&n(4,u=e.isArray),\"bracketOpen\"in e&&n(5,d=e.bracketOpen),\"bracketClose\"in e&&n(6,f=e.bracketClose),\"previewKeys\"in e&&n(7,p=e.previewKeys),\"getKey\"in e&&n(8,m=e.getKey),\"getValue\"in e&&n(9,g=e.getValue),\"getPreviewValue\"in e&&n(10,v=e.getPreviewValue),\"expanded\"in e&&n(0,$=e.expanded),\"expandable\"in e&&n(11,y=e.expandable)}),e.$$.update=(()=>{4&e.$$.dirty&&(i||n(0,$=!1)),131201&e.$$.dirty&&n(13,r=$?o:p.slice(0,5))}),[$,s,i,c,u,d,f,p,m,g,v,y,l,r,h,function(){n(0,$=!$)},function(){n(0,$=!0)},o,a]}class qt extends Le{constructor(e){super(),Je(this,e,Ct,St,d,{key:12,keys:17,colon:18,label:1,isParentExpanded:2,isParentArray:3,isArray:4,bracketOpen:5,bracketClose:6,previewKeys:7,getKey:8,getValue:9,getPreviewValue:10,expanded:0,expandable:11},kt)}}function It(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[1],isParentArray:e[2],keys:e[5],previewKeys:e[5],getValue:e[6],label:e[3]+\" \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),32&n&&(r.keys=e[5]),32&n&&(r.previewKeys=e[5]),8&n&&(r.label=e[3]+\" \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Tt(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s,nodeType:i}=t,{expanded:c=!0}=t;return e.$$set=(e=>{\"key\"in e&&n(0,l=e.key),\"value\"in e&&n(7,o=e.value),\"isParentExpanded\"in e&&n(1,a=e.isParentExpanded),\"isParentArray\"in e&&n(2,s=e.isParentArray),\"nodeType\"in e&&n(3,i=e.nodeType),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{128&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(o))}),[l,a,s,i,c,r,function(e){return o[e]},o]}class Mt extends Le{constructor(e){super(),Je(this,e,Tt,It,d,{key:0,value:7,isParentExpanded:1,isParentArray:2,nodeType:3,expanded:4})}}function Dt(e){let t,n;return t=new qt({props:{key:e[0],expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],isArray:!0,keys:e[5],previewKeys:e[6],getValue:e[7],label:\"Array(\"+e[1].length+\")\",bracketOpen:\"[\",bracketClose:\"]\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),32&n&&(r.keys=e[5]),64&n&&(r.previewKeys=e[6]),2&n&&(r.label=\"Array(\"+e[1].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Nt(e,t,n){let r,l,{key:o,value:a,isParentExpanded:s,isParentArray:i}=t,{expanded:c=JSON.stringify(a).length<1024}=t;const u=new Set([\"length\"]);return e.$$set=(e=>{\"key\"in e&&n(0,o=e.key),\"value\"in e&&n(1,a=e.value),\"isParentExpanded\"in e&&n(2,s=e.isParentExpanded),\"isParentArray\"in e&&n(3,i=e.isParentArray),\"expanded\"in e&&n(4,c=e.expanded)}),e.$$.update=(()=>{2&e.$$.dirty&&n(5,r=Object.getOwnPropertyNames(a)),32&e.$$.dirty&&n(6,l=r.filter(e=>!u.has(e)))}),[o,a,s,i,c,r,l,function(e){return a[e]}]}class Vt extends Le{constructor(e){super(),Je(this,e,Nt,Dt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function Bt(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Rt,getValue:Kt,isArray:!0,label:e[3]+\"(\"+e[4].length+\")\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Rt(e){return String(e[0])}function Kt(e){return e[1]}function Gt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,n]);n(4,i=e)}}),[r,o,a,s,i,l]}class Jt extends Le{constructor(e){super(),Je(this,e,Gt,Bt,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}class Lt{constructor(e,t){this.key=e,this.value=t}}function Ft(e){let t,n;return t=new qt({props:{key:e[0],isParentExpanded:e[1],isParentArray:e[2],keys:e[4],getKey:Ht,getValue:Zt,label:e[3]+\"(\"+e[4].length+\")\",colon:\"\",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};1&n&&(r.key=e[0]),2&n&&(r.isParentExpanded=e[1]),4&n&&(r.isParentArray=e[2]),16&n&&(r.keys=e[4]),24&n&&(r.label=e[3]+\"(\"+e[4].length+\")\"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Ht(e){return e[0]}function Zt(e){return e[1]}function Ut(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a,nodeType:s}=t,i=[];return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(5,l=e.value),\"isParentExpanded\"in e&&n(1,o=e.isParentExpanded),\"isParentArray\"in e&&n(2,a=e.isParentArray),\"nodeType\"in e&&n(3,s=e.nodeType)}),e.$$.update=(()=>{if(32&e.$$.dirty){let e=[],t=0;for(const n of l)e.push([t++,new Lt(n[0],n[1])]);n(4,i=e)}}),[r,o,a,s,i,l]}class Xt extends Le{constructor(e){super(),Je(this,e,Ut,Ft,d,{key:0,value:5,isParentExpanded:1,isParentArray:2,nodeType:3})}}function Yt(e){let t,n;return t=new qt({props:{expanded:e[4],isParentExpanded:e[2],isParentArray:e[3],key:e[2]?String(e[0]):e[1].key,keys:e[5],getValue:e[6],label:e[2]?\"Entry \":\"=> \",bracketOpen:\"{\",bracketClose:\"}\"}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const r={};16&n&&(r.expanded=e[4]),4&n&&(r.isParentExpanded=e[2]),8&n&&(r.isParentArray=e[3]),7&n&&(r.key=e[2]?String(e[0]):e[1].key),4&n&&(r.label=e[2]?\"Entry \":\"=> \"),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Wt(e,t,n){let{key:r,value:l,isParentExpanded:o,isParentArray:a}=t,{expanded:s=!1}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"isParentExpanded\"in e&&n(2,o=e.isParentExpanded),\"isParentArray\"in e&&n(3,a=e.isParentArray),\"expanded\"in e&&n(4,s=e.expanded)}),[r,l,o,a,s,[\"key\",\"value\"],function(e){return l[e]}]}class Qt extends Le{constructor(e){super(),Je(this,e,Wt,Yt,d,{key:0,value:1,isParentExpanded:2,isParentArray:3,expanded:4})}}function en(e){z(e,\"svelte-3bjyvl\",\"li.svelte-3bjyvl{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-3bjyvl{padding-left:var(--li-identation)}.String.svelte-3bjyvl{color:var(--string-color)}.Date.svelte-3bjyvl{color:var(--date-color)}.Number.svelte-3bjyvl{color:var(--number-color)}.Boolean.svelte-3bjyvl{color:var(--boolean-color)}.Null.svelte-3bjyvl{color:var(--null-color)}.Undefined.svelte-3bjyvl{color:var(--undefined-color)}.Function.svelte-3bjyvl{color:var(--function-color);font-style:italic}.Symbol.svelte-3bjyvl{color:var(--symbol-color)}\")}function tn(e){let t,n,r,l,o,a,s,i=(e[2]?e[2](e[1]):e[1])+\"\";return n=new wt({props:{key:e[0],colon:e[6],isParentExpanded:e[3],isParentArray:e[4]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),l=M(\"span\"),o=N(i),G(l,\"class\",a=x(e[5])+\" svelte-3bjyvl\"),G(t,\"class\",\"svelte-3bjyvl\"),X(t,\"indent\",e[3])},m(e,a){q(e,t,a),Re(n,t,null),A(t,r),A(t,l),A(l,o),s=!0},p(e,[r]){const c={};1&r&&(c.key=e[0]),8&r&&(c.isParentExpanded=e[3]),16&r&&(c.isParentArray=e[4]),n.$set(c),(!s||6&r)&&i!==(i=(e[2]?e[2](e[1]):e[1])+\"\")&&F(o,i),(!s||32&r&&a!==(a=x(e[5])+\" svelte-3bjyvl\"))&&G(l,\"class\",a),8&r&&X(t,\"indent\",e[3])},i(e){s||(Ce(n.$$.fragment,e),s=!0)},o(e){qe(n.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(n)}}}function nn(e,t,n){let{key:r,value:l,valueGetter:o=null,isParentExpanded:a,isParentArray:s,nodeType:i}=t;const{colon:c}=de(pt);return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value),\"valueGetter\"in e&&n(2,o=e.valueGetter),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"nodeType\"in e&&n(5,i=e.nodeType)}),[r,l,o,a,s,i,c]}class rn extends Le{constructor(e){super(),Je(this,e,nn,tn,d,{key:0,value:1,valueGetter:2,isParentExpanded:3,isParentArray:4,nodeType:5},en)}}function ln(e){z(e,\"svelte-1ca3gb2\",\"li.svelte-1ca3gb2{user-select:text;word-wrap:break-word;word-break:break-all}.indent.svelte-1ca3gb2{padding-left:var(--li-identation)}.collapse.svelte-1ca3gb2{--li-display:inline;display:inline;font-style:italic}\")}function on(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function an(e){let t,n;return(t=new $t({props:{expanded:e[0]}})).$on(\"click\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};1&n&&(r.expanded=e[0]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function sn(e){let t,n,r=e[0]&&cn(e);return{c(){t=M(\"ul\"),r&&r.c(),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"collapse\",!e[0])},m(e,l){q(e,t,l),r&&r.m(t,null),n=!0},p(e,n){e[0]?r?(r.p(e,n),1&n&&Ce(r,1)):((r=cn(e)).c(),Ce(r,1),r.m(t,null)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se()),1&n&&X(t,\"collapse\",!e[0])},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){e&&I(t),r&&r.d()}}}function cn(e){let t,n,r,l,o,a,s;t=new $n({props:{key:\"message\",value:e[2].message}}),l=new wt({props:{key:\"stack\",colon:\":\",isParentExpanded:e[3]}});let i=e[5],c=[];for(let u=0;u<i.length;u+=1)c[u]=un(on(e,i,u));return{c(){Be(t.$$.fragment),n=V(),r=M(\"li\"),Be(l.$$.fragment),o=V(),a=M(\"span\");for(let e=0;e<c.length;e+=1)c[e].c();G(r,\"class\",\"svelte-1ca3gb2\")},m(e,i){Re(t,e,i),q(e,n,i),q(e,r,i),Re(l,r,null),A(r,o),A(r,a);for(let t=0;t<c.length;t+=1)c[t].m(a,null);s=!0},p(e,n){const r={};4&n&&(r.value=e[2].message),t.$set(r);const o={};if(8&n&&(o.isParentExpanded=e[3]),l.$set(o),32&n){let t;for(i=e[5],t=0;t<i.length;t+=1){const r=on(e,i,t);c[t]?c[t].p(r,n):(c[t]=un(r),c[t].c(),c[t].m(a,null))}for(;t<c.length;t+=1)c[t].d(1);c.length=i.length}},i(e){s||(Ce(t.$$.fragment,e),Ce(l.$$.fragment,e),s=!0)},o(e){qe(t.$$.fragment,e),qe(l.$$.fragment,e),s=!1},d(e){Ke(t,e),e&&I(n),e&&I(r),Ke(l),T(c,e)}}}function un(e){let t,n,r,l=e[8]+\"\";return{c(){t=M(\"span\"),n=N(l),r=M(\"br\"),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"indent\",e[10]>0)},m(e,l){q(e,t,l),A(t,n),q(e,r,l)},p(e,t){32&t&&l!==(l=e[8]+\"\")&&F(n,l)},d(e){e&&I(t),e&&I(r)}}}function dn(e){let t,n,r,l,o,a,s,i,c,u,d,f=(e[0]?\"\":e[2].message)+\"\",p=e[3]&&an(e);r=new wt({props:{key:e[1],colon:e[6].colon,isParentExpanded:e[3],isParentArray:e[4]}});let m=e[3]&&sn(e);return{c(){t=M(\"li\"),p&&p.c(),n=V(),Be(r.$$.fragment),l=V(),o=M(\"span\"),a=N(\"Error: \"),s=N(f),i=V(),m&&m.c(),G(t,\"class\",\"svelte-1ca3gb2\"),X(t,\"indent\",e[3])},m(f,g){q(f,t,g),p&&p.m(t,null),A(t,n),Re(r,t,null),A(t,l),A(t,o),A(o,a),A(o,s),A(t,i),m&&m.m(t,null),c=!0,u||(d=R(o,\"click\",e[7]),u=!0)},p(e,[l]){e[3]?p?(p.p(e,l),8&l&&Ce(p,1)):((p=an(e)).c(),Ce(p,1),p.m(t,n)):p&&(_e(),qe(p,1,1,()=>{p=null}),Se());const o={};2&l&&(o.key=e[1]),8&l&&(o.isParentExpanded=e[3]),16&l&&(o.isParentArray=e[4]),r.$set(o),(!c||5&l)&&f!==(f=(e[0]?\"\":e[2].message)+\"\")&&F(s,f),e[3]?m?(m.p(e,l),8&l&&Ce(m,1)):((m=sn(e)).c(),Ce(m,1),m.m(t,null)):m&&(_e(),qe(m,1,1,()=>{m=null}),Se()),8&l&&X(t,\"indent\",e[3])},i(e){c||(Ce(p),Ce(r.$$.fragment,e),Ce(m),c=!0)},o(e){qe(p),qe(r.$$.fragment,e),qe(m),c=!1},d(e){e&&I(t),p&&p.d(),Ke(r),m&&m.d(),u=!1,d()}}}function fn(e,t,n){let r,{key:l,value:o,isParentExpanded:a,isParentArray:s}=t,{expanded:i=!1}=t;const c=de(pt);return ue(pt,{...c,colon:\":\"}),e.$$set=(e=>{\"key\"in e&&n(1,l=e.key),\"value\"in e&&n(2,o=e.value),\"isParentExpanded\"in e&&n(3,a=e.isParentExpanded),\"isParentArray\"in e&&n(4,s=e.isParentArray),\"expanded\"in e&&n(0,i=e.expanded)}),e.$$.update=(()=>{4&e.$$.dirty&&n(5,r=o.stack.split(\"\\n\")),8&e.$$.dirty&&(a||n(0,i=!1))}),[i,l,o,a,s,r,c,function(){n(0,i=!i)}]}class pn extends Le{constructor(e){super(),Je(this,e,fn,dn,d,{key:1,value:2,isParentExpanded:3,isParentArray:4,expanded:0},ln)}}function mn(e){const t=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===t?\"function\"==typeof e[Symbol.iterator]?\"Iterable\":e.constructor.name:t}function gn(e){let t,n,r;var l=e[6];function o(e){return{props:{key:e[0],value:e[1],isParentExpanded:e[2],isParentArray:e[3],nodeType:e[4],valueGetter:e[5]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,[r]){const a={};if(1&r&&(a.key=e[0]),2&r&&(a.value=e[1]),4&r&&(a.isParentExpanded=e[2]),8&r&&(a.isParentArray=e[3]),16&r&&(a.nodeType=e[4]),32&r&&(a.valueGetter=e[5]),l!==(l=e[6])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function vn(e,t,n){let r,l,o,{key:a,value:s,isParentExpanded:i,isParentArray:c}=t;return e.$$set=(e=>{\"key\"in e&&n(0,a=e.key),\"value\"in e&&n(1,s=e.value),\"isParentExpanded\"in e&&n(2,i=e.isParentExpanded),\"isParentArray\"in e&&n(3,c=e.isParentArray)}),e.$$.update=(()=>{2&e.$$.dirty&&n(4,r=mn(s)),16&e.$$.dirty&&n(6,l=function(e){switch(e){case\"Object\":return Mt;case\"Error\":return pn;case\"Array\":return Vt;case\"Iterable\":case\"Map\":case\"Set\":return\"function\"==typeof s.set?Xt:Jt;case\"MapEntry\":return Qt;default:return rn}}(r)),16&e.$$.dirty&&n(5,o=function(e){switch(e){case\"Object\":case\"Error\":case\"Array\":case\"Iterable\":case\"Map\":case\"Set\":case\"MapEntry\":case\"Number\":return;case\"String\":return e=>`\"${e}\"`;case\"Boolean\":return e=>e?\"true\":\"false\";case\"Date\":return e=>e.toISOString();case\"Null\":return()=>\"null\";case\"Undefined\":return()=>\"undefined\";case\"Function\":case\"Symbol\":return e=>e.toString();default:return()=>`<${e}>`}}(r))}),[a,s,i,c,r,o,l]}class $n extends Le{constructor(e){super(),Je(this,e,vn,gn,d,{key:0,value:1,isParentExpanded:2,isParentArray:3})}}function yn(e){z(e,\"svelte-773n60\",\"ul.svelte-773n60{--string-color:var(--json-tree-string-color, #cb3f41);--symbol-color:var(--json-tree-symbol-color, #cb3f41);--boolean-color:var(--json-tree-boolean-color, #112aa7);--function-color:var(--json-tree-function-color, #112aa7);--number-color:var(--json-tree-number-color, #3029cf);--label-color:var(--json-tree-label-color, #871d8f);--arrow-color:var(--json-tree-arrow-color, #727272);--null-color:var(--json-tree-null-color, #8d8d8d);--undefined-color:var(--json-tree-undefined-color, #8d8d8d);--date-color:var(--json-tree-date-color, #8d8d8d);--li-identation:var(--json-tree-li-indentation, 1em);--li-line-height:var(--json-tree-li-line-height, 1.3);--li-colon-space:0.3em;font-size:var(--json-tree-font-size, 12px);font-family:var(--json-tree-font-family, 'Courier New', Courier, monospace)}ul.svelte-773n60 li{line-height:var(--li-line-height);display:var(--li-display, list-item);list-style:none}ul.svelte-773n60,ul.svelte-773n60 ul{padding:0;margin:0}\")}function hn(e){let t,n,r;return n=new $n({props:{key:e[0],value:e[1],isParentExpanded:!0,isParentArray:!1}}),{c(){t=M(\"ul\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-773n60\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,[t]){const r={};1&t&&(r.key=e[0]),2&t&&(r.value=e[1]),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function bn(e,t,n){ue(pt,{});let{key:r=\"\",value:l}=t;return e.$$set=(e=>{\"key\"in e&&n(0,r=e.key),\"value\"in e&&n(1,l=e.value)}),[r,l]}class xn extends Le{constructor(e){super(),Je(this,e,bn,hn,d,{key:0,value:1},yn)}}function wn(e){z(e,\"svelte-jvfq3i\",\".svelte-jvfq3i{box-sizing:border-box}section.switcher.svelte-jvfq3i{position:sticky;bottom:0;transform:translateY(20px);margin:40px -20px 0;border-top:1px solid #999;padding:20px;background:#fff}label.svelte-jvfq3i{display:flex;align-items:baseline;gap:5px;font-weight:bold}select.svelte-jvfq3i{min-width:140px}\")}function kn(e,t,n){const r=e.slice();return r[7]=t[n],r[9]=n,r}function Pn(e){let t,n,r,l,o,a,s=e[1],i=[];for(let c=0;c<s.length;c+=1)i[c]=jn(kn(e,s,c));return{c(){t=M(\"section\"),n=M(\"label\"),r=N(\"Client\\n      \\n      \"),l=M(\"select\");for(let e=0;e<i.length;e+=1)i[e].c();G(l,\"id\",On),G(l,\"class\",\"svelte-jvfq3i\"),void 0===e[2]&&be(()=>e[6].call(l)),G(n,\"class\",\"svelte-jvfq3i\"),G(t,\"class\",\"switcher svelte-jvfq3i\")},m(s,c){q(s,t,c),A(t,n),A(n,r),A(n,l);for(let e=0;e<i.length;e+=1)i[e].m(l,null);Z(l,e[2]),o||(a=[R(l,\"change\",e[3]),R(l,\"change\",e[6])],o=!0)},p(e,t){if(2&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=kn(e,s,n);i[n]?i[n].p(r,t):(i[n]=jn(r),i[n].c(),i[n].m(l,null))}for(;n<i.length;n+=1)i[n].d(1);i.length=s.length}4&t&&Z(l,e[2])},d(e){e&&I(t),T(i,e),o=!1,c(a)}}}function jn(e){let t,n,r,l,o,a,s,i,c,u,d=JSON.stringify(e[7].playerID)+\"\",f=JSON.stringify(e[7].matchID)+\"\",p=e[7].game.name+\"\";return{c(){t=M(\"option\"),n=N(e[9]),r=N(\" —\\n            playerID: \"),l=N(d),o=N(\",\\n            matchID: \"),a=N(f),s=N(\"\\n            (\"),i=N(p),c=N(\")\\n          \"),t.__value=u=e[9],t.value=t.__value,G(t,\"class\",\"svelte-jvfq3i\")},m(e,u){q(e,t,u),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),A(t,s),A(t,i),A(t,c)},p(e,t){2&t&&d!==(d=JSON.stringify(e[7].playerID)+\"\")&&F(l,d),2&t&&f!==(f=JSON.stringify(e[7].matchID)+\"\")&&F(a,f),2&t&&p!==(p=e[7].game.name+\"\")&&F(i,p)},d(e){e&&I(t)}}}function En(e){let t,n=e[1].length>1&&Pn(e);return{c(){n&&n.c(),t=B()},m(e,r){n&&n.m(e,r),q(e,t,r)},p(e,[r]){e[1].length>1?n?n.p(e,r):((n=Pn(e)).c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:l,o:l,d(e){n&&n.d(e),e&&I(t)}}}const On=\"bgio-debug-select-client\";function An(e,t,n){let r,o,a,s,i=l,c=()=>(i(),i=p(u,e=>n(5,s=e)),u);e.$$.on_destroy.push(()=>i());let{clientManager:u}=t;c();return e.$$set=(e=>{\"clientManager\"in e&&c(n(0,u=e.clientManager))}),e.$$.update=(()=>{32&e.$$.dirty&&n(4,({client:r,debuggableClients:o}=s),r,(n(1,o),n(5,s))),18&e.$$.dirty&&n(2,a=o.indexOf(r))}),[u,o,a,e=>{const t=o[e.target.value];u.switchToClient(t);const n=document.getElementById(On);n&&n.focus()},r,s,function(){a=U(this),n(2,a),n(1,o),n(4,r),n(5,s)}]}class zn extends Le{constructor(e){super(),Je(this,e,An,En,d,{clientManager:0},wn)}}function _n(e){z(e,\"svelte-1vfj1mn\",\".key.svelte-1vfj1mn.svelte-1vfj1mn{display:flex;flex-direction:row;align-items:center}button.svelte-1vfj1mn.svelte-1vfj1mn{cursor:pointer;min-width:10px;padding-left:5px;padding-right:5px;height:20px;line-height:20px;text-align:center;border:1px solid #ccc;box-shadow:1px 1px 1px #888;background:#eee;color:#444}button.svelte-1vfj1mn.svelte-1vfj1mn:hover{background:#ddd}.key.active.svelte-1vfj1mn button.svelte-1vfj1mn{background:#ddd;border:1px solid #999;box-shadow:none}label.svelte-1vfj1mn.svelte-1vfj1mn{margin-left:10px}\")}function Sn(e){let t,n,r,l,o,a=`(shortcut: ${e[0]})`+\"\";return{c(){t=M(\"label\"),n=N(e[1]),r=V(),l=M(\"span\"),o=N(a),G(l,\"class\",\"screen-reader-only\"),G(t,\"for\",e[5]),G(t,\"class\",\"svelte-1vfj1mn\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l),A(l,o)},p(e,t){2&t&&F(n,e[1]),1&t&&a!==(a=`(shortcut: ${e[0]})`+\"\")&&F(o,a)},d(e){e&&I(t)}}}function Cn(e){let t,n,r,o,a,s,i=e[1]&&Sn(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=N(e[0]),o=V(),i&&i.c(),G(n,\"id\",e[5]),n.disabled=e[2],G(n,\"class\",\"svelte-1vfj1mn\"),G(t,\"class\",\"key svelte-1vfj1mn\"),X(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),i&&i.m(t,null),a||(s=[R(window,\"keydown\",e[7]),R(n,\"click\",e[6])],a=!0)},p(e,[l]){1&l&&F(r,e[0]),4&l&&(n.disabled=e[2]),e[1]?i?i.p(e,l):((i=Sn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null),8&l&&X(t,\"active\",e[3])},i:l,o:l,d(e){e&&I(t),i&&i.d(),a=!1,c(s)}}}function qn(e,t,n){let r,{value:l}=t,{onPress:o=null}=t,{label:a=null}=t,{disable:s=!1}=t;const{disableHotkeys:i}=de(\"hotkeys\");m(e,i,e=>n(9,r=e));let c=!1,u=`key-${l}`;function d(){n(3,c=!1)}function f(){n(3,c=!0),setTimeout(d,200),o&&setTimeout(o,1)}return e.$$set=(e=>{\"value\"in e&&n(0,l=e.value),\"onPress\"in e&&n(8,o=e.onPress),\"label\"in e&&n(1,a=e.label),\"disable\"in e&&n(2,s=e.disable)}),[l,a,s,c,i,u,f,function(e){r||s||e.ctrlKey||e.metaKey||e.key!=l||(e.preventDefault(),f())},o]}class In extends Le{constructor(e){super(),Je(this,e,qn,Cn,d,{value:0,onPress:8,label:1,disable:2},_n)}}function Tn(e){z(e,\"svelte-1mppqmp\",\".move.svelte-1mppqmp{display:flex;flex-direction:row;cursor:pointer;margin-left:10px;color:#666}.move.svelte-1mppqmp:hover{color:#333}.move.active.svelte-1mppqmp{color:#111;font-weight:bold}.arg-field.svelte-1mppqmp{outline:none;font-family:monospace}\")}function Mn(e){let t,n,r,o,a,s,i,d,f,p,m;return{c(){t=M(\"div\"),n=M(\"span\"),r=N(e[2]),o=V(),(a=M(\"span\")).textContent=\"(\",s=V(),i=M(\"span\"),d=V(),(f=M(\"span\")).textContent=\")\",G(i,\"class\",\"arg-field svelte-1mppqmp\"),G(i,\"contenteditable\",\"\"),G(t,\"class\",\"move svelte-1mppqmp\"),X(t,\"active\",e[3])},m(l,c){q(l,t,c),A(t,n),A(n,r),A(t,o),A(t,a),A(t,s),A(t,i),e[6](i),A(t,d),A(t,f),p||(m=[R(i,\"focus\",function(){u(e[0])&&e[0].apply(this,arguments)}),R(i,\"blur\",function(){u(e[1])&&e[1].apply(this,arguments)}),R(i,\"keypress\",K(Dn)),R(i,\"keydown\",e[5]),R(t,\"click\",function(){u(e[0])&&e[0].apply(this,arguments)})],p=!0)},p(n,[l]){e=n,4&l&&F(r,e[2]),8&l&&X(t,\"active\",e[3])},i:l,o:l,d(n){n&&I(t),e[6](null),p=!1,c(m)}}}const Dn=()=>{};function Nn(e,t,n){let r,{Activate:l}=t,{Deactivate:o}=t,{name:a}=t,{active:s}=t;const i=ce();return se(()=>{s?r.focus():r.blur()}),e.$$set=(e=>{\"Activate\"in e&&n(0,l=e.Activate),\"Deactivate\"in e&&n(1,o=e.Deactivate),\"name\"in e&&n(2,a=e.name),\"active\"in e&&n(3,s=e.active)}),[l,o,a,s,r,function(e){\"Enter\"==e.key&&(e.preventDefault(),function(){try{const t=r.innerText;let n=new Function(`return [${t}]`)();i(\"submit\",n)}catch(e){i(\"error\",e)}n(4,r.innerText=\"\",r)}()),\"Escape\"==e.key&&(e.preventDefault(),o())},function(e){me[e?\"unshift\":\"push\"](()=>{n(4,r=e)})}]}class Vn extends Le{constructor(e){super(),Je(this,e,Nn,Mn,d,{Activate:0,Deactivate:1,name:2,active:3},Tn)}}function Bn(e){z(e,\"svelte-smqssc\",\".move-error.svelte-smqssc{color:#a00;font-weight:bold}.wrapper.svelte-smqssc{display:flex;flex-direction:row;align-items:center}\")}function Rn(e){let t,n;return{c(){t=M(\"span\"),n=N(e[2]),G(t,\"class\",\"move-error svelte-smqssc\")},m(e,r){q(e,t,r),A(t,n)},p(e,t){4&t&&F(n,e[2])},d(e){e&&I(t)}}}function Kn(e){let t,n,r,l,o,a,s;r=new In({props:{value:e[0],onPress:e[4]}}),(o=new Vn({props:{Activate:e[4],Deactivate:e[5],name:e[1],active:e[3]}})).$on(\"submit\",e[6]),o.$on(\"error\",e[7]);let i=e[2]&&Rn(e);return{c(){t=M(\"div\"),n=M(\"div\"),Be(r.$$.fragment),l=V(),Be(o.$$.fragment),a=V(),i&&i.c(),G(n,\"class\",\"wrapper svelte-smqssc\")},m(e,c){q(e,t,c),A(t,n),Re(r,n,null),A(n,l),Re(o,n,null),A(t,a),i&&i.m(t,null),s=!0},p(e,[n]){const l={};1&n&&(l.value=e[0]),r.$set(l);const a={};2&n&&(a.name=e[1]),8&n&&(a.active=e[3]),o.$set(a),e[2]?i?i.p(e,n):((i=Rn(e)).c(),i.m(t,null)):i&&(i.d(1),i=null)},i(e){s||(Ce(r.$$.fragment,e),Ce(o.$$.fragment,e),s=!0)},o(e){qe(r.$$.fragment,e),qe(o.$$.fragment,e),s=!1},d(e){e&&I(t),Ke(r),Ke(o),i&&i.d()}}}function Gn(t,n,r){let{shortcut:l}=n,{name:o}=n,{fn:a}=n;const{disableHotkeys:s}=de(\"hotkeys\");let i=\"\",c=!1;function u(){s.set(!1),r(2,i=\"\"),r(3,c=!1)}return t.$$set=(e=>{\"shortcut\"in e&&r(0,l=e.shortcut),\"name\"in e&&r(1,o=e.name),\"fn\"in e&&r(8,a=e.fn)}),[l,o,i,c,function(){s.set(!0),r(3,c=!0)},u,function(e){r(2,i=\"\"),u(),a.apply(this,e.detail)},function(t){r(2,i=t.detail),(0,e.e)(t.detail)},a]}class Jn extends Le{constructor(e){super(),Je(this,e,Gn,Kn,d,{shortcut:0,name:1,fn:8},Bn)}}function Ln(e){z(e,\"svelte-c3lavh\",\"ul.svelte-c3lavh{padding-left:0}li.svelte-c3lavh{list-style:none;margin:none;margin-bottom:5px}\")}function Fn(e){let t,n,r,l,o,a,s,i,c,u,d,f,p;return r=new In({props:{value:\"1\",onPress:e[0].reset,label:\"reset\"}}),a=new In({props:{value:\"2\",onPress:e[2],label:\"save\"}}),c=new In({props:{value:\"3\",onPress:e[3],label:\"restore\"}}),f=new In({props:{value:\".\",onPress:e[1],label:\"hide\"}}),{c(){t=M(\"ul\"),n=M(\"li\"),Be(r.$$.fragment),l=V(),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(c.$$.fragment),u=V(),d=M(\"li\"),Be(f.$$.fragment),G(n,\"class\",\"svelte-c3lavh\"),G(o,\"class\",\"svelte-c3lavh\"),G(i,\"class\",\"svelte-c3lavh\"),G(d,\"class\",\"svelte-c3lavh\"),G(t,\"id\",\"debug-controls\"),G(t,\"class\",\"controls svelte-c3lavh\")},m(e,m){q(e,t,m),A(t,n),Re(r,n,null),A(t,l),A(t,o),Re(a,o,null),A(t,s),A(t,i),Re(c,i,null),A(t,u),A(t,d),Re(f,d,null),p=!0},p(e,[t]){const n={};1&t&&(n.onPress=e[0].reset),r.$set(n);const l={};2&t&&(l.onPress=e[1]),f.$set(l)},i(e){p||(Ce(r.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c.$$.fragment,e),Ce(f.$$.fragment,e),p=!0)},o(e){qe(r.$$.fragment,e),qe(a.$$.fragment,e),qe(c.$$.fragment,e),qe(f.$$.fragment,e),p=!1},d(e){e&&I(t),Ke(r),Ke(a),Ke(c),Ke(f)}}}function Hn(t,r,l){let{client:o}=r,{ToggleVisibility:a}=r;return t.$$set=(e=>{\"client\"in e&&l(0,o=e.client),\"ToggleVisibility\"in e&&l(1,a=e.ToggleVisibility)}),[o,a,function(){const e=o.getState(),t=(0,n.stringify)({...e,_undo:[],_redo:[],deltalog:[]});window.localStorage.setItem(\"gamestate\",t),window.localStorage.setItem(\"initialState\",(0,n.stringify)(o.initialState))},function(){const t=window.localStorage.getItem(\"gamestate\"),r=window.localStorage.getItem(\"initialState\");if(null!==t&&null!==r){const l=(0,n.parse)(t),a=(0,n.parse)(r);o.store.dispatch((0,e.s)({state:l,initialState:a}))}}]}class Zn extends Le{constructor(e){super(),Je(this,e,Hn,Fn,d,{client:0,ToggleVisibility:1},Ln)}}function Un(e){z(e,\"svelte-19aan9p\",\".player-box.svelte-19aan9p{display:flex;flex-direction:row}.player.svelte-19aan9p{cursor:pointer;text-align:center;width:30px;height:30px;line-height:30px;background:#eee;border:3px solid #fefefe;box-sizing:content-box;padding:0}.player.current.svelte-19aan9p{background:#555;color:#eee;font-weight:bold}.player.active.svelte-19aan9p{border:3px solid #ff7f50}\")}function Xn(e,t,n){const r=e.slice();return r[7]=t[n],r}function Yn(e){let t,n,r,l,o,a,s=e[7]+\"\";function i(){return e[5](e[7])}return{c(){t=M(\"button\"),n=N(s),r=V(),G(t,\"class\",\"player svelte-19aan9p\"),G(t,\"aria-label\",l=e[4](e[7])),X(t,\"current\",e[7]==e[0].currentPlayer),X(t,\"active\",e[7]==e[1])},m(e,l){q(e,t,l),A(t,n),A(t,r),o||(a=R(t,\"click\",i),o=!0)},p(r,o){e=r,4&o&&s!==(s=e[7]+\"\")&&F(n,s),4&o&&l!==(l=e[4](e[7]))&&G(t,\"aria-label\",l),5&o&&X(t,\"current\",e[7]==e[0].currentPlayer),6&o&&X(t,\"active\",e[7]==e[1])},d(e){e&&I(t),o=!1,a()}}}function Wn(e){let t,n=e[2],r=[];for(let l=0;l<n.length;l+=1)r[l]=Yn(Xn(e,n,l));return{c(){t=M(\"div\");for(let e=0;e<r.length;e+=1)r[e].c();G(t,\"class\",\"player-box svelte-19aan9p\")},m(e,n){q(e,t,n);for(let l=0;l<r.length;l+=1)r[l].m(t,null)},p(e,[l]){if(31&l){let o;for(n=e[2],o=0;o<n.length;o+=1){const a=Xn(e,n,o);r[o]?r[o].p(a,l):(r[o]=Yn(a),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){e&&I(t),T(r,e)}}}function Qn(e,t,n){let{ctx:r}=t,{playerID:l}=t;const o=ce();function a(e){o(\"change\",e==l?{playerID:null}:{playerID:e})}let s;return e.$$set=(e=>{\"ctx\"in e&&n(0,r=e.ctx),\"playerID\"in e&&n(1,l=e.playerID)}),e.$$.update=(()=>{1&e.$$.dirty&&n(2,s=r?[...Array(r.numPlayers).keys()].map(e=>e.toString()):[])}),[r,l,s,a,function(e){const t=[];e==r.currentPlayer&&t.push(\"current\"),e==l&&t.push(\"active\");let n=`Player ${e}`;return t.length&&(n+=` (${t.join(\", \")})`),n},e=>a(e)]}class er extends Le{constructor(e){super(),Je(this,e,Qn,Wn,d,{ctx:0,playerID:1},Un)}}function tr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rr(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function lr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,\"value\"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function or(e,t,n){return t&&lr(e.prototype,t),n&&lr(e,n),e}function ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sr(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cr(e,t)}function ir(e){return(ir=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function cr(e,t){return(cr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ur(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function dr(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}function fr(e,t){if(null==e)return{};var n,r,l=dr(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}function pr(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e}function mr(e,t){return!t||\"object\"!=typeof t&&\"function\"!=typeof t?pr(e):t}function gr(e){var t=ur();return function(){var n,r=ir(e);if(t){var l=ir(this).constructor;n=Reflect.construct(r,arguments,l)}else n=r.apply(this,arguments);return mr(this,n)}}function vr(e,t){if(e){if(\"string\"==typeof e)return $r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===n&&e.constructor&&(n=e.constructor.name),\"Map\"===n||\"Set\"===n?Array.from(e):\"Arguments\"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$r(e,t):void 0}}function $r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yr(e,t){var n=\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(!n){if(Array.isArray(e)||(n=vr(e))||t&&e&&\"number\"==typeof e.length){n&&(e=n);var r=0,l=function(){};return{s:l,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:l}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function hr(e,t){var n,r={},l={},o=yr(t);try{for(o.s();!(n=o.n()).done;){l[n.value]=!0}}catch(p){o.e(p)}finally{o.f()}var a=l,s=!0;for(var i in e){var c=i[0];if(a[c]){s=!1;break}a[c]=!0,r[i]=c}if(s)return r;a=l;var u=97;for(var d in r={},e){for(var f=String.fromCharCode(u);a[f];)u++,f=String.fromCharCode(u);a[f]=!0,r[d]=f}return r}function br(e){z(e,\"svelte-146sq5f\",\".tree.svelte-146sq5f{--json-tree-font-family:monospace;--json-tree-font-size:14px;--json-tree-null-color:#757575}.label.svelte-146sq5f{margin-bottom:0;text-transform:none}h3.svelte-146sq5f{text-transform:uppercase}ul.svelte-146sq5f{padding-left:0}li.svelte-146sq5f{list-style:none;margin:0;margin-bottom:5px}\")}function xr(e,t,n){const r=e.slice();return r[10]=t[n][0],r[11]=t[n][1],r}function wr(e){let t,n,r,l;return n=new Jn({props:{shortcut:e[8][e[10]],fn:e[11],name:e[10]}}),{c(){t=M(\"li\"),Be(n.$$.fragment),r=V(),G(t,\"class\",\"svelte-146sq5f\")},m(e,o){q(e,t,o),Re(n,t,null),A(t,r),l=!0},p(e,t){const r={};16&t&&(r.shortcut=e[8][e[10]]),16&t&&(r.fn=e[11]),16&t&&(r.name=e[10]),n.$set(r)},i(e){l||(Ce(n.$$.fragment,e),l=!0)},o(e){qe(n.$$.fragment,e),l=!1},d(e){e&&I(t),Ke(n)}}}function kr(e){let t,n,r;return n=new Jn({props:{name:\"endStage\",shortcut:7,fn:e[5].endStage}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endStage),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Pr(e){let t,n,r;return n=new Jn({props:{name:\"endTurn\",shortcut:8,fn:e[5].endTurn}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endTurn),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function jr(e){let t,n,r;return n=new Jn({props:{name:\"endPhase\",shortcut:9,fn:e[5].endPhase}}),{c(){t=M(\"li\"),Be(n.$$.fragment),G(t,\"class\",\"svelte-146sq5f\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},p(e,t){const r={};32&t&&(r.fn=e[5].endPhase),n.$set(r)},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function Er(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j,E,O,z,_,S,C,D,N,B;l=new Zn({props:{client:e[0],ToggleVisibility:e[2]}}),(c=new er({props:{ctx:e[6],playerID:e[3]}})).$on(\"change\",e[9]);let R=Object.entries(e[4]),K=[];for(let A=0;A<R.length;A+=1)K[A]=wr(xr(e,R,A));const J=e=>qe(K[e],1,1,()=>{K[e]=null});let L=e[6].activePlayers&&e[5].endStage&&kr(e),F=e[5].endTurn&&Pr(e),H=e[6].phase&&e[5].endPhase&&jr(e);return E=new xn({props:{value:e[7]}}),C=new xn({props:{value:Or(e[6])}}),N=new zn({props:{clientManager:e[1]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),Be(l.$$.fragment),o=V(),a=M(\"section\"),(s=M(\"h3\")).textContent=\"Players\",i=V(),Be(c.$$.fragment),u=V(),d=M(\"section\"),(f=M(\"h3\")).textContent=\"Moves\",p=V(),m=M(\"ul\");for(let e=0;e<K.length;e+=1)K[e].c();g=V(),v=M(\"section\"),($=M(\"h3\")).textContent=\"Events\",y=V(),h=M(\"ul\"),L&&L.c(),b=V(),F&&F.c(),x=V(),H&&H.c(),w=V(),k=M(\"section\"),(P=M(\"h3\")).textContent=\"G\",j=V(),Be(E.$$.fragment),O=V(),z=M(\"section\"),(_=M(\"h3\")).textContent=\"ctx\",S=V(),Be(C.$$.fragment),D=V(),Be(N.$$.fragment),G(n,\"class\",\"svelte-146sq5f\"),G(s,\"class\",\"svelte-146sq5f\"),G(f,\"class\",\"svelte-146sq5f\"),G(m,\"class\",\"svelte-146sq5f\"),G($,\"class\",\"svelte-146sq5f\"),G(h,\"class\",\"svelte-146sq5f\"),G(P,\"class\",\"label svelte-146sq5f\"),G(k,\"class\",\"tree svelte-146sq5f\"),G(_,\"class\",\"label svelte-146sq5f\"),G(z,\"class\",\"tree svelte-146sq5f\")},m(e,I){q(e,t,I),A(t,n),A(t,r),Re(l,t,null),q(e,o,I),q(e,a,I),A(a,s),A(a,i),Re(c,a,null),q(e,u,I),q(e,d,I),A(d,f),A(d,p),A(d,m);for(let t=0;t<K.length;t+=1)K[t].m(m,null);q(e,g,I),q(e,v,I),A(v,$),A(v,y),A(v,h),L&&L.m(h,null),A(h,b),F&&F.m(h,null),A(h,x),H&&H.m(h,null),q(e,w,I),q(e,k,I),A(k,P),A(k,j),Re(E,k,null),q(e,O,I),q(e,z,I),A(z,_),A(z,S),Re(C,z,null),q(e,D,I),Re(N,e,I),B=!0},p(e,[t]){const n={};1&t&&(n.client=e[0]),4&t&&(n.ToggleVisibility=e[2]),l.$set(n);const r={};if(64&t&&(r.ctx=e[6]),8&t&&(r.playerID=e[3]),c.$set(r),272&t){let n;for(R=Object.entries(e[4]),n=0;n<R.length;n+=1){const r=xr(e,R,n);K[n]?(K[n].p(r,t),Ce(K[n],1)):(K[n]=wr(r),K[n].c(),Ce(K[n],1),K[n].m(m,null))}for(_e(),n=R.length;n<K.length;n+=1)J(n);Se()}e[6].activePlayers&&e[5].endStage?L?(L.p(e,t),96&t&&Ce(L,1)):((L=kr(e)).c(),Ce(L,1),L.m(h,b)):L&&(_e(),qe(L,1,1,()=>{L=null}),Se()),e[5].endTurn?F?(F.p(e,t),32&t&&Ce(F,1)):((F=Pr(e)).c(),Ce(F,1),F.m(h,x)):F&&(_e(),qe(F,1,1,()=>{F=null}),Se()),e[6].phase&&e[5].endPhase?H?(H.p(e,t),96&t&&Ce(H,1)):((H=jr(e)).c(),Ce(H,1),H.m(h,null)):H&&(_e(),qe(H,1,1,()=>{H=null}),Se());const o={};128&t&&(o.value=e[7]),E.$set(o);const a={};64&t&&(a.value=Or(e[6])),C.$set(a);const s={};2&t&&(s.clientManager=e[1]),N.$set(s)},i(e){if(!B){Ce(l.$$.fragment,e),Ce(c.$$.fragment,e);for(let e=0;e<R.length;e+=1)Ce(K[e]);Ce(L),Ce(F),Ce(H),Ce(E.$$.fragment,e),Ce(C.$$.fragment,e),Ce(N.$$.fragment,e),B=!0}},o(e){qe(l.$$.fragment,e),qe(c.$$.fragment,e),K=K.filter(Boolean);for(let t=0;t<K.length;t+=1)qe(K[t]);qe(L),qe(F),qe(H),qe(E.$$.fragment,e),qe(C.$$.fragment,e),qe(N.$$.fragment,e),B=!1},d(e){e&&I(t),Ke(l),e&&I(o),e&&I(a),Ke(c),e&&I(u),e&&I(d),T(K,e),e&&I(g),e&&I(v),L&&L.d(),F&&F.d(),H&&H.d(),e&&I(w),e&&I(k),Ke(E),e&&I(O),e&&I(z),Ke(C),e&&I(D),Ke(N,e)}}}function Or(e){let t={};for(const n in e)n.startsWith(\"_\")||(t[n]=e[n]);return t}function Ar(e,t,n){let{client:r}=t,{clientManager:l}=t,{ToggleVisibility:o}=t;const a=hr(r.moves,\"mlia\");let{playerID:s,moves:i,events:c}=r,u={},d={};r.subscribe(e=>{e&&n(7,({G:d,ctx:u}=e),d,n(6,u)),n(3,({playerID:s,moves:i,events:c}=r),s,n(4,i),n(5,c))});return e.$$set=(e=>{\"client\"in e&&n(0,r=e.client),\"clientManager\"in e&&n(1,l=e.clientManager),\"ToggleVisibility\"in e&&n(2,o=e.ToggleVisibility)}),[r,l,o,s,i,c,u,d,a,e=>l.switchPlayerID(e.detail.playerID)]}class zr extends Le{constructor(e){super(),Je(this,e,Ar,Er,d,{client:0,clientManager:1,ToggleVisibility:2},br)}}function _r(e){z(e,\"svelte-13qih23\",\".item.svelte-13qih23.svelte-13qih23{padding:10px}.item.svelte-13qih23.svelte-13qih23:not(:first-child){border-top:1px dashed #aaa}.item.svelte-13qih23 div.svelte-13qih23{float:right;text-align:right}\")}function Sr(e){let t,n,r,o,a,s,i=JSON.stringify(e[1])+\"\";return{c(){t=M(\"div\"),n=M(\"strong\"),r=N(e[0]),o=V(),a=M(\"div\"),s=N(i),G(a,\"class\",\"svelte-13qih23\"),G(t,\"class\",\"item svelte-13qih23\")},m(e,l){q(e,t,l),A(t,n),A(n,r),A(t,o),A(t,a),A(a,s)},p(e,[t]){1&t&&F(r,e[0]),2&t&&i!==(i=JSON.stringify(e[1])+\"\")&&F(s,i)},i:l,o:l,d(e){e&&I(t)}}}function Cr(e,t,n){let{name:r}=t,{value:l}=t;return e.$$set=(e=>{\"name\"in e&&n(0,r=e.name),\"value\"in e&&n(1,l=e.value)}),[r,l]}class qr extends Le{constructor(e){super(),Je(this,e,Cr,Sr,d,{name:0,value:1},_r)}}function Ir(e){z(e,\"svelte-1yzq5o8\",\".gameinfo.svelte-1yzq5o8{padding:10px}\")}function Tr(e){let t,n;return t=new qr({props:{name:\"isConnected\",value:e[1].isConnected}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.value=e[1].isConnected),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Mr(e){let t,n,r,l,o,a,s,i;n=new qr({props:{name:\"matchID\",value:e[0].matchID}}),l=new qr({props:{name:\"playerID\",value:e[0].playerID}}),a=new qr({props:{name:\"isActive\",value:e[1].isActive}});let c=e[0].multiplayer&&Tr(e);return{c(){t=M(\"section\"),Be(n.$$.fragment),r=V(),Be(l.$$.fragment),o=V(),Be(a.$$.fragment),s=V(),c&&c.c(),G(t,\"class\",\"gameinfo svelte-1yzq5o8\")},m(e,u){q(e,t,u),Re(n,t,null),A(t,r),Re(l,t,null),A(t,o),Re(a,t,null),A(t,s),c&&c.m(t,null),i=!0},p(e,[r]){const o={};1&r&&(o.value=e[0].matchID),n.$set(o);const s={};1&r&&(s.value=e[0].playerID),l.$set(s);const i={};2&r&&(i.value=e[1].isActive),a.$set(i),e[0].multiplayer?c?(c.p(e,r),1&r&&Ce(c,1)):((c=Tr(e)).c(),Ce(c,1),c.m(t,null)):c&&(_e(),qe(c,1,1,()=>{c=null}),Se())},i(e){i||(Ce(n.$$.fragment,e),Ce(l.$$.fragment,e),Ce(a.$$.fragment,e),Ce(c),i=!0)},o(e){qe(n.$$.fragment,e),qe(l.$$.fragment,e),qe(a.$$.fragment,e),qe(c),i=!1},d(e){e&&I(t),Ke(n),Ke(l),Ke(a),c&&c.d()}}}function Dr(e,t,n){let r,o=l,a=()=>(o(),o=p(s,e=>n(1,r=e)),s);e.$$.on_destroy.push(()=>o());let{client:s}=t;a();let{clientManager:i}=t;return e.$$set=(e=>{\"client\"in e&&a(n(0,s=e.client)),\"clientManager\"in e&&n(2,i=e.clientManager)}),[s,r,i]}class Nr extends Le{constructor(e){super(),Je(this,e,Dr,Mr,d,{client:0,clientManager:2},Ir)}}function Vr(e){z(e,\"svelte-6eza86\",\".turn-marker.svelte-6eza86{display:flex;justify-content:center;align-items:center;grid-column:1;background:#555;color:#eee;text-align:center;font-weight:bold;border:1px solid #888}\")}function Br(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"class\",\"turn-marker svelte-6eza86\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&F(n,e[0])},i:l,o:l,d(e){e&&I(t)}}}function Rr(e,t,n){let{turn:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"turn\"in e&&n(0,r=e.turn),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Kr extends Le{constructor(e){super(),Je(this,e,Rr,Br,d,{turn:0,numEvents:2},Vr)}}function Gr(e){z(e,\"svelte-1t4xap\",\".phase-marker.svelte-1t4xap{grid-column:3;background:#555;border:1px solid #888;color:#eee;text-align:center;font-weight:bold;padding-top:10px;padding-bottom:10px;text-orientation:sideways;writing-mode:vertical-rl;line-height:30px;width:100%}\")}function Jr(e){let t,n,r=(e[0]||\"\")+\"\";return{c(){t=M(\"div\"),n=N(r),G(t,\"class\",\"phase-marker svelte-1t4xap\"),G(t,\"style\",e[1])},m(e,r){q(e,t,r),A(t,n)},p(e,[t]){1&t&&r!==(r=(e[0]||\"\")+\"\")&&F(n,r)},i:l,o:l,d(e){e&&I(t)}}}function Lr(e,t,n){let{phase:r}=t,{numEvents:l}=t;const o=`grid-row: span ${l}`;return e.$$set=(e=>{\"phase\"in e&&n(0,r=e.phase),\"numEvents\"in e&&n(2,l=e.numEvents)}),[r,o,l]}class Fr extends Le{constructor(e){super(),Je(this,e,Lr,Jr,d,{phase:0,numEvents:2},Gr)}}function Hr(e){let t;return{c(){(t=M(\"div\")).textContent=`${e[0]}`},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Zr(e,t,n){let{metadata:r}=t;const l=void 0!==r?JSON.stringify(r,null,4):\"\";return e.$$set=(e=>{\"metadata\"in e&&n(1,r=e.metadata)}),[l,r]}class Ur extends Le{constructor(e){super(),Je(this,e,Zr,Hr,d,{metadata:1})}}function Xr(e){z(e,\"svelte-vajd9z\",\".log-event.svelte-vajd9z{grid-column:2;cursor:pointer;overflow:hidden;display:flex;flex-direction:column;justify-content:center;background:#fff;border:1px dotted #ccc;border-left:5px solid #ccc;padding:5px;text-align:center;color:#666;font-size:14px;min-height:25px;line-height:25px}.log-event.svelte-vajd9z:hover,.log-event.svelte-vajd9z:focus{border-style:solid;background:#eee}.log-event.pinned.svelte-vajd9z{border-style:solid;background:#eee;opacity:1}.args.svelte-vajd9z{text-align:left;white-space:pre-wrap}.player0.svelte-vajd9z{border-left-color:#ff851b}.player1.svelte-vajd9z{border-left-color:#7fdbff}.player2.svelte-vajd9z{border-left-color:#0074d9}.player3.svelte-vajd9z{border-left-color:#39cccc}.player4.svelte-vajd9z{border-left-color:#3d9970}.player5.svelte-vajd9z{border-left-color:#2ecc40}.player6.svelte-vajd9z{border-left-color:#01ff70}.player7.svelte-vajd9z{border-left-color:#ffdc00}.player8.svelte-vajd9z{border-left-color:#001f3f}.player9.svelte-vajd9z{border-left-color:#ff4136}.player10.svelte-vajd9z{border-left-color:#85144b}.player11.svelte-vajd9z{border-left-color:#f012be}.player12.svelte-vajd9z{border-left-color:#b10dc9}.player13.svelte-vajd9z{border-left-color:#111111}.player14.svelte-vajd9z{border-left-color:#aaaaaa}.player15.svelte-vajd9z{border-left-color:#dddddd}\")}function Yr(e){let t,n;return t=new Ur({props:{metadata:e[2]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.metadata=e[2]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Wr(e){let t,n,r;var l=e[3];function o(e){return{props:{metadata:e[2]}}}return l&&(t=new l(o(e))),{c(){t&&Be(t.$$.fragment),n=B()},m(e,l){t&&Re(t,e,l),q(e,n,l),r=!0},p(e,r){const a={};if(4&r&&(a.metadata=e[2]),l!==(l=e[3])){if(t){_e();const e=t;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((t=new l(o(e))).$$.fragment),Ce(t.$$.fragment,1),Re(t,n.parentNode,n)):t=null}else l&&t.$set(a)},i(e){r||(t&&Ce(t.$$.fragment,e),r=!0)},o(e){t&&qe(t.$$.fragment,e),r=!1},d(e){e&&I(n),t&&Ke(t,e)}}}function Qr(e){let t,n,r,l,o,a,s,i,u,d,f,p,m;const g=[Wr,Yr],v=[];function $(e,t){return e[3]?0:1}return i=$(e),u=v[i]=g[i](e),{c(){t=M(\"button\"),n=M(\"div\"),r=N(e[4]),l=N(\"(\"),o=N(e[6]),a=N(\")\"),s=V(),u.c(),G(n,\"class\",\"args svelte-vajd9z\"),G(t,\"class\",d=\"log-event player\"+e[7]+\" svelte-vajd9z\"),X(t,\"pinned\",e[1])},m(c,u){q(c,t,u),A(t,n),A(n,r),A(n,l),A(n,o),A(n,a),A(t,s),v[i].m(t,null),f=!0,p||(m=[R(t,\"click\",e[9]),R(t,\"mouseenter\",e[10]),R(t,\"focus\",e[11]),R(t,\"mouseleave\",e[12]),R(t,\"blur\",e[13])],p=!0)},p(e,[n]){(!f||16&n)&&F(r,e[4]);let l=i;(i=$(e))===l?v[i].p(e,n):(_e(),qe(v[l],1,1,()=>{v[l]=null}),Se(),(u=v[i])?u.p(e,n):(u=v[i]=g[i](e)).c(),Ce(u,1),u.m(t,null)),2&n&&X(t,\"pinned\",e[1])},i(e){f||(Ce(u),f=!0)},o(e){qe(u),f=!1},d(e){e&&I(t),v[i].d(),p=!1,c(m)}}}function el(e,t,n){let{logIndex:r}=t,{action:l}=t,{pinned:o}=t,{metadata:a}=t,{metadataComponent:s}=t;const i=ce(),c=l.payload.args,u=Array.isArray(c)?c.map(e=>JSON.stringify(e,null,2)).join(\",\"):JSON.stringify(c,null,2)||\"\",d=l.payload.playerID;let f;switch(l.type){case\"UNDO\":f=\"undo\";break;case\"REDO\":f=\"redo\";case\"GAME_EVENT\":case\"MAKE_MOVE\":default:f=l.payload.type}return e.$$set=(e=>{\"logIndex\"in e&&n(0,r=e.logIndex),\"action\"in e&&n(8,l=e.action),\"pinned\"in e&&n(1,o=e.pinned),\"metadata\"in e&&n(2,a=e.metadata),\"metadataComponent\"in e&&n(3,s=e.metadataComponent)}),[r,o,a,s,f,i,u,d,l,()=>i(\"click\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseenter\",{logIndex:r}),()=>i(\"mouseleave\"),()=>i(\"mouseleave\")]}class tl extends Le{constructor(e){super(),Je(this,e,el,Qr,d,{logIndex:0,action:8,pinned:1,metadata:2,metadataComponent:3},Xr)}}function nl(e){let t;return{c(){G(t=D(\"path\"),\"d\",\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z\")},m(e,n){q(e,t,n)},d(e){e&&I(t)}}}function rl(e){let t,n;const r=[{viewBox:\"0 0 512 512\"},e[0]];let l={$$slots:{default:[nl]},$$scope:{ctx:e}};for(let o=0;o<r.length;o+=1)l=a(l,r[o]);return t=new nt({props:l}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,[n]){const l=1&n?Ne(r,[r[0],Ve(e[0])]):{};2&n&&(l.$$scope={dirty:n,ctx:e}),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ll(e,t,n){return e.$$set=(e=>{n(0,t=a(a({},t),b(e)))}),[t=b(t)]}class ol extends Le{constructor(e){super(),Je(this,e,ll,rl,d,{})}}function al(e){z(e,\"svelte-1a7time\",\"div.svelte-1a7time{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:500px}\")}function sl(e){let t,n;return{c(){t=M(\"div\"),n=N(e[0]),G(t,\"alt\",e[0]),G(t,\"class\",\"svelte-1a7time\")},m(e,r){q(e,t,r),A(t,n)},p(e,[r]){1&r&&F(n,e[0]),1&r&&G(t,\"alt\",e[0])},i:l,o:l,d(e){e&&I(t)}}}function il(e,t,n){let r,{action:l}=t;return e.$$set=(e=>{\"action\"in e&&n(1,l=e.action)}),e.$$.update=(()=>{if(2&e.$$.dirty){const{type:e,args:t}=l.payload,o=(t||[]).join(\",\");n(0,r=`${e}(${o})`)}}),[r,l]}class cl extends Le{constructor(e){super(),Je(this,e,il,sl,d,{action:1},al)}}function ul(e){z(e,\"svelte-ztcwsu\",\"table.svelte-ztcwsu.svelte-ztcwsu{font-size:12px;border-collapse:collapse;border:1px solid #ddd;padding:0}tr.svelte-ztcwsu.svelte-ztcwsu{cursor:pointer}tr.svelte-ztcwsu:hover td.svelte-ztcwsu{background:#eee}tr.selected.svelte-ztcwsu td.svelte-ztcwsu{background:#eee}td.svelte-ztcwsu.svelte-ztcwsu{padding:10px;height:10px;line-height:10px;font-size:12px;border:none}th.svelte-ztcwsu.svelte-ztcwsu{background:#888;color:#fff;padding:10px;text-align:center}\")}function dl(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function fl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g=e[10].value+\"\",v=e[10].visits+\"\";function $(){return e[6](e[10],e[12])}function y(){return e[7](e[12])}function h(){return e[8](e[10],e[12])}return u=new cl({props:{action:e[10].parentAction}}),{c(){t=M(\"tr\"),n=M(\"td\"),r=N(g),l=V(),o=M(\"td\"),a=N(v),s=V(),i=M(\"td\"),Be(u.$$.fragment),d=V(),G(n,\"class\",\"svelte-ztcwsu\"),G(o,\"class\",\"svelte-ztcwsu\"),G(i,\"class\",\"svelte-ztcwsu\"),G(t,\"class\",\"svelte-ztcwsu\"),X(t,\"clickable\",e[1].length>0),X(t,\"selected\",e[12]===e[0])},m(e,c){q(e,t,c),A(t,n),A(n,r),A(t,l),A(t,o),A(o,a),A(t,s),A(t,i),Re(u,i,null),A(t,d),f=!0,p||(m=[R(t,\"click\",$),R(t,\"mouseout\",y),R(t,\"mouseover\",h)],p=!0)},p(n,l){e=n,(!f||2&l)&&g!==(g=e[10].value+\"\")&&F(r,g),(!f||2&l)&&v!==(v=e[10].visits+\"\")&&F(a,v);const o={};2&l&&(o.action=e[10].parentAction),u.$set(o),2&l&&X(t,\"clickable\",e[1].length>0),1&l&&X(t,\"selected\",e[12]===e[0])},i(e){f||(Ce(u.$$.fragment,e),f=!0)},o(e){qe(u.$$.fragment,e),f=!1},d(e){e&&I(t),Ke(u),p=!1,c(m)}}}function pl(e){let t,n,r,l,o,a=e[1],s=[];for(let c=0;c<a.length;c+=1)s[c]=fl(dl(e,a,c));const i=e=>qe(s[e],1,1,()=>{s[e]=null});return{c(){t=M(\"table\"),(n=M(\"thead\")).innerHTML='<th class=\"svelte-ztcwsu\">Value</th> \\n    <th class=\"svelte-ztcwsu\">Visits</th> \\n    <th class=\"svelte-ztcwsu\">Action</th>',r=V(),l=M(\"tbody\");for(let e=0;e<s.length;e+=1)s[e].c();G(t,\"class\",\"svelte-ztcwsu\")},m(e,a){q(e,t,a),A(t,n),A(t,r),A(t,l);for(let t=0;t<s.length;t+=1)s[t].m(l,null);o=!0},p(e,[t]){if(15&t){let n;for(a=e[1],n=0;n<a.length;n+=1){const r=dl(e,a,n);s[n]?(s[n].p(r,t),Ce(s[n],1)):(s[n]=fl(r),s[n].c(),Ce(s[n],1),s[n].m(l,null))}for(_e(),n=a.length;n<s.length;n+=1)i(n);Se()}},i(e){if(!o){for(let e=0;e<a.length;e+=1)Ce(s[e]);o=!0}},o(e){s=s.filter(Boolean);for(let t=0;t<s.length;t+=1)qe(s[t]);o=!1},d(e){e&&I(t),T(s,e)}}}function ml(e,t,n){let{root:r}=t,{selectedIndex:l=null}=t;const o=ce();let a=[],s=[];function i(e,t){o(\"select\",{node:e,selectedIndex:t})}function c(e,t){null===l&&o(\"preview\",{node:e})}return e.$$set=(e=>{\"root\"in e&&n(4,r=e.root),\"selectedIndex\"in e&&n(0,l=e.selectedIndex)}),e.$$.update=(()=>{if(48&e.$$.dirty){let e=r;for(n(5,a=[]);e.parent;){const t=e.parent,{type:n,args:r}=e.parentAction.payload,l=`${n}(${(r||[]).join(\",\")})`;a.push({parent:t,arrowText:l}),e=t}a.reverse(),n(1,s=[...r.children].sort((e,t)=>e.visits<t.visits?1:-1).slice(0,50))}}),[l,s,i,c,r,a,(e,t)=>i(e,t),e=>c(null),(e,t)=>c(e)]}class gl extends Le{constructor(e){super(),Je(this,e,ml,pl,d,{root:4,selectedIndex:0},ul)}}function vl(e){z(e,\"svelte-1f0amz4\",\".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}\")}function $l(e,t,n){const r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function yl(e){let t,n,r;return n=new ol({}),{c(){t=M(\"div\"),Be(n.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\")},m(e,l){q(e,t,l),Re(n,t,null),r=!0},i(e){r||(Ce(n.$$.fragment,e),r=!0)},o(e){qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),Ke(n)}}}function hl(e){let t,n;return(t=new gl({props:{root:e[9],selectedIndex:e[10]}})).$on(\"select\",function(...t){return e[7](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),1&r&&(l.selectedIndex=e[10]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function bl(e){let t,n;return(t=new gl({props:{root:e[9]}})).$on(\"select\",function(...t){return e[5](e[12],...t)}),t.$on(\"preview\",function(...t){return e[6](e[12],...t)}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(n,r){e=n;const l={};1&r&&(l.root=e[9]),t.$set(l)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function xl(e){let t,n,r,l,o,a=0!==e[12]&&yl();const s=[bl,hl],i=[];function c(e,t){return e[12]===e[0].length-1?0:1}return r=c(e),l=i[r]=s[r](e),{c(){a&&a.c(),t=V(),n=M(\"section\"),l.c()},m(e,l){a&&a.m(e,l),q(e,t,l),q(e,n,l),i[r].m(n,null),o=!0},p(e,t){let o=r;(r=c(e))===o?i[r].p(e,t):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(l=i[r])?l.p(e,t):(l=i[r]=s[r](e)).c(),Ce(l,1),l.m(n,null))},i(e){o||(Ce(a),Ce(l),o=!0)},o(e){qe(a),qe(l),o=!1},d(e){a&&a.d(e),e&&I(t),e&&I(n),i[r].d()}}}function wl(e){let t,n,r,l,o,a;return n=new ol({}),o=new gl({props:{root:e[1]}}),{c(){t=M(\"div\"),Be(n.$$.fragment),r=V(),l=M(\"section\"),Be(o.$$.fragment),G(t,\"class\",\"icon svelte-1f0amz4\"),G(l,\"class\",\"preview svelte-1f0amz4\")},m(e,s){q(e,t,s),Re(n,t,null),q(e,r,s),q(e,l,s),Re(o,l,null),a=!0},p(e,t){const n={};2&t&&(n.root=e[1]),o.$set(n)},i(e){a||(Ce(n.$$.fragment,e),Ce(o.$$.fragment,e),a=!0)},o(e){qe(n.$$.fragment,e),qe(o.$$.fragment,e),a=!1},d(e){e&&I(t),Ke(n),e&&I(r),e&&I(l),Ke(o)}}}function kl(e){let t,n,r,l=e[0],o=[];for(let i=0;i<l.length;i+=1)o[i]=xl($l(e,l,i));const a=e=>qe(o[e],1,1,()=>{o[e]=null});let s=e[1]&&wl(e);return{c(){t=M(\"div\");for(let e=0;e<o.length;e+=1)o[e].c();n=V(),s&&s.c(),G(t,\"class\",\"visualizer svelte-1f0amz4\")},m(e,l){q(e,t,l);for(let n=0;n<o.length;n+=1)o[n].m(t,null);A(t,n),s&&s.m(t,null),r=!0},p(e,[r]){if(13&r){let s;for(l=e[0],s=0;s<l.length;s+=1){const a=$l(e,l,s);o[s]?(o[s].p(a,r),Ce(o[s],1)):(o[s]=xl(a),o[s].c(),Ce(o[s],1),o[s].m(t,n))}for(_e(),s=l.length;s<o.length;s+=1)a(s);Se()}e[1]?s?(s.p(e,r),2&r&&Ce(s,1)):((s=wl(e)).c(),Ce(s,1),s.m(t,null)):s&&(_e(),qe(s,1,1,()=>{s=null}),Se())},i(e){if(!r){for(let e=0;e<l.length;e+=1)Ce(o[e]);Ce(s),r=!0}},o(e){o=o.filter(Boolean);for(let t=0;t<o.length;t+=1)qe(o[t]);qe(s),r=!1},d(e){e&&I(t),T(o,e),s&&s.d()}}}function Pl(e,t,n){let{metadata:r}=t,l=[],o=null;function a({node:e,selectedIndex:t},r){n(1,o=null),n(0,l[r].selectedIndex=t,l),n(0,l=[...l.slice(0,r+1),{node:e}])}function s({node:e},t){n(1,o=e)}return e.$$set=(e=>{\"metadata\"in e&&n(4,r=e.metadata)}),e.$$.update=(()=>{16&e.$$.dirty&&n(0,l=[{node:r}])}),[l,o,a,s,r,(e,t)=>a(t.detail,e),(e,t)=>s(t.detail),(e,t)=>a(t.detail,e)]}class jl extends Le{constructor(e){super(),Je(this,e,Pl,kl,d,{metadata:4},vl)}}function El(e){z(e,\"svelte-1pq5e4b\",\".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}\")}function Ol(e,t,n){const r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Al(e,t,n){const r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function zl(e,t,n){const r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function _l(e){let t,n;return t=new Kr({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.turn=e[22]),8&n&&(r.numEvents=e[3][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Sl(e){let t,n,r=e[18]in e[3]&&_l(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[3]?r?(r.p(e,n),8&n&&Ce(r,1)):((r=_l(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Cl(e){let t,n;return(t=new tl({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}})).$on(\"click\",e[5]),t.$on(\"mouseenter\",e[6]),t.$on(\"mouseleave\",e[7]),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};4&n&&(r.pinned=e[18]===e[2]),2&n&&(r.action=e[19]),2&n&&(r.metadata=e[20]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function ql(e){let t,n;return t=new Fr({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){Be(t.$$.fragment)},m(e,r){Re(t,e,r),n=!0},p(e,n){const r={};2&n&&(r.phase=e[16]),16&n&&(r.numEvents=e[4][e[18]]),t.$set(r)},i(e){n||(Ce(t.$$.fragment,e),n=!0)},o(e){qe(t.$$.fragment,e),n=!1},d(e){Ke(t,e)}}}function Il(e){let t,n,r=e[18]in e[4]&&ql(e);return{c(){r&&r.c(),t=B()},m(e,l){r&&r.m(e,l),q(e,t,l),n=!0},p(e,n){e[18]in e[4]?r?(r.p(e,n),16&n&&Ce(r,1)):((r=ql(e)).c(),Ce(r,1),r.m(t.parentNode,t)):r&&(_e(),qe(r,1,1,()=>{r=null}),Se())},i(e){n||(Ce(r),n=!0)},o(e){qe(r),n=!1},d(e){r&&r.d(e),e&&I(t)}}}function Tl(e){let t,n,r,l,o,a,s=e[1],i=[];for(let v=0;v<s.length;v+=1)i[v]=Sl(zl(e,s,v));const c=e=>qe(i[e],1,1,()=>{i[e]=null});let u=e[1],d=[];for(let v=0;v<u.length;v+=1)d[v]=Cl(Al(e,u,v));const f=e=>qe(d[e],1,1,()=>{d[e]=null});let p=e[1],m=[];for(let v=0;v<p.length;v+=1)m[v]=Il(Ol(e,p,v));const g=e=>qe(m[e],1,1,()=>{m[e]=null});return{c(){t=M(\"div\");for(let e=0;e<i.length;e+=1)i[e].c();n=V();for(let e=0;e<d.length;e+=1)d[e].c();r=V();for(let e=0;e<m.length;e+=1)m[e].c();G(t,\"class\",\"gamelog svelte-1pq5e4b\"),X(t,\"pinned\",e[2])},m(s,c){q(s,t,c);for(let e=0;e<i.length;e+=1)i[e].m(t,null);A(t,n);for(let e=0;e<d.length;e+=1)d[e].m(t,null);A(t,r);for(let e=0;e<m.length;e+=1)m[e].m(t,null);l=!0,o||(a=R(window,\"keydown\",e[8]),o=!0)},p(e,[l]){if(10&l){let r;for(s=e[1],r=0;r<s.length;r+=1){const o=zl(e,s,r);i[r]?(i[r].p(o,l),Ce(i[r],1)):(i[r]=Sl(o),i[r].c(),Ce(i[r],1),i[r].m(t,n))}for(_e(),r=s.length;r<i.length;r+=1)c(r);Se()}if(230&l){let n;for(u=e[1],n=0;n<u.length;n+=1){const o=Al(e,u,n);d[n]?(d[n].p(o,l),Ce(d[n],1)):(d[n]=Cl(o),d[n].c(),Ce(d[n],1),d[n].m(t,r))}for(_e(),n=u.length;n<d.length;n+=1)f(n);Se()}if(18&l){let n;for(p=e[1],n=0;n<p.length;n+=1){const r=Ol(e,p,n);m[n]?(m[n].p(r,l),Ce(m[n],1)):(m[n]=Il(r),m[n].c(),Ce(m[n],1),m[n].m(t,null))}for(_e(),n=p.length;n<m.length;n+=1)g(n);Se()}4&l&&X(t,\"pinned\",e[2])},i(e){if(!l){for(let e=0;e<s.length;e+=1)Ce(i[e]);for(let e=0;e<u.length;e+=1)Ce(d[e]);for(let e=0;e<p.length;e+=1)Ce(m[e]);l=!0}},o(e){i=i.filter(Boolean);for(let t=0;t<i.length;t+=1)qe(i[t]);d=d.filter(Boolean);for(let t=0;t<d.length;t+=1)qe(d[t]);m=m.filter(Boolean);for(let t=0;t<m.length;t+=1)qe(m[t]);l=!1},d(e){e&&I(t),T(i,e),T(d,e),T(m,e),o=!1,a()}}}function Ml(e,n,r){let o,a=l,s=()=>(a(),a=p(i,e=>r(10,o=e)),i);e.$$.on_destroy.push(()=>a());let{client:i}=n;s();const{secondaryPane:c}=de(\"secondaryPane\"),u=(0,t.C)({game:i.game}),d=i.getInitialState();let f,{log:m}=o,g=null;function v(e){let t=d;for(let n=0;n<m.length;n++){const{action:r,automatic:l}=m[n];if(!l){if(t=u(t,r),0==e)break;e--}}return{G:t.G,ctx:t.ctx,plugins:t.plugins}}function $(){r(2,g=null),i.overrideGameState(null),c.set(null)}ie($);let y={},h={};return e.$$set=(e=>{\"client\"in e&&s(r(0,i=e.client))}),e.$$.update=(()=>{if(1538&e.$$.dirty){r(9,m=o.log),r(1,f=m.filter(e=>!e.automatic));let e=0,t=0;r(3,y={}),r(4,h={});for(let n=0;n<f.length;n++){const{action:l,payload:o,turn:a,phase:s}=f[n];t++,e++,n!=f.length-1&&f[n+1].turn==a||(r(3,y[n]=t,y),t=0),n!=f.length-1&&f[n+1].phase==s||(r(4,h[n]=e,h),e=0)}}}),[i,f,g,y,h,function(e){const{logIndex:t}=e.detail,n=v(t),l=m.filter(e=>!e.automatic);if(i.overrideGameState(n),g==t)r(2,g=null),c.set(null);else{r(2,g=t);const{metadata:e}=l[t].action.payload;e&&c.set({component:jl,metadata:e})}},function(e){const{logIndex:t}=e.detail;if(null===g){const e=v(t);i.overrideGameState(e)}},function(){null===g&&i.overrideGameState(null)},function(e){27==e.keyCode&&$()},m,o]}class Dl extends Le{constructor(e){super(),Je(this,e,Ml,Tl,d,{client:0},El)}}function Nl(e){z(e,\"svelte-1fu900w\",\"label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}\")}function Vl(e,t,n){const r=e.slice();return r[5]=t[n][0],r[6]=t[n][1],r[7]=t,r[8]=n,r}function Bl(e){let t,n,r,l,o,a,s,i,u=e[1][e[5]]+\"\";function d(){e[3].call(l,e[5])}return{c(){t=M(\"span\"),n=N(u),r=V(),l=M(\"input\"),G(t,\"class\",\"value svelte-1fu900w\"),G(l,\"type\",\"range\"),G(l,\"min\",o=e[6].range.min),G(l,\"max\",a=e[6].range.max)},m(o,a){q(o,t,a),A(t,n),q(o,r,a),q(o,l,a),H(l,e[1][e[5]]),s||(i=[R(l,\"change\",d),R(l,\"input\",d),R(l,\"change\",e[2])],s=!0)},p(t,r){e=t,3&r&&u!==(u=e[1][e[5]]+\"\")&&F(n,u),1&r&&o!==(o=e[6].range.min)&&G(l,\"min\",o),1&r&&a!==(a=e[6].range.max)&&G(l,\"max\",a),3&r&&H(l,e[1][e[5]])},d(e){e&&I(t),e&&I(r),e&&I(l),s=!1,c(i)}}}function Rl(e){let t,n,r;function l(){e[4].call(t,e[5])}return{c(){G(t=M(\"input\"),\"type\",\"checkbox\"),G(t,\"class\",\"svelte-1fu900w\")},m(o,a){q(o,t,a),t.checked=e[1][e[5]],n||(r=[R(t,\"change\",l),R(t,\"change\",e[2])],n=!0)},p(n,r){e=n,3&r&&(t.checked=e[1][e[5]])},d(e){e&&I(t),n=!1,c(r)}}}function Kl(e){let t,n,r,l,o,a,s=e[5]+\"\",i=e[6].range&&Bl(e),c=\"boolean\"==typeof e[6].value&&Rl(e);return{c(){t=M(\"div\"),n=M(\"label\"),r=N(s),l=V(),i&&i.c(),o=V(),c&&c.c(),a=V(),G(n,\"class\",\"svelte-1fu900w\"),G(t,\"class\",\"option svelte-1fu900w\")},m(e,s){q(e,t,s),A(t,n),A(n,r),A(t,l),i&&i.m(t,null),A(t,o),c&&c.m(t,null),A(t,a)},p(e,n){1&n&&s!==(s=e[5]+\"\")&&F(r,s),e[6].range?i?i.p(e,n):((i=Bl(e)).c(),i.m(t,o)):i&&(i.d(1),i=null),\"boolean\"==typeof e[6].value?c?c.p(e,n):((c=Rl(e)).c(),c.m(t,a)):c&&(c.d(1),c=null)},d(e){e&&I(t),i&&i.d(),c&&c.d()}}}function Gl(e){let t,n=Object.entries(e[0].opts()),r=[];for(let l=0;l<n.length;l+=1)r[l]=Kl(Vl(e,n,l));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=B()},m(e,n){for(let t=0;t<r.length;t+=1)r[t].m(e,n);q(e,t,n)},p(e,[l]){if(7&l){let o;for(n=Object.entries(e[0].opts()),o=0;o<n.length;o+=1){const a=Vl(e,n,o);r[o]?r[o].p(a,l):(r[o]=Kl(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:l,o:l,d(e){T(r,e),e&&I(t)}}}function Jl(e,t,n){let{bot:r}=t,l={};for(let[o,a]of Object.entries(r.opts()))l[o]=a.value;return e.$$set=(e=>{\"bot\"in e&&n(0,r=e.bot)}),[r,l,function(){for(let[e,t]of Object.entries(l))r.setOpt(e,t)},function(e){l[e]=J(this.value),n(1,l),n(0,r)},function(e){l[e]=this.checked,n(1,l),n(0,r)}]}class Ll extends Le{constructor(e){super(),Je(this,e,Jl,Gl,d,{bot:0},Nl)}}function Fl(e){z(e,\"svelte-lifdi8\",\"ul.svelte-lifdi8{padding-left:0}li.svelte-lifdi8{list-style:none;margin:none;margin-bottom:5px}h3.svelte-lifdi8{text-transform:uppercase}label.svelte-lifdi8{color:#666}input[type='checkbox'].svelte-lifdi8{vertical-align:middle}\")}function Hl(e,t,n){const r=e.slice();return r[7]=t[n],r}function Zl(e){let t,n,r;return{c(){(t=M(\"p\")).textContent=\"No bots available.\",n=V(),(r=M(\"p\")).innerHTML='Follow the instructions\\n        <a href=\"https://boardgame.io/documentation/#/tutorial?id=bots\" target=\"_blank\">here</a>\\n        to set up bots.'},m(e,l){q(e,t,l),q(e,n,l),q(e,r,l)},p:l,i:l,o:l,d(e){e&&I(t),e&&I(n),e&&I(r)}}}function Ul(e){let t;return{c(){(t=M(\"p\")).textContent=\"The bot debugger is only available in singleplayer mode.\"},m(e,n){q(e,t,n)},p:l,i:l,o:l,d(e){e&&I(t)}}}function Xl(e){let t,n,r,l,o,a,s,i,u,d,f,p,m,g,v,$,y,h,b,x,w,k,P,j=Object.keys(e[7].opts()).length;a=new In({props:{value:\"1\",onPress:e[13],label:\"reset\"}}),u=new In({props:{value:\"2\",onPress:e[11],label:\"play\"}}),p=new In({props:{value:\"3\",onPress:e[12],label:\"simulate\"}});let E=Object.keys(e[8]),O=[];for(let c=0;c<E.length;c+=1)O[c]=Yl(Hl(e,E,c));let z=j&&Wl(e),_=(e[5]||e[3])&&Ql(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Controls\",r=V(),l=M(\"ul\"),o=M(\"li\"),Be(a.$$.fragment),s=V(),i=M(\"li\"),Be(u.$$.fragment),d=V(),f=M(\"li\"),Be(p.$$.fragment),m=V(),g=M(\"section\"),(v=M(\"h3\")).textContent=\"Bot\",$=V(),y=M(\"select\");for(let e=0;e<O.length;e+=1)O[e].c();h=V(),z&&z.c(),b=V(),_&&_.c(),x=B(),G(n,\"class\",\"svelte-lifdi8\"),G(o,\"class\",\"svelte-lifdi8\"),G(i,\"class\",\"svelte-lifdi8\"),G(f,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(v,\"class\",\"svelte-lifdi8\"),void 0===e[4]&&be(()=>e[16].call(y))},m(c,j){q(c,t,j),A(t,n),A(t,r),A(t,l),A(l,o),Re(a,o,null),A(l,s),A(l,i),Re(u,i,null),A(l,d),A(l,f),Re(p,f,null),q(c,m,j),q(c,g,j),A(g,v),A(g,$),A(g,y);for(let e=0;e<O.length;e+=1)O[e].m(y,null);Z(y,e[4]),q(c,h,j),z&&z.m(c,j),q(c,b,j),_&&_.m(c,j),q(c,x,j),w=!0,k||(P=[R(y,\"change\",e[16]),R(y,\"change\",e[10])],k=!0)},p(e,t){if(256&t){let n;for(E=Object.keys(e[8]),n=0;n<E.length;n+=1){const r=Hl(e,E,n);O[n]?O[n].p(r,t):(O[n]=Yl(r),O[n].c(),O[n].m(y,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=E.length}272&t&&Z(y,e[4]),128&t&&(j=Object.keys(e[7].opts()).length),j?z?(z.p(e,t),128&t&&Ce(z,1)):((z=Wl(e)).c(),Ce(z,1),z.m(b.parentNode,b)):z&&(_e(),qe(z,1,1,()=>{z=null}),Se()),e[5]||e[3]?_?_.p(e,t):((_=Ql(e)).c(),_.m(x.parentNode,x)):_&&(_.d(1),_=null)},i(e){w||(Ce(a.$$.fragment,e),Ce(u.$$.fragment,e),Ce(p.$$.fragment,e),Ce(z),w=!0)},o(e){qe(a.$$.fragment,e),qe(u.$$.fragment,e),qe(p.$$.fragment,e),qe(z),w=!1},d(e){e&&I(t),Ke(a),Ke(u),Ke(p),e&&I(m),e&&I(g),T(O,e),e&&I(h),z&&z.d(e),e&&I(b),_&&_.d(e),e&&I(x),k=!1,c(P)}}}function Yl(e){let t,n,r,o=e[7]+\"\";return{c(){t=M(\"option\"),n=N(o),t.__value=r=e[7],t.value=t.__value},m(e,r){q(e,t,r),A(t,n)},p:l,d(e){e&&I(t)}}}function Wl(e){let t,n,r,l,o,a,s,i,u,d,f;return i=new Ll({props:{bot:e[7]}}),{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Options\",r=V(),(l=M(\"label\")).textContent=\"debug\",o=V(),a=M(\"input\"),s=V(),Be(i.$$.fragment),G(n,\"class\",\"svelte-lifdi8\"),G(l,\"class\",\"svelte-lifdi8\"),G(a,\"type\",\"checkbox\"),G(a,\"class\",\"svelte-lifdi8\")},m(c,p){q(c,t,p),A(t,n),A(t,r),A(t,l),A(t,o),A(t,a),a.checked=e[1],A(t,s),Re(i,t,null),u=!0,d||(f=[R(a,\"change\",e[17]),R(a,\"change\",e[9])],d=!0)},p(e,t){2&t&&(a.checked=e[1]);const n={};128&t&&(n.bot=e[7]),i.$set(n)},i(e){u||(Ce(i.$$.fragment,e),u=!0)},o(e){qe(i.$$.fragment,e),u=!1},d(e){e&&I(t),Ke(i),d=!1,c(f)}}}function Ql(e){let t,n,r,l,o=e[2]&&e[2]<1&&eo(e),a=e[5]&&to(e);return{c(){t=M(\"section\"),(n=M(\"h3\")).textContent=\"Result\",r=V(),o&&o.c(),l=V(),a&&a.c(),G(n,\"class\",\"svelte-lifdi8\")},m(e,s){q(e,t,s),A(t,n),A(t,r),o&&o.m(t,null),A(t,l),a&&a.m(t,null)},p(e,n){e[2]&&e[2]<1?o?o.p(e,n):((o=eo(e)).c(),o.m(t,l)):o&&(o.d(1),o=null),e[5]?a?a.p(e,n):((a=to(e)).c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&I(t),o&&o.d(),a&&a.d()}}}function eo(e){let t;return{c(){(t=M(\"progress\")).value=e[2]},m(e,n){q(e,t,n)},p(e,n){4&n&&(t.value=e[2])},d(e){e&&I(t)}}}function to(e){let t,n,r,l,o,a,s,i,c=JSON.stringify(e[6])+\"\";return{c(){t=M(\"ul\"),n=M(\"li\"),r=N(\"Action: \"),l=N(e[5]),o=V(),a=M(\"li\"),s=N(\"Args: \"),i=N(c),G(n,\"class\",\"svelte-lifdi8\"),G(a,\"class\",\"svelte-lifdi8\"),G(t,\"class\",\"svelte-lifdi8\")},m(e,c){q(e,t,c),A(t,n),A(n,r),A(n,l),A(t,o),A(t,a),A(a,s),A(a,i)},p(e,t){32&t&&F(l,e[5]),64&t&&c!==(c=JSON.stringify(e[6])+\"\")&&F(i,c)},d(e){e&&I(t)}}}function no(e){let t,n,r,l,o,a;const s=[Xl,Ul,Zl],i=[];function c(e,t){return e[0].game.ai&&!e[0].multiplayer?0:e[0].multiplayer?1:2}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c()},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keydown\",e[14]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function ro(e,t,n){let{client:l}=t,{clientManager:o}=t;const{secondaryPane:a}=de(\"secondaryPane\"),s={MCTS:r.M,Random:r.R};let i=!1,c=null,u=0,d=null;const f=({iterationCounter:e,numIterations:t,metadata:r})=>{n(3,u=e),n(2,c=e/t),d=r,i&&d&&a.set({component:jl,metadata:d})};let p,m,g,v;function $(){l.overrideGameState(null),a.set(null),n(1,i=!1)}return l.game.ai&&(p=new r.M({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:f})).setOpt(\"async\",!0),ie($),e.$$set=(e=>{\"client\"in e&&n(0,l=e.client),\"clientManager\"in e&&n(15,o=e.clientManager)}),[l,i,c,u,m,g,v,p,s,function(){i&&d?a.set({component:jl,metadata:d}):a.set(null)},function(){const e=s[m];n(7,p=new e({game:l.game,enumerate:l.game.ai.enumerate,iterationCallback:f})),p.setOpt(\"async\",!0),n(5,g=null),d=null,a.set(null),n(3,u=0)},async function(){n(5,g=null),d=null,n(3,u=0);const e=await(0,r.S)(l,p);e&&(n(5,g=e.payload.type),n(6,v=e.payload.args))},function(e=1e4,t=100){return n(5,g=null),d=null,n(3,u=0),(async()=>{for(let n=0;n<e&&await(0,r.S)(l,p);n++)await new Promise(e=>setTimeout(e,t))})()},function(){l.reset(),n(5,g=null),d=null,n(3,u=0),$()},function(e){27==e.keyCode&&$()},o,function(){m=U(this),n(4,m),n(8,s)},function(){i=this.checked,n(1,i)}]}class lo extends Le{constructor(e){super(),Je(this,e,ro,no,d,{client:0,clientManager:15},Fl)}}function oo(e){z(e,\"svelte-18rjbx9\",\".debug-panel.svelte-18rjbx9.svelte-18rjbx9{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-18rjbx9.svelte-18rjbx9{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9:hover,.visibility-toggle.svelte-18rjbx9.svelte-18rjbx9:focus{background:#eee}.opener.svelte-18rjbx9.svelte-18rjbx9{right:10px}.closer.svelte-18rjbx9.svelte-18rjbx9{left:175px}@keyframes svelte-18rjbx9-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-18rjbx9.svelte-18rjbx9{display:flex;height:100%;animation:svelte-18rjbx9-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\\n      normal forwards}.closer.svelte-18rjbx9 .icon.svelte-18rjbx9{animation-direction:reverse}.pane.svelte-18rjbx9.svelte-18rjbx9{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-18rjbx9.svelte-18rjbx9{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-18rjbx9 button,.debug-panel.svelte-18rjbx9 select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-18rjbx9 select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-18rjbx9 section{margin-bottom:20px}.debug-panel.svelte-18rjbx9 .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}\")}function ao(e){let t,n,r,l,o,a,s,i,c,u,d,f,p,m,g,v;l=new at({}),(i=new ft({props:{panes:e[6],pane:e[2]}})).$on(\"change\",e[8]);var $=e[6][e[2]].component;function y(e){return{props:{client:e[4],clientManager:e[0],ToggleVisibility:e[9]}}}$&&(d=new $(y(e)));let h=e[5]&&io(e);return{c(){t=M(\"div\"),n=M(\"button\"),r=M(\"span\"),Be(l.$$.fragment),s=V(),Be(i.$$.fragment),c=V(),u=M(\"div\"),d&&Be(d.$$.fragment),f=V(),h&&h.c(),G(r,\"class\",\"icon svelte-18rjbx9\"),G(r,\"aria-hidden\",\"true\"),G(n,\"class\",\"visibility-toggle closer svelte-18rjbx9\"),G(n,\"title\",\"Hide Debug Panel\"),G(u,\"class\",\"pane svelte-18rjbx9\"),G(u,\"role\",\"region\"),G(u,\"aria-label\",e[2]),G(u,\"tabindex\",\"-1\"),G(t,\"class\",\"panel svelte-18rjbx9\")},m(o,a){q(o,t,a),A(t,n),A(n,r),Re(l,r,null),A(t,s),Re(i,t,null),A(t,c),A(t,u),d&&Re(d,u,null),e[15](u),A(t,f),h&&h.m(t,null),m=!0,g||(v=R(n,\"click\",e[9]),g=!0)},p(n,r){e=n;const l={};4&r&&(l.pane=e[2]),i.$set(l);const o={};if(16&r&&(o.client=e[4]),1&r&&(o.clientManager=e[0]),$!==($=e[6][e[2]].component)){if(d){_e();const e=d;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}$?(Be((d=new $(y(e))).$$.fragment),Ce(d.$$.fragment,1),Re(d,u,null)):d=null}else $&&d.$set(o);(!m||4&r)&&G(u,\"aria-label\",e[2]),e[5]?h?(h.p(e,r),32&r&&Ce(h,1)):((h=io(e)).c(),Ce(h,1),h.m(t,null)):h&&(_e(),qe(h,1,1,()=>{h=null}),Se())},i(r){m||(Ce(l.$$.fragment,r),be(()=>{a&&a.end(1),(o=Te(n,e[13],{key:\"toggle\"})).start()}),Ce(i.$$.fragment,r),d&&Ce(d.$$.fragment,r),Ce(h),be(()=>{p||(p=De(t,Xe,{x:400,...e[11]},!0)),p.run(1)}),m=!0)},o(r){qe(l.$$.fragment,r),o&&o.invalidate(),a=Me(n,e[12],{key:\"toggle\"}),qe(i.$$.fragment,r),d&&qe(d.$$.fragment,r),qe(h),p||(p=De(t,Xe,{x:400,...e[11]},!1)),p.run(0),m=!1},d(n){n&&I(t),Ke(l),n&&a&&a.end(),Ke(i),d&&Ke(d),e[15](null),h&&h.d(),n&&p&&p.end(),g=!1,v()}}}function so(e){let t,n,r,o,a,s,i,c;return r=new at({}),{c(){t=M(\"button\"),n=M(\"span\"),Be(r.$$.fragment),G(n,\"class\",\"icon svelte-18rjbx9\"),G(n,\"aria-hidden\",\"true\"),G(t,\"class\",\"visibility-toggle opener svelte-18rjbx9\"),G(t,\"title\",\"Show Debug Panel\")},m(l,o){q(l,t,o),A(t,n),Re(r,n,null),s=!0,i||(c=R(t,\"click\",e[9]),i=!0)},p:l,i(n){s||(Ce(r.$$.fragment,n),be(()=>{a&&a.end(1),(o=Te(t,e[13],{key:\"toggle\"})).start()}),s=!0)},o(n){qe(r.$$.fragment,n),o&&o.invalidate(),a=Me(t,e[12],{key:\"toggle\"}),s=!1},d(e){e&&I(t),Ke(r),e&&a&&a.end(),i=!1,c()}}}function io(e){let t,n,r;var l=e[5].component;function o(e){return{props:{metadata:e[5].metadata}}}return l&&(n=new l(o(e))),{c(){t=M(\"div\"),n&&Be(n.$$.fragment),G(t,\"class\",\"secondary-pane svelte-18rjbx9\")},m(e,l){q(e,t,l),n&&Re(n,t,null),r=!0},p(e,r){const a={};if(32&r&&(a.metadata=e[5].metadata),l!==(l=e[5].component)){if(n){_e();const e=n;qe(e.$$.fragment,1,0,()=>{Ke(e,1)}),Se()}l?(Be((n=new l(o(e))).$$.fragment),Ce(n.$$.fragment,1),Re(n,t,null)):n=null}else l&&n.$set(a)},i(e){r||(n&&Ce(n.$$.fragment,e),r=!0)},o(e){n&&qe(n.$$.fragment,e),r=!1},d(e){e&&I(t),n&&Ke(n)}}}function co(e){let t,n,r,l,o,a;const s=[so,ao],i=[];function c(e,t){return e[3]?1:0}return n=c(e),r=i[n]=s[n](e),{c(){t=M(\"section\"),r.c(),G(t,\"aria-label\",\"boardgame.io Debug Panel\"),G(t,\"class\",\"debug-panel svelte-18rjbx9\")},m(r,s){q(r,t,s),i[n].m(t,null),l=!0,o||(a=R(window,\"keypress\",e[10]),o=!0)},p(e,[l]){let o=n;(n=c(e))===o?i[n].p(e,l):(_e(),qe(i[o],1,1,()=>{i[o]=null}),Se(),(r=i[n])?r.p(e,l):(r=i[n]=s[n](e)).c(),Ce(r,1),r.m(t,null))},i(e){l||(Ce(r),l=!0)},o(e){qe(r),l=!1},d(e){e&&I(t),i[n].d(),o=!1,a()}}}function uo(e,t,n){let r,o,a,s=l,i=()=>(s(),s=p(c,e=>n(14,o=e)),c);e.$$.on_destroy.push(()=>s());let{clientManager:c}=t;i();const u={main:{label:\"Main\",shortcut:\"m\",component:zr},log:{label:\"Log\",shortcut:\"l\",component:Dl},info:{label:\"Info\",shortcut:\"i\",component:Nr},ai:{label:\"AI\",shortcut:\"a\",component:lo}},d=He(!1),f=He(null);let g;m(e,f,e=>n(5,a=e)),ue(\"hotkeys\",{disableHotkeys:d}),ue(\"secondaryPane\",{secondaryPane:f});let v=\"main\";function $(){n(3,y=!y)}let y=!0;const h={duration:150,easing:Ze},[b,x]=Ye(h);return e.$$set=(e=>{\"clientManager\"in e&&i(n(0,c=e.clientManager))}),e.$$.update=(()=>{16384&e.$$.dirty&&n(4,r=o.client)}),[c,g,v,y,r,a,u,f,function(e){n(2,v=e.detail),g.focus()},$,function(e){\".\"!=e.key?y&&Object.entries(u).forEach(([t,{shortcut:r}])=>{e.key==r&&n(2,v=t)}):$()},h,b,x,o,function(e){me[e?\"unshift\":\"push\"](()=>{n(1,g=e)})}]}class fo extends Le{constructor(e){super(),Je(this,e,uo,co,d,{clientManager:0},oo)}}exports.D=fo;\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"flatted\":\"O5av\",\"./ai-f28cab02.js\":\"vgbL\"}],\"KkrQ\":[function(require,module,exports) {\n\"use strict\";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=e;\n},{}],\"e8DE\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=n;var e=r(require(\"./defineProperty.js\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){(0,e.default)(r,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}\n},{\"./defineProperty.js\":\"KkrQ\"}],\"OV4J\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.applyMiddleware=v,exports.bindActionCreators=y,exports.combineReducers=d,exports.compose=h,exports.createStore=c,exports.__DO_NOT_USE__ActionTypes=void 0;var e=r(require(\"@babel/runtime/helpers/esm/objectSpread2\"));function r(e){return e&&e.__esModule?e:{default:e}}function t(e){return\"Minified Redux error #\"+e+\"; visit https://redux.js.org/Errors?code=\"+e+\" for the full message or use the non-minified dev environment for full errors. \"}var n=\"function\"==typeof Symbol&&Symbol.observable||\"@@observable\",o=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},i={INIT:\"@@redux/INIT\"+o(),REPLACE:\"@@redux/REPLACE\"+o(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+o()}};function u(e){if(\"object\"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function f(e){var r=typeof e;return r}function c(e,r,o){var f;if(\"function\"==typeof r&&\"function\"==typeof o||\"function\"==typeof o&&\"function\"==typeof arguments[3])throw new Error(t(0));if(\"function\"==typeof r&&void 0===o&&(o=r,r=void 0),void 0!==o){if(\"function\"!=typeof o)throw new Error(t(1));return o(c)(e,r)}if(\"function\"!=typeof e)throw new Error(t(2));var a=e,p=r,s=[],d=s,l=!1;function y(){d===s&&(d=s.slice())}function h(){if(l)throw new Error(t(3));return p}function v(e){if(\"function\"!=typeof e)throw new Error(t(4));if(l)throw new Error(t(5));var r=!0;return y(),d.push(e),function(){if(r){if(l)throw new Error(t(6));r=!1,y();var n=d.indexOf(e);d.splice(n,1),s=null}}}function w(e){if(!u(e))throw new Error(t(7));if(void 0===e.type)throw new Error(t(8));if(l)throw new Error(t(9));try{l=!0,p=a(p,e)}finally{l=!1}for(var r=s=d,n=0;n<r.length;n++){(0,r[n])()}return e}return w({type:i.INIT}),(f={dispatch:w,subscribe:v,getState:h,replaceReducer:function(e){if(\"function\"!=typeof e)throw new Error(t(10));a=e,w({type:i.REPLACE})}})[n]=function(){var e,r=v;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new Error(t(11));function n(){e.next&&e.next(h())}return n(),{unsubscribe:r(n)}}})[n]=function(){return this},e},f}function a(e){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(r){}}function p(e,r,t,n){var o=Object.keys(r),c=t&&t.type===i.INIT?\"preloadedState argument passed to createStore\":\"previous state received by the reducer\";if(0===o.length)return\"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.\";if(!u(e))return\"The \"+c+' has unexpected type of \"'+f(e)+'\". Expected argument to be an object with the following keys: \"'+o.join('\", \"')+'\"';var a=Object.keys(e).filter(function(e){return!r.hasOwnProperty(e)&&!n[e]});return a.forEach(function(e){n[e]=!0}),t&&t.type===i.REPLACE?void 0:a.length>0?\"Unexpected \"+(a.length>1?\"keys\":\"key\")+' \"'+a.join('\", \"')+'\" found in '+c+'. Expected to find one of the known reducer keys instead: \"'+o.join('\", \"')+'\". Unexpected keys will be ignored.':void 0}function s(e){Object.keys(e).forEach(function(r){var n=e[r];if(void 0===n(void 0,{type:i.INIT}))throw new Error(t(12));if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw new Error(t(13))})}function d(e){for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o];0,\"function\"==typeof e[i]&&(n[i]=e[i])}var u,f=Object.keys(n);try{s(n)}catch(c){u=c}return function(e,r){if(void 0===e&&(e={}),u)throw u;for(var o=!1,i={},c=0;c<f.length;c++){var a=f[c],p=n[a],s=e[a],d=p(s,r);if(void 0===d){r&&r.type;throw new Error(t(14))}i[a]=d,o=o||d!==s}return(o=o||f.length!==Object.keys(e).length)?i:e}}function l(e,r){return function(){return r(e.apply(this,arguments))}}function y(e,r){if(\"function\"==typeof e)return l(e,r);if(\"object\"!=typeof e||null===e)throw new Error(t(16));var n={};for(var o in e){var i=e[o];\"function\"==typeof i&&(n[o]=l(i,r))}return n}function h(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return 0===r.length?function(e){return e}:1===r.length?r[0]:r.reduce(function(e,r){return function(){return e(r.apply(void 0,arguments))}})}function v(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return function(r){return function(){var o=r.apply(void 0,arguments),i=function(){throw new Error(t(15))},u={getState:o.getState,dispatch:function(){return i.apply(void 0,arguments)}},f=n.map(function(e){return e(u)});return i=h.apply(void 0,f)(o.dispatch),(0,e.default)((0,e.default)({},o),{},{dispatch:i})}}}function w(){}exports.__DO_NOT_USE__ActionTypes=i;\n},{\"@babel/runtime/helpers/esm/objectSpread2\":\"e8DE\"}],\"azvt\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.I=r;var e=require(\"./turn-order-0d61594c.js\"),t=require(\"./reducer-77828ca8.js\");function r({game:r,numPlayers:u,setupData:s}){u||(u=2);let n={G:{},ctx:(r=(0,t.P)(r)).flow.ctx(u),plugins:{}};n=(0,e.r)(n,{game:r}),n=(0,e.f)(n,{game:r,playerID:void 0});const o=(0,e.E)(n);n.G=r.setup(o,s);let a={...n,_undo:[],_redo:[],_stateID:0};return a=r.flow.init(a),[a]=(0,e.p)(a,{game:r}),r.disableUndo||(a._undo=[{G:a.G,ctx:a.ctx,plugins:a.plugins}]),a}\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\"}],\"KLsr\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.T=void 0;class e{constructor({store:e,gameName:t,playerID:s,matchID:a,credentials:r,numPlayers:l}){this.store=e,this.gameName=t||\"default\",this.playerID=s||null,this.matchID=a||\"default\",this.credentials=r,this.numPlayers=l||2}}exports.T=e;\n},{}],\"yBCo\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.C=y;var t=require(\"nanoid\"),e=require(\"./Debug-a4f4cad1.js\"),s=require(\"redux\"),i=require(\"./turn-order-0d61594c.js\"),r=require(\"./reducer-77828ca8.js\"),a=require(\"./initialize-68f0dc41.js\"),n=require(\"./transport-0079de87.js\");class h extends n.T{connect(){}disconnect(){}onAction(){}onChatMessage(){}subscribe(){}subscribeChatMessage(){}subscribeMatchData(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}}const l=t=>new h(t);class u{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(const[t]of this.clients){if(this.debugPanel)break;this.mountDebug(t)}}this.notifySubscribers()}subscribe(t){const e=Symbol();return this.subscribers.set(e,t),t(this.getState()),()=>{this.subscribers.delete(e)}}switchPlayerID(t){if(this.currentClient.multiplayer)for(const[e]of this.clients)if(e.playerID===t&&!1!==e.debugOpt&&e.multiplayer===this.currentClient.multiplayer)return void this.switchToClient(e);this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){const t=this.getState();this.subscribers.forEach(e=>{e(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>!1!==t.debugOpt)}mountDebug(t){if(!1===t.debugOpt||null!==this.debugPanel||\"undefined\"==typeof document)return;let e,s=document.body;t.debugOpt&&!0!==t.debugOpt&&(e=t.debugOpt.impl||e,s=t.debugOpt.target||s),e&&(this.currentClient=t,this.debugPanel=new e({target:s,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}}const c=new u;function o(t,e,s){if(!s&&null==t){t=e.getState().ctx.currentPlayer}return t}function g(t,e,s,r,a,n){const h={};for(const l of e)h[l]=((...e)=>{const h=i.A[t](l,e,o(r,s,n),a);s.dispatch(h)});return h}const b=g.bind(null,\"makeMove\"),d=g.bind(null,\"gameEvent\"),p=g.bind(null,\"plugin\");class m{constructor({game:e,debug:n,numPlayers:h,multiplayer:u,matchID:g,playerID:b,credentials:d,enhancer:p}){this.game=(0,r.P)(e),this.playerID=b,this.matchID=g,this.credentials=d,this.multiplayer=u,this.debugOpt=n,this.manager=c,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=(0,r.C)({game:this.game,isClient:void 0!==u}),this.initialState=null,u||(this.initialState=(0,a.I)({game:this.game,numPlayers:h})),this.reset=(()=>{this.store.dispatch((0,i.t)(this.initialState))}),this.undo=(()=>{const t=(0,i.u)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.redo=(()=>{const t=(0,i.v)(o(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(t)}),this.log=[];const m=(0,s.applyMiddleware)(r.T,()=>t=>e=>{const s=t(e);return this.notifySubscribers(),s},t=>e=>s=>{const r=t.getState(),a=e(s);return\"clientOnly\"in s||s.type===i.c||this.transport.onAction(r,s),a},t=>e=>s=>{const r=e(s),a=t.getState();switch(s.type){case i.M:case i.d:case i.l:case i.m:{const t=a.deltalog;this.log=[...this.log,...t];break}case i.R:this.log=[];break;case i.o:case i.j:{let t=-1;this.log.length>0&&(t=this.log[this.log.length-1]._stateID);let e=s.deltalog||[];e=e.filter(e=>e._stateID>t),this.log=[...this.log,...e];break}case i.k:this.initialState=s.initialState,this.log=s.log||[]}return r});p=void 0!==p?(0,s.compose)(m,p):m,this.store=(0,s.createStore)(this.reducer,this.initialState,p),u||(u=l),this.transport=u({gameKey:e,game:this.game,store:this.store,matchID:g,playerID:b,credentials:d,gameName:this.game.name,numPlayers:h}),this.createDispatchers(),this.transport.subscribeMatchData(t=>{this.matchData=t,this.notifySubscribers()}),this.chatMessages=[],this.sendChatMessage=(e=>{this.transport.onChatMessage(this.matchID,{id:(0,t.nanoid)(7),sender:this.playerID,payload:e})}),this.transport.subscribeChatMessage(t=>{this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()})}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){const e=Object.keys(this.subscribers).length;return this.subscribers[e]=t,this.transport.subscribe(()=>this.notifySubscribers()),!this._running&&this.multiplayer||t(this.getState()),()=>{delete this.subscribers[e]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(null!==this.gameStateOverride&&(t=this.gameStateOverride),null===t)return t;let e=!0;const s=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!s&&(e=!1),this.multiplayer||null===this.playerID||void 0===this.playerID||s||(e=!1),void 0!==t.ctx.gameover&&(e=!1),this.multiplayer||(t={...t,G:this.game.playerView(t.G,t.ctx,this.playerID),plugins:(0,i.w)(t,this)}),{...t,log:this.log,isActive:e,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=b(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=d(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=p(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}}function y(t){return new m(t)}\n},{\"nanoid\":\"b767\",\"./Debug-a4f4cad1.js\":\"odqP\",\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\"}],\"hK59\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.a=exports.L=void 0;const t=(t,e)=>{if(!t||\"string\"!=typeof t)throw new Error(`Expected ${e} string, got \"${t}\".`)},e=e=>t(e,\"game name\"),s=e=>t(e,\"match ID\"),r=(t,e)=>{if(!t)throw new Error(`Expected body, got “${t}”.`);for(const s in e){const r=e[s],a=t[s];if(typeof a!==r)throw new TypeError(`Expected body.${s} to be of type ${r}, got “${a}”.`)}};class a extends Error{constructor(t,e){super(t),this.details=e}}exports.a=a;class i{constructor({server:t=\"\"}={}){this.server=t.replace(/\\/$/,\"\")}async request(t,e){const s=await fetch(this.server+t,e);if(!s.ok){let t;try{t=await s.json()}catch{try{t=await s.text()}catch(r){t=r.message}}throw new a(`HTTP status ${s.status}`,t)}return s.json()}async post(t,e){let s={method:\"post\",body:JSON.stringify(e.body),headers:{\"Content-Type\":\"application/json\"}};return e.init&&(s={...s,...e.init,headers:{...s.headers,...e.init.headers}}),this.request(t,s)}async listGames(t){return this.request(\"/games\",t)}async listMatches(t,s,r){e(t);let a=\"\";if(s){const t=[],{isGameover:e,updatedBefore:r,updatedAfter:i}=s;void 0!==e&&t.push(`isGameover=${e}`),r&&t.push(`updatedBefore=${r}`),i&&t.push(`updatedAfter=${i}`),t.length>0&&(a=\"?\"+t.join(\"&\"))}return this.request(`/games/${t}${a}`,r)}async getMatch(t,r,a){return e(t),s(r),this.request(`/games/${t}/${r}`,a)}async createMatch(t,s,a){return e(t),r(s,{numPlayers:\"number\"}),this.post(`/games/${t}/create`,{body:s,init:a})}async joinMatch(t,a,i,n){return e(t),s(a),r(i,{playerID:\"string\",playerName:\"string\"}),this.post(`/games/${t}/${a}/join`,{body:i,init:n})}async leaveMatch(t,a,i,n){e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${t}/${a}/leave`,{body:i,init:n})}async updatePlayer(t,a,i,n){e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),await this.post(`/games/${t}/${a}/update`,{body:i,init:n})}async playAgain(t,a,i,n){return e(t),s(a),r(i,{playerID:\"string\",credentials:\"string\"}),this.post(`/games/${t}/${a}/playAgain`,{body:i,init:n})}}exports.L=i;\n},{}],\"iSKo\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Client\",{enumerable:!0,get:function(){return e.C}}),Object.defineProperty(exports,\"LobbyClient\",{enumerable:!0,get:function(){return r.L}}),Object.defineProperty(exports,\"LobbyClientError\",{enumerable:!0,get:function(){return r.a}}),require(\"nanoid\"),require(\"./Debug-a4f4cad1.js\"),require(\"redux\"),require(\"./turn-order-0d61594c.js\"),require(\"immer\"),require(\"lodash.isplainobject\"),require(\"./reducer-77828ca8.js\"),require(\"rfc6902\"),require(\"./initialize-68f0dc41.js\"),require(\"./transport-0079de87.js\");var e=require(\"./client-1535506e.js\");require(\"flatted\"),require(\"./ai-f28cab02.js\");var r=require(\"./client-99609c4d.js\");\n},{\"nanoid\":\"b767\",\"./Debug-a4f4cad1.js\":\"odqP\",\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-77828ca8.js\":\"b133\",\"rfc6902\":\"B6py\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\",\"./client-1535506e.js\":\"yBCo\",\"flatted\":\"O5av\",\"./ai-f28cab02.js\":\"vgbL\",\"./client-99609c4d.js\":\"hK59\"}],\"VAT5\":[function(require,module,exports) {\n\"use strict\";var e;function t(t){return t.type()===e.SYNC}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.i=t,exports.S=exports.A=void 0,function(e){e[e.SYNC=0]=\"SYNC\",e[e.ASYNC=1]=\"ASYNC\"}(e||(e={}));class a{type(){return e.ASYNC}async createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}async listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.A=a;class s{type(){return e.SYNC}connect(){}createMatch(e,t){if(this.createGame)return console.warn(\"The database connector does not implement a createMatch method.\",\"\\nUsing the deprecated createGame method instead.\"),this.createGame(e,t);console.error(\"The database connector does not implement a createMatch method.\")}listMatches(e){if(this.listGames)return console.warn(\"The database connector does not implement a listMatches method.\",\"\\nUsing the deprecated listGames method instead.\"),this.listGames(e);console.error(\"The database connector does not implement a listMatches method.\")}}exports.S=s;\n},{}],\"pSJp\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.M=void 0;var t=require(\"redux\"),a=require(\"./turn-order-0d61594c.js\"),e=require(\"./reducer-77828ca8.js\"),r=require(\"./initialize-68f0dc41.js\"),s=require(\"./base-13e38c3e.js\");const i=({game:t,unlisted:a,setupData:e,numPlayers:r})=>{const s={gameName:t.name,unlisted:!!a,players:{},createdAt:Date.now(),updatedAt:Date.now()};void 0!==e&&(s.setupData=e);for(let i=0;i<r;i++)s.players[i]={id:i};return s},o=({game:t,numPlayers:a,setupData:e,unlisted:s})=>{a&&\"number\"==typeof a||(a=2);const o=t.validateSetupData&&t.validateSetupData(e,a);return void 0!==o?{setupDataError:o}:{metadata:i({game:t,numPlayers:a,setupData:e,unlisted:s}),initialState:(0,r.I)({game:t,numPlayers:a,setupData:e})}},n=t=>Object.values(t.players).map(t=>{const{credentials:a,...e}=t;return e}),l=t=>{const{credentials:a,...e}=t.payload;return{...t,payload:e}};class d{constructor(t,a,r,s){this.game=(0,e.P)(t),this.storageAPI=a,this.transportAPI=r,this.subscribeCallback=(()=>{}),this.auth=s}subscribe(t){this.subscribeCallback=t}async onUpdate(r,i,o,n){if(!r||!r.payload)return{error:\"missing action or action payload\"};let d;if((0,s.i)(this.storageAPI)?({metadata:d}=this.storageAPI.fetch(o,{metadata:!0})):({metadata:d}=await this.storageAPI.fetch(o,{metadata:!0})),this.auth){if(!(await this.auth.authenticateCredentials({playerID:n,credentials:r.payload.credentials,metadata:d})))return{error:\"unauthorized action\"}}const c=l(r),h=o;let u;if((0,s.i)(this.storageAPI)?({state:u}=this.storageAPI.fetch(h,{state:!0})):({state:u}=await this.storageAPI.fetch(h,{state:!0})),void 0===u)return(0,a.e)(`game not found, matchID=[${h}]`),{error:\"game not found\"};if(void 0!==u.ctx.gameover)return void(0,a.e)(`game over - matchID=[${h}] - playerID=[${n}]`+` - action[${c.payload.type}]`);const p=(0,e.C)({game:this.game}),g=(0,t.applyMiddleware)(e.T),m=(0,t.createStore)(p,u,g);if(c.type==a.l||c.type==a.m){const t=null!==u.ctx.activePlayers,e=u.ctx.currentPlayer===n;if(!t&&!e||t&&(void 0===u.ctx.activePlayers[n]||Object.keys(u.ctx.activePlayers).length>1))return void(0,a.e)(`playerID=[${n}] cannot undo / redo right now`)}if(!this.game.flow.isPlayerActive(u.G,u.ctx,n))return void(0,a.e)(`player not active - playerID=[${n}]`+` - action[${c.payload.type}]`);const y=c.type==a.M?this.game.flow.getMove(u.ctx,c.payload.type,n):null;if(c.type==a.M&&!y)return void(0,a.e)(`move not processed - canPlayerMakeMove=false - playerID=[${n}]`+` - action[${c.payload.type}]`);if(u._stateID!==i&&!(y&&(0,e.I)(y)&&y.ignoreStaleStateID))return void(0,a.e)(`invalid stateID, was=[${i}], expected=[${u._stateID}]`+` - playerID=[${n}] - action[${c.payload.type}]`);const I=m.getState();m.dispatch(c),u=m.getState(),this.subscribeCallback({state:u,action:c,matchID:o}),this.game.deltaState?this.transportAPI.sendAll({type:\"patch\",args:[o,i,I,u]}):this.transportAPI.sendAll({type:\"update\",args:[o,u]});const{deltalog:f,...P}=u;let A;if(!d||\"gameover\"in d||(A={...d,updatedAt:Date.now()},void 0!==u.ctx.gameover&&(A.gameover=u.ctx.gameover)),(0,s.i)(this.storageAPI))this.storageAPI.setState(h,P,f),A&&this.storageAPI.setMetadata(h,A);else{const t=[this.storageAPI.setState(h,P,f)];A&&t.push(this.storageAPI.setMetadata(h,A)),await Promise.all(t)}}async onSync(t,a,e,r=2){const i=t,l={state:!0,metadata:!0,log:!0,initialState:!0},d=(0,s.i)(this.storageAPI)?this.storageAPI.fetch(i,l):await this.storageAPI.fetch(i,l);let{state:c,initialState:h,log:u,metadata:p}=d;if(this.auth&&null!=a){if(!(await this.auth.authenticateCredentials({playerID:a,credentials:e,metadata:p})))return{error:\"unauthorized\"}}if(void 0===c){const a=o({game:this.game,unlisted:!0,numPlayers:r,setupData:void 0});if(\"setupDataError\"in a)return{error:\"game requires setupData\"};h=c=a.initialState,p=a.metadata,this.subscribeCallback({state:c,matchID:t}),(0,s.i)(this.storageAPI)?this.storageAPI.createMatch(i,{initialState:h,metadata:p}):await this.storageAPI.createMatch(i,{initialState:h,metadata:p})}const g={state:c,log:u,filteredMetadata:p?n(p):void 0,initialState:h};this.transportAPI.send({playerID:a,type:\"sync\",args:[t,g]})}async onConnectionChange(t,e,r,i){const o=t;if(null==e)return;let l;if((0,s.i)(this.storageAPI)?({metadata:l}=this.storageAPI.fetch(o,{metadata:!0})):({metadata:l}=await this.storageAPI.fetch(o,{metadata:!0})),void 0===l)return(0,a.e)(`metadata not found for matchID=[${o}]`),{error:\"metadata not found\"};if(void 0===l.players[e])return(0,a.e)(`Player not in the match, matchID=[${o}] playerID=[${e}]`),{error:\"player not in the match\"};if(this.auth){if(!(await this.auth.authenticateCredentials({playerID:e,credentials:r,metadata:l})))return{error:\"unauthorized\"}}l.players[e].isConnected=i;const d=n(l);this.transportAPI.sendAll({type:\"matchData\",args:[t,d]}),(0,s.i)(this.storageAPI)?this.storageAPI.setMetadata(o,l):await this.storageAPI.setMetadata(o,l)}async onChatMessage(t,a,e){const r=t;if(this.auth){const{metadata:t}=await this.storageAPI.fetch(r,{metadata:!0});if(!a||\"string\"!=typeof a.sender)return{error:\"unauthorized\"};if(!(await this.auth.authenticateCredentials({playerID:a.sender,credentials:e,metadata:t})))return{error:\"unauthorized\"}}this.transportAPI.sendAll({type:\"chat\",args:[t,a]})}}exports.M=d;\n},{\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"./reducer-77828ca8.js\":\"b133\",\"./initialize-68f0dc41.js\":\"azvt\",\"./base-13e38c3e.js\":\"VAT5\"}],\"A28J\":[function(require,module,exports) {\nvar r=/^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/,e=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];function t(r,e){var t=e.replace(/\\/{2,9}/g,\"/\").split(\"/\");return\"/\"!=e.substr(0,1)&&0!==e.length||t.splice(0,1),\"/\"==e.substr(e.length-1,1)&&t.splice(t.length-1,1),t}function s(r,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,e,s){e&&(t[e]=s)}),t}module.exports=function(u){var a=u,n=u.indexOf(\"[\"),o=u.indexOf(\"]\");-1!=n&&-1!=o&&(u=u.substring(0,n)+u.substring(n,o).replace(/:/g,\";\")+u.substring(o,u.length));for(var i=r.exec(u||\"\"),p={},c=14;c--;)p[e[c]]=i[c]||\"\";return-1!=n&&-1!=o&&(p.source=a,p.host=p.host.substring(1,p.host.length-1).replace(/;/g,\":\"),p.authority=p.authority.replace(\"[\",\"\").replace(\"]\",\"\").replace(/;/g,\":\"),p.ipv6uri=!0),p.pathNames=t(p,p.path),p.queryKey=s(p,p.query),p};\n},{}],\"EmkX\":[function(require,module,exports) {\nvar s=1e3,e=60*s,r=60*e,a=24*r,n=7*a,c=365.25*a;function t(t){if(!((t=String(t)).length>100)){var u=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(u){var i=parseFloat(u[1]);switch((u[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return i*c;case\"weeks\":case\"week\":case\"w\":return i*n;case\"days\":case\"day\":case\"d\":return i*a;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return i*r;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return i*e;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return i*s;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return i;default:return}}}}function u(n){var c=Math.abs(n);return c>=a?Math.round(n/a)+\"d\":c>=r?Math.round(n/r)+\"h\":c>=e?Math.round(n/e)+\"m\":c>=s?Math.round(n/s)+\"s\":n+\"ms\"}function i(n){var c=Math.abs(n);return c>=a?o(n,c,a,\"day\"):c>=r?o(n,c,r,\"hour\"):c>=e?o(n,c,e,\"minute\"):c>=s?o(n,c,s,\"second\"):n+\" ms\"}function o(s,e,r,a){var n=e>=1.5*r;return Math.round(s/r)+\" \"+a+(n?\"s\":\"\")}module.exports=function(s,e){e=e||{};var r=typeof s;if(\"string\"===r&&s.length>0)return t(s);if(\"number\"===r&&isFinite(s))return e.long?i(s):u(s);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(s))};\n},{}],\"sQiI\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"pBGv\":[function(require,module,exports) {\n\nvar t,e,n=module.exports={};function r(){throw new Error(\"setTimeout has not been defined\")}function o(){throw new Error(\"clearTimeout has not been defined\")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===r||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}function u(t){if(e===clearTimeout)return clearTimeout(t);if((e===o||!e)&&clearTimeout)return e=clearTimeout,clearTimeout(t);try{return e(t)}catch(n){try{return e.call(null,t)}catch(n){return e.call(this,t)}}}!function(){try{t=\"function\"==typeof setTimeout?setTimeout:r}catch(n){t=r}try{e=\"function\"==typeof clearTimeout?clearTimeout:o}catch(n){e=o}}();var c,s=[],l=!1,a=-1;function f(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}function h(){if(!l){var t=i(f);l=!0;for(var e=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}function m(t,e){this.fun=t,this.array=e}function p(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(new m(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=\"browser\",n.env={},n.argv=[],n.version=\"\",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){throw new Error(\"process.binding is not supported\")},n.cwd=function(){return\"/\"},n.chdir=function(t){throw new Error(\"process.chdir is not supported\")},n.umask=function(){return 0};\n},{}],\"fhQu\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"sQiI\",\"process\":\"pBGv\"}],\"U1mP\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.url=void 0;const t=require(\"parseuri\"),o=require(\"debug\")(\"socket.io-client:url\");function r(r,e=\"\",s){let p=r;s=s||\"undefined\"!=typeof location&&location,null==r&&(r=s.protocol+\"//\"+s.host),\"string\"==typeof r&&(\"/\"===r.charAt(0)&&(r=\"/\"===r.charAt(1)?s.protocol+r:s.host+r),/^(https?|wss?):\\/\\//.test(r)||(o(\"protocol-less url %s\",r),r=void 0!==s?s.protocol+\"//\"+r:\"https://\"+r),o(\"parse %s\",r),p=t(r)),p.port||(/^(http|ws)$/.test(p.protocol)?p.port=\"80\":/^(http|ws)s$/.test(p.protocol)&&(p.port=\"443\")),p.path=p.path||\"/\";const l=-1!==p.host.indexOf(\":\")?\"[\"+p.host+\"]\":p.host;return p.id=p.protocol+\"://\"+l+\":\"+p.port+e,p.href=p.protocol+\"://\"+l+(s&&s.port===p.port?\"\":\":\"+p.port),p}exports.url=r;\n},{\"parseuri\":\"A28J\",\"debug\":\"fhQu\"}],\"cnu0\":[function(require,module,exports) {\ntry{module.exports=\"undefined\"!=typeof XMLHttpRequest&&\"withCredentials\"in new XMLHttpRequest}catch(e){module.exports=!1}\n},{}],\"gHSz\":[function(require,module,exports) {\nmodule.exports=(()=>\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:Function(\"return this\")())();\n},{}],\"jhGE\":[function(require,module,exports) {\nconst e=require(\"has-cors\"),t=require(\"./globalThis\");module.exports=function(n){const c=n.xdomain,o=n.xscheme,r=n.enablesXDR;try{if(\"undefined\"!=typeof XMLHttpRequest&&(!c||e))return new XMLHttpRequest}catch(i){}try{if(\"undefined\"!=typeof XDomainRequest&&!o&&r)return new XDomainRequest}catch(i){}if(!c)try{return new(t[[\"Active\"].concat(\"Object\").join(\"X\")])(\"Microsoft.XMLHTTP\")}catch(i){}};\n},{\"has-cors\":\"cnu0\",\"./globalThis\":\"gHSz\"}],\"c8qu\":[function(require,module,exports) {\nconst e=Object.create(null);e.open=\"0\",e.close=\"1\",e.ping=\"2\",e.pong=\"3\",e.message=\"4\",e.upgrade=\"5\",e.noop=\"6\";const o=Object.create(null);Object.keys(e).forEach(r=>{o[e[r]]=r});const r={type:\"error\",data:\"parser error\"};module.exports={PACKET_TYPES:e,PACKET_TYPES_REVERSE:o,ERROR_PACKET:r};\n},{}],\"h2jv\":[function(require,module,exports) {\nconst{PACKET_TYPES:e}=require(\"./commons\"),o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===Object.prototype.toString.call(Blob),r=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,f=({type:f,data:a},u,i)=>o&&a instanceof Blob?u?i(a):n(a,i):r&&(a instanceof ArrayBuffer||t(a))?u?i(a instanceof ArrayBuffer?a:a.buffer):n(new Blob([a]),i):i(e[f]+(a||\"\")),n=(e,o)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(\",\")[1];o(\"b\"+e)},r.readAsDataURL(e)};module.exports=f;\n},{\"./commons\":\"c8qu\"}],\"VBf3\":[function(require,module,exports) {\n!function(n){\"use strict\";exports.encode=function(e){var r,t=new Uint8Array(e),i=t.length,f=\"\";for(r=0;r<i;r+=3)f+=n[t[r]>>2],f+=n[(3&t[r])<<4|t[r+1]>>4],f+=n[(15&t[r+1])<<2|t[r+2]>>6],f+=n[63&t[r+2]];return i%3==2?f=f.substring(0,f.length-1)+\"=\":i%3==1&&(f=f.substring(0,f.length-2)+\"==\"),f},exports.decode=function(e){var r,t,i,f,g,o=.75*e.length,u=e.length,s=0;\"=\"===e[e.length-1]&&(o--,\"=\"===e[e.length-2]&&o--);var d=new ArrayBuffer(o),h=new Uint8Array(d);for(r=0;r<u;r+=4)t=n.indexOf(e[r]),i=n.indexOf(e[r+1]),f=n.indexOf(e[r+2]),g=n.indexOf(e[r+3]),h[s++]=t<<2|i>>4,h[s++]=(15&i)<<4|f>>2,h[s++]=(3&f)<<6|63&g;return d}}(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\");\n},{}],\"zzjK\":[function(require,module,exports) {\nconst{PACKET_TYPES_REVERSE:e,ERROR_PACKET:r}=require(\"./commons\"),t=\"function\"==typeof ArrayBuffer;let a;t&&(a=require(\"base64-arraybuffer\"));const s=(t,a)=>{if(\"string\"!=typeof t)return{type:\"message\",data:u(t,a)};const s=t.charAt(0);return\"b\"===s?{type:\"message\",data:n(t.substring(1),a)}:e[s]?t.length>1?{type:e[s],data:t.substring(1)}:{type:e[s]}:r},n=(e,r)=>{if(a){const t=a.decode(e);return u(t,r)}return{base64:!0,data:e}},u=(e,r)=>{switch(r){case\"blob\":return e instanceof ArrayBuffer?new Blob([e]):e;case\"arraybuffer\":default:return e}};module.exports=s;\n},{\"./commons\":\"c8qu\",\"base64-arraybuffer\":\"VBf3\"}],\"c8NG\":[function(require,module,exports) {\nconst e=require(\"./encodePacket\"),o=require(\"./decodePacket\"),r=String.fromCharCode(30),t=(o,t)=>{const c=o.length,d=new Array(c);let n=0;o.forEach((o,a)=>{e(o,!1,e=>{d[a]=e,++n===c&&t(d.join(r))})})},c=(e,t)=>{const c=e.split(r),d=[];for(let r=0;r<c.length;r++){const e=o(c[r],t);if(d.push(e),\"error\"===e.type)break}return d};module.exports={protocol:4,encodePacket:e,encodePayload:t,decodePacket:o,decodePayload:c};\n},{\"./encodePacket\":\"h2jv\",\"./decodePacket\":\"zzjK\"}],\"G6pK\":[function(require,module,exports) {\nfunction t(t){if(t)return e(t)}function e(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}\"undefined\"!=typeof module&&(module.exports=t),t.prototype.on=t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[\"$\"+t]=this._callbacks[\"$\"+t]||[]).push(e),this},t.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,r=this._callbacks[\"$\"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[\"$\"+t],this;for(var i=0;i<r.length;i++)if((s=r[i])===e||s.fn===e){r.splice(i,1);break}return 0===r.length&&delete this._callbacks[\"$\"+t],this},t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks[\"$\"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(s){r=0;for(var i=(s=s.slice(0)).length;r<i;++r)s[r].apply(this,e)}return this},t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[\"$\"+t]||[]},t.prototype.hasListeners=function(t){return!!this.listeners(t).length};\n},{}],\"cq18\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,s,o,a=null;function l(...e){if(!l.enabled)return;const t=l,s=Number(new Date),o=s-(r||s);t.diff=o,t.prev=r,t.curr=s,r=s,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,s)=>{if(\"%%\"===r)return\"%\";a++;const o=n.formatters[s];if(\"function\"==typeof o){const n=e[a];r=o.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return l.namespace=e,l.useColors=n.useColors(),l.color=n.selectColor(e),l.extend=t,l.destroy=n.destroy,Object.defineProperty(l,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(s!==n.namespaces&&(s=n.namespaces,o=n.enabled(e)),o),set:e=>{a=e}}),\"function\"==typeof n.init&&n.init(l),l}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),s=r.length;for(t=0;t<s;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"sXsT\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"cq18\",\"process\":\"pBGv\"}],\"aoJx\":[function(require,module,exports) {\nconst e=require(\"engine.io-parser\"),t=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:transport\");class r extends t{constructor(e){super(),this.opts=e,this.query=e.query,this.readyState=\"\",this.socket=e.socket}onError(e,t){const s=new Error(e);return s.type=\"TransportError\",s.description=t,this.emit(\"error\",s),this}open(){return\"closed\"!==this.readyState&&\"\"!==this.readyState||(this.readyState=\"opening\",this.doOpen()),this}close(){return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){\"open\"===this.readyState?this.write(e):s(\"transport is not open, discarding packets\")}onOpen(){this.readyState=\"open\",this.writable=!0,this.emit(\"open\")}onData(t){const s=e.decodePacket(t,this.socket.binaryType);this.onPacket(s)}onPacket(e){this.emit(\"packet\",e)}onClose(){this.readyState=\"closed\",this.emit(\"close\")}}module.exports=r;\n},{\"engine.io-parser\":\"c8NG\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\"}],\"a1bU\":[function(require,module,exports) {\nexports.encode=function(e){var n=\"\";for(var o in e)e.hasOwnProperty(o)&&(n.length&&(n+=\"&\"),n+=encodeURIComponent(o)+\"=\"+encodeURIComponent(e[o]));return n},exports.decode=function(e){for(var n={},o=e.split(\"&\"),t=0,r=o.length;t<r;t++){var d=o[t].split(\"=\");n[decodeURIComponent(d[0])]=decodeURIComponent(d[1])}return n};\n},{}],\"hQ4G\":[function(require,module,exports) {\n\"use strict\";var r,e=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_\".split(\"\"),t=64,n={},o=0,u=0;function a(r){var n=\"\";do{n=e[r%t]+n,r=Math.floor(r/t)}while(r>0);return n}function c(r){var e=0;for(u=0;u<r.length;u++)e=e*t+n[r.charAt(u)];return e}function f(){var e=a(+new Date);return e!==r?(o=0,r=e):e+\".\"+a(o++)}for(;u<t;u++)n[e[u]]=u;f.encode=a,f.decode=c,module.exports=f;\n},{}],\"BPT5\":[function(require,module,exports) {\nconst t=require(\"../transport\"),e=require(\"parseqs\"),s=require(\"engine.io-parser\"),i=require(\"yeast\"),o=require(\"debug\")(\"engine.io-client:polling\");class p extends t{get name(){return\"polling\"}doOpen(){this.poll()}pause(t){this.readyState=\"pausing\";const e=()=>{o(\"paused\"),this.readyState=\"paused\",t()};if(this.polling||!this.writable){let t=0;this.polling&&(o(\"we are currently polling - waiting to pause\"),t++,this.once(\"pollComplete\",function(){o(\"pre-pause polling complete\"),--t||e()})),this.writable||(o(\"we are currently writing - waiting to pause\"),t++,this.once(\"drain\",function(){o(\"pre-pause writing complete\"),--t||e()}))}else e()}poll(){o(\"polling\"),this.polling=!0,this.doPoll(),this.emit(\"poll\")}onData(t){o(\"polling got data %s\",t);s.decodePayload(t,this.socket.binaryType).forEach(t=>{if(\"opening\"===this.readyState&&\"open\"===t.type&&this.onOpen(),\"close\"===t.type)return this.onClose(),!1;this.onPacket(t)}),\"closed\"!==this.readyState&&(this.polling=!1,this.emit(\"pollComplete\"),\"open\"===this.readyState?this.poll():o('ignoring poll - transport state \"%s\"',this.readyState))}doClose(){const t=()=>{o(\"writing close packet\"),this.write([{type:\"close\"}])};\"open\"===this.readyState?(o(\"transport open - closing\"),t()):(o(\"transport not open - deferring close\"),this.once(\"open\",t))}write(t){this.writable=!1,s.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit(\"drain\")})})}uri(){let t=this.query||{};const s=this.opts.secure?\"https\":\"http\";let o=\"\";return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=e.encode(t),this.opts.port&&(\"https\"===s&&443!==Number(this.opts.port)||\"http\"===s&&80!==Number(this.opts.port))&&(o=\":\"+this.opts.port),t.length&&(t=\"?\"+t),s+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+o+this.opts.path+t}}module.exports=p;\n},{\"../transport\":\"aoJx\",\"parseqs\":\"a1bU\",\"engine.io-parser\":\"c8NG\",\"yeast\":\"hQ4G\",\"debug\":\"sXsT\"}],\"nxc0\":[function(require,module,exports) {\nmodule.exports.pick=((e,...r)=>r.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{}));\n},{}],\"uJlD\":[function(require,module,exports) {\nconst t=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),e=require(\"./polling\"),s=require(\"component-emitter\"),{pick:o}=require(\"../util\"),r=require(\"../globalThis\"),i=require(\"debug\")(\"engine.io-client:polling-xhr\");function n(){}const h=null!=new t({xdomain:!1}).responseType;class a extends e{constructor(t){if(super(t),\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let s=location.port;s||(s=e?443:80),this.xd=\"undefined\"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=h&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new u(this.uri(),t)}doWrite(t,e){const s=this.request({method:\"POST\",data:t});s.on(\"success\",e),s.on(\"error\",t=>{this.onError(\"xhr post error\",t)})}doPoll(){i(\"xhr poll\");const t=this.request();t.on(\"data\",this.onData.bind(this)),t.on(\"error\",t=>{this.onError(\"xhr poll error\",t)}),this.pollXhr=t}}class u extends s{constructor(t,e){super(),this.opts=e,this.method=e.method||\"GET\",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const e=o(this.opts,\"agent\",\"enablesXDR\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"autoUnref\");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const s=this.xhr=new t(e);try{i(\"xhr open %s: %s\",this.method,this.uri),s.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(r){}if(\"POST\"===this.method)try{s.setRequestHeader(\"Content-type\",\"text/plain;charset=UTF-8\")}catch(r){}try{s.setRequestHeader(\"Accept\",\"*/*\")}catch(r){}\"withCredentials\"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),this.hasXDR()?(s.onload=(()=>{this.onLoad()}),s.onerror=(()=>{this.onError(s.responseText)})):s.onreadystatechange=(()=>{4===s.readyState&&(200===s.status||1223===s.status?this.onLoad():setTimeout(()=>{this.onError(\"number\"==typeof s.status?s.status:0)},0))}),i(\"xhr data %s\",this.data),s.send(this.data)}catch(r){return void setTimeout(()=>{this.onError(r)},0)}\"undefined\"!=typeof document&&(this.index=u.requestsCount++,u.requests[this.index]=this)}onSuccess(){this.emit(\"success\"),this.cleanup()}onData(t){this.emit(\"data\",t),this.onSuccess()}onError(t){this.emit(\"error\",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=n:this.xhr.onreadystatechange=n,t)try{this.xhr.abort()}catch(e){}\"undefined\"!=typeof document&&delete u.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return\"undefined\"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(u.requestsCount=0,u.requests={},\"undefined\"!=typeof document)if(\"function\"==typeof attachEvent)attachEvent(\"onunload\",d);else if(\"function\"==typeof addEventListener){addEventListener(\"onpagehide\"in r?\"pagehide\":\"unload\",d,!1)}function d(){for(let t in u.requests)u.requests.hasOwnProperty(t)&&u.requests[t].abort()}module.exports=a,module.exports.Request=u;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling\":\"BPT5\",\"component-emitter\":\"G6pK\",\"../util\":\"nxc0\",\"../globalThis\":\"gHSz\",\"debug\":\"sXsT\"}],\"dWDe\":[function(require,module,exports) {\nconst e=require(\"./polling\"),t=require(\"../globalThis\"),i=/\\n/g,r=/\\\\n/g;let s;class o extends e{constructor(e){super(e),this.query=this.query||{},s||(s=t.___eio=t.___eio||[]),this.index=s.length,s.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=(()=>{}),this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const e=document.createElement(\"script\");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=(e=>{this.onError(\"jsonp poll error\",e)});const t=document.getElementsByTagName(\"script\")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e,\"undefined\"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){const e=document.createElement(\"iframe\");document.body.appendChild(e),document.body.removeChild(e)},100)}doWrite(e,t){let s;if(!this.form){const e=document.createElement(\"form\"),t=document.createElement(\"textarea\"),i=this.iframeId=\"eio_iframe_\"+this.index;e.className=\"socketio\",e.style.position=\"absolute\",e.style.top=\"-1000px\",e.style.left=\"-1000px\",e.target=i,e.method=\"POST\",e.setAttribute(\"accept-charset\",\"utf-8\"),t.name=\"d\",e.appendChild(t),document.body.appendChild(e),this.form=e,this.area=t}function o(){n(),t()}this.form.action=this.uri();const n=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(e){this.onError(\"jsonp polling iframe removal error\",e)}try{const t='<iframe src=\"javascript:0\" name=\"'+this.iframeId+'\">';s=document.createElement(t)}catch(e){(s=document.createElement(\"iframe\")).name=this.iframeId,s.src=\"javascript:0\"}s.id=this.iframeId,this.form.appendChild(s),this.iframe=s};n(),e=e.replace(r,\"\\\\\\n\"),this.area.value=e.replace(i,\"\\\\n\");try{this.form.submit()}catch(a){}this.iframe.attachEvent?this.iframe.onreadystatechange=(()=>{\"complete\"===this.iframe.readyState&&o()}):this.iframe.onload=o}}module.exports=o;\n},{\"./polling\":\"BPT5\",\"../globalThis\":\"gHSz\"}],\"CU8L\":[function(require,module,exports) {\nconst e=require(\"../globalThis\"),o=\"function\"==typeof Promise&&\"function\"==typeof Promise.resolve?e=>Promise.resolve().then(e):e=>setTimeout(e,0);module.exports={WebSocket:e.WebSocket||e.MozWebSocket,usingBrowserWebSocket:!0,defaultBinaryType:\"arraybuffer\",nextTick:o};\n},{\"../globalThis\":\"gHSz\"}],\"yh9p\":[function(require,module,exports) {\n\"use strict\";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(var r=[],t=[],e=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,n=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;function h(r){var t=r.length;if(t%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var e=r.indexOf(\"=\");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function u(r){var t=h(r),e=t[0],n=t[1];return 3*(e+n)/4-n}function c(r,t,e){return 3*(t+e)/4-e}function i(r){var n,o,a=h(r),u=a[0],i=a[1],f=new e(c(r,u,i)),A=0,d=i>0?u-4:u;for(o=0;o<d;o+=4)n=t[r.charCodeAt(o)]<<18|t[r.charCodeAt(o+1)]<<12|t[r.charCodeAt(o+2)]<<6|t[r.charCodeAt(o+3)],f[A++]=n>>16&255,f[A++]=n>>8&255,f[A++]=255&n;return 2===i&&(n=t[r.charCodeAt(o)]<<2|t[r.charCodeAt(o+1)]>>4,f[A++]=255&n),1===i&&(n=t[r.charCodeAt(o)]<<10|t[r.charCodeAt(o+1)]<<4|t[r.charCodeAt(o+2)]>>2,f[A++]=n>>8&255,f[A++]=255&n),f}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function A(r,t,e){for(var n,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));return o.join(\"\")}function d(t){for(var e,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return 1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+\"==\")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\")),a.join(\"\")}t[\"-\".charCodeAt(0)]=62,t[\"_\".charCodeAt(0)]=63;\n},{}],\"JgNJ\":[function(require,module,exports) {\nexports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,N=i>>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l};\n},{}],\"REa7\":[function(require,module,exports) {\nvar r={}.toString;module.exports=Array.isArray||function(t){return\"[object Array]\"==r.call(t)};\n},{}],\"dskh\":[function(require,module,exports) {\n\nvar global = arguments[3];\nvar t=arguments[3],r=require(\"base64-js\"),e=require(\"ieee754\"),n=require(\"isarray\");function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&\"function\"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,r){if(o()<r)throw new RangeError(\"Invalid typed array length\");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=f.prototype:(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if(\"number\"==typeof t){if(\"string\"==typeof r)throw new Error(\"If encoding is specified then the first argument must be a string\");return c(this,t)}return s(this,t,r,e)}function s(t,r,e,n){if(\"number\"==typeof r)throw new TypeError('\"value\" argument must not be a number');return\"undefined\"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?g(t,r,e,n):\"string\"==typeof r?l(t,r,e):y(t,r)}function h(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be a number');if(t<0)throw new RangeError('\"size\" argument must not be negative')}function a(t,r,e,n){return h(r),r<=0?u(t,r):void 0!==e?\"string\"==typeof n?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}function c(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function l(t,r,e){if(\"string\"==typeof e&&\"\"!==e||(e=\"utf8\"),!f.isEncoding(e))throw new TypeError('\"encoding\" must be a valid string encoding');var n=0|v(r,e),i=(t=u(t,n)).write(r,e);return i!==n&&(t=t.slice(0,i)),t}function p(t,r){var e=r.length<0?0:0|w(r.length);t=u(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function g(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError(\"'offset' is out of bounds\");if(r.byteLength<e+(n||0))throw new RangeError(\"'length' is out of bounds\");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}function y(t,r){if(f.isBuffer(r)){var e=0|w(r.length);return 0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if(\"undefined\"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||\"length\"in r)return\"number\"!=typeof r.length||W(r.length)?u(t,0):p(t,r);if(\"Buffer\"===r.type&&n(r.data))return p(t,r.data)}throw new TypeError(\"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.\")}function w(t){if(t>=o())throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+o().toString(16)+\" bytes\");return 0|t}function d(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if(\"undefined\"!=typeof ArrayBuffer&&\"function\"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;\"string\"!=typeof t&&(t=\"\"+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case\"ascii\":case\"latin1\":case\"binary\":return e;case\"utf8\":case\"utf-8\":case void 0:return $(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*e;case\"hex\":return e>>>1;case\"base64\":return K(t).length;default:if(n)return $(t).length;r=(\"\"+r).toLowerCase(),n=!0}}function E(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return\"\";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return\"\";if((e>>>=0)<=(r>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return x(this,r,e);case\"utf8\":case\"utf-8\":return Y(this,r,e);case\"ascii\":return L(this,r,e);case\"latin1\":case\"binary\":return D(this,r,e);case\"base64\":return S(this,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return C(this,r,e);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function R(t,r,e,n,i){if(0===t.length)return-1;if(\"string\"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if(\"string\"==typeof r&&(r=f.from(r,n)),f.isBuffer(r))return 0===r.length?-1:_(t,r,e,n,i);if(\"number\"==typeof r)return r&=255,f.TYPED_ARRAY_SUPPORT&&\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):_(t,[r],e,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function _(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||r.length<2)return-1;u=2,f/=2,s/=2,e/=2}function h(t,r){return 1===u?t[r]:t.readUInt16BE(r*u)}if(i){var a=-1;for(o=e;o<f;o++)if(h(t,o)===h(r,-1===a?0:o-a)){if(-1===a&&(a=o),o-a+1===s)return a*u}else-1!==a&&(o-=o-a),a=-1}else for(e+s>f&&(e=f-s),o=e;o>=0;o--){for(var c=!0,l=0;l<s;l++)if(h(t,o+l)!==h(r,l)){c=!1;break}if(c)return o}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=r.length;if(o%2!=0)throw new TypeError(\"Invalid hex string\");n>o/2&&(n=o/2);for(var u=0;u<n;++u){var f=parseInt(r.substr(2*u,2),16);if(isNaN(f))return u;t[e+u]=f}return u}function m(t,r,e,n){return Q($(r,t.length-e),t,e,n)}function P(t,r,e,n){return Q(G(r),t,e,n)}function T(t,r,e,n){return P(t,r,e,n)}function B(t,r,e,n){return Q(K(r),t,e,n)}function U(t,r,e,n){return Q(H(r,t.length-e),t,e,n)}function S(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o,u,f,s,h=t[i],a=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=e)switch(c){case 1:h<128&&(a=h);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&h)<<6|63&o)>127&&(a=s);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(s=(15&h)<<12|(63&o)<<6|63&u)>2047&&(s<55296||s>57343)&&(a=s);break;case 4:o=t[i+1],u=t[i+2],f=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&f)&&(s=(15&h)<<18|(63&o)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(a=s)}null===a?(a=65533,c=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=c}return O(n)}exports.Buffer=f,exports.SlowBuffer=d,exports.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),exports.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return s(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,\"undefined\"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return a(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError(\"Arguments must be Buffers\");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"latin1\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return!0;default:return!1}},f.concat=function(t,r){if(!n(t))throw new TypeError('\"list\" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var i=f.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var u=t[e];if(!f.isBuffer(u))throw new TypeError('\"list\" argument must be an Array of Buffers');u.copy(i,o),o+=u.length}return i},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError(\"Buffer size must be a multiple of 32-bits\");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError(\"Buffer size must be a multiple of 64-bits\");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?\"\":0===arguments.length?Y(this,0,t):E.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t=\"\",r=exports.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString(\"hex\",0,r).match(/.{2}/g).join(\" \"),this.length>r&&(t+=\" ... \")),\"<Buffer \"+t+\">\"},f.prototype.compare=function(t,r,e,n,i){if(!f.isBuffer(t))throw new TypeError(\"Argument must be a Buffer\");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),u=(e>>>=0)-(r>>>=0),s=Math.min(o,u),h=this.slice(n,i),a=t.slice(r,e),c=0;c<s;++c)if(h[c]!==a[c]){o=h[c],u=a[c];break}return o<u?-1:u<o?1:0},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.indexOf=function(t,r,e){return R(this,t,r,e,!0)},f.prototype.lastIndexOf=function(t,r,e){return R(this,t,r,e,!1)},f.prototype.write=function(t,r,e,n){if(void 0===r)n=\"utf8\",e=this.length,r=0;else if(void 0===e&&\"string\"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error(\"Buffer.write(string, encoding, offset[, length]) is no longer supported\");r|=0,isFinite(e)?(e|=0,void 0===n&&(n=\"utf8\")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");for(var o=!1;;)switch(n){case\"hex\":return A(this,t,r,e);case\"utf8\":case\"utf-8\":return m(this,t,r,e);case\"ascii\":return P(this,t,r,e);case\"latin1\":case\"binary\":return T(this,t,r,e);case\"base64\":return B(this,t,r,e);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return U(this,t,r,e);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t){var r=t.length;if(r<=I)return String.fromCharCode.apply(String,t);for(var e=\"\",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=I));return e}function L(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function D(t,r,e){var n=\"\";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function x(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i=\"\",o=r;o<e;++o)i+=Z(t[o]);return i}function C(t,r,e){for(var n=t.slice(r,e),i=\"\",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(t,r,e){if(t%1!=0||t<0)throw new RangeError(\"offset is not uint\");if(t+r>e)throw new RangeError(\"Trying to access beyond buffer length\")}function k(t,r,e,n,i,o){if(!f.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('\"value\" argument is out of bounds');if(e+n>t.length)throw new RangeError(\"Index out of range\")}function N(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function F(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError(\"Index out of range\");if(e<0)throw new RangeError(\"Index out of range\")}function j(t,r,n,i,o){return o||F(t,r,n,4,3.4028234663852886e38,-3.4028234663852886e38),e.write(t,r,n,i,23,4),n+4}function q(t,r,n,i,o){return o||F(t,r,n,8,1.7976931348623157e308,-1.7976931348623157e308),e.write(t,r,n,i,52,8),n+8}f.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),f.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=f.prototype;else{var i=r-t;e=new f(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+t]}return e},f.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},f.prototype.readUInt8=function(t,r){return r||M(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||M(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||M(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*r)),n},f.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||M(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},f.prototype.readInt8=function(t,r){return r||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||M(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||M(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||M(t,4,this.length),e.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||M(t,8,this.length),e.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[r]=255&t;++o<e&&(i*=256);)this[r+o]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||k(this,t,r,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):z(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=0,u=1,f=0;for(this[r]=255&t;++o<e&&(u*=256);)t<0&&0===f&&0!==this[r+o-1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var i=Math.pow(2,8*e-1);k(this,t,r,e,i-1,-i)}var o=e-1,u=1,f=0;for(this[r+o]=255&t;--o>=0&&(u*=256);)t<0&&0===f&&0!==this[r+o+1]&&(f=1),this[r+o]=(t/u>>0)-f&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):N(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):N(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):z(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||k(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):z(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return q(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return q(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError(\"targetStart out of bounds\");if(e<0||e>=this.length)throw new RangeError(\"sourceStart out of bounds\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},f.prototype.fill=function(t,r,e,n){if(\"string\"==typeof t){if(\"string\"==typeof r?(n=r,r=0,e=this.length):\"string\"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&\"string\"!=typeof n)throw new TypeError(\"encoding must be a string\");if(\"string\"==typeof n&&!f.isEncoding(n))throw new TypeError(\"Unknown encoding: \"+n)}else\"number\"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError(\"Out of range index\");if(e<=r)return this;var o;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),\"number\"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var u=f.isBuffer(t)?t:$(new f(t,n).toString()),s=u.length;for(o=0;o<e-r;++o)this[o+r]=u[o%s]}return this};var V=/[^+\\/0-9A-Za-z-_]/g;function X(t){if((t=J(t).replace(V,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}function J(t){return t.trim?t.trim():t.replace(/^\\s+|\\s+$/g,\"\")}function Z(t){return t<16?\"0\"+t.toString(16):t.toString(16)}function $(t,r){var e;r=r||1/0;for(var n=t.length,i=null,o=[],u=0;u<n;++u){if((e=t.charCodeAt(u))>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error(\"Invalid code point\");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function G(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function H(t,r){for(var e,n,i,o=[],u=0;u<t.length&&!((r-=2)<0);++u)n=(e=t.charCodeAt(u))>>8,i=e%256,o.push(i),o.push(n);return o}function K(t){return r.toByteArray(X(t))}function Q(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function W(t){return t!=t}\n},{\"base64-js\":\"yh9p\",\"ieee754\":\"JgNJ\",\"isarray\":\"REa7\",\"buffer\":\"dskh\"}],\"rRq3\":[function(require,module,exports) {\nvar Buffer = require(\"buffer\").Buffer;\nvar e=require(\"buffer\").Buffer;const t=require(\"../transport\"),s=require(\"engine.io-parser\"),r=require(\"parseqs\"),o=require(\"yeast\"),{pick:i}=require(\"../util\"),{WebSocket:n,usingBrowserWebSocket:a,defaultBinaryType:h,nextTick:p}=require(\"./websocket-constructor\"),c=require(\"debug\")(\"engine.io-client:websocket\"),u=\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.product&&\"reactnative\"===navigator.product.toLowerCase();class l extends t{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return\"websocket\"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=u?{}:i(this.opts,\"agent\",\"perMessageDeflate\",\"pfx\",\"key\",\"passphrase\",\"cert\",\"ca\",\"ciphers\",\"rejectUnauthorized\",\"localAddress\",\"protocolVersion\",\"origin\",\"maxPayload\",\"family\",\"checkServerIdentity\");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=a&&!u?t?new n(e,t):new n(e):new n(e,t,s)}catch(r){return this.emit(\"error\",r)}this.ws.binaryType=this.socket.binaryType||h,this.addEventListeners()}addEventListeners(){this.ws.onopen=(()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()}),this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=(e=>this.onData(e.data)),this.ws.onerror=(e=>this.onError(\"websocket error\",e))}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const o=t[r],i=r===t.length-1;s.encodePacket(o,this.supportsBinary,t=>{const s={};if(!a&&(o.options&&(s.compress=o.options.compress),this.opts.perMessageDeflate)){(\"string\"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(s.compress=!1)}try{a?this.ws.send(t):this.ws.send(t,s)}catch(r){c(\"websocket closed before onclose event\")}i&&p(()=>{this.writable=!0,this.emit(\"drain\")})})}}onClose(){t.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?\"wss\":\"ws\";let s=\"\";return this.opts.port&&(\"wss\"===t&&443!==Number(this.opts.port)||\"ws\"===t&&80!==Number(this.opts.port))&&(s=\":\"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=o()),this.supportsBinary||(e.b64=1),(e=r.encode(e)).length&&(e=\"?\"+e),t+\"://\"+(-1!==this.opts.hostname.indexOf(\":\")?\"[\"+this.opts.hostname+\"]\":this.opts.hostname)+s+this.opts.path+e}check(){return!(!n||\"__initialize\"in n&&this.name===l.prototype.name)}}module.exports=l;\n},{\"../transport\":\"aoJx\",\"engine.io-parser\":\"c8NG\",\"parseqs\":\"a1bU\",\"yeast\":\"hQ4G\",\"../util\":\"nxc0\",\"./websocket-constructor\":\"CU8L\",\"debug\":\"sXsT\",\"buffer\":\"dskh\"}],\"DZ9o\":[function(require,module,exports) {\nconst e=require(\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\"),o=require(\"./polling-xhr\"),t=require(\"./polling-jsonp\"),n=require(\"./websocket\");function r(n){let r,i=!1,s=!1;const l=!1!==n.jsonp;if(\"undefined\"!=typeof location){const e=\"https:\"===location.protocol;let o=location.port;o||(o=e?443:80),i=n.hostname!==location.hostname||o!==n.port,s=n.secure!==e}if(n.xdomain=i,n.xscheme=s,\"open\"in(r=new e(n))&&!n.forceJSONP)return new o(n);if(!l)throw new Error(\"JSONP disabled\");return new t(n)}exports.polling=r,exports.websocket=n;\n},{\"../../contrib/xmlhttprequest-ssl/XMLHttpRequest\":\"jhGE\",\"./polling-xhr\":\"uJlD\",\"./polling-jsonp\":\"dWDe\",\"./websocket\":\"rRq3\"}],\"wtcu\":[function(require,module,exports) {\nconst t=require(\"./transports/index\"),e=require(\"component-emitter\"),s=require(\"debug\")(\"engine.io-client:socket\"),r=require(\"engine.io-parser\"),i=require(\"parseuri\"),o=require(\"parseqs\");class n extends e{constructor(t,e={}){super(),t&&\"object\"==typeof t&&(e=t,t=null),t?(t=i(t),e.hostname=t.host,e.secure=\"https\"===t.protocol||\"wss\"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=i(e.host).host),this.secure=null!=e.secure?e.secure:\"undefined\"!=typeof location&&\"https:\"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?\"443\":\"80\"),this.hostname=e.hostname||(\"undefined\"!=typeof location?location.hostname:\"localhost\"),this.port=e.port||(\"undefined\"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||[\"polling\",\"websocket\"],this.readyState=\"\",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:\"/engine.io\",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:\"t\",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\\/$/,\"\")+\"/\",\"string\"==typeof this.opts.query&&(this.opts.query=o.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,\"function\"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener(\"beforeunload\",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),\"localhost\"!==this.hostname&&(this.offlineEventListener=(()=>{this.onClose(\"transport close\")}),addEventListener(\"offline\",this.offlineEventListener,!1))),this.open()}createTransport(e){s('creating transport \"%s\"',e);const i=a(this.opts.query);i.EIO=r.protocol,i.transport=e,this.id&&(i.sid=this.id);const o=Object.assign({},this.opts.transportOptions[e],this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return s(\"options: %j\",o),new t[e](o)}open(){let t;if(this.opts.rememberUpgrade&&n.priorWebsocketSuccess&&-1!==this.transports.indexOf(\"websocket\"))t=\"websocket\";else{if(0===this.transports.length)return void setTimeout(()=>{this.emit(\"error\",\"No transports available\")},0);t=this.transports[0]}this.readyState=\"opening\";try{t=this.createTransport(t)}catch(e){return s(\"error while creating transport: %s\",e),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){s(\"setting transport %s\",t.name),this.transport&&(s(\"clearing existing transport %s\",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on(\"drain\",this.onDrain.bind(this)).on(\"packet\",this.onPacket.bind(this)).on(\"error\",this.onError.bind(this)).on(\"close\",()=>{this.onClose(\"transport close\")})}probe(t){s('probing transport \"%s\"',t);let e=this.createTransport(t,{probe:1}),r=!1;n.priorWebsocketSuccess=!1;const i=()=>{r||(s('probe transport \"%s\" opened',t),e.send([{type:\"ping\",data:\"probe\"}]),e.once(\"packet\",i=>{if(!r)if(\"pong\"===i.type&&\"probe\"===i.data){if(s('probe transport \"%s\" pong',t),this.upgrading=!0,this.emit(\"upgrading\",e),!e)return;n.priorWebsocketSuccess=\"websocket\"===e.name,s('pausing current transport \"%s\"',this.transport.name),this.transport.pause(()=>{r||\"closed\"!==this.readyState&&(s(\"changing transport and sending upgrade packet\"),u(),this.setTransport(e),e.send([{type:\"upgrade\"}]),this.emit(\"upgrade\",e),e=null,this.upgrading=!1,this.flush())})}else{s('probe transport \"%s\" failed',t);const r=new Error(\"probe error\");r.transport=e.name,this.emit(\"upgradeError\",r)}}))};function o(){r||(r=!0,u(),e.close(),e=null)}const a=r=>{const i=new Error(\"probe error: \"+r);i.transport=e.name,o(),s('probe transport \"%s\" failed because of error: %s',t,r),this.emit(\"upgradeError\",i)};function p(){a(\"transport closed\")}function h(){a(\"socket closed\")}function c(t){e&&t.name!==e.name&&(s('\"%s\" works - aborting \"%s\"',t.name,e.name),o())}const u=()=>{e.removeListener(\"open\",i),e.removeListener(\"error\",a),e.removeListener(\"close\",p),this.removeListener(\"close\",h),this.removeListener(\"upgrading\",c)};e.once(\"open\",i),e.once(\"error\",a),e.once(\"close\",p),this.once(\"close\",h),this.once(\"upgrading\",c),e.open()}onOpen(){if(s(\"socket open\"),this.readyState=\"open\",n.priorWebsocketSuccess=\"websocket\"===this.transport.name,this.emit(\"open\"),this.flush(),\"open\"===this.readyState&&this.opts.upgrade&&this.transport.pause){s(\"starting upgrade probes\");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if(\"opening\"===this.readyState||\"open\"===this.readyState||\"closing\"===this.readyState)switch(s('socket receive: type \"%s\", data \"%s\"',t.type,t.data),this.emit(\"packet\",t),this.emit(\"heartbeat\"),t.type){case\"open\":this.onHandshake(JSON.parse(t.data));break;case\"ping\":this.resetPingTimeout(),this.sendPacket(\"pong\"),this.emit(\"ping\"),this.emit(\"pong\");break;case\"error\":const e=new Error(\"server error\");e.code=t.data,this.onError(e);break;case\"message\":this.emit(\"data\",t.data),this.emit(\"message\",t.data)}else s('packet received with socket readyState \"%s\"',this.readyState)}onHandshake(t){this.emit(\"handshake\",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),\"closed\"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=setTimeout(()=>{this.onClose(\"ping timeout\")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit(\"drain\"):this.flush()}flush(){\"closed\"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(s(\"flushing %d packets in socket\",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit(\"flush\"))}write(t,e,s){return this.sendPacket(\"message\",t,e,s),this}send(t,e,s){return this.sendPacket(\"message\",t,e,s),this}sendPacket(t,e,s,r){if(\"function\"==typeof e&&(r=e,e=void 0),\"function\"==typeof s&&(r=s,s=null),\"closing\"===this.readyState||\"closed\"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emit(\"packetCreate\",i),this.writeBuffer.push(i),r&&this.once(\"flush\",r),this.flush()}close(){const t=()=>{this.onClose(\"forced close\"),s(\"socket closing - telling transport to close\"),this.transport.close()},e=()=>{this.removeListener(\"upgrade\",e),this.removeListener(\"upgradeError\",e),t()},r=()=>{this.once(\"upgrade\",e),this.once(\"upgradeError\",e)};return\"opening\"!==this.readyState&&\"open\"!==this.readyState||(this.readyState=\"closing\",this.writeBuffer.length?this.once(\"drain\",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){s(\"socket error %j\",t),n.priorWebsocketSuccess=!1,this.emit(\"error\",t),this.onClose(\"transport error\",t)}onClose(t,e){\"opening\"!==this.readyState&&\"open\"!==this.readyState&&\"closing\"!==this.readyState||(s('socket close with reason: \"%s\"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners(\"close\"),this.transport.close(),this.transport.removeAllListeners(),\"function\"==typeof removeEventListener&&removeEventListener(\"offline\",this.offlineEventListener,!1),this.readyState=\"closed\",this.id=null,this.emit(\"close\",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const r=t.length;for(;s<r;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}function a(t){const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e}n.priorWebsocketSuccess=!1,n.protocol=r.protocol,module.exports=n;\n},{\"./transports/index\":\"DZ9o\",\"component-emitter\":\"G6pK\",\"debug\":\"sXsT\",\"engine.io-parser\":\"c8NG\",\"parseuri\":\"A28J\",\"parseqs\":\"a1bU\"}],\"wC1p\":[function(require,module,exports) {\nconst e=require(\"./socket\");module.exports=((r,o)=>new e(r,o)),module.exports.Socket=e,module.exports.protocol=e.protocol,module.exports.Transport=require(\"./transport\"),module.exports.transports=require(\"./transports/index\"),module.exports.parser=require(\"engine.io-parser\");\n},{\"./socket\":\"wtcu\",\"./transport\":\"aoJx\",\"./transports/index\":\"DZ9o\",\"engine.io-parser\":\"c8NG\"}],\"qd9m\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.hasBinary=exports.isBinary=void 0;const e=\"function\"==typeof ArrayBuffer,t=e=>\"function\"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,r=Object.prototype.toString,o=\"function\"==typeof Blob||\"undefined\"!=typeof Blob&&\"[object BlobConstructor]\"===r.call(Blob),n=\"function\"==typeof File||\"undefined\"!=typeof File&&\"[object FileConstructor]\"===r.call(File);function f(r){return e&&(r instanceof ArrayBuffer||t(r))||o&&r instanceof Blob||n&&r instanceof File}function i(e,t){if(!e||\"object\"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(i(e[t]))return!0;return!1}if(f(e))return!0;if(e.toJSON&&\"function\"==typeof e.toJSON&&1===arguments.length)return i(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&i(e[r]))return!0;return!1}exports.isBinary=f,exports.hasBinary=i;\n},{}],\"BlgA\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.reconstructPacket=exports.deconstructPacket=void 0;const t=require(\"./is-binary\");function e(t){const e=[],n=t.data,o=t;return o.data=r(n,e),o.attachments=e.length,{packet:o,buffers:e}}function r(e,n){if(!e)return e;if(t.isBinary(e)){const t={_placeholder:!0,num:n.length};return n.push(e),t}if(Array.isArray(e)){const t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=r(e[o],n);return t}if(\"object\"==typeof e&&!(e instanceof Date)){const t={};for(const o in e)e.hasOwnProperty(o)&&(t[o]=r(e[o],n));return t}return e}function n(t,e){return t.data=o(t.data,e),t.attachments=void 0,t}function o(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=o(t[r],e);else if(\"object\"==typeof t)for(const r in t)t.hasOwnProperty(r)&&(t[r]=o(t[r],e));return t}exports.deconstructPacket=e,exports.reconstructPacket=n;\n},{\"./is-binary\":\"qd9m\"}],\"La3N\":[function(require,module,exports) {\nfunction e(e){function n(e){let r,o=null;function s(...e){if(!s.enabled)return;const t=s,o=Number(new Date),l=o-(r||o);t.diff=l,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),\"string\"!=typeof e[0]&&e.unshift(\"%O\");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if(\"%%\"===r)return\"%\";i++;const s=n.formatters[o];if(\"function\"==typeof s){const n=e[i];r=s.call(t,n),e.splice(i,1),i--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=t,s.destroy=n.destroy,Object.defineProperty(s,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),\"function\"==typeof n.init&&n.init(s),s}function t(e,t){const r=n(this.namespace+(void 0===t?\":\":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>\"-\"+e)].join(\",\");return n.enable(\"\"),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=(\"string\"==typeof e?e:\"\").split(/[\\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&(\"-\"===(e=r[t].replace(/\\*/g,\".*?\"))[0]?n.skips.push(new RegExp(\"^\"+e.substr(1)+\"$\")):n.names.push(new RegExp(\"^\"+e+\"$\")))},n.enabled=function(e){if(\"*\"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=require(\"ms\"),n.destroy=function(){console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}module.exports=e;\n},{\"ms\":\"EmkX\"}],\"AqXJ\":[function(require,module,exports) {\nvar process = require(\"process\");\nvar e=require(\"process\");function o(){return!(\"undefined\"==typeof window||!window.process||\"renderer\"!==window.process.type&&!window.process.__nwjs)||(\"undefined\"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))&&(\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/))}function t(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+module.exports.humanize(this.diff),!this.useColors)return;const o=\"color: \"+this.color;e.splice(1,0,o,\"color: inherit\");let t=0,C=0;e[0].replace(/%[a-zA-Z%]/g,e=>{\"%%\"!==e&&(t++,\"%c\"===e&&(C=t))}),e.splice(C,0,o)}function C(e){try{e?exports.storage.setItem(\"debug\",e):exports.storage.removeItem(\"debug\")}catch(o){}}function r(){let o;try{o=exports.storage.getItem(\"debug\")}catch(t){}return!o&&void 0!==e&&\"env\"in e&&(o=void 0),o}function n(){try{return localStorage}catch(e){}}exports.formatArgs=t,exports.save=C,exports.load=r,exports.useColors=o,exports.storage=n(),exports.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),exports.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],exports.log=console.debug||console.log||(()=>{}),module.exports=require(\"./common\")(exports);const{formatters:s}=module.exports;s.j=function(e){try{return JSON.stringify(e)}catch(o){return\"[UnexpectedJSONParseError]: \"+o.message}};\n},{\"./common\":\"La3N\",\"process\":\"pBGv\"}],\"DoTO\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Decoder=exports.Encoder=exports.PacketType=exports.protocol=void 0;const t=require(\"component-emitter\"),e=require(\"./binary\"),r=require(\"./is-binary\"),s=require(\"debug\")(\"socket.io-parser\");var n;exports.protocol=5,function(t){t[t.CONNECT=0]=\"CONNECT\",t[t.DISCONNECT=1]=\"DISCONNECT\",t[t.EVENT=2]=\"EVENT\",t[t.ACK=3]=\"ACK\",t[t.CONNECT_ERROR=4]=\"CONNECT_ERROR\",t[t.BINARY_EVENT=5]=\"BINARY_EVENT\",t[t.BINARY_ACK=6]=\"BINARY_ACK\"}(n=exports.PacketType||(exports.PacketType={}));class c{encode(t){return s(\"encoding packet %j\",t),t.type!==n.EVENT&&t.type!==n.ACK||!r.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===n.EVENT?n.BINARY_EVENT:n.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=\"\"+t.type;return t.type!==n.BINARY_EVENT&&t.type!==n.BINARY_ACK||(e+=t.attachments+\"-\"),t.nsp&&\"/\"!==t.nsp&&(e+=t.nsp+\",\"),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),s(\"encoded %j as %s\",t,e),e}encodeAsBinary(t){const r=e.deconstructPacket(t),s=this.encodeAsString(r.packet),n=r.buffers;return n.unshift(s),n}}exports.Encoder=c;class o extends t{constructor(){super()}add(t){let e;if(\"string\"==typeof t)(e=this.decodeString(t)).type===n.BINARY_EVENT||e.type===n.BINARY_ACK?(this.reconstructor=new a(e),0===e.attachments&&super.emit(\"decoded\",e)):super.emit(\"decoded\",e);else{if(!r.isBinary(t)&&!t.base64)throw new Error(\"Unknown type: \"+t);if(!this.reconstructor)throw new Error(\"got binary data when not reconstructing a packet\");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,super.emit(\"decoded\",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===n[r.type])throw new Error(\"unknown packet type \"+r.type);if(r.type===n.BINARY_EVENT||r.type===n.BINARY_ACK){const s=e+1;for(;\"-\"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(s,e);if(n!=Number(n)||\"-\"!==t.charAt(e))throw new Error(\"Illegal attachments\");r.attachments=Number(n)}if(\"/\"===t.charAt(e+1)){const s=e+1;for(;++e;){if(\",\"===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(s,e)}else r.nsp=\"/\";const c=t.charAt(e+1);if(\"\"!==c&&Number(c)==c){const s=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(s,e+1))}if(t.charAt(++e)){const s=i(t.substr(e));if(!o.isPayloadValid(r.type,s))throw new Error(\"invalid payload\");r.data=s}return s(\"decoded %s as %j\",t,r),r}static isPayloadValid(t,e){switch(t){case n.CONNECT:return\"object\"==typeof e;case n.DISCONNECT:return void 0===e;case n.CONNECT_ERROR:return\"string\"==typeof e||\"object\"==typeof e;case n.EVENT:case n.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case n.ACK:case n.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}function i(t){try{return JSON.parse(t)}catch(e){return!1}}exports.Decoder=o;class a{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=e.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}\n},{\"component-emitter\":\"G6pK\",\"./binary\":\"BlgA\",\"./is-binary\":\"qd9m\",\"debug\":\"AqXJ\"}],\"mFdb\":[function(require,module,exports) {\n\"use strict\";function e(e,o,t){return e.on(o,t),function(){e.off(o,t)}}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.on=void 0,exports.on=e;\n},{}],\"TNz3\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.StrictEventEmitter=void 0;const e=require(\"component-emitter\");class t extends e{on(e,t){return super.on(e,t),this}once(e,t){return super.once(e,t),this}emit(e,...t){return super.emit(e,...t),this}emitReserved(e,...t){return super.emit(e,...t),this}listeners(e){return super.listeners(e)}}exports.StrictEventEmitter=t;\n},{\"component-emitter\":\"G6pK\"}],\"dju0\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Socket=void 0;const t=require(\"socket.io-parser\"),e=require(\"./on\"),s=require(\"./typed-events\"),i=require(\"debug\")(\"socket.io-client:socket\"),n=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends s.StrictEventEmitter{constructor(t,e,s){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[e.on(t,\"open\",this.onopen.bind(this)),e.on(t,\"packet\",this.onpacket.bind(this)),e.on(t,\"error\",this.onerror.bind(this)),e.on(t,\"close\",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),\"open\"===this.io._readyState&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift(\"message\"),this.emit.apply(this,t),this}emit(e,...s){if(n.hasOwnProperty(e))throw new Error('\"'+e+'\" is a reserved event name');s.unshift(e);const c={type:t.PacketType.EVENT,data:s,options:{}};c.options.compress=!1!==this.flags.compress,\"function\"==typeof s[s.length-1]&&(i(\"emitting packet with ack id %d\",this.ids),this.acks[this.ids]=s.pop(),c.id=this.ids++);const o=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!o||!this.connected)?i(\"discard packet as the transport is not currently writable\"):this.connected?this.packet(c):this.sendBuffer.push(c),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i(\"transport is open - connecting\"),\"function\"==typeof this.auth?this.auth(e=>{this.packet({type:t.PacketType.CONNECT,data:e})}):this.packet({type:t.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved(\"connect_error\",t)}onclose(t){i(\"close (%s)\",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved(\"disconnect\",t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case t.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved(\"connect_error\",new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));break;case t.PacketType.EVENT:case t.PacketType.BINARY_EVENT:this.onevent(e);break;case t.PacketType.ACK:case t.PacketType.BINARY_ACK:this.onack(e);break;case t.PacketType.DISCONNECT:this.ondisconnect();break;case t.PacketType.CONNECT_ERROR:const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved(\"connect_error\",s)}}onevent(t){const e=t.data||[];i(\"emitting event %j\",e),null!=t.id&&(i(\"attaching ack callback to event\"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(e){const s=this;let n=!1;return function(...c){n||(n=!0,i(\"sending ack %j\",c),s.packet({type:t.PacketType.ACK,id:e,data:c}))}}onack(t){const e=this.acks[t.id];\"function\"==typeof e?(i(\"calling ack %s with %j\",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i(\"bad ack %s\",t.id)}onconnect(t){i(\"socket connected with id %s\",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved(\"connect\")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i(\"server disconnect (%s)\",this.nsp),this.destroy(),this.onclose(\"io server disconnect\")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i(\"performing disconnect (%s)\",this.nsp),this.packet({type:t.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose(\"io client disconnect\"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}exports.Socket=c;\n},{\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"one5\":[function(require,module,exports) {\nfunction t(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}module.exports=t,t.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var i=Math.random(),o=Math.floor(i*this.jitter*t);t=0==(1&Math.floor(10*i))?t-o:t+o}return 0|Math.min(t,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(t){this.ms=t},t.prototype.setMax=function(t){this.max=t},t.prototype.setJitter=function(t){this.jitter=t};\n},{}],\"jC6d\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.Manager=void 0;const e=require(\"engine.io-client\"),t=require(\"./socket\"),n=require(\"socket.io-parser\"),i=require(\"./on\"),o=require(\"backo2\"),s=require(\"./typed-events\"),c=require(\"debug\")(\"socket.io-client:manager\");class r extends s.StrictEventEmitter{constructor(e,t){super(),this.nsps={},this.subs=[],e&&\"object\"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||\"/socket.io\",this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new o({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState=\"closed\",this.uri=e;const i=t.parser||n;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(c(\"readyState %s\",this._readyState),~this._readyState.indexOf(\"open\"))return this;c(\"opening %s\",this.uri),this.engine=e(this.uri,this.opts);const n=this.engine,o=this;this._readyState=\"opening\",this.skipReconnect=!1;const s=i.on(n,\"open\",function(){o.onopen(),t&&t()}),r=i.on(n,\"error\",e=>{c(\"error\"),o.cleanup(),o._readyState=\"closed\",this.emitReserved(\"error\",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){const e=this._timeout;c(\"connect attempt will timeout after %d\",e),0===e&&s();const t=setTimeout(()=>{c(\"connect attempt timed out after %d\",e),s(),n.close(),n.emit(\"error\",new Error(\"timeout\"))},e);this.opts.autoUnref&&t.unref(),this.subs.push(function(){clearTimeout(t)})}return this.subs.push(s),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){c(\"open\"),this.cleanup(),this._readyState=\"open\",this.emitReserved(\"open\");const e=this.engine;this.subs.push(i.on(e,\"ping\",this.onping.bind(this)),i.on(e,\"data\",this.ondata.bind(this)),i.on(e,\"error\",this.onerror.bind(this)),i.on(e,\"close\",this.onclose.bind(this)),i.on(this.decoder,\"decoded\",this.ondecoded.bind(this)))}onping(){this.emitReserved(\"ping\")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved(\"packet\",e)}onerror(e){c(\"error\",e),this.emitReserved(\"error\",e)}socket(e,n){let i=this.nsps[e];return i||(i=new t.Socket(this,e,n),this.nsps[e]=i),i}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return void c(\"socket %s is still active, skipping close\",n)}this._close()}_packet(e){c(\"writing packet %j\",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){c(\"cleanup\"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){c(\"disconnect\"),this.skipReconnect=!0,this._reconnecting=!1,\"opening\"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){c(\"onclose\"),this.cleanup(),this.backoff.reset(),this._readyState=\"closed\",this.emitReserved(\"close\",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)c(\"reconnect failed\"),this.backoff.reset(),this.emitReserved(\"reconnect_failed\"),this._reconnecting=!1;else{const t=this.backoff.duration();c(\"will wait %dms before reconnect attempt\",t),this._reconnecting=!0;const n=setTimeout(()=>{e.skipReconnect||(c(\"attempting reconnect\"),this.emitReserved(\"reconnect_attempt\",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(c(\"reconnect attempt error\"),e._reconnecting=!1,e.reconnect(),this.emitReserved(\"reconnect_error\",t)):(c(\"reconnect success\"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(\"reconnect\",e)}}exports.Manager=r;\n},{\"engine.io-client\":\"wC1p\",\"./socket\":\"dju0\",\"socket.io-parser\":\"DoTO\",\"./on\":\"mFdb\",\"backo2\":\"one5\",\"./typed-events\":\"TNz3\",\"debug\":\"fhQu\"}],\"x518\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.io=exports.Socket=exports.Manager=exports.protocol=void 0;const e=require(\"./url\"),r=require(\"./manager\"),o=require(\"debug\")(\"socket.io-client\");module.exports=exports=n;const t=exports.managers={};function n(n,c){\"object\"==typeof n&&(c=n,n=void 0),c=c||{};const s=e.url(n,c.path||\"/socket.io\"),i=s.source,u=s.id,a=s.path,p=t[u]&&a in t[u].nsps;let l;return c.forceNew||c[\"force new connection\"]||!1===c.multiplex||p?(o(\"ignoring socket cache for %s\",i),l=new r.Manager(i,c)):(t[u]||(o(\"new io instance for %s\",i),t[u]=new r.Manager(i,c)),l=t[u]),s.query&&!c.query&&(c.query=s.queryKey),l.socket(s.path,c)}exports.io=n;var c=require(\"socket.io-parser\");Object.defineProperty(exports,\"protocol\",{enumerable:!0,get:function(){return c.protocol}}),exports.connect=n;var s=require(\"./manager\");Object.defineProperty(exports,\"Manager\",{enumerable:!0,get:function(){return s.Manager}});var i=require(\"./socket\");Object.defineProperty(exports,\"Socket\",{enumerable:!0,get:function(){return i.Socket}}),exports.default=n;\n},{\"./url\":\"U1mP\",\"./manager\":\"jC6d\",\"debug\":\"fhQu\",\"socket.io-parser\":\"DoTO\",\"./socket\":\"dju0\"}],\"a3MF\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.L=f,exports.S=I;var t=require(\"./turn-order-0d61594c.js\"),e=require(\"rfc6902\"),s=require(\"./transport-0079de87.js\"),a=require(\"./base-13e38c3e.js\"),i=require(\"./master-cf52dceb.js\"),c=r(require(\"socket.io-client\"));function r(t){return t&&t.__esModule?t:{default:t}}class n extends a.S{constructor(){super(),this.state=new Map,this.initial=new Map,this.metadata=new Map,this.log=new Map}createMatch(t,e){this.initial.set(t,e.initialState),this.setState(t,e.initialState),this.setMetadata(t,e.metadata)}setMetadata(t,e){this.metadata.set(t,e)}setState(t,e,s){if(s&&s.length>0){const e=this.log.get(t)||[];this.log.set(t,[...e,...s])}this.state.set(t,e)}fetch(t,e){const s={};return e.state&&(s.state=this.state.get(t)),e.metadata&&(s.metadata=this.metadata.get(t)),e.log&&(s.log=this.log.get(t)||[]),e.initialState&&(s.initialState=this.initial.get(t)),s}wipe(t){this.state.delete(t),this.metadata.delete(t)}listMatches(t){return[...this.metadata.entries()].filter(([,e])=>{if(!t)return!0;if(void 0!==t.gameName&&e.gameName!==t.gameName)return!1;if(void 0!==t.where){if(void 0!==t.where.isGameover){if(void 0!==e.gameover!==t.where.isGameover)return!1}if(void 0!==t.where.updatedBefore&&e.updatedAt>=t.where.updatedBefore)return!1;if(void 0!==t.where.updatedAfter&&e.updatedAt<=t.where.updatedAfter)return!1}return!0}).map(([t])=>t)}}class h extends Map{constructor(t){super(),this.key=t,(JSON.parse(localStorage.getItem(this.key))||[]).forEach(t=>this.set(...t))}sync(){const t=[...this.entries()];localStorage.setItem(this.key,JSON.stringify(t))}set(t,e){return super.set(t,e),this.sync(),this}delete(t){const e=super.delete(t);return this.sync(),e}}class o extends n{constructor(t=\"bgio\"){super();const e=e=>new h(`${t}_${e}`);this.state=e(\"state\"),this.initial=e(\"initial\"),this.metadata=e(\"metadata\"),this.log=e(\"log\")}}const l=(e,s,a)=>({...a,G:e.playerView(a.G,a.ctx,s),plugins:(0,t.w)(a,{playerID:s,game:e}),deltalog:void 0,_undo:[],_redo:[]}),d=t=>(s,a)=>{switch(a.type){case\"patch\":{const[i,c,r,n]=a.args,h=u(n.deltalog,s),o=l(t,s,n),d=n._stateID,p=l(t,s,r);return{type:\"patch\",args:[i,c,d,(0,e.createPatch)(p,o),h]}}case\"update\":{const[e,i]=a.args,c=u(i.deltalog,s);return{type:\"update\",args:[e,l(t,s,i),c]}}case\"sync\":{const[e,i]=a.args,c=l(t,s,i.state),r=u(i.log,s);return{type:\"sync\",args:[e,{...i,state:c,log:r}]}}default:return a}};function u(t,e){return void 0===t?t:t.map(t=>{if(null!==e&&+e==+t.action.payload.playerID)return t;if(!0!==t.redact)return t;const s={...t.action.payload,args:null},a={...t,action:{...t.action,payload:s}},{redact:i,...c}=a;return c})}function p(t,e){if(void 0!==t.ctx.gameover)return null;if(t.ctx.activePlayers){for(const s of Object.keys(e))if(s in t.ctx.activePlayers)return s}else if(t.ctx.currentPlayer in e)return t.ctx.currentPlayer;return null}class m extends i.M{constructor({game:t,bots:e,storageKey:s,persist:a}){const i={},c={};if(t&&t.ai&&e)for(const n in e){const s=e[n];c[n]=new s({game:t,enumerate:t.ai.enumerate,seed:t.seed})}const r=({playerID:t,...e})=>{const s=i[t];void 0!==s&&s(h(t,e))},h=d(t),l={send:r,sendAll:t=>{for(const e in i)r({playerID:e,...t})}};super(t,a?new o(s):new n,l),this.connect=((t,e,s)=>{i[e]=s}),this.subscribe(({state:t,matchID:s})=>{if(!e)return;const a=p(t,c);null!==a&&setTimeout(async()=>{const e=await c[a].play(t,a);await this.onUpdate(e.action,t._stateID,s,e.action.payload.playerID)},100)})}}class g extends s.T{constructor({master:t,...e}){super(e),this.master=t,this.isConnected=!0}onChatMessage(t,e){const s=[t,e,this.credentials];this.master.onChatMessage(...s)}async onUpdate(e,s,a){const i=this.store.getState();if(e==this.matchID&&s._stateID>=i._stateID){const e=(0,t.B)(s,a);this.store.dispatch(e)}}onSync(e,s){if(e==this.matchID){const e=(0,t.s)(s);this.store.dispatch(e)}}onAction(t,e){this.master.onUpdate(e,t._stateID,this.matchID,this.playerID)}connect(){this.master.connect(this.matchID,this.playerID,t=>{switch(t.type){case\"sync\":return this.onSync(...t.args);case\"update\":return this.onUpdate(...t.args);case\"chat\":return this.chatMessageCallback(t.args[1])}}),this.master.onSync(this.matchID,this.playerID,this.credentials,this.numPlayers)}disconnect(){}subscribe(){}subscribeMatchData(){}subscribeChatMessage(t){this.chatMessageCallback=t}resetAndSync(){const e=(0,t.t)(null);this.store.dispatch(e),this.connect()}updateMatchID(t){this.matchID=t,this.resetAndSync()}updatePlayerID(t){this.playerID=t,this.resetAndSync()}updateCredentials(t){this.credentials=t,this.resetAndSync()}}const y=new Map;function f({bots:t,persist:e,storageKey:s}={}){return a=>{const{gameKey:i,game:c}=a;let r;const n=y.get(i);return n&&n.bots===t&&n.storageKey===s&&n.persist===e&&(r=n.master),r||(r=new m({game:c,bots:t,persist:e,storageKey:s}),y.set(i,{master:r,bots:t,persist:e,storageKey:s})),new g({master:r,...a})}}const D=c.default;class k extends s.T{constructor({socket:t,socketOpts:e,server:s,...a}={}){super(a),this.server=s,this.socket=t,this.socketOpts=e,this.isConnected=!1,this.callback=(()=>{}),this.matchDataCallback=(()=>{}),this.chatMessageCallback=(()=>{})}onAction(t,e){const s=[e,t._stateID,this.matchID,this.playerID];this.socket.emit(\"update\",...s)}onChatMessage(t,e){const s=[t,e,this.credentials];this.socket.emit(\"chat\",...s)}connect(){if(!this.socket)if(this.server){let t=this.server;-1==t.search(/^https?:\\/\\//)&&(t=\"http://\"+this.server),\"/\"!=t.slice(-1)&&(t+=\"/\"),this.socket=D(t+this.gameName,this.socketOpts)}else this.socket=D(\"/\"+this.gameName,this.socketOpts);this.socket.on(\"patch\",(e,s,a,i,c)=>{const r=this.store.getState()._stateID;if(e===this.matchID&&s===r){const e=(0,t.C)(s,a,i,c);this.store.dispatch(e),this.store.getState()._stateID===r&&this.sync()}}),this.socket.on(\"update\",(e,s,a)=>{const i=this.store.getState();if(e==this.matchID&&s._stateID>=i._stateID){const e=(0,t.B)(s,a);this.store.dispatch(e)}}),this.socket.on(\"sync\",(e,s)=>{if(e==this.matchID){const e=(0,t.s)(s);this.matchDataCallback(s.filteredMetadata),this.store.dispatch(e)}}),this.socket.on(\"matchData\",(t,e)=>{t==this.matchID&&this.matchDataCallback(e)}),this.socket.on(\"chat\",(t,e)=>{t===this.matchID&&this.chatMessageCallback(e)}),this.socket.on(\"connect\",()=>{this.sync(),this.isConnected=!0,this.callback()}),this.socket.on(\"disconnect\",()=>{this.isConnected=!1,this.callback()})}disconnect(){this.socket.close(),this.socket=null,this.isConnected=!1,this.callback()}subscribe(t){this.callback=t}subscribeMatchData(t){this.matchDataCallback=t}subscribeChatMessage(t){this.chatMessageCallback=t}sync(){if(this.socket){const t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit(\"sync\",...t)}}resetAndSync(){const e=(0,t.t)(null);this.store.dispatch(e),this.sync()}updateMatchID(t){this.matchID=t,this.resetAndSync()}updatePlayerID(t){this.playerID=t,this.resetAndSync()}updateCredentials(t){this.credentials=t,this.resetAndSync()}}function I({server:t,socketOpts:e}={}){return s=>new k({server:t,socketOpts:e,...s})}\n},{\"./turn-order-0d61594c.js\":\"Tr4D\",\"rfc6902\":\"B6py\",\"./transport-0079de87.js\":\"KLsr\",\"./base-13e38c3e.js\":\"VAT5\",\"./master-cf52dceb.js\":\"pSJp\",\"socket.io-client\":\"x518\"}],\"Q5yd\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),Object.defineProperty(exports,\"Local\",{enumerable:!0,get:function(){return e.L}}),Object.defineProperty(exports,\"SocketIO\",{enumerable:!0,get:function(){return e.S}}),require(\"redux\"),require(\"./turn-order-0d61594c.js\"),require(\"immer\"),require(\"lodash.isplainobject\"),require(\"./reducer-77828ca8.js\"),require(\"rfc6902\"),require(\"./initialize-68f0dc41.js\"),require(\"./transport-0079de87.js\"),require(\"./base-13e38c3e.js\");var e=require(\"./socketio-b981ab77.js\");require(\"./master-cf52dceb.js\"),require(\"socket.io-client\");\n},{\"redux\":\"OV4J\",\"./turn-order-0d61594c.js\":\"Tr4D\",\"immer\":\"VB7z\",\"lodash.isplainobject\":\"B6zW\",\"./reducer-77828ca8.js\":\"b133\",\"rfc6902\":\"B6py\",\"./initialize-68f0dc41.js\":\"azvt\",\"./transport-0079de87.js\":\"KLsr\",\"./base-13e38c3e.js\":\"VAT5\",\"./socketio-b981ab77.js\":\"a3MF\",\"./master-cf52dceb.js\":\"pSJp\",\"socket.io-client\":\"x518\"}],\"yB5F\":[function(require,module,exports) {\n\"use strict\";function e(e,t){t.events.setActivePlayers({others:\"discard\",moveLimit:1})}function t(e,t){}Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;const s={moves:{militia:e},turn:{stages:{discard:{moves:{discard:t}}}}};var i=s;exports.default=i;\n},{}],\"aBzy\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=require(\"svelte/internal\"),t=require(\"boardgame.io/client\"),n=require(\"boardgame.io/multiplayer\"),l=i(require(\"./game\"));function i(e){return e&&e.__esModule?e:{default:e}}function a(t){(0,e.append_styles)(t,\"svelte-temvio\",\".client.svelte-temvio.svelte-temvio{border-radius:5px;width:100px;border:1px solid #ddd;background:#fafafa;opacity:.8}.client.active.svelte-temvio.svelte-temvio{box-shadow:0 0 5px #aaa;background:#fff;opacity:1}.client.svelte-temvio li.svelte-temvio{list-style:none;padding:5px;height:30px;line-height:30px;text-align:center;font-family:monospace}\")}function s(t){let n,l,i,a,s,c;function d(e,t){return e[2]?o:r}let p=d(t),u=p(t);return{c(){n=(0,e.element)(\"li\"),u.c(),l=(0,e.space)(),i=(0,e.element)(\"li\"),(a=(0,e.element)(\"button\")).textContent=\"End Turn\",(0,e.attr)(n,\"class\",\"svelte-temvio\"),(0,e.attr)(i,\"class\",\"svelte-temvio\")},m(r,o){(0,e.insert)(r,n,o),u.m(n,null),(0,e.insert)(r,l,o),(0,e.insert)(r,i,o),(0,e.append)(i,a),s||(c=(0,e.listen)(a,\"click\",t[6]),s=!0)},p(e,t){p===(p=d(e))&&u?u.p(e,t):(u.d(1),(u=p(e))&&(u.c(),u.m(n,null)))},d(t){t&&(0,e.detach)(n),u.d(),t&&(0,e.detach)(l),t&&(0,e.detach)(i),s=!1,c()}}}function r(t){let n,l,i;return{c(){(n=(0,e.element)(\"button\")).textContent=\"Play Card\"},m(a,s){(0,e.insert)(a,n,s),l||(i=(0,e.listen)(n,\"click\",t[5]),l=!0)},p:e.noop,d(t){t&&(0,e.detach)(n),l=!1,i()}}}function o(t){let n,l,i;return{c(){(n=(0,e.element)(\"button\")).textContent=\"Discard\"},m(a,s){(0,e.insert)(a,n,s),l||(i=(0,e.listen)(n,\"click\",t[4]),l=!0)},p:e.noop,d(t){t&&(0,e.detach)(n),l=!1,i()}}}function c(t){let n,l,i,a,r,o,c=t[1].isActive&&s(t);return{c(){n=(0,e.element)(\"div\"),l=(0,e.element)(\"li\"),i=(0,e.element)(\"strong\"),a=(0,e.text)(\"Player \"),r=(0,e.text)(t[0]),o=(0,e.space)(),c&&c.c(),(0,e.attr)(l,\"class\",\"svelte-temvio\"),(0,e.attr)(n,\"class\",\"client svelte-temvio\"),(0,e.toggle_class)(n,\"active\",t[1].isActive)},m(t,s){(0,e.insert)(t,n,s),(0,e.append)(n,l),(0,e.append)(l,i),(0,e.append)(i,a),(0,e.append)(i,r),(0,e.append)(n,o),c&&c.m(n,null)},p(t,[l]){1&l&&(0,e.set_data)(r,t[0]),t[1].isActive?c?c.p(t,l):((c=s(t)).c(),c.m(n,null)):c&&(c.d(1),c=null),2&l&&(0,e.toggle_class)(n,\"active\",t[1].isActive)},i:e.noop,o:e.noop,d(t){t&&(0,e.detach)(n),c&&c.d()}}}function d(i,a,s){let r,o,{playerID:c}=a;const d=(0,t.Client)({game:l.default,matchID:\"default\",playerID:c,debug:!1,numPlayers:3,multiplayer:(0,n.Local)()});(0,e.component_subscribe)(i,d,e=>s(1,o=e)),d.start();return i.$$set=(e=>{\"playerID\"in e&&s(0,c=e.playerID)}),i.$$.update=(()=>{3&i.$$.dirty&&s(2,r=o.ctx.activePlayers&&\"discard\"==o.ctx.activePlayers[c])}),[c,o,r,d,()=>d.moves.discard(),()=>d.moves.militia(),()=>d.events.endTurn()]}class p extends e.SvelteComponent{constructor(t){super(),(0,e.init)(this,t,d,c,e.safe_not_equal,{playerID:0},a)}}var u=p;exports.default=u;\n},{\"svelte/internal\":\"YkLP\",\"boardgame.io/client\":\"iSKo\",\"boardgame.io/multiplayer\":\"Q5yd\",\"./game\":\"yB5F\"}],\"N1CG\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=require(\"svelte/internal\"),t=n(require(\"./Player.svelte\"));function n(e){return e&&e.__esModule?e:{default:e}}function o(t){(0,e.append_styles)(t,\"svelte-1wp7gvh\",\".container.svelte-1wp7gvh{display:flex;flex-direction:row;justify-content:space-evenly}\")}function r(n){let o,r,a,p,s,l,i,u;return a=new t.default({props:{playerID:\"0\"}}),s=new t.default({props:{playerID:\"1\"}}),i=new t.default({props:{playerID:\"2\"}}),{c(){o=(0,e.element)(\"div\"),r=(0,e.element)(\"div\"),(0,e.create_component)(a.$$.fragment),p=(0,e.space)(),(0,e.create_component)(s.$$.fragment),l=(0,e.space)(),(0,e.create_component)(i.$$.fragment),(0,e.attr)(r,\"class\",\"container svelte-1wp7gvh\")},m(t,n){(0,e.insert)(t,o,n),(0,e.append)(o,r),(0,e.mount_component)(a,r,null),(0,e.append)(r,p),(0,e.mount_component)(s,r,null),(0,e.append)(r,l),(0,e.mount_component)(i,r,null),u=!0},p:e.noop,i(t){u||((0,e.transition_in)(a.$$.fragment,t),(0,e.transition_in)(s.$$.fragment,t),(0,e.transition_in)(i.$$.fragment,t),u=!0)},o(t){(0,e.transition_out)(a.$$.fragment,t),(0,e.transition_out)(s.$$.fragment,t),(0,e.transition_out)(i.$$.fragment,t),u=!1},d(t){t&&(0,e.detach)(o),(0,e.destroy_component)(a),(0,e.destroy_component)(s),(0,e.destroy_component)(i)}}}class a extends e.SvelteComponent{constructor(t){super(),(0,e.init)(this,t,null,r,e.safe_not_equal,{},o)}}var p=a;exports.default=p;\n},{\"svelte/internal\":\"YkLP\",\"./Player.svelte\":\"aBzy\"}],\"k7Rb\":[function(require,module,exports) {\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default=void 0;var e=t(require(\"./App.svelte\"));function t(e){return e&&e.__esModule?e:{default:e}}const r=new e.default({target:document.getElementById(\"app\"),props:{name:\"world\"}});var o=r;exports.default=o;\n},{\"./App.svelte\":\"N1CG\"}]},{},[\"k7Rb\"], null)"
  },
  {
    "path": "docs/documentation/snippets/stages-1.bcf7ab84.css",
    "content": ".client.svelte-temvio.svelte-temvio{border-radius:5px;width:100px;border:1px solid #ddd;background:#fafafa;opacity:.8}.client.active.svelte-temvio.svelte-temvio{box-shadow:0 0 5px #aaa;background:#fff;opacity:1}.client.svelte-temvio li.svelte-temvio{list-style:none;padding:5px;height:30px;line-height:30px;text-align:center;font-family:monospace}.container.svelte-1wp7gvh{display:flex;flex-direction:row;justify-content:space-evenly}"
  },
  {
    "path": "docs/documentation/stages.md",
    "content": "# Stages\n\nA stage is similar to a phase, except that it happens within a turn.\nA turn can be subdivided into many stages, each allowing a different\nset of moves during that stage.\n\nStages are also useful to allow more than one player to play during a turn.\nBy default, only the `currentPlayer` is allowed to make moves during a turn.\nHowever, some game situations call for moves by other players. For example,\nthe `currentPlayer` might play a card that requires every other player in\nthe game to discard a card. These discards don't have to happen in any\nparticular order, and they're not really separate turns (the `currentPlayer`\ncan still play other cards before the turn finally ends). Stages are useful\nin such situations.\n\nWhenever one or more players enters a stage during a turn, then the framework\nonly allows moves from those players (rather than `currentPlayer`). The\nplayers don't have to all be in the same stage either (each player can be\nin their own stage). Each player that is in a stage is now considered an\n\"active\" player that can make moves as allowed by the stage that they are in.\n\nYou can check `playerID` inside a move to figure out\nwhich player made it. This may be necessary in situations\nwhere multiple players are active (and could simultaneously make a move).\n\n```js\nconst move = ({ G, ctx, playerID }) => {\n  console.log(`move made by player ${playerID}`);\n};\n```\n\n### Defining Stages\n\nStages are defined inside a `turn` section:\n\n```js\nconst game = {\n  moves: { ... },\n\n  turn: {\n    stages: {\n      discard: {\n        moves: { DiscardCard },\n      },\n    },\n  },\n};\n\n```\n\nThe example above defines a single `discard` stage that players enter when they are\nrequired to discard a card. The stage defines its own `moves` section which specifies\nwhat moves a player in that stage can make. This `moves` section completely overrides\nthe global `moves` section for players in that stage (players are not allowed to make\nany moves from the global `moves` section while they are in that stage). However, if\na stage does not contain a `moves` section, then players can make moves from the global `moves`.\n\n!> A move defined in a stage can have the same name as a global move, but it isn't related to the global equivalent in any way.\n\n### Entering Stages\n\nA stage can be entered by calling the `setStage` event.\nThis takes the player that called the event into the specified stage:\n\n```js\nsetStage('discard');\n```\n\n### Exiting Stages\n\nExiting a stage is performed by calling the `endStage` event.\nThis removes the player from the stage that they are currently\nin and returns them to a state where they aren't in any stage.\n\n```js\nendStage();\n```\n\nIt is possible to automatically take a player to another stage\nwhen `endStage` is called. This is done by specifying a `next`\noption in the stage config.\n\n```js\nstages: {\n  A: { next: 'B' },\n  B: { next: 'C' },\n  C: { next: 'A' },\n}\n```\n\nIn the example above, `endStage` will cycle between the three\nstages.\n\n### Advanced\n\nSometimes you need to move a group of players into a stage\n(as opposed to just the player that called the event).\nWe use the `setActivePlayers` event for this:\n\n```js\nsetActivePlayers({\n  // Move the current player to a stage.\n  currentPlayer: 'stage-name',\n\n  // Move every other player to a stage.\n  others: 'stage-name',\n\n  // Move all players to a stage.\n  all: 'stage-name',\n\n  // Enumerate the set of players and the stages that they\n  // are in.\n  value: {\n    '0': 'stage-name',\n    '1': 'stage-name',\n    ...\n  },\n\n  // Prevents manual endStage before the player\n  // has made the specified number of moves.\n  minMoves: 1,\n\n  // Calls endStage automatically after the player\n  // has made the specified number of moves.\n  maxMoves: 5,\n\n  // This takes the stage configuration to the\n  // value prior to this setActivePlayers call\n  // once the set of active players becomes empty\n  // (due to players either calling endStage or\n  // maxMoves ending the stage for them).\n  revert: true,\n\n  // A next option will be used once the set of active players\n  // becomes empty (either by using maxMoves or manually removing\n  // players).\n  // All options available inside setActivePlayers are available\n  // inside next.\n  next: { ... },\n});\n```\n\nLet's go back to the example we discussed earlier where we\nrequire every other player to discard a card when we play one:\n\n```js\nfunction PlayCard({ events }) {\n  events.setActivePlayers({ others: 'discard', minMoves: 1, maxMoves: 1 });\n}\n\nconst game = {\n  moves: { PlayCard },\n  turn: {\n    stages: {\n      discard: {\n        moves: { Discard },\n      },\n    },\n  },\n};\n```\n\n```react\n<iframe class='plain' src='snippets/stages-1' height='160' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>\n```\n\n#### Advanced Move Limits\n\nPassing a `minMoves` argument to `setActivePlayers` forces all the\nactive players to make at least that number of moves before being able to\nend the stage, but sometimes you might want to set different move limits \nfor different players. For cases like this, `setStage` and `setActivePlayers` \nsupport long-form arguments:\n\n```js\nsetStage({ stage: 'stage-name', minMoves: 3 });\n```\n\n```js\nsetActivePlayers({\n  currentPlayer: { stage: 'stage-name', minMoves: 2 },\n  others: { stage: 'stage-name', minMoves: 1 },\n  value: {\n    '0': { stage: 'stage-name', minMoves: 4 },\n  },\n});\n```\n\nPassing a `maxMoves` argument to `setActivePlayers` limits all the\nactive players to making that number of moves, but sometimes you might want\nto set different move limits for different players. For cases like this,\n`setStage` and `setActivePlayers` support long-form arguments:\n\n```js\nsetStage({ stage: 'stage-name', maxMoves: 3 });\n```\n\n```js\nsetActivePlayers({\n  currentPlayer: { stage: 'stage-name', maxMoves: 2 },\n  others: { stage: 'stage-name', maxMoves: 1 },\n  value: {\n    '0': { stage: 'stage-name', maxMoves: 4 },\n  },\n});\n```\n\n### Stage.NULL\n\nSometimes you want to add a player to the set of active players\nbut don't want them to be in a specific stage. You can use `Stage.NULL`\nfor this:\n\n```js\nimport { Stage } from 'boardgame.io/core';\n\n// This allows any player to make a move, but doesn't restrict them to\n// a particular stage.\nsetActivePlayers({ all: Stage.NULL });\n```\n\nThere is also a convenient syntax to enumerate the players\nthat you want in the set of active players:\n\n```js\n// Players 0 and 3 are added to the set of active players,\n// and neither is placed in a stage.\nsetActivePlayers(['0', '3']);\n```\n\n### Configuring active players at the beginning of a turn.\n\nYou can have `setActivePlayers` called automatically\nat the beginning of the turn by adding an `activePlayers` section\nto the `turn` config:\n\n```js\nturn: {\n  activePlayers: { all: Stage.NULL },\n}\n```\n\n### Presets\n\nA number of `activePlayers` configurations are available as presets that you\ncan use directly:\n\n```js\nimport { ActivePlayers } from 'boardgame.io/core';\n\nturn: {\n  activePlayers: ActivePlayers.ALL;\n}\n```\n\n#### ALL\n\nEquivalent to `{ all: Stage.NULL }`. Any player can play, and they\naren't restricted to any particular stage.\n\n#### ALL_ONCE\n\nEquivalent to `{ all: Stage.NULL, minMoves: 1, maxMoves: 1 }`. Any player can make\nexactly one move before they are removed from the set of active players.\n\n#### OTHERS\n\nSimilar to `ALL`, but excludes the current player from the set\nof active players.\n\n#### OTHERS_ONCE\n\nSimilar to `ALL_ONCE`, but excludes the current player from the set\nof active players.\n"
  },
  {
    "path": "docs/documentation/storage.md",
    "content": "# Storage\n\n**boardgame.io** is storage agnostic. Various adapters are\navailable that allow you to persist your game state in\ndifferent storage systems.\n\nYou can even write your [own adapter](/storage?id=writing-a-custom-adapter)\nfor a custom backend.\n\n### Flatfile\n\nFirst, install the necessary packages:\n\n```\nnpm install node-persist\n```\n\nThen modify your server spec to indicate that you want to connect to a flatfile database:\n\n```js\nconst { Server, FlatFile } = require('boardgame.io/server');\nconst { TicTacToe } = require('./game');\n\nconst server = Server({\n  games: [TicTacToe],\n\n  db: new FlatFile({\n    dir: '/storage/directory',\n    logging: (true/false),\n    ttl: (optional, see node-persist docs),\n  }),\n});\n\nserver.run(8000);\n```\n\n### Other backends\n\n#### Firebase\n\nInstructions at https://github.com/delucis/bgio-firebase.\n\n#### Azure Storage\n\nInstructions at https://github.com/c-w/bgio-azure-storage.\n\n#### Postgres\n\nInstructions at https://github.com/janKir/bgio-postgres.\n\n#### MongoDB\n\nComing soon (used to be supported but is not in sync with the\nlatest release).\n\n### Caching\n\nDepending on your set-up, you may want the server to cache some of the data,\nreducing the load on your database and speeding up server responses.\n[@boardgame.io/storage-cache](https://github.com/boardgameio/storage-cache) offers\na basic caching model compatible with any boardgame.io database connector.\n\n### Writing a Custom Adapter\n\nCreate a class that implements the [StorageAPI.Async](https://github.com/boardgameio/boardgame.io/blob/main/src/server/db/base.ts) interface.\n"
  },
  {
    "path": "docs/documentation/testing.md",
    "content": "# Testing Strategies\n\n### Unit Tests\n\nMoves are just functions, so they lend themselves to unit testing.\nA useful strategy is to implement each move as a standalone function\nbefore passing them to the game object:\n\n`Game.js`\n\n```js\nexport function clickCell({ G, playerID }, id) {\n  G.cells[id] = playerID;\n}\n\nexport const TicTacToe = {\n  moves: { clickCell },\n  // ...\n}\n```\n\n`Game.test.js`\n\n```js\nimport { clickCell } from './Game';\n\nit('should place the correct value in the cell', () => {\n  // original state.\n  const G = {\n    cells: [null, null, null, null, null, null, null, null, null],\n  };\n\n  // make move.\n  clickCell({ G, playerID: '1' }, 3);\n\n  // verify new state.\n  expect(G).toEqual({\n    cells: [null, null, null, '1', null, null, null, null, null],\n  });\n});\n```\n\n### Scenario Tests\n\nTest your game logic in specific scenarios.\n\n```js\nimport { Client } from 'boardgame.io/client';\nimport { TicTacToe } from './Game';\n\nit('should declare player 1 as the winner', () => {\n  // set up a specific board scenario\n  const TicTacToeCustomScenario = {\n    ...TicTacToe,\n    setup: () => ({\n      cells: ['0', '0', null, '1', '1', null, null, null, null],\n    }),\n  };\n\n  // initialize the client with your custom scenario\n  const client = Client({\n    game: TicTacToeCustomScenario,\n  });\n\n  // make some game moves\n  client.moves.clickCell(8);\n  client.moves.clickCell(5);\n\n  // get the latest game state\n  const { G, ctx } = client.getState();\n\n  // the board should look like this now\n  expect(G.cells).toEqual(['0', '0', null, '1', '1', '1', null, null, '0']);\n  // player '1' should be declared the winner\n  expect(ctx.gameover).toEqual({ winner: '1' });\n});\n```\n\n?> Note that we imported the vanilla JavaScript client, not the\none from `boardgame.io/react`.\n\n### Testing Randomness\n\nIf you are testing a move that uses the [Random API](/random), by definition\nyou can’t always expect the same result, making it harder to test. In this\ncase, you can use one of the following strategies.\n\n#### Fixed PRNG seed\n\nYou can set `seed` in your game object. This will be used to initialise the\nRandom API’s internal state and you’ll see a predictable sequence of results\nfrom calls to random API methods:\n\n```js\nimport { Client } from 'boardgame.io/client';\n\nconst Game = {\n  moves: {\n    rollDice: ({ G, random }) => {\n      G.roll = random.D6();\n    },\n  },\n};\n\nit('updates G.roll with a random number', () => {\n  const client = Client({\n      // Set seed so PRNG always starts in same state\n    game: { ...Game, seed: 'fixed-seed' },\n  });\n  client.moves.rollDice();\n  const { G } = client.getState();\n  expect(G.roll).toMatchInlineSnapshot(`4`);\n});\n```\n\n#### Override Random API <small>`since v0.49.10`</small>\n\nIf you need to test specific random outcomes, you can override the Random\nAPI entirely to allow complete control of the results of API methods.\n\n```js\nimport { Client } from 'boardgame.io/client';\nimport { MockRandom } from 'boardgame.io/testing';\n\n// Create a mock of the random plugin, where the D6 method always returns 6.\n// Any methods you don’t provide an implementation for will behave as usual.\nconst randomPlugin = MockRandom({\n  D6: () => 6,\n});\n\nit ('rolls a six', () => {\n  const client = Client({\n    game: {\n      ...Game,\n      // Add the random plugin mock to the game’s plugins.\n      plugins: [...(Game.plugins || []), randomPlugin]\n    },\n  });\n  client.moves.rollDice();\n  const { G } = client.getState();\n  expect(G.roll).toMatchInlineSnapshot(`6`);\n});\n```\n\n### Multiplayer Tests\n\nUse the local multiplayer mode to simulate multiplayer interactions\nin unit tests.\n\n```js\nit('multiplayer test', () => {\n  const spec = {\n    game: MyGame,\n    multiplayer: Local(),\n  };\n\n  const p0 = Client({ ...spec, playerID: '0' });\n  const p1 = Client({ ...spec, playerID: '1' });\n\n  p0.start();\n  p1.start();\n\n  p0.moves.moveA();\n  p0.events.endTurn();\n\n  // Player 1's state reflects the moves made by Player 0.\n  expect(p1.getState()).toEqual(...);\n\n  p1.moves.moveA();\n  p1.events.endTurn();\n\n  ...\n});\n```\n\n### Integration Tests\n\nTest the application end-to-end from the UI layer's point of view.\n\nIn this case we use [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/)\nto mount our React component and look for the TicTacToe board inside of it.\nWe then check the board is rendered and responds to user interaction as expected.\n\n```js\nimport React from 'react';\nimport { render, fireEvent } from '@testing-library/react';\nimport '@testing-library/jest-dom/extend-expect';\nimport App from './app';\n\ndescribe('Tic-Tac-Toe', () => {\n  const { container } = render(<App />);\n  const cells = container.querySelectorAll('td');\n  \n  test('board is empty initially', () => {\n    expect(cells).toHaveLength(9);\n    for (const cell of cells) {\n      expect(cell).toBeEmptyDOMElement();\n    }\n  });\n  \n  test('clicking a cell places player 0’s marker', () => {\n    fireEvent.click(cells[5]);\n    expect(cells[5]).toHaveTextContent('0');\n  });\n});\n```\n"
  },
  {
    "path": "docs/documentation/theme.css",
    "content": ":root {\n  --theme-hue: 152;\n  --theme-lightness : 26%;\n  --mono-hue: calc(var(--theme-hue) + 400);\n  --mono-saturation: 5%;\n\n  --link-color: var(--theme-color);\n\n  /* add rounded corners */\n  --border-radius-s: .25em;\n  --border-radius-m: .5em;\n  --border-radius-l: 1.5em;\n\n  /* Sidebar Menu */\n  /* layout */\n  --sidebar-horizontal-padding: 1em;\n  --sidebar-padding: 0 var(--sidebar-horizontal-padding);\n  --sidebar-nav-indent: 0;\n  --sidebar-nav-link-margin: 0 calc(-1 * var(--sidebar-horizontal-padding)) 0 0;\n  --sidebar-nav-pagelink-padding: .25em 0 0 20px;\n  /* active page link styling */\n  --sidebar-nav-link-font-weight--active: bold;\n  --sidebar-nav-link-before-content-l3: \"\";\n  --sidebar-nav-link-before-content-l3--active: \"→\";\n  /* section headings */\n  --sidebar-nav-strong-font-size: var(--font-size-s);\n  --sidebar-nav-strong-margin: 2em calc(-1 * var(--sidebar-horizontal-padding)) .25em 0;\n  --sidebar-nav-strong-padding: .25em 0 0;\n\n  /* syntax highlighting tweaks for contrast accessibility */\n  --code-theme-comment: hsl(0, 0%, 44%);\n  --code-theme-function: hsl(347, 88%, 47%);\n  --code-theme-punctuation: var(--mono-shade1);\n  --code-theme-operator: hsl(29, 30%, 40%);\n  --code-theme-selector: hsl(100, 100%, 25%);\n  --code-theme-tag: hsl(310, 100%, 30%);\n}\n\n.markdown-section {\n  padding: 2em;\n  margin-bottom: 6em;\n}\n\nimg[alt*=\"github stars\" i] {\n  vertical-align: middle;\n}\n\n.sidebar-nav li > strong {\n  letter-spacing: .15ch;\n}\n\n.app-sub-sidebar {\n  --sidebar-nav-indent: 1em;\n  --sidebar-nav-pagelink-padding: 0;\n}\n\n@media screen and (max-width: 768px) {\n  :root {\n    --docsifytabs-content-padding: 1rem;\n    --code-block-margin: 1em -1em;\n    --code-block-padding: 1.75em 1em 1.25em;\n    --code-block-border-radius: 0;\n  }\n\n  .markdown-section {\n    padding: 2em 1em;\n  }\n}\n\n@media screen and (max-width: 1250px) {\n  /* prevent transparent part of GitHub Corner intercepting clicks */\n  .github-corner { pointer-events: none; }\n  .github-corner path { pointer-events: all; }\n}\n"
  },
  {
    "path": "docs/documentation/turn-order.md",
    "content": "# Turn Order\n\nThe framework's default behavior is to pass the turn around\nin a round-robin fashion. A player makes one or more moves\nbefore triggering an `endTurn` event, which passes the turn\nto the next player.\n\nTurn order state is maintained in the following fields:\n\n```js\nctx: {\n  currentPlayer: '0',\n  playOrder: ['0', '1', '2', ...],\n  playOrderPos: 0,\n}\n```\n\n##### `currentPlayer`\n\nThis is the owner of the current turn and the only player that\ncan normally make moves during the turn. You may also allow\nadditional players to make moves during the turn using [Stages](stages.md).\n\n##### `playOrder`\n\nThe default value is `['0', '1', '2', ... ]`. You can think of this\nas the order in which players sit down at the table. A round\nrobin turn order would move `currentPlayer` through this\nlist in order.\n\n##### `playOrderPos`\n\nAn index into `playOrder`. It is the value that is updated\nby the turn order policy in order to compute `currentPlayer`.\nThe default behavior is to just increment it in a round-robin\nfashion. `currentPlayer` is just `playOrder[playOrderPos]`.\n\n### Changing the Turn Order\n\nChanging the game's turn order is accomplished by using the `order`\noption inside the `turn` section of the game config:\n\n```js\nimport { TurnOrder } from 'boardgame.io/core';\n\nconst game = {\n  turn: {\n    order: TurnOrder.ONCE,\n  },\n};\n```\n\nYou will typically use one of the presets below. You may also\nchange the turn order at each phase of the game. See the guide\non [Phases](phases.md) for more details.\n\n### Presets\n\n#### DEFAULT\n\nThis is the default round-robin. It is used if you don't\nspecify any turn order.\n\n#### RESET\n\nThis is similar to `DEFAULT`, but instead of incrementing\nthe previous position at the beginning of a phase, it\nwill always start from `0`.\n\n#### CONTINUE\n\nThis is also similar to `DEFAULT`, but instead of incrementing\nthe previous position at the beginning of a phase, it will\nstart with the player who ended the previous phase.\n\n#### ONCE\n\nThis is another round-robin, but it goes around only once.\nAfter this, the phase ends automatically.\n\n#### CUSTOM\n\nRound-robin like `DEFAULT`, but sets `playOrder` to the provided\nvalue.\n\n```js\nturn: {\n  order: TurnOrder.CUSTOM(['1', '3']),\n}\n```\n\n#### CUSTOM_FROM\n\nRound-robin like `DEFAULT`, but sets `playOrder` to the value\nin a specified field in `G`.\n\n```js\nturn: {\n  order: TurnOrder.CUSTOM_FROM('property_in_G'),\n}\n```\n\n### Ad Hoc\n\nYou can also specify the next player during the `endTurn` event.\n\n```js\nendTurn({ next: playerID });\n```\n\nThis argument can also be the return value of `turn.endIf` and\nworks the same way.\n\nPlayer `3` is made the new player in both examples below:\n\n```js\nfunction Move({ events }) {\n  events.endTurn({ next: '3' });\n}\n```\n\n```js\nconst game = {\n  turn: {\n    endIf: () => ({ next: '3' }),\n  },\n};\n```\n\n### Creating a Custom Turn Order\n\nIf the presets above aren't what you're looking for, you can\ncreate a custom turn order from scratch:\n\n```js\nturn: {\n  order: {\n    // Get the initial value of playOrderPos.\n    // This is called at the beginning of the phase.\n    first: ({ G, ctx }) => 0,\n\n    // Get the next value of playOrderPos.\n    // This is called at the end of each turn.\n    // The phase ends if this returns undefined.\n    next: ({ G, ctx }) => (ctx.playOrderPos + 1) % ctx.numPlayers,\n\n    // OPTIONAL:\n    // Override the initial value of playOrder.\n    // This is called at the beginning of the game / phase.\n    playOrder: ({ G, ctx }) => [...],\n  }\n}\n```\n"
  },
  {
    "path": "docs/documentation/tutorial.md",
    "content": "# Tutorial\n\nThis tutorial walks through a simple game of Tic-Tac-Toe.\n\n?> We’re going to be running commands from a terminal and using Node.js/npm.\n   If you haven’t done that before, you might want to read [an introduction to the command line][cmd]\n   and follow [the instructions on how to install Node][node]. You’ll also want\n   a text editor to write code in like [VS Code][vsc] or [Atom][atom].\n\n[node]: https://nodejs.dev/learn/how-to-install-nodejs\n[cmd]: https://tutorial.djangogirls.org/en/intro_to_command_line/\n[vsc]: https://code.visualstudio.com/\n[atom]: https://atom.io/\n\n\n\n## Setup\n\nWe’re going to use ES2015 features like module [imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)\nand the [object spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator)\nsyntax, so we’ll need to use some kind of build system to compile\nour code for the browser.\n\nThis tutorial shows two different approaches: one using [React](https://reactjs.org/),\nthe other using basic browser APIs and compiling our app with\n[Parcel](https://parceljs.org/).\nYou can follow whichever you feel most comfortable with.\n\n<!-- tabs:start -->\n\n### **Plain JS**\n\nLet’s create a new Node project from the command line:\n\n```\nmkdir bgio-tutorial\ncd bgio-tutorial\nnpm init --yes\n```\n\n?> These commands will make a new directory called `bgio-tutorial`,\n   change to that directory, and initialise a new Node package.\n   [Read more in the Node Package Manager docs.][pkgjson]\n\n[pkgjson]: https://docs.npmjs.com/creating-a-package-json-file#creating-a-default-packagejson-file\n\nWe’re going to add boardgame.io and also Parcel to help us build our app:\n\n```\nnpm install boardgame.io\nnpm install --save-dev parcel-bundler\n```\n\n\nNow, let’s create the basic structure our project needs:\n\n\n1. A JavaScript file for our web app at `src/App.js`.\n\n\n2. A JavaScript file for our game definition at `src/Game.js`.\n\n\n3. A basic HTML page that will load our app at `index.html`:\n\n    ```html\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>boardgame.io Tutorial</title>\n      <meta charset=\"utf-8\" />\n    </head>\n    <body>\n      <div id=\"app\"></div>\n      <script src=\"./src/App.js\"></script>\n    </body>\n    </html>\n    ```\n\nYour project directory should now look like this:\n\n    bgio-tutorial/\n    ├── index.html\n    ├── node_modules/\n    ├── package-lock.json\n    ├── package.json\n    └── src/\n        ├── App.js\n        └── Game.js\n\nLooking good? OK, let’s get started! 🚀\n\n?> You can check out the complete code for this tutorial\nand play around with it on CodeSandbox:<br/><br/>\n[![Edit bgio-plain-js-tutorial](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/bgio-plain-js-tutorial-ewyyt?fontsize=14&hidenavigation=1&module=%2Fsrc%2FApp.js&theme=dark)\n\n### **React**\n\nWe’ll use the [create-react-app](https://create-react-app.dev/)\ncommand line tool to initialize our React app and then add boardgame.io to it.\n\n```\nnpx create-react-app bgio-tutorial\ncd bgio-tutorial\nnpm install boardgame.io\n```\n\nWhile we’re here, let’s also create an empty JavaScript file for our game code:\n\n```\ntouch src/Game.js\n```\n\n?> You can check out the complete code for this tutorial\nand play around with it on CodeSandbox:<br/><br/>\n[![Edit boardgame.io](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/boardgameio-wlvi2)\n\n<!-- tabs:end -->\n\n\n\n## Defining a Game\n\nWe define a game by creating an object whose contents\ntell boardgame.io how your game works. More or less everything\nis optional, so we can start simple and gradually add complexity.\nTo start, we’ll add a `setup` function, which will set the\ninitial value of the game state `G`, and a `moves` object\ncontaining the moves that make up the game.\n\nA move is a function that updates `G` to the desired new state.\nIt receives an object containing various fields\nas its first argument. This object includes the game state `G` and\n`ctx` — an object managed by boardgame.io that contains game metadata.\nIt also includes `playerID`, which identifies the player making the move.\nAfter the object containing `G` and `ctx`, moves can receive arbitrary arguments\nthat you pass in when making the move.\n\nIn Tic-Tac-Toe, we only have one type of move and we will\nname it `clickCell`. It will take the ID of the cell that was clicked\nand update that cell with the ID of the player who clicked it.\n\nLet’s put this together in our `src/Game.js` file to start\ndefining our game:\n\n```js\nexport const TicTacToe = {\n  setup: () => ({ cells: Array(9).fill(null) }),\n\n  moves: {\n    clickCell: ({ G, playerID }, id) => {\n      G.cells[id] = playerID;\n    },\n  },\n};\n```\n\n?> The `setup` function also receives an object as its first argument\nlike moves. This is useful if you need to customize the initial\nstate based on some field in `ctx` — the number of players, for example —\nbut we don't need that for Tic-Tac-Toe.\n\n\n\n## Creating a Client\n\n<!-- tabs:start -->\n\n### **Plain JS**\n\nWe’ll start by creating a class to manage our web app’s logic in `src/App.js`.\n\nIn the class’s constructor we’ll create a boardgame.io client\nand call its `start` method to run it.\n\n```js\nimport { Client } from 'boardgame.io/client';\nimport { TicTacToe } from './Game';\n\nclass TicTacToeClient {\n  constructor() {\n    this.client = Client({ game: TicTacToe });\n    this.client.start();\n  }\n}\n\nconst app = new TicTacToeClient();\n```\n\nLet’s also add a script to `package.json` to make serving the web app simpler\nand a [browserslist string](https://github.com/browserslist/browserslist) to\nindicate the browsers we want to support:\n\n```json\n{\n  \"scripts\": {\n    \"start\": \"parcel index.html --open\"\n  },\n  \"browserslist\": \"defaults and supports async-functions\"\n}\n```\n?> By dropping support for browsers that don’t support async functions, we don’t\n   need to worry about including the `regenerator-runtime` polyfill. If you need to\n   support older browsers, you can skip adding `browserslist`, but may need to\n   include the polyfill manually.\n\nYou can now serve the app from the command line by running:\n\n```\nnpm start\n```\n\n### **React**\n\nReplace the contents of `src/App.js` with\n\n```js\nimport { Client } from 'boardgame.io/react';\nimport { TicTacToe } from './Game';\n\nconst App = Client({ game: TicTacToe });\n\nexport default App;\n```\n\nYou can now serve the app from the command line by running:\n\n```\nnpm start\n```\n\n<!-- tabs:end -->\n\nAlthough we haven’t built any UI yet, boardgame.io renders a Debug Panel.\nThis panel means we can already play our Tic-Tac-Toe game!\n\nYou can make a move by clicking on `clickCell` on the\nDebug Panel, entering a number between `0` and `8`, and pressing\n**Enter**. The current player will make a move on the chosen\ncell. The number you enter is the `id` passed to the `clickCell` function as\nthe first argument after `G` and `ctx`. Notice how the\n`cells` array on the Debug Panel updates as you make moves. You\ncan end the turn by clicking `endTurn` and pressing **Enter**. The next call to\n`clickCell` will result in a “1” in the chosen cell instead of a “0”.\n\n```react\n<iframe class='react' src='snippets/example-1' height='760' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>\n```\n\n\n?> You can turn off the Debug Panel by passing `debug: false`\nin the `Client` config.\n\n\n\n## Game Improvements\n\n### Validating Moves\n\nSo far, if a player calls `clickCell` for a cell that is already filled,\nit will be overwritten. Let’s prevent that by updating `clickCell`\nto let us know that a move is invalid if the selected cell isn’t `null`.\n\nMoves can let the framework know they are invalid by returning a\nspecial constant which we import into `src/Game.js`:\n\n```js\nimport { INVALID_MOVE } from 'boardgame.io/core';\n```\n\nNow we can return `INVALID_MOVE` from `clickCell`:\n\n```js\nclickCell: ({ G, playerID }, id) => {\n  if (G.cells[id] !== null) {\n    return INVALID_MOVE;\n  }\n  G.cells[id] = playerID;\n}\n```\n\n### Managing Turns\n\nIn the Debug Panel we clicked `endTurn` to pass the turn\nto the next player after making a move. We could do this from our\nclient code too: make a move, then end the turn. This could be flexible\nbecause a player could choose when to end their turn, but in\nTic-Tac-Toe we know that the turn should always end when a move is made.\n\nThere are several different ways to manage turns in boardgame.io.\nWe’ll use the `maxMoves` option in our game definition to tell\nthe framework to automatically end a player’s turn after a single\nmove has been made, as well as the `minMoves` option, so players\n*have* to make a move and can't just `endTurn`.\n\n```js\nexport const TicTacToe = {\n  setup: () => { /* ... */ },\n\n  turn: {\n    minMoves: 1,\n    maxMoves: 1,\n  },\n\n  moves: { /* ... */ },\n}\n```\n\n?> You can learn more in the [Turn Order](turn-order.md)\n    and [Events](events.md) guides.\n\n### Victory Condition\n\nThe Tic-Tac-Toe game we have so far doesn't really ever end.\nLet's keep track of a winner in case one player wins the game.\n\nFirst, let’s declare two helper functions in `src/Game.js`\nto test the `cells` array with:\n\n```js\n// Return true if `cells` is in a winning configuration.\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6],\n    [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]\n  ];\n\n  const isRowComplete = row => {\n    const symbols = row.map(i => cells[i]);\n    return symbols.every(i => i !== null && i === symbols[0]);\n  };\n\n  return positions.map(isRowComplete).some(i => i === true);\n}\n\n// Return true if all `cells` are occupied.\nfunction IsDraw(cells) {\n  return cells.filter(c => c === null).length === 0;\n}\n```\n\nNow, we add an `endIf` method to our game.\nThis method will be called each time our state updates to\ncheck if the game is over.\n\n```js\nexport const TicTacToe = {\n  // setup, moves, etc.\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n    if (IsDraw(G.cells)) {\n      return { draw: true };\n    }\n  },\n};\n```\n\n?> `endIf` takes a function that determines if\nthe game is over. If it returns anything at all, the game ends and\nthe return value is available at `ctx.gameover`.\n\n\n\n## Building a Board\n\n<!-- tabs:start -->\n\n### **Plain JS**\n\nYou can build your game board with your preferred UI tools.\nThis example will use basic JavaScript, but you should be able\nto adapt this approach to many other frameworks.\n\nTo start with, let’s add a `createBoard` method to our\n`TicTacToeClient` and call it in the constructor. This will inject\nthe required DOM structure for our board into the web page.\nTo know where to insert our board UI, we’ll pass in an\nelement when instantiating the class.\n\nWe’ll also add an `attachListeners` method. This will\nset up our board cells so that they trigger the `clickCell`\nmove when they are clicked.\n\n```js\nclass TicTacToeClient {\n  constructor(rootElement) {\n    this.client = Client({ game: TicTacToe });\n    this.client.start();\n    this.rootElement = rootElement;\n    this.createBoard();\n    this.attachListeners();\n  }\n\n  createBoard() {\n    // Create cells in rows for the Tic-Tac-Toe board.\n    const rows = [];\n    for (let i = 0; i < 3; i++) {\n      const cells = [];\n      for (let j = 0; j < 3; j++) {\n        const id = 3 * i + j;\n        cells.push(`<td class=\"cell\" data-id=\"${id}\"></td>`);\n      }\n      rows.push(`<tr>${cells.join('')}</tr>`);\n    }\n\n    // Add the HTML to our app <div>.\n    // We’ll use the empty <p> to display the game winner later.\n    this.rootElement.innerHTML = `\n      <table>${rows.join('')}</table>\n      <p class=\"winner\"></p>\n    `;\n  }\n\n  attachListeners() {\n    // This event handler will read the cell id from a cell’s\n    // `data-id` attribute and make the `clickCell` move.\n    const handleCellClick = event => {\n      const id = parseInt(event.target.dataset.id);\n      this.client.moves.clickCell(id);\n    };\n    // Attach the event listener to each of the board cells.\n    const cells = this.rootElement.querySelectorAll('.cell');\n    cells.forEach(cell => {\n      cell.onclick = handleCellClick;\n    });\n  }\n}\n\nconst appElement = document.getElementById('app');\nconst app = new TicTacToeClient(appElement);\n```\n\nYou probably won’t see anything just yet, because all the cells are empty.\nLet’s fix that by adding a style for the cells to `index.html`:\n\n```html\n<style>\n  .cell {\n    border: 1px solid #555;\n    width: 50px;\n    height: 50px;\n    line-height: 50px;\n    text-align: center;\n  }\n</style>\n```\n\nNow you should see an empty Tic-Tac-Toe board!\nBut there’s still one thing missing. If you click\non the board cells, you should see `G.cells` update\nin the Debug Panel, but the board itself doesn’t change.\nWe need to add a way to refresh the board every time\nboardgame.io’s state changes.\n\nLet’s do that by writing an `update` method for our `TicTacToeClient`\nclass and subscribing to the boardgame.io state:\n\n```js\nclass TicTacToeClient {\n  constructor() {\n    // As before, but we also subscribe to the client:\n    this.client.subscribe(state => this.update(state));\n  }\n\n  createBoard() { /* ... */ }\n\n  attachListeners() { /* ... */ }\n\n  update(state) {\n    // Get all the board cells.\n    const cells = this.rootElement.querySelectorAll('.cell');\n    // Update cells to display the values in game state.\n    cells.forEach(cell => {\n      const cellId = parseInt(cell.dataset.id);\n      const cellValue = state.G.cells[cellId];\n      cell.textContent = cellValue !== null ? cellValue : '';\n    });\n    // Get the gameover message element.\n    const messageEl = this.rootElement.querySelector('.winner');\n    // Update the element to show a winner if any.\n    if (state.ctx.gameover) {\n      messageEl.textContent =\n        state.ctx.gameover.winner !== undefined\n          ? 'Winner: ' + state.ctx.gameover.winner\n          : 'Draw!';\n    } else {\n      messageEl.textContent = '';\n    }\n  }\n}\n```\n\nHere are the key things to remember:\n\n- You can trigger the moves defined in your game definition\n  by calling `client.moves['moveName']`.\n\n\n- You can register callbacks for every state change using `client.subscribe`.\n\n### **React**\n\nReact can be a good fit for board games because\nit provides a declarative API to translate objects\nto UI elements. To create a board we need to translate\nthe game state `G` into actual cells that are clickable.\n\nLet’s create a new file at `src/Board.js`:\n\n```js\nimport React from 'react';\n\nexport function TicTacToeBoard({ ctx, G, moves }) {\n  const onClick = (id) => moves.clickCell(id);\n\n  let winner = '';\n  if (ctx.gameover) {\n    winner =\n      ctx.gameover.winner !== undefined ? (\n        <div id=\"winner\">Winner: {ctx.gameover.winner}</div>\n      ) : (\n        <div id=\"winner\">Draw!</div>\n      );\n  }\n\n  const cellStyle = {\n    border: '1px solid #555',\n    width: '50px',\n    height: '50px',\n    lineHeight: '50px',\n    textAlign: 'center',\n  };\n\n  let tbody = [];\n  for (let i = 0; i < 3; i++) {\n    let cells = [];\n    for (let j = 0; j < 3; j++) {\n      const id = 3 * i + j;\n      cells.push(\n        <td key={id}>\n          {G.cells[id] ? (\n            <div style={cellStyle}>{G.cells[id]}</div>\n          ) : (\n            <button style={cellStyle} onClick={() => onClick(id)} />\n          )}\n        </td>\n      );\n    }\n    tbody.push(<tr key={i}>{cells}</tr>);\n  }\n\n  return (\n    <div>\n      <table id=\"board\">\n        <tbody>{tbody}</tbody>\n      </table>\n      {winner}\n    </div>\n  );\n}\n```\n\nThe important bit to pay attention to is about how to\ndispatch moves. We have the following code in our click\nhandler:\n\n```js\nmoves.clickCell(id);\n```\n\n- `moves` is passed in your component’s props by the framework and\n  contains functions to dispatch your game’s moves. `props.moves.clickCell`\n  dispatches the `clickCell` move, and any data passed in is made\n  available in the move handler.\n\n\nNow, we pass the board component to our `Client` in `src/App.js`:\n\n```js\nimport { TicTacToeBoard } from './Board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: TicTacToeBoard,\n});\n\nexport default App;\n```\n\n<!-- tabs:end -->\n\nAnd there you have it. A basic tic-tac-toe game!\n\n```react\n<iframe class='react' src='snippets/example-2' height='760' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>\n```\n\n?> You can press <kbd>1</kbd> (or click on the button next to “reset”)\n   to reset the state of the game and start over.\n\n\n\n## Bots\n\nIn this section we will show you how to add a bot that is\ncapable of playing your game. We need to tell the\nbot what moves are allowed in the game, and it will find moves that\ntend to produce winning results.\n\nTo do this, add an `ai` section to the game definition.\nThe `enumerate` function should return an array of possible\nmoves, so in our case it returns a `clickCell` move for every\nempty cell.\n\n```js\nexport const TicTacToe = {\n  // setup, turn, moves, endIf ...\n\n  ai: {\n    enumerate: (G, ctx) => {\n      let moves = [];\n      for (let i = 0; i < 9; i++) {\n        if (G.cells[i] === null) {\n          moves.push({ move: 'clickCell', args: [i] });\n        }\n      }\n      return moves;\n    },\n  },\n};\n```\n\nThat's it! Now that you can visit the AI section of the Debug Panel:\n\n- `play` causes the bot to calculate and make a single move\n  (shortcut: <kbd>2</kbd>)\n\n- `simulate` causes the bot to play the entire game by itself\n  (shortcut: <kbd>3</kbd>)\n\n`play` helps you combine moves that you make yourself\nand bot moves. For example, you can make\nsome manual moves to get two in a row and then verify that\nthe bot makes a block.\n\n```react\n<iframe class='react' src='snippets/example-3' height='760' scrolling='no' title='example' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>\n```\n\n?> The bot uses [MCTS](https://nicolodavis.com/blog/tic-tac-toe/) under the\nhood to explore the game tree and find good moves. The default uses\n1000 iterations per move.  This can be configured to adjust the\nbot's playing strength.\n\nThe framework will come bundled with a few different bot algorithms, and an advanced\nversion of MCTS that will allow you to specify a set of objectives to optimize for.\nFor example, at any given point in the game you can tell the bot to gather resources\nin the short term and wage wars in the late stages. You just tell the bot what to do\nand it will figure out the right combination of moves to make it happen!\n\nDetailed documentation about all this is coming soon. Adding bots to games for actual\nnetworked play (as opposed to merely simulating moves) is also in the works.\n"
  },
  {
    "path": "docs/documentation/typescript.md",
    "content": "# TypeScript\n\nboardgame.io includes type definitions for TypeScript.\n\n### Basic usage\n\n```typescript\n// Game.ts\nimport type { Game, Move } from \"boardgame.io\";\n\nexport interface MyGameState {\n  // aka 'G', your game's state\n}\n\nconst move: Move<MyGameState> = ({ G, ctx }) => {};\n\nexport const MyGame: Game<MyGameState> = {\n  // ...\n};\n```\n\n[Open this snippet in the TypeScript Playground ↗︎](https://www.typescriptlang.org/play?#code/PTAEHEEMFsFMDoAuBnAUAS2gBwPYCdFREBPLWUAbwhlgBpQBZHAN3IF9QAzPHaUAcgBGOSHgAmAcxrx0OfgG5UqWAA9cBUOgB2iWHk6QAxuQbEocAMqJIuyqlCgQoSAGtIA8P3rEcAVzygUnD8yKDI1rqobEqGOFrhoNAssABcjMkAPKbmsFY2sAB8oAC8oAAU4PSGiCoAlCVFFGyKymr4hLHxhNk0aTlZZjR5ukWlFPaOYPDTUUA)\n\n### React\n\nReact components must include boardgame.io-specific properties, so extend your\nprops from `BoardProps`. By passing your game state type to `BoardProps`,\nyou’ll get the correct typing for `G` in your board component.\n\n```typescript\n// Board.tsx\nimport type { BoardProps } from 'boardgame.io/react';\nimport type { MyGameState } from './Game.ts'\n\ninterface MyGameProps extends BoardProps<MyGameState> {\n  // Additional custom properties for your component\n}\n\nexport function MyGameBoard(props: MyGameProps) {\n  // Your game board\n}\n```\n\nRead more about [Client](api/Client.md) in the reference. No special typing should be required.\n\n```typescript\n// App.tsx\nimport { Client } from 'boardgame.io/react';\n\nimport { MyGame } from './Game';\nimport { MyGameBoard } from './Board';\n\nconst App = Client({\n  game: MyGame,\n  board: MyGameBoard,\n});\nexport default App;\n```\n\n?> Want to see a more complete example? Check out a TypeScript–React implementation of the Tic-Tac-Toe tutorial on CodeSandbox:\n<br/><br/>\n[![Edit boardgame.io React-TypeScript demo](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/boardgame-io-react-typescript-demo-u5uvm?fontsize=14&hidenavigation=1&theme=dark)\n"
  },
  {
    "path": "docs/documentation/undo.md",
    "content": "# Undo / Redo\n\nboardgame.io comes with built-in support to undo / redo\nmoves in the current turn. This is a common pattern in\ngames that allow a player to make multiple moves per turn,\nand can be a useful feature to allow the player to experiment\nwith different move combinations (and seeing what they do)\nbefore committing to one. You can disable this feature by\nsetting `disableUndo` to true in the game config.\n\n### Usage\n\nYou can call the `undo` and `redo` functions from the client.\n\n<!-- tabs:start -->\n#### **Plain JS**\n\nThe methods are attached to a `Client` instance:\n\n```js\nclient.undo();\nclient.redo();\n```\n\n#### **React**\n\nThe methods are passed in your board component’s `props`:\n\n```js\nprops.undo();\nprops.redo();\n```\n<!-- tabs:end -->\n\n### Restricting Undoable Moves\n\nIn case you just want specific moves to be undoable\n(to prevent peeking at cards or rerolling of dice, for example),\nyou can use the long-form move syntax, which specifies the\nmove as an object rather than a function. The `undoable` bit\nindicates whether the move can be undone:\n\n```js\nconst game = {\n  moves: {\n    rollDice: {\n      move: ({ G, ctx }) => {},\n      undoable: false,\n    },\n\n    playCard: ({ G, ctx }) => {},\n  },\n};\n```\n\nIn the example above, `playCard` will be undoable, but not `rollDice`.\n"
  },
  {
    "path": "docs/index.css",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nbody {\n  padding: 0 3em 5em;\n  text-align: center;\n  background: var(--mono-tint3);\n}\n\n.octo-arm,\n.octo-body {\n  fill: var(--mono-tint3);\n}\n\n#summary {\n  font-size: 1.125em;\n}\n\n#main-content {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n}\n\n#features {\n  display: grid;\n  grid-template-columns: 1fr 1fr 1fr;\n  grid-gap: 20px;\n  line-height: 1.5;\n}\n\n#features h3 {\n  margin: 0 0 .5em;\n  font-size: 1em;\n}\n\n#features > div {\n  border-radius: 5px;\n  box-shadow: 0 0 5px var(--mono-tint2);\n  border: 1px solid var(--mono-tint2);\n  width: 200px;\n  height: 200px;\n  padding: 20px;\n  background: var(--base-background-color);\n}\n\n#content {\n  margin: auto;\n}\n\n#topbar {\n  margin: .5em 0;\n  font-size: 1.2em;\n}\n\n#heading {\n  font-size: 1.4em;\n}\n\n#topbar a,\n#topbar a:visited {\n  margin: 0 1em;\n  text-decoration: none;\n}\n\n@media screen and (max-width: 768px) {\n  body {\n    padding: 0 1em 6em;\n  }\n\n  #features {\n    grid-template-columns: 1fr;\n  }\n\n  #features > div {\n    width: 300px;\n    max-width: 100%;\n    height: auto;\n    font-size: 0.8em;\n  }\n\n  #summary {\n    font-size: 1em;\n  }\n\n  #topbar,\n  #heading {\n    font-size: 1.125em;\n    font-weight: bold;\n  }\n\n  #content {\n    font-size: 1.3em;\n  }\n\n  .web-only {\n    display: none;\n  }\n}\n"
  },
  {
    "path": "docs/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <title>boardgame.io - Open-Source Game Engine for Turn-Based Games</title>\n  <meta name=\"description\" content=\"Open-Source Game Engine for Board Games / Card Games / Tabletop Games\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0\">\n  <meta name=\"twitter:card\" content=\"summary_large_image\">\n  <meta name=\"twitter:creator\" content=\"@nicolodavis\">\n  <meta name=\"twitter:title\" content=\"boardgame.io\">\n  <meta name=\"twitter:image\" content=\"https://res.cloudinary.com/dyfmhmho5/image/upload/v1543585150/logo_w1snck.png\">\n  <meta name=\"twitter:description\" content=\"Open Source Game Engine for Turn-Based Games\">\n  <link rel=\"shortcut icon\" href=\"https://raw.githubusercontent.com/boardgameio/boardgame.io/main/docs/favicon.png\" type=\"image/png\" sizes=\"16x16\">\n  <link rel=\"stylesheet\" href=\"//unpkg.com/docsify-themeable@0/dist/css/theme-simple.css\">\n  <link rel=\"stylesheet\" href=\"documentation/theme.css\">\n  <link rel=\"stylesheet\" href=\"index.css\">\n</head>\n\n<body>\n  <a href=\"https://github.com/boardgameio/boardgame.io\" class=\"github-corner\" aria-label=\"View source on Github\"><svg viewBox=\"0 0 250 250\" aria-hidden=\"true\"><path d=\"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z\"></path><path d=\"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2\" style=\"transform-origin: 130px 106px;\" class=\"octo-arm\"></path><path d=\"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z\" class=\"octo-body\"></path></svg></a>\n\n  <div id=\"content\" class=\"markdown-section\">\n    <header>\n      <p>\n        <img src=\"/logo-optimized.svg?sanitize=true\" alt=\"boardgame.io\" />\n      </p>\n\n      <div class=\"web-only\">\n      <a href=\"https://www.npmjs.com/package/boardgame.io\"><img src=\"https://badge.fury.io/js/boardgame.io.svg\" alt=\"npm version\" /></a>\n      <a href=\"https://github.com/boardgameio/boardgame.io/actions?query=workflow%3ATests\"> <img src=\"https://github.com/boardgameio/boardgame.io/workflows/Tests/badge.svg\" alt='Build Status'></a>\n      <a href='https://coveralls.io/github/boardgameio/boardgame.io?branch=main'><img src='https://coveralls.io/repos/github/boardgameio/boardgame.io/badge.svg?branch=main' alt='Coverage Status' /></a>\n      <a href=\"https://gitter.im/boardgame-io\"><img src=\"https://badges.gitter.im/boardgame-io.svg\" alt=\"Gitter\" /></a>\n      </div>\n\n      <h1 id=\"heading\">\n      Open Source Game Engine for Turn-Based Games\n      </h1>\n    </header>\n\n    <nav id=\"topbar\">\n      <a href=\"/documentation\">Documentation</a>\n\n      <span class=\"web-only\">\n        •\n        <a href=\"/documentation/#/CHANGELOG\">Changelog</a>\n        •\n        <a href=\"/documentation/#/notable_projects\">Projects</a>\n      </span>\n    </nav>\n\n    <main id=\"main-content\">\n      <p id=\"summary\">\n      Write simple functions that describe how the game state changes\n      when a particular move is made. This is automatically converted\n      into a playable game complete with online multiplayer\n      features, all without requiring you to write a single line of\n      networking or storage code.\n      </p>\n\n      <h2>Features</h2>\n\n      <div id=\"features\">\n      <div>\n        <h3>State Management</h3>\n        <div>Game state is managed seamlessly across clients, server and storage.</div>\n      </div>\n      <div>\n        <h3>Multiplayer</h3>\n        <div>Game state is kept in sync in realtime and across platforms.</div>\n      </div>\n      <div>\n        <h3>AI</h3>\n        <div>Automatically generated bots that can play your game.</div>\n      </div>\n      <div>\n        <h3>Game Phases</h3>\n        <div>with different game rules and turn orders per phase.</div>\n      </div>\n      <div>\n        <h3>Lobby</h3>\n        <div>Player matchmaking and game creation.</div>\n      </div>\n      <div>\n        <h3>Prototyping</h3>\n        <div>Interface to simulate moves even before you render the game.</div>\n      </div>\n      <div>\n        <h3>Extendable</h3>\n        <div>Plugin system that allows creating new abstractions.</div>\n      </div>\n      <div>\n        <h3>View-layer Agnostic</h3>\n        <div>Use the vanilla JS client or the bindings for React.</div>\n      </div>\n      <div>\n        <h3>Logs</h3>\n        <div>Game logs with the ability to time travel (viewing the board at an earlier state).</div>\n      </div>\n      </div>\n\n      <h2>Installation</h2>\n\n      <code>\n      npm install boardgame.io\n      </code>\n\n      <h2>License</h2>\n\n      MIT\n    </main>\n  </div>\n</body>\n\n</html>\n"
  },
  {
    "path": "examples/react-native/.gitignore",
    "content": "# See https://help.github.com/ignore-files/ for more about ignoring files.\n\n# expo\n.expo/\n\n# dependencies\n/node_modules\n\n# misc\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n"
  },
  {
    "path": "examples/react-native/.watchmanconfig",
    "content": "{}\n"
  },
  {
    "path": "examples/react-native/App.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Image, StyleSheet, View } from 'react-native';\nimport { Client } from 'boardgame.io/react-native';\nimport logo from './logo.png';\n\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n});\n\nconst Singleplayer = () => (\n  <View style={styles.container}>\n    <Image source={logo} style={styles.logo} />\n    <App matchID=\"single\" />\n  </View>\n);\n\nexport default Singleplayer;\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    backgroundColor: '#fff',\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  logo: {\n    width: 300,\n    height: 90,\n    marginBottom: 24,\n  },\n});\n"
  },
  {
    "path": "examples/react-native/README.md",
    "content": "# Setup\n\n1. Go to `examples/react-native`.\n1. Run `npm install`.\n1. Run `npm start`.\n\n### Platform specific issues and how to fix them\n\n#### Linux\n\nYou may have to run the following to get it to work on Linux:\n\n```\n$ sudo sysctl -w fs.inotify.max_user_instances=1024\n$ sudo sysctl -w fs.inotify.max_user_watches=12288\n```\n\n#### MacOS\n\nInstall `watchman` from HomeBrew on Mac.\n"
  },
  {
    "path": "examples/react-native/app.json",
    "content": "{\n  \"expo\": {\n    \"name\": \"react-native\",\n    \"slug\": \"react-native\",\n    \"privacy\": \"public\",\n    \"sdkVersion\": \"32.0.0\",\n    \"packagerOpts\": {\n      \"projectRoots\": \"\",\n      \"config\": \"rn-cli.config.js\"\n     },\n    \"platforms\": [\n      \"ios\",\n      \"android\"\n    ],\n    \"version\": \"1.0.0\",\n    \"orientation\": \"portrait\",\n    \"icon\": \"./assets/icon.png\",\n    \"splash\": {\n      \"image\": \"./assets/splash.png\",\n      \"resizeMode\": \"contain\",\n      \"backgroundColor\": \"#ffffff\"\n    },\n    \"updates\": {\n      \"fallbackToCacheTimeout\": 0\n    },\n    \"assetBundlePatterns\": [\n      \"**/*\"\n    ],\n    \"ios\": {\n      \"supportsTablet\": true\n    }\n  }\n}\n"
  },
  {
    "path": "examples/react-native/board.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { StyleSheet, Text, TouchableHighlight, View } from 'react-native';\nimport PropTypes from 'prop-types';\n\nclass Board extends React.Component {\n  static propTypes = {\n    G: PropTypes.any.isRequired,\n    ctx: PropTypes.any.isRequired,\n    moves: PropTypes.any.isRequired,\n    playerID: PropTypes.string,\n    isActive: PropTypes.bool,\n    isMultiplayer: PropTypes.bool,\n    isConnected: PropTypes.bool,\n  };\n\n  onClick = (id) => {\n    if (this.isActive(id)) {\n      this.props.moves.clickCell(id);\n    }\n  };\n\n  isActive(id) {\n    if (!this.props.isActive) return false;\n    if (this.props.G.cells[id] !== null) return false;\n    return true;\n  }\n\n  render() {\n    const tbody = [];\n    const marker = {\n      0: 'X',\n      1: 'O',\n    };\n    for (let i = 0; i < 3; i++) {\n      const cells = [];\n      for (let j = 0; j < 3; j++) {\n        const id = 3 * i + j;\n        cells.push(\n          <TouchableHighlight\n            key={id}\n            onPress={() => this.onClick(id)}\n            style={[styles.cell, styles[`cell${id}`]]}\n            underlayColor=\"transparent\"\n          >\n            <Text style={styles.value}>{marker[this.props.G.cells[id]]}</Text>\n          </TouchableHighlight>\n        );\n      }\n      tbody.push(\n        <View key={i} style={styles.row}>\n          {cells}\n        </View>\n      );\n    }\n\n    let disconnected = null;\n    if (this.props.isMultiplayer && !this.props.isConnected) {\n      disconnected = (\n        <Text id=\"disconnected\" style={styles.infoText}>\n          Disconnected!\n        </Text>\n      );\n    }\n\n    let winner = null;\n    if (this.props.ctx.gameover !== undefined) {\n      winner = (\n        <Text id=\"winner\" style={styles.infoText}>\n          Winner: {marker[this.props.ctx.gameover]}\n        </Text>\n      );\n    }\n\n    let player = null;\n    if (this.props.playerID !== null) {\n      player = (\n        <Text id=\"player\" style={styles.infoText}>\n          Player: {this.props.playerID}\n        </Text>\n      );\n    }\n\n    return (\n      <View>\n        <View id=\"board\">{tbody}</View>\n        <View style={styles.info}>\n          {player}\n          {winner}\n          {disconnected}\n        </View>\n      </View>\n    );\n  }\n}\n\nconst styles = StyleSheet.create({\n  row: {\n    flexDirection: 'row',\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  cell: {\n    alignItems: 'center',\n    justifyContent: 'center',\n    width: 96,\n    height: 96,\n    borderWidth: 4,\n    borderColor: '#666',\n    borderStyle: 'solid',\n  },\n  value: {\n    fontSize: 48,\n    fontWeight: '700',\n    color: '#373748',\n  },\n  cell0: {\n    borderLeftColor: 'transparent',\n    borderTopColor: 'transparent',\n  },\n  cell1: {\n    borderTopColor: 'transparent',\n  },\n  cell2: {\n    borderTopColor: 'transparent',\n    borderRightColor: 'transparent',\n  },\n  cell3: {\n    borderLeftColor: 'transparent',\n  },\n  cell5: {\n    borderRightColor: 'transparent',\n  },\n  cell6: {\n    borderLeftColor: 'transparent',\n    borderBottomColor: 'transparent',\n  },\n  cell7: {\n    borderBottomColor: 'transparent',\n  },\n  cell8: {\n    borderRightColor: 'transparent',\n    borderBottomColor: 'transparent',\n    borderStyle: 'solid',\n  },\n  info: {\n    justifyContent: 'center',\n    alignItems: 'center',\n    height: 60,\n    marginTop: 24,\n  },\n  infoText: {\n    fontSize: 32,\n    fontWeight: '700',\n    color: '#373748',\n  },\n});\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-native/game.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  for (let pos of positions) {\n    const symbol = cells[pos[0]];\n    let winner = symbol;\n    for (let i of pos) {\n      if (cells[i] != symbol) {\n        winner = null;\n        break;\n      }\n    }\n    if (winner != null) return true;\n  }\n\n  return false;\n}\n\nconst TicTacToe = {\n  name: 'tic-tac-toe',\n\n  setup: () => ({\n    cells: new Array(9).fill(null),\n  }),\n\n  moves: {\n    clickCell({ G, playerID }, id) {\n      const cells = [...G.cells];\n\n      if (cells[id] === null) {\n        cells[id] = playerID;\n      }\n\n      return { ...G, cells };\n    },\n  },\n\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return ctx.currentPlayer;\n    }\n  },\n};\n\nexport default TicTacToe;\n"
  },
  {
    "path": "examples/react-native/package.json",
    "content": "{\n  \"main\": \"node_modules/expo/AppEntry.js\",\n  \"scripts\": {\n    \"start\": \"expo start\",\n    \"android\": \"expo start --android\",\n    \"ios\": \"expo start --ios\",\n    \"eject\": \"expo eject\"\n  },\n  \"dependencies\": {\n    \"boardgame.io\": \"^0.31.4\",\n    \"expo\": \"^32.0.0\",\n    \"react\": \"16.5.0\",\n    \"react-native\": \"https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz\"\n  },\n  \"devDependencies\": {\n    \"babel-plugin-module-resolver\": \"^3.2.0\",\n    \"babel-preset-expo\": \"^5.0.0\"\n  },\n  \"private\": true\n}\n"
  },
  {
    "path": "examples/react-native/rn-cli.config.js",
    "content": "const path = require('path');\n\nmodule.exports = {\n  getProjectRoots() {\n    return [path.join(__dirname, '..', '..', 'packages'), __dirname];\n  },\n};\n"
  },
  {
    "path": "examples/react-web/.gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n\n# production\n/build\n\n# misc\n.DS_Store\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\nyarn.lock\npackage-lock.json\n"
  },
  {
    "path": "examples/react-web/package.json",
    "content": "{\n  \"name\": \"react-web\",\n  \"scripts\": {\n    \"start\": \"parcel src/index.html --port 3000 --open\",\n    \"build\": \"parcel build src/index.html\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"^1.11.0\"\n  },\n  \"alias\": {\n    \"boardgame.io\": \"../../dist/esm\"\n  },\n  \"browserslist\": [\n    \"last 1 Chrome versions\",\n    \"last 1 Safari versions\",\n    \"last 1 Firefox versions\"\n  ],\n  \"dependencies\": {\n    \"@babel/core\": \"^7.13.14\",\n    \"@babel/preset-env\": \"^7.13.12\",\n    \"@babel/preset-react\": \"^7.13.13\",\n    \"chess.js\": \"^0.11.0\",\n    \"parcel-plugin-svelte\": \"^4.0.6\",\n    \"react\": \"^18.2.0\",\n    \"react-dom\": \"^18.2.0\",\n    \"react-router-dom\": \"^5.2.0\",\n    \"superagent\": \"^6.1.0\",\n    \"svelte\": \"^3.37.0\",\n    \"three\": \"^0.127.0\"\n  },\n  \"babel\": {\n    \"presets\": [\n      \"@babel/preset-react\"\n    ]\n  }\n}\n"
  },
  {
    "path": "examples/react-web/server.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Server, Origins } from 'boardgame.io/server';\nimport TicTacToe from './src/tic-tac-toe/game';\nimport Chess from './src/chess/game';\n\nconst PORT = process.env.PORT || 8000;\nconst server = Server({\n  games: [TicTacToe, Chess],\n  origins: [Origins.LOCALHOST],\n});\nserver.run(PORT, () => {\n  console.log(`Serving at: http://localhost:${PORT}`);\n});\n"
  },
  {
    "path": "examples/react-web/src/app.css",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n* {\n  box-sizing: content-box;\n}\n\n.content {\n  padding: 50px;\n}\n\n.runner {\n  display: flex;\n  flex-direction: row;\n  justify-content: space-around;\n  width: 100%;\n}\n\na:hover {\n  color: #555;\n}\n\na.active {\n  color: #333;\n  font-weight: bold;\n}\n\n.runner .run {\n  text-align: center;\n}\n\n.logo {\n  max-width: 120px;\n  max-height: 120px;\n  margin-top: 10px;\n}\n"
  },
  {
    "path": "examples/react-web/src/app.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { HashRouter as Router, Route } from 'react-router-dom';\nimport _ from 'lodash';\nimport LiNavLink from './li-navlink';\n\nimport routes from './routes';\nimport './app.css';\n\n// CSS for the sidebar is taken from vue.css\nexport const App = () => (\n  <Router>\n    <main>\n      <aside className=\"sidebar\">\n        <div className=\"sidebar-nav\" style={{ height: '90%' }}>\n          <ul>\n            {routes.map((route_category, idx) => (\n              <li key={idx}>\n                <p>{route_category.name}</p>\n                <ul>\n                  {route_category.routes.map((route, _idx) => (\n                    <LiNavLink\n                      key={`${idx}.${_idx}`}\n                      to={route.path}\n                      exact={true}\n                      activeClassName=\"active\"\n                    >\n                      {route.text}\n                    </LiNavLink>\n                  ))}\n                </ul>\n              </li>\n            ))}\n          </ul>\n        </div>\n      </aside>\n      <section className=\"content\">\n        {_.flattenDeep(routes.map((route) => route.routes)).map(\n          (route, idx) => (\n            <Route\n              key={idx}\n              exact\n              path={route.path}\n              component={route.component}\n            />\n          )\n        )}\n      </section>\n    </main>\n  </Router>\n);\n"
  },
  {
    "path": "examples/react-web/src/app.test.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n// TODO: separate testing for TicTacToe from this overall test\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { MemoryRouter } from 'react-router';\nimport Enzyme from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\nimport { App } from './app';\n\nEnzyme.configure({ adapter: new Adapter() });\n\nconst Grid = (n) => new Array(n).fill(null);\n\n// This wraps up the App in a MemoryRouter, which let's us set the route how we want\nconst RoutedApp = (props) => (\n  <MemoryRouter initialEntries={[props.route]}>\n    <App />\n  </MemoryRouter>\n);\nRoutedApp.propTypes = {\n  route: PropTypes.string,\n};\n\ntest('sanity', () => {\n  Enzyme.mount(<RoutedApp route=\"/\" />);\n});\n\ntest('makeMove changes the game state', () => {\n  const game = Enzyme.mount(<RoutedApp route=\"/\" />);\n  const board = game.find('Board').instance();\n\n  expect(board.props.G).toEqual({\n    cells: Grid(9),\n  });\n\n  const moves = [0, 1];\n\n  for (let id of moves) {\n    board.props.moves.clickCell(id);\n  }\n\n  expect(board.props.G).toEqual({\n    cells: ['0', '1'].concat(Grid(7)),\n  });\n  expect(board.props.ctx.gameover).toEqual(undefined);\n});\n\ntest('clicked cells are inactive', () => {\n  const game = Enzyme.mount(<RoutedApp route=\"/\" />);\n\n  expect(game.find('td').get(0).props.className).toBe('active');\n  game.find('td').forEach((node) => node.simulate('click'));\n  expect(game.find('td').get(0).props.className).toBe('');\n});\n\ntest('victory', () => {\n  const game = Enzyme.mount(<RoutedApp route=\"/\" />);\n  const board = game.find('Board').instance();\n  const cells = new Array(9).fill(null);\n\n  expect(board.props.G).toEqual({\n    cells: cells,\n  });\n  expect(board.props.ctx.gameover).toEqual(undefined);\n\n  const moves = [0, 3, 1, 4, 2];\n\n  for (let id of moves) {\n    board.props.moves.clickCell(id);\n  }\n\n  expect(board.props.G).toEqual({\n    cells: ['0', '0', '0', '1', '1'].concat(Grid(4)),\n  });\n  expect(board.props.ctx.gameover).toEqual({ winner: '0' });\n});\n"
  },
  {
    "path": "examples/react-web/src/chess/board.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { Chess } from 'chess.js';\nimport { Checkerboard, cartesianToAlgebraic } from './checkerboard';\nimport { Token } from './token';\nimport Chat from './chat';\nimport Bishop from './pieces/bishop';\nimport King from './pieces/king';\nimport Knight from './pieces/knight';\nimport Pawn from './pieces/pawn';\nimport Queen from './pieces/queen';\nimport Rook from './pieces/rook';\n\nconst COL_NAMES = 'abcdefgh';\nconst HIGHLIGHTED_COLOR = 'green';\nconst MOVABLE_COLOR = 'palegreen';\n\nclass Board extends React.Component {\n  static propTypes = {\n    G: PropTypes.any.isRequired,\n    ctx: PropTypes.any.isRequired,\n    moves: PropTypes.any.isRequired,\n    playerID: PropTypes.string,\n    isActive: PropTypes.bool,\n    isMultiplayer: PropTypes.bool,\n    isConnected: PropTypes.bool,\n    sendChatMessage: PropTypes.func,\n    chatMessages: PropTypes.array,\n  };\n\n  constructor(props) {\n    super(props);\n    this.chess = new Chess();\n  }\n\n  state = {\n    selected: '',\n    highlighted: '',\n    dragged: '',\n  };\n\n  render() {\n    if (this.props.G.pgn !== undefined) {\n      this.chess.load_pgn(this.props.G.pgn);\n    }\n    let disconnected = null;\n    if (this.props.isMultiplayer && !this.props.isConnected) {\n      disconnected = <p>Disconnected!</p>;\n    }\n    return (\n      <div>\n        <Checkerboard\n          highlightedSquares={this._getHighlightedSquares()}\n          style={{ width: '400px' }}\n          onClick={this.click}\n        >\n          {this._getPieces()}\n        </Checkerboard>\n\n        {this._getStatus()}\n        {disconnected}\n        {this.props.isMultiplayer && this.props.playerID !== null && (\n          <Chat\n            onSend={this.props.sendChatMessage}\n            messages={this.props.chatMessages}\n          />\n        )}\n      </div>\n    );\n  }\n\n  click = ({ square }) => {\n    if (!this.props.isActive) {\n      return;\n    }\n\n    if (!this.state.selected && this._isSelectable(square)) {\n      this.setState({ ...this.state, selected: square, highlighted: square });\n    } else if (this.state.selected) {\n      this._tryMove(this.state.selected, square);\n    }\n  };\n\n  _getHighlightedSquares() {\n    let result = {};\n    for (let move of this._getMoves()) {\n      result[move.to] = MOVABLE_COLOR;\n    }\n    if (this.state.highlighted) {\n      result[this.state.highlighted] = HIGHLIGHTED_COLOR;\n    }\n    return result;\n  }\n\n  _shouldDrag = ({ x, y }) => {\n    const square = cartesianToAlgebraic(x, y);\n    const result = this.props.isActive && this._isSelectable(square);\n    if (result) {\n      this.setState({\n        ...this.state,\n        dragged: this._getInitialCell(square),\n      });\n      return true;\n    }\n  };\n\n  _onDrag = ({ x, y, originalX, originalY }) => {\n    if (Math.sqrt((x - originalX) ** 2 + (y - originalY) ** 2) > 0.2) {\n      this.setState({\n        ...this.state,\n        selected: this._getSquare(originalX, originalY),\n        highlighted: this._getSquare(x, y),\n      });\n    } else {\n      this.setState({\n        ...this.state,\n        selected: '',\n        highlighted: '',\n      });\n    }\n  };\n\n  _onDrop = ({ x, y }) => {\n    if (this.state.selected) {\n      this.setState({ ...this.state, dragged: '' });\n      this._tryMove(this.state.selected, this._getSquare(x, y));\n    }\n  };\n\n  _getSquare(x, y) {\n    return cartesianToAlgebraic(this._getInRange(x), this._getInRange(y));\n  }\n\n  _getInRange(x) {\n    return Math.max(Math.min(Math.round(x), 7), 0);\n  }\n\n  _getPieces() {\n    let dragged = [];\n    let result = [];\n    for (let y = 1; y <= 8; y++) {\n      for (let x = 0; x < 8; x++) {\n        let square = COL_NAMES[x] + y;\n        let piece = this.chess.get(square);\n        if (piece) {\n          const token = (\n            <Token\n              draggable={true}\n              shouldDrag={this._shouldDrag}\n              onDrag={this._onDrag}\n              onDrop={this._onDrop}\n              square={square}\n              animate={true}\n              key={this._getInitialCell(square)}\n            >\n              {this._getPieceByTypeAndColor(piece.type, piece.color)}\n            </Token>\n          );\n          if (square === this.state.dragged) {\n            result.push(token);\n          } else {\n            dragged.push(token);\n          }\n        }\n      }\n    }\n    return dragged.concat(result);\n  }\n\n  _getPieceByTypeAndColor(type, color) {\n    switch (type) {\n      case 'b':\n        return <Bishop color={color} />;\n      case 'k':\n        return <King color={color} />;\n      case 'n':\n        return <Knight color={color} />;\n      case 'p':\n        return <Pawn color={color} />;\n      case 'q':\n        return <Queen color={color} />;\n      case 'r':\n        return <Rook color={color} />;\n    }\n  }\n\n  _getStatus() {\n    let message = null;\n    if (this.chess.in_check()) {\n      message = 'CHECK';\n    }\n    if (this.props.ctx.winner) {\n      switch (this.props.ctx.winner) {\n        case 'b':\n          message = 'Black won!';\n          break;\n        case 'w':\n          message = 'White won!';\n          break;\n        case 'd':\n          message = 'Draw!';\n          break;\n      }\n    }\n    if (message) {\n      return (\n        <p>\n          <strong>{message}</strong>\n        </p>\n      );\n    }\n  }\n\n  _getInitialCell(square) {\n    let history = this.chess.history({ verbose: true });\n    let lastSeen = square;\n    for (let i = history.length - 1; i >= 0; i--) {\n      let move = history[i];\n      if (lastSeen == move.to) {\n        lastSeen = move.from;\n      }\n    }\n    return lastSeen;\n  }\n\n  _isSelectable(square) {\n    let piece = this.chess.get(square);\n    return (\n      piece &&\n      piece.color === this._getCurrentPlayer() &&\n      this.chess.moves({ square }).length > 0\n    );\n  }\n\n  _getCurrentPlayer() {\n    if (this.props.ctx.currentPlayer == 0) {\n      return 'w';\n    } else {\n      return 'b';\n    }\n  }\n\n  _getMoves() {\n    if (!this.state.selected) {\n      return [];\n    }\n    return this.chess.moves({\n      verbose: true,\n      square: this.state.selected,\n    });\n  }\n\n  _tryMove(from, to) {\n    const moves = this._getMoves();\n    const move = moves.find((move) => move.from == from && move.to == to);\n    if (move) {\n      this.props.moves.move(move.san);\n    }\n    this.setState({ ...this.state, selected: '', highlighted: '' });\n  }\n}\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-web/src/chess/chat.js",
    "content": "import React, { useState } from 'react';\n\nconst Chat = ({ onSend, messages }) => {\n  const [message, setMessage] = useState('');\n\n  const onChange = (event) => {\n    setMessage(event.target.value);\n  };\n\n  const triggerSend = (event) => {\n    event.preventDefault();\n    onSend(message);\n    setMessage('');\n  };\n\n  return (\n    <div>\n      <div\n        style={{\n          height: 200,\n          maxWidth: 400,\n          padding: '.5em',\n          overflow: 'scroll',\n          border: '1px solid black',\n        }}\n      >\n        {messages.map((message) => (\n          <div key={message.id} style={{ marginBottom: '.25em' }}>\n            <strong>Player {message.sender}:</strong> {message.payload}\n          </div>\n        ))}\n      </div>\n      <form onSubmit={triggerSend}>\n        <input onChange={onChange} value={message} />\n        <button type=\"submit\">Send</button>\n      </form>\n    </div>\n  );\n};\n\nexport default Chat;\n"
  },
  {
    "path": "examples/react-web/src/chess/checkerboard.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { Grid } from './grid';\n\n/**\n * Checkerboard\n *\n * Component that will show a configurable checker board for games like\n * chess, checkers and others. The vertical columns of squares are labeled\n * with letters from a to z, while the rows are labeled with numbers, starting\n * with 1.\n *\n * Props:\n *   rows    - How many rows to show up, 8 by default.\n *   cols    - How many columns to show up, 8 by default. Maximum is 26.\n *   onClick - On Click Callback, (row, col) of the square passed as argument.\n *   primaryColor - Primary color, #d18b47 by default.\n *   secondaryColor - Secondary color, #ffce9e by default.\n *   colorMap - Object of object having cell names as key and colors as values.\n *   Ex: { 'c5': 'red' } colors cells c5 with red.\n *\n * Usage:\n *\n * <Checkerboard>\n *   <Token square={'c5'}>\n *     <Knight color='dark' />\n *   </Token>\n * </Checkerboard>\n */\nexport class Checkerboard extends React.Component {\n  static propTypes = {\n    rows: PropTypes.number,\n    cols: PropTypes.number,\n    onClick: PropTypes.func,\n    primaryColor: PropTypes.string,\n    secondaryColor: PropTypes.string,\n    highlightedSquares: PropTypes.object,\n    style: PropTypes.object,\n    children: PropTypes.oneOfType([\n      PropTypes.arrayOf(PropTypes.element),\n      PropTypes.element,\n    ]),\n  };\n\n  static defaultProps = {\n    rows: 8,\n    cols: 8,\n    onClick: () => {},\n    primaryColor: '#d18b47',\n    secondaryColor: '#ffce9e',\n    highlightedSquares: {},\n    style: {},\n  };\n\n  onClick = ({ x, y }) => {\n    this.props.onClick({ square: cartesianToAlgebraic(x, y, this.props.rows) });\n  };\n\n  render() {\n    // Convert the square=\"\" prop to x and y.\n    const tokens = React.Children.map(this.props.children, (child) => {\n      const square = child.props.square;\n      const { x, y } = algebraicToCartesian(square, this.props.rows);\n      return React.cloneElement(child, { x, y });\n    });\n\n    // Build colorMap with checkerboard pattern.\n    let colorMap = {};\n    for (let x = 0; x < this.props.cols; x++) {\n      for (let y = 0; y < this.props.rows; y++) {\n        const key = `${x},${y}`;\n        let color = this.props.secondaryColor;\n        if ((x + y) % 2 == 0) {\n          color = this.props.primaryColor;\n        }\n        colorMap[key] = color;\n      }\n    }\n\n    // Add highlighted squares.\n    for (const square in this.props.highlightedSquares) {\n      const { x, y } = algebraicToCartesian(square, this.props.rows);\n      const key = `${x},${y}`;\n      colorMap[key] = this.props.highlightedSquares[square];\n    }\n\n    return (\n      <Grid\n        rows={this.props.rows}\n        cols={this.props.cols}\n        style={this.props.style}\n        onClick={this.onClick}\n        colorMap={colorMap}\n      >\n        {tokens}\n      </Grid>\n    );\n  }\n}\n\n/**\n * Given an algebraic notation, returns x and y values.\n * Example: A1 returns { x: 0, y: 0 }\n */\nexport function algebraicToCartesian(square, rows = 8) {\n  let regexp = /([A-Za-z])(\\d+)/g;\n  let match = regexp.exec(square);\n  if (match == null) {\n    throw 'Invalid square provided: ' + square;\n  }\n  let colSymbol = match[1].toLowerCase();\n  let col = colSymbol.charCodeAt(0) - 'a'.charCodeAt(0);\n  let row = parseInt(match[2]);\n  return { x: col, y: rows - row };\n}\n\n/**\n * Given an x and y values, returns algebraic notation.\n * Example: 0, 0 returns A1\n */\nexport function cartesianToAlgebraic(x, y, rows = 8) {\n  let colSymbol = String.fromCharCode(x + 'a'.charCodeAt(0));\n  return colSymbol + (rows - y);\n}\n"
  },
  {
    "path": "examples/react-web/src/chess/checkerboard.test.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Checkerboard } from './checkerboard';\nimport { Token } from 'boardgame.io/ui';\nimport Enzyme from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\n\nEnzyme.configure({ adapter: new Adapter() });\n\ntest('render squares correctly', () => {\n  const grid = Enzyme.mount(<Checkerboard />);\n  expect(grid.find('rect')).toHaveLength(64);\n});\n\ntest('position', () => {\n  const grid = Enzyme.shallow(\n    <Checkerboard>\n      <Token square=\"b5\">\n        <circle r=\"0.25\" fill=\"red\" />\n      </Token>\n    </Checkerboard>\n  );\n  expect(grid.html()).toContain('translate(1, 3)');\n});\n\ntest('click', () => {\n  const onClick = jest.fn();\n  const grid = Enzyme.mount(<Checkerboard onClick={onClick} />);\n  grid.find('rect').at(5).simulate('click');\n  expect(onClick).toHaveBeenCalledWith({ square: 'a3' });\n});\n\ntest('invalid square', () => {\n  let invalidSquare = () => {\n    Enzyme.shallow(<Checkerboard />)\n      .instance()\n      .algebraicCord({ square: '*1' });\n  };\n  expect(invalidSquare).toThrow();\n});\n\ntest('colorMap', () => {\n  const grid = Enzyme.mount(\n    <Checkerboard highlightedSquares={{ a5: 'blue' }} />\n  );\n  expect(grid.find('rect').at(3).html()).toContain('blue');\n});\n"
  },
  {
    "path": "examples/react-web/src/chess/game.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Chess from 'chess.js';\n\n// Helper to instantiate chess.js correctly on\n// both browser and Node.\nfunction Load(pgn) {\n  let chess = null;\n  if (Chess.Chess) {\n    chess = new Chess.Chess();\n  } else {\n    chess = new Chess();\n  }\n  chess.load_pgn(pgn);\n  return chess;\n}\n\nconst ChessGame = {\n  name: 'chess',\n\n  setup: () => ({ pgn: '' }),\n\n  moves: {\n    move({ G, ctx }, san) {\n      const chess = Load(G.pgn);\n      if (\n        (chess.turn() == 'w' && ctx.currentPlayer == '1') ||\n        (chess.turn() == 'b' && ctx.currentPlayer == '0')\n      ) {\n        return { ...G };\n      }\n      chess.move(san);\n      return { pgn: chess.pgn() };\n    },\n  },\n\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  endIf: ({ G }) => {\n    const chess = Load(G.pgn);\n    if (chess.game_over()) {\n      if (\n        chess.in_draw() ||\n        chess.in_threefold_repetition() ||\n        chess.insufficient_material() ||\n        chess.in_stalemate()\n      ) {\n        return 'd';\n      }\n      if (chess.in_checkmate()) {\n        if (chess.turn() == 'w') {\n          return 'b';\n        } else {\n          return 'w';\n        }\n      }\n    }\n  },\n};\n\nexport default ChessGame;\n"
  },
  {
    "path": "examples/react-web/src/chess/grid.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\n/**\n * Grid\n *\n * Component that will show children on a cartesian regular grid.\n *\n * Props:\n *   rows       - Number of rows (height) of the grid.\n *   cols       - Number of columns (width) of the grid.\n *   style      - CSS style of the Grid HTML element.\n *   colorMap   - A map from 'x,y' => color.\n *   onClick    - (x, y) => {}\n *                Called when a square is clicked.\n *   onMouseOver    - (x, y) => {}\n *                Called when a square is mouse over.\n *   onMouseOut    - (x, y) => {}\n *                Called when a square is mouse out.\n *\n * Usage:\n *\n * <Grid rows={8} cols={8}>\n *   <Token x={1} y={2}/>\n * </Grid>\n */\nexport class Grid extends React.Component {\n  static propTypes = {\n    rows: PropTypes.number.isRequired,\n    cols: PropTypes.number.isRequired,\n    outline: PropTypes.bool,\n    style: PropTypes.object,\n    colorMap: PropTypes.object,\n    cellSize: PropTypes.number,\n    onClick: PropTypes.func,\n    onMouseOver: PropTypes.func,\n    onMouseOut: PropTypes.func,\n    children: PropTypes.oneOfType([\n      PropTypes.arrayOf(PropTypes.element),\n      PropTypes.element,\n    ]),\n  };\n\n  static defaultProps = {\n    colorMap: {},\n    outline: true,\n    cellSize: 1,\n  };\n\n  _svgRef = React.createRef();\n\n  _getCellColor(x, y) {\n    const key = `${x},${y}`;\n    let color = 'white';\n    if (key in this.props.colorMap) {\n      color = this.props.colorMap[key];\n    }\n    return color;\n  }\n\n  _getGrid() {\n    if (!this.props.outline) {\n      return null;\n    }\n\n    let squares = [];\n    for (let x = 0; x < this.props.cols; x++) {\n      for (let y = 0; y < this.props.rows; y++) {\n        squares.push(\n          <Square\n            key={this.props.cols * y + x}\n            style={{ fill: this._getCellColor(x, y) }}\n            x={x}\n            y={y}\n            size={this.props.cellSize}\n            onClick={this.onClick}\n            onMouseOver={this.onMouseOver}\n            onMouseOut={this.onMouseOut}\n            svgRef={this._svgRef}\n          />\n        );\n      }\n    }\n    return squares;\n  }\n\n  onClick = (args) => {\n    if (this.props.onClick) {\n      this.props.onClick(args);\n    }\n  };\n\n  onMouseOver = (args) => {\n    if (this.props.onMouseOver) {\n      this.props.onMouseOver(args);\n    }\n  };\n\n  onMouseOut = (args) => {\n    if (this.props.onMouseOut) {\n      this.props.onMouseOut(args);\n    }\n  };\n\n  render() {\n    const tokens = React.Children.map(this.props.children, (child) => {\n      return React.cloneElement(child, {\n        template: Square,\n        // Overwrites Token's onClick, onMouseOver, onMouseOut\n        onClick: this.onClick,\n        onMouseOver: this.onMouseOver,\n        onMouseOut: this.onMouseOut,\n        svgRef: this._svgRef,\n      });\n    });\n\n    return (\n      <svg\n        ref={this._svgRef}\n        viewBox={'0 0 ' + this.props.cols + ' ' + this.props.rows}\n        style={this.props.style}\n      >\n        <g>{this._getGrid()}</g>\n        {tokens}\n      </svg>\n    );\n  }\n}\n\n/**\n * Square\n *\n * Component that renders a square inside a Grid.\n *\n * Props:\n *   x       - X coordinate on grid coordinates.\n *   y       - Y coordinate on grid coordinates.\n *   size    - Square size.\n *   style   - Custom styling.\n *   onClick - Invoked when a Square is clicked.\n *   onMouseOver - Invoked when a Square is mouse over.\n *   onMouseOut - Invoked when a Square is mouse out.\n *   eventListeners - Array of objects with name and callback\n *   for DOM events.\n *\n * Not meant to be used by the end user directly (use Token).\n * Also not exposed in the NPM.\n */\nexport class Square extends React.Component {\n  static propTypes = {\n    x: PropTypes.number.isRequired,\n    y: PropTypes.number.isRequired,\n    size: PropTypes.number,\n    style: PropTypes.any,\n    onClick: PropTypes.func,\n    onMouseOver: PropTypes.func,\n    onMouseOut: PropTypes.func,\n    eventListeners: PropTypes.array,\n    children: PropTypes.element,\n    svgRef: PropTypes.object,\n  };\n\n  static defaultProps = {\n    size: 1,\n    x: 0,\n    y: 0,\n    style: { fill: '#fff' },\n    eventListeners: [],\n  };\n\n  _gRef = React.createRef();\n\n  onClick = (e) => {\n    this.props.onClick(this.getCoords(), e);\n  };\n\n  onMouseOver = (e) => {\n    this.props.onMouseOver(this.getCoords(), e);\n  };\n\n  onMouseOut = (e) => {\n    this.props.onMouseOut(this.getCoords(), e);\n  };\n\n  getCoords() {\n    return {\n      x: this.props.x,\n      y: this.props.y,\n    };\n  }\n\n  componentDidMount() {\n    const element = this._gRef.current;\n    for (let listener of this.props.eventListeners) {\n      element.addEventListener(listener.name, listener.callback);\n    }\n  }\n\n  componentWillUnmount() {\n    const element = this._gRef.current;\n    for (let listener of this.props.eventListeners) {\n      element.removeEventListener(listener.name, listener.callback);\n    }\n  }\n\n  render() {\n    const tx = this.props.x * this.props.size;\n    const ty = this.props.y * this.props.size;\n\n    // If no child, render a square.\n    let children = (\n      <rect\n        style={this.props.style}\n        width={this.props.size}\n        height={this.props.size}\n        x={0}\n        y={0}\n      />\n    );\n    // If a child is passed, render child.\n    if (this.props.children) {\n      children = this.props.children;\n    }\n\n    if (this.props.svgRef) {\n      return (\n        <g\n          ref={this._gRef}\n          onClick={this.onClick}\n          onMouseOver={this.onMouseOver}\n          onMouseOut={this.onMouseOut}\n          transform={`translate(${tx}, ${ty})`}\n        >\n          {children}\n        </g>\n      );\n    }\n\n    return (\n      <svg\n        ref={this._gRef}\n        onClick={this.onClick}\n        onMouseOver={this.onMouseOver}\n        onMouseOut={this.onMouseOut}\n        transform={`translate(${tx}, ${ty})`}\n      >\n        {children}\n      </svg>\n    );\n  }\n}\n"
  },
  {
    "path": "examples/react-web/src/chess/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Singleplayer from './singleplayer';\nimport Multiplayer from './multiplayer';\n\nconst routes = [\n  {\n    path: '/chess/singleplayer',\n    text: 'Singleplayer',\n    component: Singleplayer,\n  },\n  {\n    path: '/chess/multiplayer0',\n    text: 'Multiplayer (Player 0)',\n    component: Multiplayer('0'),\n  },\n  {\n    path: '/chess/multiplayer1',\n    text: 'Multiplayer (Player 1)',\n    component: Multiplayer('1'),\n  },\n  {\n    path: '/chess/multiplayer',\n    text: 'Multiplayer (Spectator)',\n    component: Multiplayer(),\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/react-web/src/chess/multiplayer.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { SocketIO } from 'boardgame.io/multiplayer';\nimport ChessGame from './game';\nimport ChessBoard from './board';\n\nconst hostname = window.location.hostname;\nconst App = Client({\n  game: ChessGame,\n  board: ChessBoard,\n  multiplayer: SocketIO({ server: `${hostname}:8000` }),\n  debug: true,\n});\n\nconst Multiplayer = (playerID) => () => (\n  <div style={{ padding: 50 }}>\n    <App matchID=\"multi\" playerID={playerID} />\n    PlayerID: {playerID}\n  </div>\n);\n\nexport default Multiplayer;\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/CREDITS",
    "content": "Chess piece artwork comes from\n\nhttps://en.wikipedia.org/wiki/Chess_piece\n\nand was made available by its authors under BSD license.\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/bishop.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nclass Bishop extends React.Component {\n  static propTypes = {\n    color: PropTypes.string,\n  };\n\n  render() {\n    let primaryColor = this.props.color == 'b' ? '#000000' : '#FFFFFF';\n    let secondaryColor = this.props.color == 'b' ? '#FFFFFF' : '#000000';\n    return (\n      <g transform=\"scale(.022222,.022222)\">\n        <g\n          style={{\n            opacity: 1,\n            fill: 'none',\n            fillRule: 'evenodd',\n            fillOpacity: 1,\n            stroke: '#000000',\n            strokeWidth: 1.5,\n            strokeLinecap: 'round',\n            strokeLinejoin: 'round',\n            strokeMiterlimit: 4,\n            strokeDasharray: 'none',\n            strokeOpacity: 1,\n          }}\n        >\n          <g\n            style={{\n              fill: primaryColor,\n              stroke: '#000000',\n              strokeLinecap: 'butt',\n            }}\n          >\n            <path d=\"M 9,36 C 12.39,35.03 19.11,36.43 22.5,34 C 25.89,36.43 32.61,35.03 36,36 C 36,36 37.65,36.54 39,38 C 38.32,38.97 37.35,38.99 36,38.5 C 32.61,37.53 25.89,38.96 22.5,37.5 C 19.11,38.96 12.39,37.53 9,38.5 C 7.646,38.99 6.677,38.97 6,38 C 7.354,36.06 9,36 9,36 z\" />\n            <path d=\"M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z\" />\n            <path d=\"M 25 8 A 2.5 2.5 0 1 1  20,8 A 2.5 2.5 0 1 1  25 8 z\" />\n          </g>\n          <path\n            d=\"M 17.5,26 L 27.5,26 M 15,30 L 30,30 M 22.5,15.5 L 22.5,20.5 M 20,18 L 25,18\"\n            style={{\n              fill: 'none',\n              stroke: secondaryColor,\n              strokeLinejoin: 'miter',\n            }}\n          />\n        </g>\n      </g>\n    );\n  }\n}\n\nexport default Bishop;\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/king.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nclass King extends React.Component {\n  static propTypes = {\n    color: PropTypes.string,\n  };\n\n  render() {\n    let primaryColor = this.props.color == 'b' ? '#000000' : '#FFFFFF';\n    let secondaryColor = this.props.color == 'b' ? '#FFFFFF' : '#000000';\n    let extra = null;\n    if (this.props.color == 'b') {\n      extra = (\n        <path\n          d=\"M 32,29.5 C 32,29.5 40.5,25.5 38.03,19.85 C 34.15,14 25,18 22.5,24.5 L 22.51,26.6 L 22.5,24.5 C 20,18 9.906,14 6.997,19.85 C 4.5,25.5 11.85,28.85 11.85,28.85\"\n          style={{\n            fill: 'none',\n            stroke: '#ffffff',\n          }}\n        />\n      );\n    }\n    return (\n      <g transform=\"scale(.022222,.022222)\">\n        <g\n          style={{\n            fill: 'none',\n            fillOpacity: 1,\n            fillRule: 'evenodd',\n            stroke: '#000000',\n            strokeWidth: 1.5,\n            strokeLinecap: 'round',\n            strokeLinejoin: 'round',\n            strokeMiterlimit: 4,\n            strokeDasharray: 'none',\n            strokeOpacity: 1,\n          }}\n        >\n          <path\n            d=\"M 22.5,11.63 L 22.5,6\"\n            style={{\n              fill: 'none',\n              stroke: '#000000',\n              strokeLinejoin: 'miter',\n            }}\n          />\n          <path\n            d=\"M 20,8 L 25,8\"\n            style={{\n              fill: 'none',\n              stroke: '#000000',\n              strokeLinejoin: 'miter',\n            }}\n          />\n          <path\n            d=\"M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25\"\n            style={{\n              fill: primaryColor,\n              stroke: secondaryColor,\n              strokeLinecap: 'butt',\n              strokeLinejoin: 'miter',\n            }}\n          />\n          <path\n            d=\"M 11.5,37 C 17,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 19,16 9.5,13 6.5,19.5 C 3.5,25.5 11.5,29.5 11.5,29.5 L 11.5,37 z \"\n            style={{\n              fill: primaryColor,\n              stroke: '#000000',\n            }}\n          />\n          <path\n            d=\"M 11.5,30 C 17,27 27,27 32.5,30\"\n            style={{ fill: 'none', stroke: secondaryColor }}\n          />\n          <path\n            d=\"M 11.5,33.5 C 17,30.5 27,30.5 32.5,33.5\"\n            style={{ fill: 'none', stroke: secondaryColor }}\n          />\n          <path\n            d=\"M 11.5,37 C 17,34 27,34 32.5,37\"\n            style={{ fill: 'none', stroke: secondaryColor }}\n          />\n          {extra}\n        </g>\n      </g>\n    );\n  }\n}\n\nexport default King;\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/knight.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nclass Knight extends React.Component {\n  static propTypes = {\n    color: PropTypes.string,\n  };\n\n  render() {\n    let primaryColor = this.props.color == 'b' ? '#000000' : '#FFFFFF';\n    let secondaryColor = this.props.color == 'b' ? '#FFFFFF' : '#000000';\n    let extra = null;\n    if (this.props.color == 'b') {\n      extra = (\n        <path\n          d=\"M 24.55,10.4 L 24.1,11.85 L 24.6,12 C 27.75,13 30.25,14.49 32.5,18.75 C 34.75,23.01 35.75,29.06 35.25,39 L 35.2,39.5 L 37.45,39.5 L 37.5,39 C 38,28.94 36.62,22.15 34.25,17.66 C 31.88,13.17 28.46,11.02 25.06,10.5 L 24.55,10.4 z \"\n          style={{\n            fill: '#ffffff',\n            stroke: 'none',\n          }}\n        />\n      );\n    }\n    return (\n      <g transform=\"scale(.022222,.022222)\">\n        <g\n          style={{\n            opacity: 1,\n            fill: 'none',\n            fillOpacity: 1,\n            fillRule: 'evenodd',\n            stroke: '#000000',\n            strokeWidth: 1.5,\n            strokeLinecap: 'round',\n            strokeLinejoin: 'round',\n            strokeMiterlimit: 4,\n            strokeDasharray: 'none',\n            strokeOpacity: 1,\n          }}\n        >\n          <path\n            d=\"M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18\"\n            style={{\n              fill: primaryColor,\n              stroke: '#000000',\n            }}\n          />\n          <path\n            d=\"M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10\"\n            style={{\n              fill: primaryColor,\n              stroke: '#000000',\n            }}\n          />\n          <path\n            d=\"M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z\"\n            style={{\n              fill: secondaryColor,\n              stroke: secondaryColor,\n            }}\n          />\n          <path\n            d=\"M 15 15.5 A 0.5 1.5 0 1 1  14,15.5 A 0.5 1.5 0 1 1  15 15.5 z\"\n            transform=\"matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)\"\n            style={{\n              fill: secondaryColor,\n              stroke: secondaryColor,\n            }}\n          />\n          {extra}\n        </g>\n      </g>\n    );\n  }\n}\n\nexport default Knight;\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/pawn.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nclass Pawn extends React.Component {\n  static propTypes = {\n    color: PropTypes.string,\n  };\n\n  render() {\n    let primaryColor = this.props.color == 'b' ? '#000000' : '#FFFFFF';\n    return (\n      <g transform=\"scale(.022222,.022222)\">\n        <path\n          d=\"M 22,9 C 19.79,9 18,10.79 18,13 C 18,13.89 18.29,14.71 18.78,15.38 C 16.83,16.5 15.5,18.59 15.5,21 C 15.5,23.03 16.44,24.84 17.91,26.03 C 14.91,27.09 10.5,31.58 10.5,39.5 L 33.5,39.5 C 33.5,31.58 29.09,27.09 26.09,26.03 C 27.56,24.84 28.5,23.03 28.5,21 C 28.5,18.59 27.17,16.5 25.22,15.38 C 25.71,14.71 26,13.89 26,13 C 26,10.79 24.21,9 22,9 z \"\n          style={{\n            opacity: 1,\n            fill: primaryColor,\n            fillOpacity: 1,\n            fillRule: 'nonzero',\n            stroke: '#000000',\n            strokeWidth: 1.5,\n            strokeLinecap: 'round',\n            strokeLinejoin: 'miter',\n            strokeMiterlimit: 4,\n            strokeDasharray: 'none',\n            strokeOpacity: 1,\n          }}\n        />\n      </g>\n    );\n  }\n}\n\nexport default Pawn;\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/queen.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nclass Queen extends React.Component {\n  static propTypes = {\n    color: PropTypes.string,\n  };\n\n  render() {\n    let primaryColor = this.props.color == 'b' ? '#000000' : '#FFFFFF';\n    let secondaryColor = this.props.color == 'b' ? '#FFFFFF' : '#000000';\n    return (\n      <g transform=\"scale(.022222,.022222)\">\n        <g\n          style={{\n            opacity: 1,\n            fill: primaryColor,\n            fillOpacity: 1,\n            fillRule: 'evenodd',\n            stroke: '#000000',\n            strokeWidth: 1.5,\n            strokeLinecap: 'round',\n            strokeLinejoin: 'round',\n            strokeMiterlimit: 4,\n            strokeDasharray: 'none',\n            strokeOpacity: 1,\n          }}\n        >\n          <path\n            d=\"M 9 13 A 2 2 0 1 1  5,13 A 2 2 0 1 1  9 13 z\"\n            transform=\"translate(-1,-1)\"\n          />\n          <path\n            d=\"M 9 13 A 2 2 0 1 1  5,13 A 2 2 0 1 1  9 13 z\"\n            transform=\"translate(15.5,-5.5)\"\n          />\n          <path\n            d=\"M 9 13 A 2 2 0 1 1  5,13 A 2 2 0 1 1  9 13 z\"\n            transform=\"translate(32,-1)\"\n          />\n          <path\n            d=\"M 9 13 A 2 2 0 1 1  5,13 A 2 2 0 1 1  9 13 z\"\n            transform=\"translate(7,-4.5)\"\n          />\n          <path\n            d=\"M 9 13 A 2 2 0 1 1  5,13 A 2 2 0 1 1  9 13 z\"\n            transform=\"translate(24,-4)\"\n          />\n          <path\n            d=\"M 9,26 C 17.5,24.5 30,24.5 36,26 L 38,14 L 31,25 L 31,11 L 25.5,24.5 L 22.5,9.5 L 19.5,24.5 L 14,10.5 L 14,25 L 7,14 L 9,26 z \"\n            style={{ strokeLinecap: 'butt' }}\n          />\n          <path\n            d=\"M 9,26 C 9,28 10.5,28 11.5,30 C 12.5,31.5 12.5,31 12,33.5 C 10.5,34.5 10.5,36 10.5,36 C 9,37.5 11,38.5 11,38.5 C 17.5,39.5 27.5,39.5 34,38.5 C 34,38.5 35.5,37.5 34,36 C 34,36 34.5,34.5 33,33.5 C 32.5,31 32.5,31.5 33.5,30 C 34.5,28 36,28 36,26 C 27.5,24.5 17.5,24.5 9,26 z \"\n            style={{ strokeLinecap: 'butt' }}\n          />\n          <path\n            d=\"M 11.5,30 C 15,29 30,29 33.5,30\"\n            style={{\n              fill: 'none',\n              stroke: secondaryColor,\n            }}\n          />\n          <path\n            d=\"M 12,33.5 C 18,32.5 27,32.5 33,33.5\"\n            style={{\n              fill: 'none',\n              stroke: secondaryColor,\n            }}\n          />\n        </g>\n      </g>\n    );\n  }\n}\n\nexport default Queen;\n"
  },
  {
    "path": "examples/react-web/src/chess/pieces/rook.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nclass Rook extends React.Component {\n  static propTypes = {\n    color: PropTypes.string,\n  };\n\n  render() {\n    if (this.props.color == 'b') {\n      return (\n        <g transform=\"scale(.022222,.022222)\">\n          <g\n            style={{\n              opacity: 1,\n              fill: '#000000',\n              fillOpacity: 1,\n              fillRule: 'evenodd',\n              stroke: '#000000',\n              strokeWidth: 1.5,\n              strokeLinecap: 'round',\n              strokeLinejoin: 'round',\n              strokeMiterlimit: 4,\n              strokeDasharray: 'none',\n              strokeOpacity: 1,\n            }}\n          >\n            <path\n              d=\"M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 12.5,32 L 14,29.5 L 31,29.5 L 32.5,32 L 12.5,32 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 14,29.5 L 14,16.5 L 31,16.5 L 31,29.5 L 14,29.5 z \"\n              style={{\n                strokeLinecap: 'butt',\n                strokeLinejoin: 'miter',\n              }}\n            />\n            <path\n              d=\"M 14,16.5 L 11,14 L 34,14 L 31,16.5 L 14,16.5 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14 L 11,14 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 12,35.5 L 33,35.5 L 33,35.5\"\n              style={{\n                fill: 'none',\n                stroke: '#ffffff',\n                strokeWidth: 1,\n                strokeLinejoin: 'miter',\n              }}\n            />\n            <path\n              d=\"M 13,31.5 L 32,31.5\"\n              style={{\n                fill: 'none',\n                stroke: '#ffffff',\n                strokeWidth: 1,\n                strokeLinejoin: 'miter',\n              }}\n            />\n            <path\n              d=\"M 14,29.5 L 31,29.5\"\n              style={{\n                fill: 'none',\n                stroke: '#ffffff',\n                strokeWidth: 1,\n                strokeLinejoin: 'miter',\n              }}\n            />\n            <path\n              d=\"M 14,16.5 L 31,16.5\"\n              style={{\n                fill: 'none',\n                stroke: '#ffffff',\n                strokeWidth: 1,\n                strokeLinejoin: 'miter',\n              }}\n            />\n            <path\n              d=\"M 11,14 L 34,14\"\n              style={{\n                fill: 'none',\n                stroke: '#ffffff',\n                strokeWidth: 1,\n                strokeLinejoin: 'miter',\n              }}\n            />\n          </g>\n        </g>\n      );\n    } else {\n      return (\n        <g transform=\"scale(.022222,.022222)\">\n          <g\n            style={{\n              opacity: 1,\n              fill: '#ffffff',\n              fillOpacity: 1,\n              fillRule: 'evenodd',\n              stroke: '#000000',\n              strokeWidth: 1.5,\n              strokeLinecap: 'round',\n              strokeLinejoin: 'round',\n              strokeMiterlimit: 4,\n              strokeDasharray: 'none',\n              strokeOpacity: 1,\n            }}\n          >\n            <path\n              d=\"M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z \"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path\n              d=\"M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14\"\n              style={{ strokeLinecap: 'butt' }}\n            />\n            <path d=\"M 34,14 L 31,17 L 14,17 L 11,14\" />\n            <path\n              d=\"M 31,17 L 31,29.5 L 14,29.5 L 14,17\"\n              style={{\n                strokeLinecap: 'butt',\n                strokeLinejoin: 'miter',\n              }}\n            />\n            <path d=\"M 31,29.5 L 32.5,32 L 12.5,32 L 14,29.5\" />\n            <path\n              d=\"M 11,14 L 34,14\"\n              style={{\n                fill: 'none',\n                stroke: '#000000',\n                strokeLinejoin: 'miter',\n              }}\n            />\n          </g>\n        </g>\n      );\n    }\n  }\n}\n\nexport default Rook;\n"
  },
  {
    "path": "examples/react-web/src/chess/singleplayer.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport ChessGame from './game';\nimport ChessBoard from './board';\n\nconst App = Client({\n  game: ChessGame,\n  board: ChessBoard,\n});\n\nconst Singleplayer = () => (\n  <div style={{ padding: 50 }}>\n    <App matchID=\"single\" />\n  </div>\n);\n\nexport default Singleplayer;\n"
  },
  {
    "path": "examples/react-web/src/chess/token.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-syle\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { Square } from './grid';\n\n/**\n * Token\n *\n * Component that represents a board game piece (or token).\n * Can be used by itself or with one of the grid systems\n * provided (Grid or HexGrid).\n *\n * A token renders as a square inside a Grid and a\n * hexagon inside a HexGrid. Additionally, you can pass\n * it a child if you want any other custom rendering.\n *\n * Props:\n *   x       - X coordinate on grid / hex grid.\n *   y       - Y coordinate on grid / hex grid.\n *   z       - Z coordinate on hex grid.\n *   animate - Changes in position are animated if true.\n *   animationDuration - Length of animation.\n *   onClick - Called when the token is clicked.\n *   onMouseOver - Called when the token is mouse over.\n *   onMouseOut - Called when the token is mouse out.\n *   draggable - Whether a Token is draggable or not.\n *   shouldDrag - Whether a draggable token should start drag.\n *   onDrag - Called when a token was dragged (moved).\n *            Parameter contain { x, y, originalX, originalY }.\n *   onDrop - Called when the token was dropped after dragging.\n *            Parameter contain { x, y, originalX, originalY }.\n *\n * Usage:\n *\n * <Grid rows={8} cols={8}>\n *   <Token x={1} y={2}/>\n * </Grid>\n *\n * <HexGrid>\n *   <Token x={1} y={2} z={-3}/>\n * </HexGrid>\n *\n * <Grid rows={8} cols={8}>\n *   <Token x={1} y={2}>\n *     <Knight color=\"white\"/>\n *   </Token>\n * </Grid>\n */\nexport class Token extends React.Component {\n  static propTypes = {\n    x: PropTypes.number,\n    y: PropTypes.number,\n    z: PropTypes.number,\n    template: PropTypes.any,\n    style: PropTypes.any,\n    animate: PropTypes.bool,\n    onClick: PropTypes.func,\n    onMouseOver: PropTypes.func,\n    onMouseOut: PropTypes.func,\n    children: PropTypes.element,\n    animationDuration: PropTypes.number,\n    draggable: PropTypes.bool,\n    shouldDrag: PropTypes.func,\n    onDrag: PropTypes.func,\n    onDrop: PropTypes.func,\n    svgRef: PropTypes.object,\n  };\n\n  static defaultProps = {\n    animationDuration: 750,\n    template: Square,\n  };\n\n  constructor(props) {\n    super(props);\n    this.state = {\n      ...this.getCoords(),\n      dragged: null,\n      usingTouch: false,\n    };\n  }\n\n  _startDrag = (e) => {\n    if (this.props.draggable && this.props.shouldDrag(this.getCoords())) {\n      e.preventDefault(); // Required for Safari/iOs.\n      e = e.touches ? e.touches[0] : e;\n      this.setState({\n        ...this.state,\n        dragged: { x: e.pageX, y: e.pageY },\n      });\n      this._addOrRemoveDragEventListeners(true);\n    }\n  };\n\n  _drag = (e) => {\n    if (this.state.dragged) {\n      e.preventDefault(); // Required for Safari/iOs.\n      e = e.touches ? e.touches[0] : e;\n      const ctm = this.props.svgRef.current.getScreenCTM().inverse();\n      const deltaPageX = e.pageX - this.state.dragged.x;\n      const deltaPageY = e.pageY - this.state.dragged.y;\n      const deltaSvgX = ctm.a * deltaPageX + ctm.b * deltaPageY;\n      const deltaSvgY = ctm.c * deltaPageX + ctm.d * deltaPageY;\n      const x = this.state.x + deltaSvgX;\n      const y = this.state.y + deltaSvgY;\n      if (this.props.onDrag) {\n        this.props.onDrag({\n          x,\n          y,\n          originalX: this.props.x,\n          originalY: this.props.y,\n        });\n      }\n\n      this.setState({\n        ...this.state,\n        x,\n        y,\n        dragged: { x: e.pageX, y: e.pageY },\n      });\n    }\n  };\n\n  _endDrag = (e) => {\n    if (this.state.dragged) {\n      e.preventDefault();\n      // Whether this is a drop or a click depends if the mouse moved after drag.\n      // Android will issue very small drag events, so we need a distance.\n      const dist = Math.sqrt(\n        (this.state.x - this.props.x) ** 2 + (this.state.y - this.props.y) ** 2\n      );\n      if (dist > 0.2) {\n        this.props.onDrop({\n          x: this.state.x,\n          y: this.state.y,\n          originalX: this.props.x,\n          originalY: this.props.y,\n        });\n      } else {\n        this.props.onClick({ x: this.state.x, y: this.state.y });\n      }\n      this.setState({\n        ...this.state,\n        x: this.props.x,\n        y: this.props.y,\n        dragged: null,\n      });\n      this._addOrRemoveDragEventListeners(false);\n    }\n  };\n\n  _onClick = (param) => {\n    // Ignore onClick if the element is draggable, because desktops will\n    // send both onClick and touch events, leading to duplication.\n    // Whether this will be a click or a drop will be defined in _endDrag.\n    if (!(this.props.draggable && this.props.shouldDrag(this.getCoords()))) {\n      this.props.onClick(param);\n    }\n  };\n\n  componentWillUnmount() {\n    if (this.state.dragged) {\n      this._addOrRemoveDragEventListeners(false);\n    }\n  }\n\n  /**\n   * If there is a change in props, saves old x/y,\n   * and current time. Starts animation.\n   * @param {Object} nextProps Next props.\n   */\n  // eslint-disable-next-line react/no-deprecated\n  UNSAFE_componentWillReceiveProps(nextProps) {\n    let oldCoord = this.getCoords();\n    let newCoord = this.getCoords(nextProps);\n\n    // Debounce.\n    if (oldCoord.x == newCoord.x && oldCoord.y == newCoord.y) {\n      return;\n    }\n\n    this.setState({\n      ...this.state,\n      originTime: Date.now(),\n      originX: this.state.x,\n      originY: this.state.y,\n      originZ: this.state.z,\n    });\n\n    requestAnimationFrame(this._animate(Date.now()));\n  }\n\n  /**\n   * Add or remove event listeners.\n   * @param {boolean} shouldAdd If it should add (or remove) listeners.\n   */\n  _addOrRemoveDragEventListeners(shouldAdd) {\n    const svgEl = this.props.svgRef.current;\n    if (!svgEl) return;\n    let addOrRemoveEventListener = svgEl.addEventListener;\n    if (!shouldAdd) {\n      addOrRemoveEventListener = svgEl.removeEventListener;\n    }\n    addOrRemoveEventListener('touchmove', this._drag, { passive: false });\n    addOrRemoveEventListener('mousemove', this._drag, { passive: false });\n    addOrRemoveEventListener('mouseup', this._endDrag, { passive: false });\n    addOrRemoveEventListener('mouseleave', this._endDrag, { passive: false });\n    addOrRemoveEventListener('touchcancel', this._endDrag, { passive: false });\n    addOrRemoveEventListener('touchleave', this._endDrag, { passive: false });\n    addOrRemoveEventListener('touchend', this._endDrag, { passive: false });\n  }\n\n  /**\n   * Recursively animates x and y.\n   * @param {number} now Unix timestamp when this was called.\n   */\n  _animate(now) {\n    return (() => {\n      let elapsed = now - this.state.originTime;\n      let svgCoord = this.getCoords();\n      if (elapsed < this.props.animationDuration && this.props.animate) {\n        const percentage = this._easeInOutCubic(\n          elapsed,\n          0,\n          1,\n          this.props.animationDuration\n        );\n\n        this.setState({\n          ...this.state,\n          x:\n            (svgCoord.x - this.state.originX) * percentage + this.state.originX,\n          y:\n            (svgCoord.y - this.state.originY) * percentage + this.state.originY,\n          z:\n            (svgCoord.z - this.state.originZ) * percentage + this.state.originZ,\n        });\n\n        requestAnimationFrame(this._animate(Date.now()));\n      } else {\n        this.setState({\n          ...this.state,\n          x: svgCoord.x,\n          y: svgCoord.y,\n          z: svgCoord.z,\n        });\n      }\n    }).bind(this);\n  }\n\n  /**\n   * Gets SVG x/y/z coordinates.\n   * @param {Object} props Props object to get coordinates from.\n   * @return {Object} Object with x, y and z parameters.\n   */\n  getCoords(props = this.props) {\n    return { x: props.x, y: props.y, z: props.z };\n  }\n\n  /**\n   * Returns animation easing value. See http://easings.net/#easeInOutCubic.\n   * @param {number} t Current time.\n   * @param {number} b Beginning value.\n   * @param {number} c Final value.\n   * @param {number} d Duration.\n   */\n  _easeInOutCubic(t, b, c, d) {\n    t /= d / 2;\n    if (t < 1) return (c / 2) * t * t * t + b;\n    t -= 2;\n    return (c / 2) * (t * t * t + 2) + b;\n  }\n\n  /**\n   * Gets event listeners needed for drag and drop.\n   */\n  _eventListeners() {\n    return [\n      { name: 'mousedown', callback: this._startDrag },\n      { name: 'touchstart', callback: this._startDrag },\n    ];\n  }\n\n  render() {\n    const Component = this.props.template;\n\n    return (\n      <Component\n        x={this.state.x}\n        y={this.state.y}\n        z={this.state.z}\n        style={this.props.style}\n        onClick={this._onClick}\n        onMouseOver={this.props.onMouseOver}\n        onMouseOut={this.props.onMouseOut}\n        eventListeners={this._eventListeners()}\n        svgRef={this.props.svgRef}\n      >\n        {this.props.children}\n      </Component>\n    );\n  }\n}\n"
  },
  {
    "path": "examples/react-web/src/index.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta content=\"width=device-width,initial-scale=1\" name=\"viewport\">\n    <link rel=\"stylesheet\" href=\"//unpkg.com/docsify/lib/themes/vue.css\">\n  </head>\n  <body class=\"ready sticky\">\n    <div id=\"test\" style=\"position: absolute; top: 0px; right: 0px; width: 100%; height: 100%; margin: 0px\"></div>\n  </body>\n\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</html>\n"
  },
  {
    "path": "examples/react-web/src/index.js",
    "content": "import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { App } from './app';\n\nconst container =\n  document.getElementById('test') || document.createElement('div');\nconst root = createRoot(container);\nroot.render(\n  <React.StrictMode>\n    <App />\n  </React.StrictMode>\n);\n"
  },
  {
    "path": "examples/react-web/src/li-navlink.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { NavLink, Route } from 'react-router-dom';\n\nconst LiNavLink = (props) => {\n  const {\n    to,\n    exact,\n    strict,\n    activeClassName,\n    className,\n    activeStyle,\n    style,\n    isActive: getIsActive,\n    ...rest\n  } = props;\n  return (\n    <Route\n      path={typeof to === 'object' ? to.pathname : to}\n      exact={exact}\n      strict={strict}\n    >\n      {({ location, match }) => {\n        const isActive = !!(getIsActive ? getIsActive(match, location) : match);\n        return (\n          <li\n            className={\n              isActive ? [activeClassName, className].join(' ') : className\n            }\n            style={isActive ? { ...style, ...activeStyle } : style}\n          >\n            <NavLink to={to} {...rest} />\n          </li>\n        );\n      }}\n    </Route>\n  );\n};\n\nLiNavLink.propTypes = {\n  to: PropTypes.string,\n  exact: PropTypes.bool,\n  strict: PropTypes.bool,\n  activeClassName: PropTypes.string,\n  className: PropTypes.string,\n  activeStyle: PropTypes.object,\n  style: PropTypes.object,\n  isActive: PropTypes.func,\n};\n\nexport default LiNavLink;\n"
  },
  {
    "path": "examples/react-web/src/lobby/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport routes from './routes';\n\n// Any other additional setup for this module\nexport default {\n  routes,\n};\n"
  },
  {
    "path": "examples/react-web/src/lobby/lobby.css",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n#lobby-view {\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n}\n\n.phase-title {\n  margin-top: 40px;\n}\n\n.hidden {\n  display: none;\n}\n\n.phase {\n  border: none;\n  outline: none;\n}\n\n#game-creation select {\n  font-size: 14px;\n  margin-right: 10px;\n}\n\n#game-creation span {\n  margin-right: 10px;\n}\n\n#instances td {\n  list-style: none;\n  border: 0px solid #eee;\n  border-top: none;\n  height: 30px;\n  line-height: 30px;\n  text-align: left;\n  font-size: 14px;\n  padding-left: 10px;\n  padding-right: 10px;\n}\n\n#instances table {\n  height: 100%;\n  width: 500px;\n  white-space: nowrap;\n}\n\n#instances button {\n  font-size: 12px;\n}\n\n.error-msg {\n  font-size: 12px;\n  color: red;\n  margin-top: 10px;\n  margin-bottom: 10px;\n  display: block;\n}\n\n.buttons button {\n  margin-left: 10px;\n  margin-top: 10px;\n  width: 70px;\n}\n"
  },
  {
    "path": "examples/react-web/src/lobby/lobby.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Lobby } from 'boardgame.io/react';\nimport { default as BoardTicTacToe } from '../tic-tac-toe/board';\nimport { default as BoardChess } from '../chess/board';\nimport { default as GameTicTacToe } from '../tic-tac-toe/game';\nimport { default as GameChess } from '../chess/game';\nimport './lobby.css';\n\nGameTicTacToe.minPlayers = 1;\nGameTicTacToe.maxPlayers = 2;\nGameChess.minPlayers = GameChess.maxPlayers = 2;\n\nconst hostname = window.location.hostname;\nconst importedGames = [\n  { game: GameTicTacToe, board: BoardTicTacToe },\n  { game: GameChess, board: BoardChess },\n];\n\nconst LobbyView = () => (\n  <div style={{ padding: 50 }}>\n    <h1>Lobby</h1>\n\n    <Lobby\n      gameServer={`http://${hostname}:8000`}\n      lobbyServer={`http://${hostname}:8000`}\n      gameComponents={importedGames}\n    />\n  </div>\n);\n\nexport default LobbyView;\n"
  },
  {
    "path": "examples/react-web/src/lobby/routes.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport LobbyView from './lobby';\n\nconst routes = [\n  {\n    path: '/lobby/main',\n    text: 'Example',\n    component: LobbyView,\n  },\n];\n\nexport default routes;\n"
  },
  {
    "path": "examples/react-web/src/random/board.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nconst Board = ({ G, moves }) => (\n  <div>\n    <pre>{JSON.stringify(G, null, 2)}</pre>\n    <button onClick={() => moves.shuffle()}>shuffle</button>\n    <button onClick={() => moves.rollD6()}>roll</button>\n  </div>\n);\n\nBoard.propTypes = {\n  G: PropTypes.any.isRequired,\n  moves: PropTypes.any.isRequired,\n};\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-web/src/random/game.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nconst RandomExample = {\n  name: 'shuffle',\n\n  setup: () => ({\n    deck: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],\n  }),\n\n  moves: {\n    shuffle: ({ G, random }) => ({ ...G, deck: random.Shuffle(G.deck) }),\n    rollDie: ({ G, random }, value) => ({ ...G, dice: random.Die(value) }),\n    rollD6: ({ G, random }) => ({ ...G, dice: random.D6() }),\n  },\n};\n\nexport default RandomExample;\n"
  },
  {
    "path": "examples/react-web/src/random/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport Game from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: Game,\n  numPlayers: 1,\n  board: Board,\n});\n\nconst SingleView = () => (\n  <div style={{ padding: 50 }}>\n    <App matchID=\"Random\" />\n  </div>\n);\n\nconst routes = [\n  {\n    path: '/random/main',\n    text: 'Examples',\n    component: SingleView,\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/react-web/src/redacted-move/board.css",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n.secret-state section {\n  text-align: left;\n  padding: 10px;\n  margin-bottom: 20px;\n  background: #eee;\n}\n"
  },
  {
    "path": "examples/react-web/src/redacted-move/board.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport './board.css';\n\nconst Board = ({ G, ctx, moves, playerID, log }) => (\n  <div className=\"secret-state\">\n    <section>\n      <strong>G</strong>\n      <pre>{JSON.stringify(G, null, 2)}</pre>\n\n      <strong>log</strong>\n      <pre>{JSON.stringify(log, null, 2)}</pre>\n      {playerID && (\n        <button\n          onClick={() => moves.clickCell({ secret: G.players[playerID] })}\n        >\n          Click Cell\n        </button>\n      )}\n    </section>\n  </div>\n);\n\nBoard.propTypes = {\n  G: PropTypes.any.isRequired,\n  ctx: PropTypes.any.isRequired,\n  moves: PropTypes.any.isRequired,\n  playerID: PropTypes.any,\n  log: PropTypes.any,\n};\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-web/src/redacted-move/game.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { PlayerView, ActivePlayers } from 'boardgame.io/core';\n\nconst RedactedMoves = {\n  name: 'secret-state',\n\n  setup: () => ({\n    other: {},\n    players: {\n      0: 'player 0 state',\n      1: 'player 1 state',\n    },\n  }),\n\n  moves: {\n    clickCell: {\n      /* eslint-disable no-unused-vars */\n      move: (_, secretstuff) => {},\n      /* eslint-enable no-unused-vars */\n      redact: true,\n    },\n  },\n\n  turn: { activePlayers: ActivePlayers.ALL },\n\n  playerView: PlayerView.STRIP_SECRETS,\n};\n\nexport default RedactedMoves;\n"
  },
  {
    "path": "examples/react-web/src/redacted-move/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Multiview from './multiview';\n\nconst routes = [\n  {\n    path: '/redacted_move',\n    text: 'Example',\n    component: Multiview,\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/react-web/src/redacted-move/multiview.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport Game from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: Game,\n  numPlayers: 2,\n  board: Board,\n  debug: false,\n  multiplayer: Local(),\n});\n\nconst Multiview = () => (\n  <div style={{ padding: 50 }}>\n    <h1>Redacted Moves</h1>\n    <p>\n      This examples demonstrates the use of redacted moves. Using redacted moves\n      allows for secret information to be stripped from the log for other\n      players.\n    </p>\n    <p>\n      Clicking the button on one of the players, you should see complete log\n      event for that player but a redacted one for everyone else.\n    </p>\n    <div className=\"runner\">\n      <div className=\"run\">\n        <App matchID=\"redacted-move\" playerID=\"0\" />\n        &lt;App playerID=&quot;0&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"redacted-move\" playerID=\"1\" />\n        &lt;App playerID=&quot;1&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"redacted-move\" />\n        &lt;App/&gt;\n      </div>\n    </div>\n  </div>\n);\n\nexport default Multiview;\n"
  },
  {
    "path": "examples/react-web/src/routes.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport tic_tac_toe from './tic-tac-toe';\nimport chess from './chess';\nimport secret_state from './secret-state';\nimport random from './random';\nimport threejs from './threejs';\nimport lobby from './lobby';\nimport simulator from './simulator';\nimport redacted_move from './redacted-move';\nimport undo from './undo';\n\nconst routes = [\n  {\n    name: 'Tic-Tac-Toe',\n    routes: tic_tac_toe.routes,\n  },\n  {\n    name: 'Chess',\n    routes: chess.routes,\n  },\n  {\n    name: 'Turn Orders',\n    routes: simulator.routes,\n  },\n  {\n    name: 'Random API',\n    routes: random.routes,\n  },\n  {\n    name: 'Secret State',\n    routes: secret_state.routes,\n  },\n  {\n    name: 'Redacted Move',\n    routes: redacted_move.routes,\n  },\n  {\n    name: 'Undo',\n    routes: undo.routes,\n  },\n  {\n    name: 'Other Frameworks',\n    routes: threejs.routes,\n  },\n  {\n    name: 'Lobby',\n    routes: lobby.routes,\n  },\n];\n\nexport default routes;\n"
  },
  {
    "path": "examples/react-web/src/secret-state/board.css",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n.secret-state section {\n  text-align: left;\n  padding: 10px;\n  margin-bottom: 20px;\n  background: #eee;\n}\n"
  },
  {
    "path": "examples/react-web/src/secret-state/board.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport './board.css';\n\nconst Board = ({ G, ctx, moves, playerID }) => (\n  <div className=\"secret-state\">\n    <section>\n      <pre>{JSON.stringify(G, null, 2)}</pre>\n    </section>\n  </div>\n);\n\nBoard.propTypes = {\n  G: PropTypes.any.isRequired,\n  ctx: PropTypes.any.isRequired,\n  moves: PropTypes.any.isRequired,\n  playerID: PropTypes.any,\n};\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-web/src/secret-state/game.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { PlayerView } from 'boardgame.io/core';\n\nconst SecretState = {\n  name: 'secret-state',\n\n  setup: () => ({\n    other: {},\n    players: {\n      0: 'player 0 state',\n      1: 'player 1 state',\n      2: 'player 2 state',\n    },\n  }),\n\n  playerView: PlayerView.STRIP_SECRETS,\n};\n\nexport default SecretState;\n"
  },
  {
    "path": "examples/react-web/src/secret-state/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Multiview from './multiview';\n\nconst routes = [\n  {\n    path: '/liars-dice',\n    text: 'Examples',\n    component: Multiview,\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/react-web/src/secret-state/multiview.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport Game from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: Game,\n  numPlayers: 3,\n  board: Board,\n  debug: false,\n  multiplayer: Local(),\n});\n\nconst Multiview = () => (\n  <div style={{ padding: 50 }}>\n    <h1>Secret Info</h1>\n    <div className=\"runner\">\n      <div className=\"run\">\n        <App matchID=\"secret-state\" playerID=\"0\" />\n        &lt;App playerID=&quot;0&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"secret-state\" playerID=\"1\" />\n        &lt;App playerID=&quot;1&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"secret-state\" playerID=\"2\" />\n        &lt;App playerID=&quot;2&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"secret-state\" />\n        &lt;App/&gt;\n      </div>\n    </div>\n  </div>\n);\n\nexport default Multiview;\n"
  },
  {
    "path": "examples/react-web/src/simulator/example-all-once.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { ActivePlayers } from 'boardgame.io/core';\n\nconst code = `{\n  turn: { activePlayers: ActivePlayers.ALL_ONCE },\n}\n`;\n\nconst Description = () => (\n  <div>\n    <pre>{code}</pre>\n  </div>\n);\n\nexport default {\n  description: Description,\n  game: {\n    moves: {\n      move: ({ G }) => G,\n    },\n\n    turn: { activePlayers: ActivePlayers.ALL_ONCE },\n\n    events: {\n      endPhase: false,\n    },\n  },\n};\n"
  },
  {
    "path": "examples/react-web/src/simulator/example-all.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { ActivePlayers } from 'boardgame.io/core';\n\nconst code = `{\n  turn: { activePlayers: ActivePlayers.ALL },\n}\n`;\n\nconst Description = () => (\n  <div>\n    <pre>{code}</pre>\n  </div>\n);\n\nexport default {\n  description: Description,\n  game: {\n    moves: {\n      move: ({ G }) => G,\n    },\n\n    turn: { activePlayers: ActivePlayers.ALL },\n\n    events: {\n      endPhase: false,\n    },\n  },\n};\n"
  },
  {
    "path": "examples/react-web/src/simulator/example-others-once.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\n\nconst code = `{\n  moves: {\n    play: ({ G, events }) => {\n      events.setActivePlayers({\n        others: 'discard',\n        minMoves: 1, \n        maxMoves: 1,\n      });\n      return G;\n    },\n  },\n\n  turn: {\n    stages: {\n      discard: {\n        moves: {\n          discard: ({ G }) => G,\n        },\n      },\n    },\n  },\n}\n`;\n\nconst Description = () => (\n  <div>\n    <pre>{code}</pre>\n  </div>\n);\n\nexport default {\n  description: Description,\n\n  game: {\n    events: {\n      endPhase: false,\n    },\n\n    moves: {\n      play: ({ G, events }) => {\n        events.setActivePlayers({\n          others: 'discard',\n          minMoves: 1,\n          maxMoves: 1,\n        });\n        return G;\n      },\n    },\n\n    turn: {\n      stages: {\n        discard: {\n          moves: {\n            discard: ({ G }) => G,\n          },\n        },\n      },\n    },\n  },\n};\n"
  },
  {
    "path": "examples/react-web/src/simulator/example-others.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { ActivePlayers } from 'boardgame.io/core';\n\nconst code = `{\n  turn: { activePlayers: ActivePlayers.OTHERS },\n}\n`;\n\nconst Description = () => (\n  <div>\n    <pre>{code}</pre>\n  </div>\n);\n\nexport default {\n  description: Description,\n  game: {\n    moves: {\n      move: ({ G }) => G,\n    },\n\n    events: {\n      endPhase: false,\n    },\n\n    turn: { activePlayers: ActivePlayers.OTHERS },\n  },\n};\n"
  },
  {
    "path": "examples/react-web/src/simulator/index.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport App from './simulator';\n\nconst routes = [\n  {\n    path: '/simulator',\n    text: 'Simulator',\n    component: App,\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/react-web/src/simulator/simulator.css",
    "content": "#turnorder {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  padding: 50px;\n}\n\n#turnorder pre {\n  font-family: monospace;\n  font-size: 12px;\n  color: #999;\n}\n\n#turnorder .description {\n  padding-top: 50px;\n  padding-bottom: 30px;\n}\n\n#turnorder .table-interior {\n  position: absolute;\n  margin-left: -3.2em;\n  margin-top: -0.85em;\n}\n\n#turnorder .player-container {\n  position: relative;\n  margin: 100px;\n  width: 16em;\n  height: 16em;\n  border-radius: 50%;\n  background: #eaeaea;\n  border: 5px solid #aaa;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n}\n\n.turnorder-options {\n  width: 500px;\n  display: flex;\n  flex-direction: row;\n  justify-content: space-evenly;\n}\n\n.turnorder-options div {\n  text-align: center;\n  cursor: pointer;\n  font-size: 12px;\n  padding: 10px;\n  border: 1px solid #aaa;\n  width: 100px;\n}\n\n.turnorder-options div:hover {\n  background: #efefef;\n}\n\n.turnorder-options div.active {\n  background: #efefef;\n  font-weight: bold;\n}\n\n#turnorder .stage-label {\n  position: absolute;\n  top: 2.25em;\n  left: 50%;\n  margin-left: -3.5em;\n  width: 8em;\n  text-align: center;\n}\n\n#turnorder .controls {\n  position: absolute;\n  margin-top: 60px;\n  margin-left: -47px;\n}\n\n#turnorder .controls button {\n  width: 80px;\n  margin-bottom: 5px;\n}\n\n#turnorder .player {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  margin: -1.5em;\n  width: 3em;\n  height: 3em;\n  line-height: 2.75em;\n  border-radius: 50%;\n  border-color: #aaa;\n  border-style: solid;\n  box-sizing: border-box;\n  text-align: center;\n  font-size: 24px;\n  font-weight: bold;\n  opacity: 0.3;\n}\n\n#turnorder .player.current {\n  opacity: 1;\n  background: #555;\n  color: #eee;\n}\n\n#turnorder .player.active {\n  opacity: 1;\n}\n\n#turnorder .phase,\n#turnorder .stage {\n  display: inline-block;\n  background: #555;\n  color: #eee;\n  padding: 3px 5px;\n  margin-left: 5px;\n}\n\n#turnorder .bgio-client {\n  padding: 0 !important;\n}\n\n.player-container span > .bgio-client:nth-child(1) .player-wrap {\n  transform: rotate(0deg) translate(12em) rotate(-0deg);\n}\n.player-container span > .bgio-client:nth-child(2) .player-wrap {\n  transform: rotate(60deg) translate(12em) rotate(-60deg);\n}\n.player-container span > .bgio-client:nth-child(3) .player-wrap {\n  transform: rotate(120deg) translate(12em) rotate(-120deg);\n}\n.player-container span > .bgio-client:nth-child(4) .player-wrap {\n  transform: rotate(180deg) translate(12em) rotate(-180deg);\n}\n.player-container span > .bgio-client:nth-child(5) .player-wrap {\n  transform: rotate(240deg) translate(12em) rotate(-240deg);\n}\n.player-container span > .bgio-client:nth-child(6) .player-wrap {\n  transform: rotate(300deg) translate(12em) rotate(-300deg);\n}\n"
  },
  {
    "path": "examples/react-web/src/simulator/simulator.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport All from './example-all';\nimport AllOnce from './example-all-once';\nimport Others from './example-others';\nimport OthersOnce from './example-others-once';\nimport './simulator.css';\n\nfunction Board({ ctx, moves, events, playerID }) {\n  if (playerID === null) {\n    return <div className=\"table-interior\"></div>;\n  }\n\n  let className = 'player';\n  let active = false;\n  let current = false;\n  let stage;\n  let onClick = () => {};\n\n  if (ctx.activePlayers) {\n    if (playerID in ctx.activePlayers) {\n      className += ' active';\n      active = true;\n      stage = ctx.activePlayers[playerID];\n    }\n  } else {\n    if (playerID === ctx.currentPlayer) {\n      className += ' active';\n      active = true;\n    }\n  }\n\n  if (playerID == ctx.currentPlayer) {\n    className += ' current';\n    current = true;\n  }\n\n  moves = Object.entries(moves)\n    .filter((e) => !(e[0] === 'play' && stage === 'discard'))\n    .filter((e) => !(e[0] === 'discard' && stage !== 'discard'))\n    .map((e) => (\n      <button key={e[0]} onClick={() => e[1]()}>\n        {e[0]}\n      </button>\n    ));\n\n  events = Object.entries(events)\n    .filter(() => current && active)\n    .filter((e) => e[0] != 'setActivePlayers')\n    .filter((e) => e[0] != 'setStage')\n    .filter((e) => e[0] != 'endStage')\n    .map((e) => (\n      <button key={e[0]} onClick={() => e[1]()}>\n        {e[0]}\n      </button>\n    ));\n\n  return (\n    <div className=\"player-wrap\">\n      <span className={className} onClick={onClick}>\n        {playerID}\n      </span>\n\n      <div className=\"controls\">\n        {active && moves}\n        {events}\n      </div>\n    </div>\n  );\n}\n\nconst examples = {\n  'others-once': OthersOnce,\n  all: All,\n  'all-once': AllOnce,\n  others: Others,\n};\n\nclass App extends React.Component {\n  constructor(props) {\n    super(props);\n    this.init('all');\n  }\n\n  init(type) {\n    let shouldUpdate = false;\n    if (this.client !== undefined) {\n      shouldUpdate = true;\n    }\n\n    this.type = type;\n    this.description = examples[type].description;\n    this.client = Client({\n      game: examples[type].game,\n      numPlayers: 6,\n      debug: false,\n      board: Board,\n      multiplayer: Local(),\n    });\n\n    if (shouldUpdate) {\n      this.forceUpdate();\n    }\n  }\n\n  render() {\n    const Description = this.description;\n    const App = this.client;\n\n    let players = [];\n    for (let i = 0; i < 6; i++) {\n      players.push(<App key={i} matchID={this.type} playerID={i + ''} />);\n    }\n\n    return (\n      <div id=\"turnorder\">\n        <div className=\"turnorder-options\">\n          <div\n            className={this.type === 'all' ? 'active' : ''}\n            onClick={() => this.init('all')}\n          >\n            ALL\n          </div>\n          <div\n            className={this.type === 'all-once' ? 'active' : ''}\n            onClick={() => this.init('all-once')}\n          >\n            ALL_ONCE\n          </div>\n          <div\n            className={this.type === 'others' ? 'active' : ''}\n            onClick={() => this.init('others')}\n          >\n            OTHERS\n          </div>\n          <div\n            className={this.type === 'others-once' ? 'active' : ''}\n            onClick={() => this.init('others-once')}\n          >\n            OTHERS_ONCE\n          </div>\n        </div>\n\n        <div className=\"turnorder-content\">\n          <div className=\"player-container\">\n            <App matchID={this.type} />\n            <span>{players}</span>\n          </div>\n          <div className=\"description\">\n            <Description />\n          </div>\n        </div>\n      </div>\n    );\n  }\n}\n\nexport default App;\n"
  },
  {
    "path": "examples/react-web/src/threejs/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport * as THREE from 'three';\nimport { Client } from 'boardgame.io/client';\nimport TicTacToe from '../tic-tac-toe/game';\nimport './main.css';\n\nfunction Init(root) {\n  const client = Client({ game: TicTacToe });\n\n  // Set up scene.\n\n  const scene = new THREE.Scene();\n  scene.background = new THREE.Color(0xffffff);\n\n  // Set up renderer.\n\n  const renderer = new THREE.WebGLRenderer({ antialias: true });\n  renderer.setSize(window.innerWidth, window.innerHeight);\n\n  // Add nine cubes.\n\n  let cubes = [];\n  for (let i = 0; i < 9; i++) {\n    const geometry = new THREE.BoxGeometry(1, 1, 1);\n    const material = new THREE.MeshLambertMaterial({ color: 0xcccccc });\n    const cube = new THREE.Mesh(geometry, material);\n    const r = Math.floor(i / 3);\n    const c = i % 3;\n    cube.position.z = -c * 2;\n    cube.position.x = r * 2;\n    cube.userData.i = i;\n    cubes.push(cube);\n    scene.add(cube);\n  }\n\n  // Set up camera.\n\n  const camera = new THREE.PerspectiveCamera(\n    45,\n    window.innerWidth / window.innerHeight,\n    0.1,\n    1000\n  );\n  camera.position.z = 5;\n  camera.position.x = 12;\n  camera.position.y = 15;\n  camera.lookAt(cubes[4].position);\n  scene.add(camera);\n\n  // Set up lights.\n\n  const ambientLight = new THREE.AmbientLight(0xffffff, 0.7);\n  scene.add(ambientLight);\n  const directionalLight = new THREE.DirectionalLight(0x555555);\n  scene.add(directionalLight);\n\n  // Animation logic.\n\n  let rotation = 0;\n  function animate() {\n    requestAnimationFrame(animate);\n\n    const { G } = client.getState();\n\n    cubes\n      .filter((c) => G.cells[c.userData.i] == '0')\n      .forEach((c) => {\n        c.material.color.setHex(0xff0000);\n        c.rotation.x = rotation;\n      });\n\n    cubes\n      .filter((c) => G.cells[c.userData.i] == '1')\n      .forEach((c) => {\n        c.material.color.setHex(0x00ff00);\n        c.rotation.y = -rotation;\n      });\n\n    rotation += 0.03;\n    renderer.render(scene, camera);\n  }\n\n  // Mouse handling.\n\n  const mouse = new THREE.Vector2();\n  const raycaster = new THREE.Raycaster();\n\n  function onMouseMove(e) {\n    const { ctx } = client.getState();\n    if (ctx.gameover !== undefined) {\n      root.style.cursor = '';\n      return;\n    }\n\n    const x = e.clientX - root.offsetParent.offsetLeft;\n    const y = e.clientY;\n    mouse.x = (x / window.innerWidth) * 2 - 1;\n    mouse.y = -(y / window.innerHeight) * 2 + 1;\n\n    raycaster.setFromCamera(mouse, camera);\n    const highlightedCubes = raycaster.intersectObjects(cubes);\n\n    cubes.forEach((c) => {\n      c.material.color.setHex(0xcccccc);\n    });\n\n    highlightedCubes.forEach((c) => {\n      c.object.material.color.setHex(0xaaaaaa);\n    });\n\n    if (highlightedCubes.length > 0) {\n      root.style.cursor = 'pointer';\n    } else {\n      root.style.cursor = '';\n    }\n  }\n\n  function onMouseDown() {\n    raycaster.setFromCamera(mouse, camera);\n    raycaster.intersectObjects(cubes).forEach((cube) => {\n      client.moves.clickCell(cube.object.userData.i);\n    });\n  }\n\n  root.appendChild(renderer.domElement);\n  root.addEventListener('mousemove', onMouseMove);\n  root.addEventListener('mousedown', onMouseDown);\n\n  animate();\n}\n\nconst routes = [\n  {\n    path: '/threejs/main',\n    text: 'threejs',\n    component: class App extends React.Component {\n      componentDidMount() {\n        Init(this.ref);\n      }\n      render() {\n        return (\n          <div\n            ref={(el) => {\n              this.ref = el;\n            }}\n          />\n        );\n      }\n    },\n  },\n];\n\nexport default {\n  routes,\n};\n"
  },
  {
    "path": "examples/react-web/src/threejs/main.css",
    "content": "div.root {\n  position: relative;\n}\n\ndiv.text {\n  position: absolute;\n  left: 10px;\n  top: 10px;\n}\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/advanced-ai.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React, { useEffect, useState } from 'react';\nimport { Client as PlainJSClient } from 'boardgame.io/client';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport { MCTSBot, Step } from 'boardgame.io/ai';\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  debug: false,\n  // Use Local transport for communication with bots.\n  multiplayer: Local(),\n});\n\n/**\n * Component that controls and runs a custom bot instance.\n */\nconst BotControls = ({ playerID, matchID }) => {\n  const difficulties = {\n    easy: {\n      iterations: 1,\n      playoutDepth: 1,\n    },\n    hard: {\n      iterations: 1000,\n      playoutDepth: 50,\n    },\n  };\n  const [difficulty, setDifficulty] = useState('easy');\n  const [client, setClient] = useState();\n\n  // Create a plain Javascript boardgame.io client on mount.\n  useEffect(() => {\n    const newClient = PlainJSClient({\n      game: TicTacToe,\n      debug: false,\n      multiplayer: Local(),\n      matchID,\n      playerID,\n    });\n    newClient.start();\n    setClient(newClient);\n    // Clean up client on unmount.\n    return () => newClient.stop();\n  }, []);\n\n  // Update the client subscription when bot difficulty changes.\n  useEffect(() => {\n    if (!client) return;\n    // Subscribe to the client with a function that will run AI on a bot\n    // player’s turn.\n    return client.subscribe((state) => {\n      if (!state) return;\n      if (state.ctx.currentPlayer === playerID) {\n        const { iterations, playoutDepth } = difficulties[difficulty];\n        const bot = new MCTSBot({\n          game: TicTacToe,\n          enumerate: TicTacToe.ai.enumerate,\n          iterations,\n          playoutDepth,\n        });\n        // Delay AI stepping by a tick to allow React to render before the\n        // main thread gets blocked by AI iterations.\n        setTimeout(() => Step(client, bot), 0);\n      }\n    });\n  }, [client, difficulty]);\n\n  // Render AI difficulty toggle buttons.\n  return (\n    <p>\n      AI Difficulty:{' '}\n      <button\n        onClick={() => setDifficulty('easy')}\n        disabled={difficulty === 'easy'}\n      >\n        Easy\n      </button>\n      <button\n        onClick={() => setDifficulty('hard')}\n        disabled={difficulty === 'hard'}\n      >\n        Hard\n      </button>\n    </p>\n  );\n};\n\nconst AdvancedAI = () => {\n  return (\n    <div>\n      <h1>Advanced AI</h1>\n      <p className=\"warn\">\n        This example shows how to use a custom bot instance to play against a\n        local player.\n        <br />\n        In the future, this will be made much simpler!\n      </p>\n      <App playerID=\"0\" matchID=\"advanced-ai\" />\n      <BotControls playerID=\"1\" matchID=\"advanced-ai\" />\n    </div>\n  );\n};\n\nexport default AdvancedAI;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/authenticated.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { SocketIO } from 'boardgame.io/multiplayer';\nimport TicTacToe from './game';\nimport Board from './board';\nimport PropTypes from 'prop-types';\nimport request from 'superagent';\n\nconst hostname = window.location.hostname;\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  debug: false,\n  multiplayer: SocketIO({ server: `${hostname}:8000` }),\n});\n\nclass AuthenticatedClient extends React.Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      matchID: 'matchID',\n      players: {\n        0: {\n          credentials: 'credentials',\n        },\n        1: {\n          credentials: 'credentials',\n        },\n      },\n    };\n  }\n\n  async componentDidMount() {\n    const gameName = 'tic-tac-toe';\n    const PORT = 8000;\n\n    const newGame = await request\n      .post(`http://${hostname}:${PORT}/games/${gameName}/create`)\n      .send({ numPlayers: 2 });\n\n    const matchID = newGame.body.matchID;\n\n    let playerCredentials = [];\n\n    for (let playerID of [0, 1]) {\n      const player = await request\n        .post(`http://${hostname}:${PORT}/games/${gameName}/${matchID}/join`)\n        .send({\n          gameName,\n          playerID,\n          playerName: playerID.toString(),\n        });\n\n      playerCredentials.push(player.body.playerCredentials);\n    }\n\n    this.setState({\n      matchID,\n      players: {\n        0: {\n          credentials: playerCredentials[0],\n        },\n        1: {\n          credentials: playerCredentials[1],\n        },\n      },\n    });\n  }\n\n  onPlayerCredentialsChange(playerID, credentials) {\n    this.setState({\n      matchID: this.state.matchID,\n      players: {\n        ...this.state.players,\n        [playerID]: {\n          credentials,\n        },\n      },\n    });\n  }\n\n  render() {\n    return (\n      <AuthenticatedExample\n        matchID={this.state.matchID}\n        players={this.state.players}\n        onPlayerCredentialsChange={this.onPlayerCredentialsChange.bind(this)}\n      />\n    );\n  }\n}\n\nclass AuthenticatedExample extends React.Component {\n  static propTypes = {\n    matchID: PropTypes.string,\n    players: PropTypes.any,\n    onPlayerCredentialsChange: PropTypes.func,\n  };\n\n  render() {\n    return (\n      <div>\n        <h1>Authenticated</h1>\n\n        <p>\n          Change the credentials of a player, and you will notice that the\n          server no longer accepts moves from that client.\n        </p>\n\n        <div className=\"runner\">\n          <div className=\"run\">\n            <App\n              matchID={this.props.matchID}\n              playerID=\"0\"\n              credentials={this.props.players['0'].credentials}\n            />\n            <input\n              type=\"text\"\n              value={this.props.players['0'].credentials}\n              onChange={(event) =>\n                this.props.onPlayerCredentialsChange('0', event.target.value)\n              }\n            />\n          </div>\n          <div className=\"run\">\n            <App\n              matchID={this.props.matchID}\n              playerID=\"1\"\n              credentials={this.props.players['1'].credentials}\n            />\n            <input\n              type=\"text\"\n              value={this.props.players['1'].credentials}\n              onChange={(event) =>\n                this.props.onPlayerCredentialsChange('1', event.target.value)\n              }\n            />\n          </div>\n        </div>\n      </div>\n    );\n  }\n}\n\nexport default AuthenticatedClient;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/board.css",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n#board {\n  border-collapse: collapse;\n}\n\n#winner {\n  margin-top: 25px;\n  width: 168px;\n  text-align: center;\n}\n\ntd {\n  text-align: center;\n  font-weight: bold;\n  font-size: 25px;\n  color: #555;\n  width: 50px;\n  height: 50px;\n  line-height: 50px;\n  border: 3px solid #aaa;\n  background: #fff;\n}\n\ntd.active {\n  cursor: pointer;\n  background: #eeffe9;\n}\n\ntd.active:hover {\n  background: #eeffff;\n}\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/board.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport './board.css';\n\nclass Board extends React.Component {\n  static propTypes = {\n    G: PropTypes.any.isRequired,\n    ctx: PropTypes.any.isRequired,\n    moves: PropTypes.any.isRequired,\n    playerID: PropTypes.string,\n    isActive: PropTypes.bool,\n    isMultiplayer: PropTypes.bool,\n    isConnected: PropTypes.bool,\n    isPreview: PropTypes.bool,\n  };\n\n  onClick = (id) => {\n    if (this.isActive(id)) {\n      this.props.moves.clickCell(id);\n    }\n  };\n\n  isActive(id) {\n    return this.props.isActive && this.props.G.cells[id] === null;\n  }\n\n  render() {\n    let tbody = [];\n    for (let i = 0; i < 3; i++) {\n      let cells = [];\n      for (let j = 0; j < 3; j++) {\n        const id = 3 * i + j;\n        cells.push(\n          <td\n            key={id}\n            className={this.isActive(id) ? 'active' : ''}\n            onClick={() => this.onClick(id)}\n          >\n            {this.props.G.cells[id]}\n          </td>\n        );\n      }\n      tbody.push(<tr key={i}>{cells}</tr>);\n    }\n\n    let disconnected = null;\n    if (this.props.isMultiplayer && !this.props.isConnected) {\n      disconnected = <div>Disconnected!</div>;\n    }\n\n    let winner = null;\n    if (this.props.ctx.gameover) {\n      winner =\n        this.props.ctx.gameover.winner !== undefined ? (\n          <div id=\"winner\">Winner: {this.props.ctx.gameover.winner}</div>\n        ) : (\n          <div id=\"winner\">Draw!</div>\n        );\n    }\n\n    let player = null;\n    if (this.props.playerID) {\n      player = <div id=\"player\">Player: {this.props.playerID}</div>;\n    }\n\n    if (this.props.isPreview) {\n      disconnected = player = null;\n    }\n\n    return (\n      <div>\n        <table id=\"board\">\n          <tbody>{tbody}</tbody>\n        </table>\n        {player}\n        {winner}\n        {disconnected}\n      </div>\n    );\n  }\n}\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/bots.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport { MCTSBot } from 'boardgame.io/ai';\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  debug: false,\n  multiplayer: Local({\n    bots: {\n      1: MCTSBot,\n    },\n  }),\n});\n\nconst Bots = () => (\n  <div>\n    <h1>Singleplayer vs AI</h1>\n    <App playerID=\"0\" matchID=\"single-vs-ai\" />\n  </div>\n);\n\nexport default Bots;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/game.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  const isRowComplete = (row) => {\n    const symbols = row.map((i) => cells[i]);\n    return symbols.every((i) => i !== null && i === symbols[0]);\n  };\n\n  return positions.map(isRowComplete).some((i) => i === true);\n}\n\nconst TicTacToe = {\n  name: 'tic-tac-toe',\n\n  setup: () => ({\n    cells: new Array(9).fill(null),\n  }),\n\n  moves: {\n    clickCell({ G, playerID }, id) {\n      const cells = [...G.cells];\n\n      if (cells[id] === null) {\n        cells[id] = playerID;\n        return { ...G, cells };\n      }\n    },\n  },\n\n  turn: {\n    minMoves: 1,\n    maxMoves: 1,\n  },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n    if (G.cells.filter((c) => c === null).length == 0) {\n      return { draw: true };\n    }\n  },\n\n  ai: {\n    enumerate: (G) => {\n      let r = [];\n      for (let i = 0; i < 9; i++) {\n        if (G.cells[i] === null) {\n          r.push({ move: 'clickCell', args: [i] });\n        }\n      }\n      return r;\n    },\n  },\n};\n\nexport default TicTacToe;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/index.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Singleplayer from './singleplayer';\nimport Multiplayer from './multiplayer';\nimport Spectator from './spectator';\nimport Authenticated from './authenticated';\nimport Bots from './bots';\nimport AdvancedAI from './advanced-ai';\n\nconst routes = [\n  {\n    path: '/',\n    text: 'Singleplayer',\n    component: Singleplayer,\n  },\n  {\n    path: '/multiplayer',\n    text: 'Multiplayer',\n    component: Multiplayer,\n  },\n  {\n    path: '/authenticated',\n    text: 'Authenticated',\n    component: Authenticated,\n  },\n  {\n    path: '/spectator',\n    text: 'Spectator',\n    component: Spectator,\n  },\n  {\n    path: '/bots',\n    text: 'Singleplayer vs AI',\n    component: Bots,\n  },\n  {\n    path: '/advanced-ai',\n    text: 'Advanced AI',\n    component: AdvancedAI,\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/multiplayer.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  multiplayer: Local(),\n});\n\nconst Multiplayer = () => (\n  <div>\n    <h1>Multiplayer</h1>\n    <div className=\"runner\" style={{ maxWidth: '600px' }}>\n      <div className=\"run\">\n        <App matchID=\"multi\" playerID=\"0\" />\n        &lt;App playerID=&quot;0&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"multi\" playerID=\"1\" />\n        &lt;App playerID=&quot;1&quot;/&gt;\n      </div>\n    </div>\n  </div>\n);\n\nexport default Multiplayer;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/singleplayer.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Debug } from 'boardgame.io/debug';\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  debug: { impl: Debug },\n});\n\nconst Singleplayer = () => (\n  <div>\n    <h1>Singleplayer</h1>\n    <App matchID=\"single\" />\n  </div>\n);\n\nexport default Singleplayer;\n"
  },
  {
    "path": "examples/react-web/src/tic-tac-toe/spectator.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { SocketIO } from 'boardgame.io/multiplayer';\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst hostname = window.location.hostname;\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  debug: false,\n  multiplayer: SocketIO({ server: `${hostname}:8000` }),\n});\n\nconst Spectator = () => (\n  <div>\n    <h1>Spectator</h1>\n    <div className=\"runner\">\n      <div className=\"run\">\n        <App matchID=\"spectator\" playerID=\"0\" />\n        &lt;App playerID=&quot;0&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"spectator\" playerID=\"1\" />\n        &lt;App playerID=&quot;1&quot;/&gt;\n      </div>\n      <div className=\"run\">\n        <App matchID=\"spectator\" />\n        Spectator\n      </div>\n    </div>\n  </div>\n);\n\nexport default Spectator;\n"
  },
  {
    "path": "examples/react-web/src/undo/board.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nconst Board = ({ playerID, G, ctx, moves, events, undo, redo }) => (\n  <div style={{ opacity: playerID == ctx.currentPlayer ? 1 : 0.5 }}>\n    <h3>Player {playerID}</h3>\n    <pre>{JSON.stringify(G, null, 2)}</pre>\n    <button onClick={() => moves.A()}>A</button>\n    <button onClick={() => moves.B()}>B</button>\n    <button onClick={() => undo()}>undo</button>\n    <button onClick={() => redo()}>redo</button>\n    <button onClick={() => events.endTurn()}>end turn</button>\n  </div>\n);\n\nBoard.propTypes = {\n  playerID: PropTypes.any.isRequired,\n  G: PropTypes.any.isRequired,\n  ctx: PropTypes.any.isRequired,\n  moves: PropTypes.any.isRequired,\n  undo: PropTypes.any.isRequired,\n  redo: PropTypes.any.isRequired,\n  events: PropTypes.any.isRequired,\n};\n\nexport default Board;\n"
  },
  {
    "path": "examples/react-web/src/undo/game.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nconst UndoExample = {\n  name: 'undo',\n\n  setup: () => ({ moves: [] }),\n\n  moves: {\n    A: ({ G }) => {\n      G.moves.push('A');\n    },\n    B: ({ G }) => {\n      G.moves.push('B');\n    },\n  },\n};\n\nexport default UndoExample;\n"
  },
  {
    "path": "examples/react-web/src/undo/index.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\nimport Game from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: Game,\n  numPlayers: 2,\n  board: Board,\n  multiplayer: Local(),\n});\n\nconst View = () => (\n  <div style={{ padding: 50 }}>\n    <App playerID=\"0\" />\n    <App playerID=\"1\" />\n  </div>\n);\n\nconst routes = [\n  {\n    path: '/undo/main',\n    text: 'Examples',\n    component: View,\n  },\n];\n\nexport default { routes };\n"
  },
  {
    "path": "examples/snippets/.gitignore",
    "content": "package-lock.json"
  },
  {
    "path": "examples/snippets/README.md",
    "content": "# snippets\n\nThis directory contains the source code for the embedded demos\nfound in boardgame.io’s documentation.\n\nTo work with the snippets, `cd` to this directory and install\nthe required dependencies:\n\n```sh\ncd examples/snippets\nnpm install\n```\n\n## Available commands\n\n### `npm start`\n\nRun a local development server with each snippet on its own\npage.\n\nEach snippet will be available at\n`https://localhost:1234/<snippet-name>/index.html`.\n\n### `npm run update-docs`\n\nBuilds the snippets and installs them at the appropriate places\nin the docs. Be careful not to let Prettier \"un-minify\" the\nbundled JS while committing the change.\n"
  },
  {
    "path": "examples/snippets/install.sh",
    "content": "#!/bin/bash\n\n# Builds the snippets and installs them at the\n# appropriate places in the docs. Be careful not\n# to let Prettier \"un-minify\" the bundled JS while\n# committing the change.\n\nrm -rf dist\nnpm run build\nrm -rf ../../docs/documentation/snippets\ncp -r dist ../../docs/documentation/snippets\n"
  },
  {
    "path": "examples/snippets/package.json",
    "content": "{\n  \"name\": \"snippets\",\n  \"scripts\": {\n    \"start\": \"parcel src/*/index.html\",\n    \"update-docs\": \"./install.sh\",\n    \"build\": \"parcel build --no-source-maps --public-url /documentation/snippets src/*/index.html\",\n    \"build:opt\": \"parcel build --experimental-scope-hoisting --no-source-maps --public-url /documentation/snippets src/*/index.html\"\n  },\n  \"devDependencies\": {\n    \"parcel-bundler\": \"^1.11.0\"\n  },\n  \"alias\": {\n    \"boardgame.io\": \"../../dist/esm\"\n  },\n  \"browserslist\": [\n    \"last 1 Chrome versions\"\n  ],\n  \"dependencies\": {\n    \"@babel/core\": \"^7.6.2\",\n    \"@babel/preset-env\": \"^7.6.2\",\n    \"@babel/preset-react\": \"^7.0.0\",\n    \"parcel-plugin-svelte\": \"^4.0.4\",\n    \"react\": \"^16.9.0\",\n    \"react-dom\": \"^16.9.0\",\n    \"svelte\": \"^3.0.0\"\n  }\n}\n"
  },
  {
    "path": "examples/snippets/src/example-1/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n<style>\nbody {\n  padding: 20px;\n}\n.msg {\n  position: absolute;\n  bottom: 0;\n  left: 20px;\n  color: #aaa;\n  font-size: 12px;\n  margin-bottom: 20px;\n}\n</style>\n</head>\n\n<body>\n  <div class=\"msg\">interactive (not an image)</div>\n  <div id=\"app\"></div>\n\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "examples/snippets/src/example-1/index.js",
    "content": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Client } from 'boardgame.io/react';\nimport { Debug } from 'boardgame.io/debug';\n\nvar TicTacToe = {\n  setup: () => ({ cells: Array(9).fill(null) }),\n\n  moves: {\n    clickCell({ G, playerID }, id) {\n      G.cells[id] = playerID;\n    },\n  },\n};\n\nvar App = Client({ game: TicTacToe, debug: { impl: Debug } });\nReactDOM.render(<App />, document.getElementById('app'));\n"
  },
  {
    "path": "examples/snippets/src/example-2/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n<style>\nbody {\n  padding: 20px;\n}\n.msg {\n  position: absolute;\n  bottom: 0;\n  left: 20px;\n  color: #aaa;\n  font-size: 12px;\n  margin-bottom: 20px;\n}\n</style>\n</head>\n\n<body>\n  <div class=\"msg\">interactive (not an image)</div>\n  <div id=\"app\"></div>\n\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "examples/snippets/src/example-2/index.js",
    "content": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Client } from 'boardgame.io/react';\nimport { Debug } from 'boardgame.io/debug';\nimport { INVALID_MOVE } from 'boardgame.io/core';\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  const isRowComplete = (row) => {\n    const symbols = row.map((i) => cells[i]);\n    return symbols.every((i) => i !== null && i === symbols[0]);\n  };\n\n  return positions.map(isRowComplete).some((i) => i === true);\n}\n\nconst TicTacToe = {\n  setup: () => ({ cells: Array(9).fill(null) }),\n\n  moves: {\n    clickCell({ G, playerID }, id) {\n      if (G.cells[id] !== null) {\n        return INVALID_MOVE;\n      }\n      G.cells[id] = playerID;\n    },\n  },\n\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n    if (G.cells.filter((c) => c === null).length == 0) {\n      return { draw: true };\n    }\n  },\n};\n\nfunction TicTacToeBoard({ ctx, G, moves }) {\n  const onClick = (id) => moves.clickCell(id);\n\n  let winner = '';\n  if (ctx.gameover) {\n    winner =\n      ctx.gameover.winner !== undefined ? (\n        <div id=\"winner\">Winner: {ctx.gameover.winner}</div>\n      ) : (\n        <div id=\"winner\">Draw!</div>\n      );\n  }\n\n  const cellStyle = {\n    border: '1px solid #555',\n    width: '50px',\n    height: '50px',\n    lineHeight: '50px',\n    textAlign: 'center',\n    fontFamily: 'monospace',\n    fontSize: '20px',\n    fontWeight: 'bold',\n    padding: '0',\n    boxSizing: 'border-box',\n  };\n\n  let tbody = [];\n  for (let i = 0; i < 3; i++) {\n    let cells = [];\n    for (let j = 0; j < 3; j++) {\n      const id = 3 * i + j;\n      cells.push(\n        <td key={id}>\n          {G.cells[id] ? (\n            <div style={cellStyle}>{G.cells[id]}</div>\n          ) : (\n            <button style={cellStyle} onClick={() => onClick(id)} />\n          )}\n        </td>\n      );\n    }\n    tbody.push(<tr key={i}>{cells}</tr>);\n  }\n\n  return (\n    <div>\n      <table id=\"board\">\n        <tbody>{tbody}</tbody>\n      </table>\n      {winner}\n    </div>\n  );\n}\n\nvar App = Client({\n  board: TicTacToeBoard,\n  game: TicTacToe,\n  debug: { impl: Debug },\n});\n\nReactDOM.render(<App />, document.getElementById('app'));\n"
  },
  {
    "path": "examples/snippets/src/example-3/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n<style>\nbody {\n  padding: 20px;\n}\n.msg {\n  position: absolute;\n  bottom: 0;\n  left: 20px;\n  color: #aaa;\n  font-size: 12px;\n  margin-bottom: 20px;\n}\n</style>\n</head>\n\n<body>\n  <div class=\"msg\">interactive (not an image)</div>\n  <div id=\"app\"></div>\n\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "examples/snippets/src/example-3/index.js",
    "content": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Client } from 'boardgame.io/react';\nimport { Debug } from 'boardgame.io/debug';\nimport { INVALID_MOVE } from 'boardgame.io/core';\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  const isRowComplete = (row) => {\n    const symbols = row.map((i) => cells[i]);\n    return symbols.every((i) => i !== null && i === symbols[0]);\n  };\n\n  return positions.map(isRowComplete).some((i) => i === true);\n}\n\nconst TicTacToe = {\n  setup: () => ({ cells: Array(9).fill(null) }),\n\n  moves: {\n    clickCell({ G, playerID }, id) {\n      if (G.cells[id] !== null) {\n        return INVALID_MOVE;\n      }\n      G.cells[id] = playerID;\n    },\n  },\n\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n    if (G.cells.filter((c) => c === null).length == 0) {\n      return { draw: true };\n    }\n  },\n\n  ai: {\n    enumerate: (G, ctx) => {\n      let moves = [];\n      for (let i = 0; i < 9; i++) {\n        if (G.cells[i] === null) {\n          moves.push({ move: 'clickCell', args: [i] });\n        }\n      }\n      return moves;\n    },\n  },\n};\n\nfunction TicTacToeBoard({ ctx, G, moves }) {\n  const onClick = (id) => moves.clickCell(id);\n\n  let winner = '';\n  if (ctx.gameover) {\n    winner =\n      ctx.gameover.winner !== undefined ? (\n        <div id=\"winner\">Winner: {ctx.gameover.winner}</div>\n      ) : (\n        <div id=\"winner\">Draw!</div>\n      );\n  }\n\n  const cellStyle = {\n    border: '1px solid #555',\n    width: '50px',\n    height: '50px',\n    lineHeight: '50px',\n    textAlign: 'center',\n    fontFamily: 'monospace',\n    fontSize: '20px',\n    fontWeight: 'bold',\n    padding: '0',\n    boxSizing: 'border-box',\n  };\n\n  let tbody = [];\n  for (let i = 0; i < 3; i++) {\n    let cells = [];\n    for (let j = 0; j < 3; j++) {\n      const id = 3 * i + j;\n      cells.push(\n        <td key={id}>\n          {G.cells[id] ? (\n            <div style={cellStyle}>{G.cells[id]}</div>\n          ) : (\n            <button style={cellStyle} onClick={() => onClick(id)} />\n          )}\n        </td>\n      );\n    }\n    tbody.push(<tr key={i}>{cells}</tr>);\n  }\n\n  return (\n    <div>\n      <table id=\"board\">\n        <tbody>{tbody}</tbody>\n      </table>\n      {winner}\n    </div>\n  );\n}\n\nvar App = Client({\n  board: TicTacToeBoard,\n  game: TicTacToe,\n  debug: { impl: Debug },\n});\n\nReactDOM.render(<App />, document.getElementById('app'));\n"
  },
  {
    "path": "examples/snippets/src/multiplayer/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n<style>\nbody {\n  padding: 1.25rem;\n}\n.msg {\n  position: absolute;\n  bottom: 0;\n  left: 1.25rem;\n  color: #aaa;\n  font-size: 0.75rem;\n  margin-bottom: 1.25rem;\n}\n\n@media screen and (max-width: 420px) {\n  :root {\n    font-size: 75%;\n  }\n}\n</style>\n</head>\n\n<body>\n  <div id=\"app\"></div>\n\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "examples/snippets/src/multiplayer/index.js",
    "content": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Client } from 'boardgame.io/react';\nimport { Local } from 'boardgame.io/multiplayer';\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  for (let pos of positions) {\n    const symbol = cells[pos[0]];\n    let winner = symbol;\n    for (let i of pos) {\n      if (cells[i] != symbol) {\n        winner = null;\n        break;\n      }\n    }\n    if (winner != null) return true;\n  }\n\n  return false;\n}\n\nconst TicTacToe = {\n  setup: () => ({ cells: Array(9).fill(null) }),\n\n  moves: {\n    clickCell({ G, playerID }, id) {\n      const cells = [...G.cells];\n\n      if (cells[id] === null) {\n        cells[id] = playerID;\n      }\n\n      return { ...G, cells };\n    },\n  },\n\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n    if (G.cells.filter((c) => c === null).length == 0) {\n      return { draw: true };\n    }\n  },\n};\n\nfunction TicTacToeBoard({ G, ctx, moves, isActive, playerID }) {\n  const canClickCell = (id) => isActive && G.cells[id] == null;\n\n  const onClick = (id) => {\n    if (canClickCell(id)) {\n      moves.clickCell(id);\n    }\n  };\n\n  let winner = '';\n  if (ctx.gameover) {\n    winner =\n      ctx.gameover.winner !== undefined ? (\n        <div id=\"winner\">Winner: {ctx.gameover.winner}</div>\n      ) : (\n        <div id=\"winner\">Draw!</div>\n      );\n  }\n\n  const cellStyle = (active) => ({\n    border: '1px solid #555',\n    width: '3.125rem',\n    height: '3.125rem',\n    lineHeight: '3.125rem',\n    textAlign: 'center',\n    fontFamily: 'monospace',\n    fontSize: '1.25rem',\n    fontWeight: 'bold',\n    background: active ? '#eeffe9' : 'transparent',\n    padding: '0',\n    boxSizing: 'border-box',\n  });\n\n  let tbody = [];\n  for (let i = 0; i < 3; i++) {\n    let cells = [];\n    for (let j = 0; j < 3; j++) {\n      const id = 3 * i + j;\n      cells.push(\n        <td key={id}>\n          {canClickCell(id) ? (\n            <button style={cellStyle(true)} onClick={() => onClick(id)} />\n          ) : (\n            <div style={cellStyle(false)}>{G.cells[id]}</div>\n          )}\n        </td>\n      );\n    }\n    tbody.push(<tr key={i}>{cells}</tr>);\n  }\n\n  return (\n    <div>\n      <p\n        style={{\n          display: 'flex',\n          justifyContent: 'space-between',\n          flexWrap: 'wrap',\n        }}\n      >\n        <span>Player {playerID}</span>\n        {isActive && <span>Your turn!</span>}\n      </p>\n      <table id=\"board\">\n        <tbody>{tbody}</tbody>\n      </table>\n      <p>{winner}</p>\n    </div>\n  );\n}\n\nvar TicTacToeClient = Client({\n  board: TicTacToeBoard,\n  game: TicTacToe,\n  debug: false,\n  multiplayer: Local(),\n});\n\nconst App = () => (\n  <div\n    style={{ display: 'flex', justifyContent: 'space-around', gap: '1.25rem' }}\n  >\n    <TicTacToeClient playerID=\"0\" />\n    <TicTacToeClient playerID=\"1\" />\n  </div>\n);\n\nReactDOM.render(<App />, document.getElementById('app'));\n"
  },
  {
    "path": "examples/snippets/src/phases-1/App.svelte",
    "content": "<script>\n  import Player from './Player.svelte';\n</script>\n\n<style>\n  #board {\n    width: 100%;\n  }\n\n  .container {\n    display: flex;\n    flex-direction: row;\n    justify-content: space-evenly;\n  }\n</style>\n\n<div>\n  <div id=\"board\">\n    <Player />\n  </div>\n  <div class=\"container\">\n    <Player playerID=\"0\" />\n    <Player playerID=\"1\" />\n    <Player playerID=\"2\" />\n  </div>\n</div>\n"
  },
  {
    "path": "examples/snippets/src/phases-1/Player.svelte",
    "content": "<script>\n  export let playerID = null;\n\n  import { Client } from 'boardgame.io/client';\n  import { Local } from 'boardgame.io/multiplayer';\n  import Game from './game';\n\n  const client = Client({\n    game: Game,\n    matchID: 'default',\n    playerID,\n    debug: false,\n    numPlayers: 3,\n    multiplayer: Local(),\n  });\n\n  client.start();\n</script>\n\n<style>\n  .phase {\n    font-size: 1.2em;\n    margin-top: 20px;\n    color: #aaa;\n  }\n\n  .deck {\n    font-family: monospace;\n    width: 40px;\n    height: 60px;\n    margin-left: auto;\n    margin-right: auto;\n    border: 1px solid #ddd;\n    padding: 20px;\n    text-align: center;\n    border-radius: 5px;\n    margin-bottom: 50px;\n  }\n\n  .client {\n    border-radius: 5px;\n    width: 100px;\n    border: 1px solid #ddd;\n    background: #fafafa;\n    opacity: .8;\n  }\n\n  .client.active {\n    box-shadow: 0 0 5px #aaa;\n    background: #fff;\n    opacity: 1;\n  }\n\n  .client li {\n    font-family: monospace;\n    list-style: none;\n    padding: 5px;\n    height: 30px;\n    line-height: 30px;\n    text-align: center;\n  }\n</style>\n\n{#if !playerID}\n  <div class=\"deck\">\n    <div>{$client.G.deck}</div>\n    <div>cards</div>\n  </div>\n{:else}\n  <div class=\"client\" class:active={$client.isActive}>\n    <li>\n      <strong>Player {playerID}</strong>\n    </li>\n    <li>{$client.G.hand[playerID]} cards</li>\n    <li>\n      <button on:click={client.moves.DrawCard}>Draw Card</button>\n    </li>\n    <li>\n      <button on:click={client.moves.PlayCard}>Play Card</button>\n    </li>\n  </div>\n{/if}\n"
  },
  {
    "path": "examples/snippets/src/phases-1/game.js",
    "content": "function DrawCard({ G, playerID }) {\n  G.deck--;\n  G.hand[playerID]++;\n}\n\nfunction PlayCard({ G, playerID }) {\n  G.deck++;\n  G.hand[playerID]--;\n}\n\nconst game = {\n  setup: ({ ctx }) => ({ deck: 6, hand: Array(ctx.numPlayers).fill(0) }),\n  moves: { DrawCard, PlayCard },\n  turn: { minMoves: 1, maxMoves: 1 },\n};\n\nexport default game;\n"
  },
  {
    "path": "examples/snippets/src/phases-1/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<body>\n  <div id=\"app\"></div>\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "examples/snippets/src/phases-1/index.js",
    "content": "import App from './App.svelte';\n\nconst app = new App({\n  target: document.getElementById('app'),\n  props: {\n    name: 'world',\n  },\n});\n\nexport default app;\n"
  },
  {
    "path": "examples/snippets/src/phases-2/App.svelte",
    "content": "<script>\n  import Player from './Player.svelte';\n</script>\n\n<style>\n  #board {\n    width: 100%;\n  }\n\n  .container {\n    display: flex;\n    flex-direction: row;\n    justify-content: space-evenly;\n  }\n</style>\n\n<div>\n  <div id=\"board\">\n    <Player />\n  </div>\n  <div class=\"container\">\n    <Player playerID=\"0\" />\n    <Player playerID=\"1\" />\n    <Player playerID=\"2\" />\n  </div>\n</div>\n"
  },
  {
    "path": "examples/snippets/src/phases-2/Player.svelte",
    "content": "<script>\n  export let playerID = null;\n\n  import { Client } from 'boardgame.io/client';\n  import { Local } from 'boardgame.io/multiplayer';\n  import Game from './game';\n\n  const client = Client({\n    game: Game,\n    matchID: 'default',\n    playerID,\n    debug: false,\n    numPlayers: 3,\n    multiplayer: Local(),\n  });\n\n  client.start();\n</script>\n\n<style>\n  .phase {\n    font-size: 1.2em;\n    margin-top: 20px;\n    color: #aaa;\n  }\n\n  .deck {\n    font-family: monospace;\n    width: 40px;\n    height: 60px;\n    margin-left: auto;\n    margin-right: auto;\n    border: 1px solid #ddd;\n    padding: 20px;\n    text-align: center;\n    border-radius: 5px;\n    margin-bottom: 50px;\n  }\n\n  .client {\n    border-radius: 5px;\n    width: 100px;\n    border: 1px solid #ddd;\n    background: #fafafa;\n    opacity: .8;\n  }\n\n  .client.active {\n    box-shadow: 0 0 5px #aaa;\n    background: #fff;\n    opacity: 1;\n  }\n\n  .client li {\n    list-style: none;\n    padding: 5px;\n    height: 30px;\n    line-height: 30px;\n    text-align: center;\n    font-family: monospace;\n  }\n</style>\n\n{#if !playerID}\n  <div class=\"deck\">\n    <div>{$client.G.deck}</div>\n    <div>cards</div>\n    <div class=\"phase\">{$client.ctx.phase}</div>\n  </div>\n{:else}\n  <div class=\"client\" class:active={$client.isActive}>\n    <li>\n      <strong>Player {playerID}</strong>\n    </li>\n    <li>{$client.G.hand[playerID]} cards</li>\n    <li>\n      <button on:click={client.moves.DrawCard}>Draw Card</button>\n    </li>\n    <li>\n      <button on:click={client.moves.PlayCard}>Play Card</button>\n    </li>\n  </div>\n{/if}\n"
  },
  {
    "path": "examples/snippets/src/phases-2/game.js",
    "content": "function DrawCard({ G, playerID }) {\n  G.deck--;\n  G.hand[playerID]++;\n}\n\nfunction PlayCard({ G, playerID }) {\n  G.deck++;\n  G.hand[playerID]--;\n}\n\nconst game = {\n  setup: ({ ctx }) => ({ deck: 6, hand: Array(ctx.numPlayers).fill(0) }),\n  phases: {\n    draw: {\n      moves: { DrawCard },\n      endIf: ({ G }) => G.deck <= 0,\n      next: 'play',\n      start: true,\n    },\n\n    play: {\n      moves: { PlayCard },\n      endIf: ({ G }) => G.deck >= 6,\n    },\n  },\n  turn: { minMoves: 1, maxMoves: 1 },\n};\n\nexport default game;\n"
  },
  {
    "path": "examples/snippets/src/phases-2/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<body>\n  <div id=\"app\"></div>\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "examples/snippets/src/phases-2/index.js",
    "content": "import App from './App.svelte';\n\nconst app = new App({\n  target: document.getElementById('app'),\n  props: {\n    name: 'world',\n  },\n});\n\nexport default app;\n"
  },
  {
    "path": "examples/snippets/src/stages-1/App.svelte",
    "content": "<script>\n  import Player from './Player.svelte';\n</script>\n\n<style>\n  .container {\n    display: flex;\n    flex-direction: row;\n    justify-content: space-evenly;\n  }\n</style>\n\n<div>\n  <div class=\"container\">\n    <Player playerID=\"0\" />\n    <Player playerID=\"1\" />\n    <Player playerID=\"2\" />\n  </div>\n</div>\n"
  },
  {
    "path": "examples/snippets/src/stages-1/Player.svelte",
    "content": "<script>\n  export let playerID;\n\n  import { Client } from 'boardgame.io/client';\n  import { Local } from 'boardgame.io/multiplayer';\n  import Game from './game';\n\n  const client = Client({\n    game: Game,\n    matchID: 'default',\n    playerID,\n    debug: false,\n    numPlayers: 3,\n    multiplayer: Local(),\n  });\n\n  client.start();\n\n  $: discard = $client.ctx.activePlayers && $client.ctx.activePlayers[playerID] == 'discard';\n</script>\n\n<style>\n  .client {\n    border-radius: 5px;\n    width: 100px;\n    border: 1px solid #ddd;\n    background: #fafafa;\n    opacity: .8;\n  }\n\n  .client.active {\n    box-shadow: 0 0 5px #aaa;\n    background: #fff;\n    opacity: 1;\n  }\n\n  .client li {\n    list-style: none;\n    padding: 5px;\n    height: 30px;\n    line-height: 30px;\n    text-align: center;\n    font-family: monospace;\n  }\n</style>\n\n<div class=\"client\" class:active={$client.isActive}>\n  <li>\n    <strong>Player {playerID}</strong>\n  </li>\n\n  {#if $client.isActive}\n    <li>\n    {#if discard}\n      <button on:click={() => client.moves.discard()}>Discard</button>\n    {:else}\n      <button on:click={() => client.moves.militia()}>Play Card</button>\n    {/if}\n    </li>\n  <li>\n    <button on:click={() => client.events.endTurn()}>End Turn</button>\n  </li>\n  {/if}\n</div>\n"
  },
  {
    "path": "examples/snippets/src/stages-1/game.js",
    "content": "function militia({ G, events }) {\n  events.setActivePlayers({ others: 'discard', minMoves: 1, maxMoves: 1 });\n}\n\nfunction discard({ G, ctx }) {}\n\nconst game = {\n  moves: { militia },\n  turn: {\n    stages: {\n      discard: {\n        moves: { discard },\n      },\n    },\n  },\n};\n\nexport default game;\n"
  },
  {
    "path": "examples/snippets/src/stages-1/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<body>\n  <div id=\"app\"></div>\n  <script type=\"text/javascript\" src=\"./index.js\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "examples/snippets/src/stages-1/index.js",
    "content": "import App from './App.svelte';\n\nconst app = new App({\n  target: document.getElementById('app'),\n  props: {\n    name: 'world',\n  },\n});\n\nexport default app;\n"
  },
  {
    "path": "integration/.gitignore",
    "content": "build/\npackage-lock.json\n"
  },
  {
    "path": "integration/README.md",
    "content": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).\n\nBelow you will find some information on how to perform common tasks.<br>\nYou can find the most recent version of this guide [here](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md).\n\n## Table of Contents\n\n* [Updating to New Releases](#updating-to-new-releases)\n* [Sending Feedback](#sending-feedback)\n* [Folder Structure](#folder-structure)\n* [Available Scripts](#available-scripts)\n  * [npm start](#npm-start)\n  * [npm test](#npm-test)\n  * [npm run build](#npm-run-build)\n  * [npm run eject](#npm-run-eject)\n* [Supported Browsers](#supported-browsers)\n* [Supported Language Features](#supported-language-features)\n* [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor)\n* [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)\n* [Debugging in the Editor](#debugging-in-the-editor)\n* [Formatting Code Automatically](#formatting-code-automatically)\n* [Changing the Page `<title>`](#changing-the-page-title)\n* [Installing a Dependency](#installing-a-dependency)\n* [Importing a Component](#importing-a-component)\n* [Code Splitting](#code-splitting)\n* [Adding a Stylesheet](#adding-a-stylesheet)\n* [Adding a CSS Modules Stylesheet](#adding-a-css-modules-stylesheet)\n* [Adding a Sass Stylesheet](#adding-a-sass-stylesheet)\n* [Post-Processing CSS](#post-processing-css)\n* [Adding Images, Fonts, and Files](#adding-images-fonts-and-files)\n* [Adding SVGs](#adding-svgs)\n* [Using the `public` Folder](#using-the-public-folder)\n  * [Changing the HTML](#changing-the-html)\n  * [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)\n  * [When to Use the `public` Folder](#when-to-use-the-public-folder)\n* [Using Global Variables](#using-global-variables)\n* [Adding Bootstrap](#adding-bootstrap)\n  * [Using a Custom Theme](#using-a-custom-theme)\n* [Adding Flow](#adding-flow)\n* [Adding a Router](#adding-a-router)\n* [Adding Custom Environment Variables](#adding-custom-environment-variables)\n  * [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html)\n  * [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell)\n  * [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env)\n* [Can I Use Decorators?](#can-i-use-decorators)\n* [Fetching Data with AJAX Requests](#fetching-data-with-ajax-requests)\n* [Integrating with an API Backend](#integrating-with-an-api-backend)\n  * [Node](#node)\n  * [Ruby on Rails](#ruby-on-rails)\n* [Proxying API Requests in Development](#proxying-api-requests-in-development)\n  * [\"Invalid Host Header\" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy)\n  * [Configuring the Proxy Manually](#configuring-the-proxy-manually)\n* [Using HTTPS in Development](#using-https-in-development)\n* [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server)\n* [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files)\n* [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page)\n* [Running Tests](#running-tests)\n  * [Filename Conventions](#filename-conventions)\n  * [Command Line Interface](#command-line-interface)\n  * [Version Control Integration](#version-control-integration)\n  * [Writing Tests](#writing-tests)\n  * [Testing Components](#testing-components)\n  * [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries)\n  * [Initializing Test Environment](#initializing-test-environment)\n  * [Focusing and Excluding Tests](#focusing-and-excluding-tests)\n  * [Coverage Reporting](#coverage-reporting)\n  * [Continuous Integration](#continuous-integration)\n  * [Disabling jsdom](#disabling-jsdom)\n  * [Snapshot Testing](#snapshot-testing)\n  * [Editor Integration](#editor-integration)\n* [Debugging Tests](#debugging-tests)\n  * [Debugging Tests in Chrome](#debugging-tests-in-chrome)\n  * [Debugging Tests in Visual Studio Code](#debugging-tests-in-visual-studio-code)\n* [Developing Components in Isolation](#developing-components-in-isolation)\n  * [Getting Started with Storybook](#getting-started-with-storybook)\n  * [Getting Started with Styleguidist](#getting-started-with-styleguidist)\n* [Publishing Components to npm](#publishing-components-to-npm)\n* [Making a Progressive Web App](#making-a-progressive-web-app)\n  * [Why Opt-in?](#why-opt-in)\n  * [Offline-First Considerations](#offline-first-considerations)\n  * [Progressive Web App Metadata](#progressive-web-app-metadata)\n* [Analyzing the Bundle Size](#analyzing-the-bundle-size)\n* [Deployment](#deployment)\n  * [Static Server](#static-server)\n  * [Other Solutions](#other-solutions)\n  * [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing)\n  * [Building for Relative Paths](#building-for-relative-paths)\n  * [Customizing Environment Variables for Arbitrary Build Environments](#customizing-environment-variables-for-arbitrary-build-environments)\n  * [Azure](#azure)\n  * [Firebase](#firebase)\n  * [GitHub Pages](#github-pages)\n  * [Heroku](#heroku)\n  * [Netlify](#netlify)\n  * [Now](#now)\n  * [S3 and CloudFront](#s3-and-cloudfront)\n  * [Surge](#surge)\n* [Advanced Configuration](#advanced-configuration)\n* [Troubleshooting](#troubleshooting)\n  * [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes)\n  * [`npm test` hangs or crashes on macOS Sierra](#npm-test-hangs-or-crashes-on-macos-sierra)\n  * [`npm run build` exits too early](#npm-run-build-exits-too-early)\n  * [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)\n  * [`npm run build` fails to minify](#npm-run-build-fails-to-minify)\n  * [Moment.js locales are missing](#momentjs-locales-are-missing)\n* [Alternatives to Ejecting](#alternatives-to-ejecting)\n* [Something Missing?](#something-missing)\n\n## Updating to New Releases\n\nCreate React App is divided into two packages:\n\n* `create-react-app` is a global command-line utility that you use to create new projects.\n* `react-scripts` is a development dependency in the generated projects (including this one).\n\nYou almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`.\n\nWhen you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically.\n\nTo update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions.\n\nIn most cases bumping the `react-scripts` version in `package.json` and running `npm install` (or `yarn install`) in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes.\n\nWe commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly.\n\n## Sending Feedback\n\nWe are always open to [your feedback](https://github.com/facebook/create-react-app/issues).\n\n## Folder Structure\n\nAfter creation, your project should look like this:\n\n```\nmy-app/\n  README.md\n  node_modules/\n  package.json\n  public/\n    index.html\n    favicon.ico\n  src/\n    App.css\n    App.js\n    App.test.js\n    index.css\n    index.js\n    logo.svg\n```\n\nFor the project to build, **these files must exist with exact filenames**:\n\n* `public/index.html` is the page template;\n* `src/index.js` is the JavaScript entry point.\n\nYou can delete or rename the other files.\n\nYou may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br>\nYou need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them.\n\nOnly files inside `public` can be used from `public/index.html`.<br>\nRead instructions below for using assets from JavaScript and HTML.\n\nYou can, however, create more top-level directories.<br>\nThey will not be included in the production build so you can use them for things like documentation.\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app in the development mode.<br>\nOpen [http://localhost:3000](http://localhost:3000) to view it in the browser.\n\nThe page will reload if you make edits.<br>\nYou will also see any lint errors in the console.\n\n### `npm test`\n\nLaunches the test runner in the interactive watch mode.<br>\nSee the section about [running tests](#running-tests) for more information.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.<br>\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.<br>\nYour app is ready to be deployed!\n\nSee the section about [deployment](#deployment) for more information.\n\n### `npm run eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can’t go back!**\n\nIf you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.\n\nYou don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.\n\n## Supported Browsers\n\nBy default, the generated project supports all modern browsers.<br>\nSupport for Internet Explorer 9, 10, and 11 requires [polyfills](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md).\n\n### Supported Language Features\n\nThis project supports a superset of the latest JavaScript standard.<br>\nIn addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports:\n\n* [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016).\n* [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017).\n* [Object Rest/Spread Properties](https://github.com/tc39/proposal-object-rest-spread) (ES2018).\n* [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal)\n* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal).\n* [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flow.org/) syntax.\n\nLearn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-).\n\nWhile we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future.\n\nNote that **this project includes no [polyfills](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md)** by default.\n\nIf you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are [including the appropriate polyfills manually](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md), or that the browsers you are targeting already support them.\n\n## Syntax Highlighting in the Editor\n\nTo configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered.\n\n## Displaying Lint Output in the Editor\n\n> Note: this feature is available with `react-scripts@0.2.0` and higher.<br>\n> It also only works with npm 3 or higher.\n\nSome editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint.\n\nThey are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do.\n\nYou would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root:\n\n```js\n{\n  \"extends\": \"react-app\"\n}\n```\n\nNow your editor should report the linting warnings.\n\nNote that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes.\n\nIf you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules.\n\n## Debugging in the Editor\n\n**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).**\n\nVisual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools.\n\n### Visual Studio Code\n\nYou would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed.\n\nThen add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory.\n\n```json\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"name\": \"Chrome\",\n      \"type\": \"chrome\",\n      \"request\": \"launch\",\n      \"url\": \"http://localhost:3000\",\n      \"webRoot\": \"${workspaceRoot}/src\",\n      \"sourceMapPathOverrides\": {\n        \"webpack:///src/*\": \"${webRoot}/*\"\n      }\n    }\n  ]\n}\n```\n\n> Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration).\n\nStart your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor.\n\nHaving problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting).\n\n### WebStorm\n\nYou would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed.\n\nIn the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration.\n\n> Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration).\n\nStart your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm.\n\nThe same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine.\n\n## Formatting Code Automatically\n\nPrettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/).\n\nTo format our code whenever we make a commit in git, we need to install the following dependencies:\n\n```sh\nnpm install --save husky lint-staged prettier\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add husky lint-staged prettier\n```\n\n* `husky` makes it easy to use githooks as if they are npm scripts.\n* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8).\n* `prettier` is the JavaScript formatter we will run before commits.\n\nNow we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root.\n\nAdd the following field to the `package.json` section:\n\n```diff\n+  \"husky\": {\n+    \"hooks\": {\n+      \"pre-commit\": \"lint-staged\"\n+    }\n+  }\n```\n\nNext we add a 'lint-staged' field to the `package.json`, for example:\n\n```diff\n  \"dependencies\": {\n    // ...\n  },\n+ \"lint-staged\": {\n+   \"src/**/*.{js,jsx,json,css}\": [\n+     \"prettier --single-quote --write\",\n+     \"git add\"\n+   ]\n+ },\n  \"scripts\": {\n```\n\nNow, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write \"src/**/*.{js,jsx}\"` to format your entire project for the first time.\n\nNext you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://prettier.io/docs/en/editors.html) on the Prettier GitHub page.\n\n## Changing the Page `<title>`\n\nYou can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else.\n\nNote that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML.\n\nIf you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library.\n\nIf you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files).\n\n## Installing a Dependency\n\nThe generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`:\n\n```sh\nnpm install --save react-router-dom\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-router-dom\n```\n\nThis works for any library, not just `react-router-dom`.\n\n## Importing a Component\n\nThis project setup supports ES6 modules thanks to Webpack.<br>\nWhile you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead.\n\nFor example:\n\n### `Button.js`\n\n```js\nimport React, { Component } from 'react';\n\nclass Button extends Component {\n  render() {\n    // ...\n  }\n}\n\nexport default Button; // Don’t forget to use export default!\n```\n\n### `DangerButton.js`\n\n```js\nimport React, { Component } from 'react';\nimport Button from './Button'; // Import a component from another file\n\nclass DangerButton extends Component {\n  render() {\n    return <Button color=\"red\" />;\n  }\n}\n\nexport default DangerButton;\n```\n\nBe aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes.\n\nWe suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`.\n\nNamed exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like.\n\nLearn more about ES6 modules:\n\n* [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281)\n* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html)\n* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules)\n\n## Code Splitting\n\nInstead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand.\n\nThis project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module.\n\nHere is an example:\n\n### `moduleA.js`\n\n```js\nconst moduleA = 'Hello';\n\nexport { moduleA };\n```\n\n### `App.js`\n\n```js\nimport React, { Component } from 'react';\n\nclass App extends Component {\n  handleClick = () => {\n    import('./moduleA')\n      .then(({ moduleA }) => {\n        // Use moduleA\n      })\n      .catch(err => {\n        // Handle failure\n      });\n  };\n\n  render() {\n    return (\n      <div>\n        <button onClick={this.handleClick}>Load</button>\n      </div>\n    );\n  }\n}\n\nexport default App;\n```\n\nThis will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button.\n\nYou can also use it with `async` / `await` syntax if you prefer it.\n\n### With React Router\n\nIf you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app).\n\nAlso check out the [Code Splitting](https://reactjs.org/docs/code-splitting.html) section in React documentation.\n\n## Adding a Stylesheet\n\nThis project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:\n\n### `Button.css`\n\n```css\n.Button {\n  padding: 20px;\n}\n```\n\n### `Button.js`\n\n```js\nimport React, { Component } from 'react';\nimport './Button.css'; // Tell Webpack that Button.js uses these styles\n\nclass Button extends Component {\n  render() {\n    // You can use them as regular CSS styles\n    return <div className=\"Button\" />;\n  }\n}\n```\n\n**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-blog/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack.\n\nIn development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output.\n\nIf you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool.\n\n## Adding a CSS Modules Stylesheet\n\n> Note: this feature is available with `react-scripts@2.0.0` and higher.\n\nThis project supports [CSS Modules](https://github.com/css-modules/css-modules) alongside regular stylesheets using the `[name].module.css` file naming convention. CSS Modules allows the scoping of CSS by automatically creating a unique classname of the format `[filename]\\_[classname]\\_\\_[hash]`.\n\n> **Tip:** Should you want to preprocess a stylesheet with Sass then make sure to [follow the installation instructions](#adding-a-sass-stylesheet) and then change the stylesheet file extension as follows: `[name].module.scss` or `[name].module.sass`.\n\nCSS Modules let you use the same CSS class name in different files without worrying about naming clashes. Learn more about CSS Modules [here](https://css-tricks.com/css-modules-part-1-need/).\n\n### `Button.module.css`\n\n```css\n.error {\n  background-color: red;\n}\n```\n\n### `another-stylesheet.css`\n\n```css\n.error {\n  color: red;\n}\n```\n\n### `Button.js`\n\n```js\nimport React, { Component } from 'react';\nimport styles from './Button.module.css'; // Import css modules stylesheet as styles\nimport './another-stylesheet.css'; // Import regular stylesheet\n\nclass Button extends Component {\n  render() {\n    // reference as a js object\n    return <button className={styles.error}>Error Button</button>;\n  }\n}\n```\n\n### Result\n\nNo clashes from other `.error` class names\n\n```html\n<!-- This button has red background but not red text -->\n<button class=\"Button_error_ax7yz\"></div>\n```\n\n**This is an optional feature.** Regular `<link>` stylesheets and CSS files are fully supported. CSS Modules are turned on for files ending with the `.module.css` extension.\n\n## Adding a Sass Stylesheet\n\n> Note: this feature is available with `react-scripts@2.0.0` and higher.\n\nGenerally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)).\n\nFollowing this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable.\n\nTo use Sass, first install `node-sass`:\n\n```bash\n$ npm install node-sass --save\n$ # or\n$ yarn add node-sass\n```\n\nNow you can rename `src/App.css` to `src/App.scss` and update `src/App.js` to import `src/App.scss`.\nThis file and any other file will be automatically compiled if imported with the extension `.scss` or `.sass`.\n\nTo share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import \"./shared.scss\";` with variable definitions.\n\nThis will allow you to do imports like\n\n```scss\n@import 'styles/_colors.scss'; // assuming a styles directory under src/\n@import '~nprogress/nprogress'; // importing a css file from the nprogress node module\n```\n\n> **Tip:** You can opt into using this feature with [CSS modules](#adding-a-css-modules-stylesheet) too!\n\n> **Note:** You must prefix imports from `node_modules` with `~` as displayed above.\n\n## Post-Processing CSS\n\nThis project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it.\n\nSupport for new CSS features like the [`all` property](https://developer.mozilla.org/en-US/docs/Web/CSS/all), [`break` properties](https://www.w3.org/TR/css-break-3/#breaking-controls), [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables), and [media query ranges](https://www.w3.org/TR/mediaqueries-4/#range-context) are automatically polyfilled to add support for older browsers.\n\nYou can customize your target support browsers by adjusting the `browserslist` key in `package.json` accoring to the [Browserslist specification](https://github.com/browserslist/browserslist#readme).\n\nFor example, this:\n\n```css\n.App {\n  display: flex;\n  flex-direction: row;\n  align-items: center;\n}\n```\n\nbecomes this:\n\n```css\n.App {\n  display: -webkit-box;\n  display: -ms-flexbox;\n  display: flex;\n  -webkit-box-orient: horizontal;\n  -webkit-box-direction: normal;\n  -ms-flex-direction: row;\n  flex-direction: row;\n  -webkit-box-align: center;\n  -ms-flex-align: center;\n  align-items: center;\n}\n```\n\nIf you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling).\n\n[CSS Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) prefixing is disabled by default, but it will **not** strip manual prefixing.\nIf you'd like to opt-in to CSS Grid prefixing, [first familiarize yourself about its limitations](https://github.com/postcss/autoprefixer#does-autoprefixer-polyfill-grid-layout-for-ie).<br>\nTo enable CSS Grid prefixing, add `/* autoprefixer grid: on */` to the top of your CSS file.\n\n## Adding Images, Fonts, and Files\n\nWith Webpack, using static assets like images and fonts works similarly to CSS.\n\nYou can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF.\n\nTo reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebook/create-react-app/issues/1153).\n\nHere is an example:\n\n```js\nimport React from 'react';\nimport logo from './logo.png'; // Tell Webpack this JS file uses this image\n\nconsole.log(logo); // /logo.84287d09.png\n\nfunction Header() {\n  // Import result is the URL of your image\n  return <img src={logo} alt=\"Logo\" />;\n}\n\nexport default Header;\n```\n\nThis ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths.\n\nThis works in CSS too:\n\n```css\n.Logo {\n  background-image: url(./logo.png);\n}\n```\n\nWebpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets.\n\nPlease be advised that this is also a custom feature of Webpack.\n\n**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br>\nAn alternative way of handling static assets is described in the next section.\n\n### Adding SVGs\n\n> Note: this feature is available with `react-scripts@2.0.0` and higher.\n\nOne way to add SVG files was described in the section above. You can also import SVGs directly as React components. You can use either of the two approaches. In your code it would look like this:\n\n```js\nimport { ReactComponent as Logo } from './logo.svg';\nconst App = () => (\n  <div>\n    {/* Logo is an actual React component */}\n    <Logo />\n  </div>\n);\n```\n\nThis is handy if you don't want to load SVG as a separate file. Don't forget the curly braces in the import! The `ReactComponent` import name is special and tells Create React App that you want a React component that renders an SVG, rather than its filename.\n\n## Using the `public` Folder\n\n> Note: this feature is available with `react-scripts@0.5.0` and higher.\n\n### Changing the HTML\n\nThe `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title).\nThe `<script>` tag with the compiled code will be added to it automatically during the build process.\n\n### Adding Assets Outside of the Module System\n\nYou can also add other assets to the `public` folder.\n\nNote that we normally encourage you to `import` assets in JavaScript files instead.\nFor example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files).\nThis mechanism provides a number of benefits:\n\n* Scripts and stylesheets get minified and bundled together to avoid extra network requests.\n* Missing files cause compilation errors instead of 404 errors for your users.\n* Result filenames include content hashes so you don’t need to worry about browsers caching their old versions.\n\nHowever there is an **escape hatch** that you can use to add an asset outside of the module system.\n\nIf you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`.\n\nInside `index.html`, you can use it like this:\n\n```html\n<link rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\">\n```\n\nOnly files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build.\n\nWhen you run `npm run build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL.\n\nIn JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes:\n\n```js\nrender() {\n  // Note: this is an escape hatch and should be used sparingly!\n  // Normally we recommend using `import` for getting asset URLs\n  // as described in “Adding Images and Fonts” above this section.\n  return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />;\n}\n```\n\nKeep in mind the downsides of this approach:\n\n* None of the files in `public` folder get post-processed or minified.\n* Missing files will not be called at compilation time, and will cause 404 errors for your users.\n* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change.\n\n### When to Use the `public` Folder\n\nNormally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript.\nThe `public` folder is useful as a workaround for a number of less common cases:\n\n* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest).\n* You have thousands of images and need to dynamically reference their paths.\n* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code.\n* Some library may be incompatible with Webpack and you have no other option but to include it as a `<script>` tag.\n\nNote that if you add a `<script>` that declares global variables, you also need to read the next section on using them.\n\n## Using Global Variables\n\nWhen you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable.\n\nYou can avoid this by reading the global variable explicitly from the `window` object, for example:\n\n```js\nconst $ = window.$;\n```\n\nThis makes it obvious you are using a global variable intentionally rather than because of a typo.\n\nAlternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it.\n\n## Adding Bootstrap\n\nYou don’t have to use [reactstrap](https://reactstrap.github.io/) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps:\n\nInstall reactstrap and Bootstrap from npm. reactstrap does not include Bootstrap CSS so this needs to be installed as well:\n\n```sh\nnpm install --save reactstrap bootstrap@4\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add bootstrap@4 reactstrap\n```\n\nImport Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your `src/index.js` file:\n\n```js\nimport 'bootstrap/dist/css/bootstrap.css';\n// Put any other imports below so that CSS from your\n// components takes precedence over default styles.\n```\n\nImport required reactstrap components within `src/App.js` file or your custom component files:\n\n```js\nimport { Button } from 'reactstrap';\n```\n\nNow you are ready to use the imported reactstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/zx6658/d9f128cd57ca69e583ea2b5fea074238/raw/a56701c142d0c622eb6c20a457fbc01d708cb485/App.js) redone using reactstrap.\n\n### Using a Custom Theme\n\n> Note: this feature is available with `react-scripts@2.0.0` and higher.\n\nSometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).<br>\nAs of `react-scripts@2.0.0` you can import `.scss` files. This makes it possible to use a package's built-in Sass variables for global style preferences.\n\nTo customize Bootstrap, create a file called `src/custom.scss` (or similar) and import the Bootstrap source stylesheet. Add any overrides _before_ the imported file(s). You can reference [Bootstrap's documentation](http://getbootstrap.com/docs/4.1/getting-started/theming/#css-variables) for the names of the available variables.\n\n```scss\n// Override default variables before the import\n$body-bg: #000;\n\n// Import Bootstrap and its default variables\n@import '~bootstrap/scss/bootstrap.scss';\n```\n\n> **Note:** You must prefix imports from `node_modules` with `~` as displayed above.\n\nFinally, import the newly created `.scss` file instead of the default Bootstrap `.css` in the beginning of your `src/index.js` file, for example:\n\n```javascript\nimport './custom.scss';\n```\n\n## Adding Flow\n\nFlow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.\n\nRecent versions of [Flow](https://flow.org/) work with Create React App projects out of the box.\n\nTo add Flow to a Create React App project, follow these steps:\n\n1. Run `npm install --save flow-bin` (or `yarn add flow-bin`).\n2. Add `\"flow\": \"flow\"` to the `scripts` section of your `package.json`.\n3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flow.org/en/docs/config/) in the root directory.\n4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`).\n\nNow you can run `npm run flow` (or `yarn flow`) to check the files for type errors.\nYou can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience.\nIn the future we plan to integrate it into Create React App even more closely.\n\nTo learn more about Flow, check out [its documentation](https://flow.org/).\n\n## Adding a Router\n\nCreate React App doesn't prescribe a specific routing solution, but [React Router](https://reacttraining.com/react-router/web/) is the most popular one.\n\nTo add it, run:\n\n```sh\nnpm install --save react-router-dom\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-router-dom\n```\n\nTo try it, delete all the code in `src/App.js` and replace it with any of the examples on its website. The [Basic Example](https://reacttraining.com/react-router/web/example/basic) is a good place to get started.\n\nNote that [you may need to configure your production server to support client-side routing](#serving-apps-with-client-side-routing) before deploying your app.\n\n## Adding Custom Environment Variables\n\n> Note: this feature is available with `react-scripts@0.2.3` and higher.\n\nYour project can consume variables declared in your environment as if they were declared locally in your JS files. By\ndefault you will have `NODE_ENV` defined for you, and any other environment variables starting with\n`REACT_APP_`.\n\n**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them.\n\n> Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebook/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running.\n\nThese environment variables will be defined for you on `process.env`. For example, having an environment\nvariable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`.\n\nThere is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production.\n\nThese environment variables can be useful for displaying information conditionally based on where the project is\ndeployed or consuming sensitive data that lives outside of version control.\n\nFirst, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined\nin the environment inside a `<form>`:\n\n```jsx\nrender() {\n  return (\n    <div>\n      <small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small>\n      <form>\n        <input type=\"hidden\" defaultValue={process.env.REACT_APP_SECRET_CODE} />\n      </form>\n    </div>\n  );\n}\n```\n\nDuring the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically.\n\nWhen you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`:\n\n```html\n<div>\n  <small>You are running this application in <b>development</b> mode.</small>\n  <form>\n    <input type=\"hidden\" value=\"abcdef\" />\n  </form>\n</div>\n```\n\nThe above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this\nvalue, we need to have it defined in the environment. This can be done using two ways: either in your shell or in\na `.env` file. Both of these ways are described in the next few sections.\n\nHaving access to the `NODE_ENV` is also useful for performing actions conditionally:\n\n```js\nif (process.env.NODE_ENV !== 'production') {\n  analytics.disable();\n}\n```\n\nWhen you compile the app with `npm run build`, the minification step will strip out this condition, and the resulting bundle will be smaller.\n\n### Referencing Environment Variables in the HTML\n\n> Note: this feature is available with `react-scripts@0.9.0` and higher.\n\nYou can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example:\n\n```html\n<title>%REACT_APP_WEBSITE_NAME%</title>\n```\n\nNote that the caveats from the above section apply:\n\n* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work.\n* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server).\n\n### Adding Temporary Environment Variables In Your Shell\n\nDefining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the\nlife of the shell session.\n\n#### Windows (cmd.exe)\n\n```cmd\nset \"REACT_APP_SECRET_CODE=abcdef\" && npm start\n```\n\n(Note: Quotes around the variable assignment are required to avoid a trailing whitespace.)\n\n#### Windows (Powershell)\n\n```Powershell\n($env:REACT_APP_SECRET_CODE = \"abcdef\") -and (npm start)\n```\n\n#### Linux, macOS (Bash)\n\n```bash\nREACT_APP_SECRET_CODE=abcdef npm start\n```\n\n### Adding Development Environment Variables In `.env`\n\n> Note: this feature is available with `react-scripts@0.5.0` and higher.\n\nTo define permanent environment variables, create a file called `.env` in the root of your project:\n\n```\nREACT_APP_SECRET_CODE=abcdef\n```\n\n> Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid [accidentally exposing a private key on the machine that could have the same name](https://github.com/facebook/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running.\n\n`.env` files **should be** checked into source control (with the exclusion of `.env*.local`).\n\n#### What other `.env` files can be used?\n\n> Note: this feature is **available with `react-scripts@1.0.0` and higher**.\n\n* `.env`: Default.\n* `.env.local`: Local overrides. **This file is loaded for all environments except test.**\n* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings.\n* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings.\n\nFiles on the left have more priority than files on the right:\n\n* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env`\n* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env`\n* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing)\n\nThese variables will act as the defaults if the machine does not explicitly set them.<br>\nPlease refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details.\n\n> Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need\n> these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars).\n\n#### Expanding Environment Variables In `.env`\n\n> Note: this feature is available with `react-scripts@1.1.0` and higher.\n\nExpand variables already on your machine for use in your `.env` file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)).\n\nFor example, to get the environment variable `npm_package_version`:\n\n```\nREACT_APP_VERSION=$npm_package_version\n# also works:\n# REACT_APP_VERSION=${npm_package_version}\n```\n\nOr expand variables local to the current `.env` file:\n\n```\nDOMAIN=www.example.com\nREACT_APP_FOO=$DOMAIN/foo\nREACT_APP_BAR=$DOMAIN/bar\n```\n\n## Can I Use Decorators?\n\nSome popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.<br>\nCreate React App intentionally doesn’t support decorator syntax at the moment because:\n\n* It is an experimental proposal and is subject to change (in fact, it has already changed once, and will change again).\n* Most libraries currently support only the old version of the proposal — which will never be a standard.\n\nHowever in many cases you can rewrite decorator-based code without decorators just as fine.<br>\nPlease refer to these two threads for reference:\n\n* [#214](https://github.com/facebook/create-react-app/issues/214)\n* [#411](https://github.com/facebook/create-react-app/issues/411)\n\nCreate React App will add decorator support when the specification advances to a stable stage.\n\n## Fetching Data with AJAX Requests\n\nReact doesn't prescribe a specific approach to data fetching, but people commonly use either a library like [axios](https://github.com/axios/axios) or the [`fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) provided by the browser.\n\nThe global `fetch` function allows you to easily make AJAX requests. It takes in a URL as an input and returns a `Promise` that resolves to a `Response` object. You can find more information about `fetch` [here](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).\n\nA Promise represents the eventual result of an asynchronous operation, you can find more information about Promises [here](https://www.promisejs.org/) and [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Both axios and `fetch()` use Promises under the hood. You can also use the [`async / await`](https://davidwalsh.name/async-await) syntax to reduce the callback nesting.\n\nMake sure the [`fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) are available in your target audience's browsers.\nFor example, support in Internet Explorer requires a [polyfill](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md).\n\nYou can learn more about making AJAX requests from React components in [the FAQ entry on the React website](https://reactjs.org/docs/faq-ajax.html).\n\n## Integrating with an API Backend\n\nThese tutorials will help you to integrate your app with an API backend running on another port,\nusing `fetch()` to access it.\n\n### Node\n\nCheck out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/).\nYou can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo).\n\n### Ruby on Rails\n\nCheck out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/).\nYou can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails).\n\n### API Platform (PHP and Symfony)\n\n[API Platform](https://api-platform.com) is a framework designed to build API-driven projects.\nIt allows to create hypermedia and GraphQL APIs in minutes.\nIt is shipped with an official Progressive Web App generator as well as a dynamic administration interface, both built for Create React App.\nCheck out [this tutorial](https://api-platform.com/docs/distribution).\n\n## Proxying API Requests in Development\n\n> Note: this feature is available with `react-scripts@0.2.3` and higher.\n\nPeople often serve the front-end React app from the same host and port as their backend implementation.<br>\nFor example, a production setup might look like this after the app is deployed:\n\n```\n/             - static server returns index.html with React app\n/todos        - static server returns index.html with React app\n/api/todos    - server handles any /api/* requests using the backend implementation\n```\n\nSuch setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development.\n\nTo tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example:\n\n```js\n  \"proxy\": \"http://localhost:4000\",\n```\n\nThis way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy.\n\nConveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development:\n\n```\nFetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.\n```\n\nKeep in mind that `proxy` only has effect in development (with `npm start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`.\n\nThe `proxy` option supports HTTP, HTTPS and WebSocket connections.<br>\nIf the `proxy` option is **not** flexible enough for you, alternatively you can:\n\n* [Configure the proxy yourself](#configuring-the-proxy-manually)\n* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)).\n* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app.\n\n### \"Invalid Host Header\" Errors After Configuring Proxy\n\nWhen you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887).\n\nThis shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebook/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option:\n\n> Invalid Host header\n\nTo work around it, you can specify your public development host in a file called `.env.development` in the root of your project:\n\n```\nHOST=mypublicdevhost.com\n```\n\nIf you restart the development server now and load the app from the specified host, it should work.\n\nIf you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:**\n\n```\n# NOTE: THIS IS DANGEROUS!\n# It exposes your machine to attacks from the websites you visit.\nDANGEROUSLY_DISABLE_HOST_CHECK=true\n```\n\nWe don’t recommend this approach.\n\n### Configuring the Proxy Manually\n\n> Note: this feature is available with `react-scripts@2.0.0` and higher.\n\nIf the `proxy` option is **not** flexible enough for you, you can get direct access to the Express app instance and hook up your own proxy middleware.\n\nYou can use this feature in conjunction with the `proxy` property in `package.json`, but it is recommended you consolidate all of your logic into `src/setupProxy.js`.\n\nFirst, install `http-proxy-middleware` using npm or Yarn:\n\n```bash\n$ npm install http-proxy-middleware --save\n$ # or\n$ yarn add http-proxy-middleware\n```\n\nNext, create `src/setupProxy.js` and place the following contents in it:\n\n```js\nconst proxy = require('http-proxy-middleware');\n\nmodule.exports = function(app) {\n  // ...\n};\n```\n\nYou can now register proxies as you wish! Here's an example using the above `http-proxy-middleware`:\n\n```js\nconst proxy = require('http-proxy-middleware');\n\nmodule.exports = function(app) {\n  app.use(proxy('/api', { target: 'http://localhost:5000/' }));\n};\n```\n\n> **Note:** You do not need to import this file anywhere. It is automatically registered when you start the development server.\n\n> **Note:** This file only supports Node's JavaScript syntax. Be sure to only use supported language features (i.e. no support for Flow, ES Modules, etc).\n\n## Using HTTPS in Development\n\n> Note: this feature is available with `react-scripts@0.4.0` and higher.\n\nYou may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the \"proxy\" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS.\n\nTo do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`:\n\n#### Windows (cmd.exe)\n\n```cmd\nset HTTPS=true&&npm start\n```\n\n(Note: the lack of whitespace is intentional.)\n\n#### Windows (Powershell)\n\n```Powershell\n($env:HTTPS = $true) -and (npm start)\n```\n\n#### Linux, macOS (Bash)\n\n```bash\nHTTPS=true npm start\n```\n\nNote that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page.\n\n## Generating Dynamic `<meta>` Tags on the Server\n\nSince Create React App doesn’t support server rendering, you might be wondering how to make `<meta>` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this:\n\n```html\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta property=\"og:title\" content=\"__OG_TITLE__\">\n    <meta property=\"og:description\" content=\"__OG_DESCRIPTION__\">\n```\n\nThen, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!\n\nIf you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases.\n\n## Pre-Rendering into Static HTML Files\n\nIf you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded.\n\nThere are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes.\n\nThe primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines.\n\nYou can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319).\n\n## Injecting Data from the Server into the Page\n\nSimilarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example:\n\n```js\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <script>\n      window.SERVER_DATA = __SERVER_DATA__;\n    </script>\n```\n\nThen, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.**\n\n## Running Tests\n\n> Note: this feature is available with `react-scripts@0.3.0` and higher.<br>\n\n> [Read the migration guide to learn how to enable it in older projects!](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030)\n\nCreate React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try.\n\nJest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness.\n\nWhile Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks.\n\nWe recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App.\n\n### Filename Conventions\n\nJest will look for test files with any of the following popular naming conventions:\n\n* Files with `.js` suffix in `__tests__` folders.\n* Files with `.test.js` suffix.\n* Files with `.spec.js` suffix.\n\nThe `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder.\n\nWe recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects.\n\n### Command Line Interface\n\nWhen you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code.\n\nThe watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run:\n\n![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif)\n\n### Version Control Integration\n\nBy default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests.\n\nJest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests.\n\nJest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository.\n\n### Writing Tests\n\nTo create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended.\n\nJest provides a built-in `expect()` global function for making assertions. A basic test could look like this:\n\n```js\nimport sum from './sum';\n\nit('sums numbers', () => {\n  expect(sum(1, 2)).toEqual(3);\n  expect(sum(2, 2)).toEqual(4);\n});\n```\n\nAll `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).<br>\nYou can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions.\n\n### Testing Components\n\nThere is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes.\n\nDifferent projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components:\n\n```js\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nit('renders without crashing', () => {\n  const div = document.createElement('div');\n  ReactDOM.render(<App />, div);\n});\n```\n\nThis test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot of value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`.\n\nWhen you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior.\n\nIf you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run:\n\n```sh\nnpm install --save enzyme enzyme-adapter-react-16 react-test-renderer\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add enzyme enzyme-adapter-react-16 react-test-renderer\n```\n\nAs of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.)\n\nThe adapter will also need to be configured in your [global setup file](#initializing-test-environment):\n\n#### `src/setupTests.js`\n\n```js\nimport { configure } from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\n\nconfigure({ adapter: new Adapter() });\n```\n\n> Note: Keep in mind that if you decide to \"eject\" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it. [Read here](#initializing-test-environment) to learn how to add this after ejecting.\n\nNow you can write a smoke test with it:\n\n```js\nimport React from 'react';\nimport { shallow } from 'enzyme';\nimport App from './App';\n\nit('renders without crashing', () => {\n  shallow(<App />);\n});\n```\n\nUnlike the previous smoke test using `ReactDOM.render()`, this test only renders `<App>` and doesn’t go deeper. For example, even if `<App>` itself renders a `<Button>` that throws, this test will pass. Shallow rendering is great for isolated unit tests, but you may still want to create some full rendering tests to ensure the components integrate correctly. Enzyme supports [full rendering with `mount()`](http://airbnb.io/enzyme/docs/api/mount.html), and you can also use it for testing state changes and component lifecycle.\n\nYou can read the [Enzyme documentation](http://airbnb.io/enzyme/) for more testing techniques. Enzyme documentation uses Chai and Sinon for assertions but you don’t have to use them because Jest provides built-in `expect()` and `jest.fn()` for spies.\n\nHere is an example from Enzyme documentation that asserts specific output, rewritten to use Jest matchers:\n\n```js\nimport React from 'react';\nimport { shallow } from 'enzyme';\nimport App from './App';\n\nit('renders welcome message', () => {\n  const wrapper = shallow(<App />);\n  const welcome = <h2>Welcome to React</h2>;\n  // expect(wrapper.contains(welcome)).toBe(true);\n  expect(wrapper.contains(welcome)).toEqual(true);\n});\n```\n\nAll Jest matchers are [extensively documented here](http://facebook.github.io/jest/docs/en/expect.html).<br>\nNevertheless you can use a third-party assertion library like [Chai](http://chaijs.com/) if you want to, as described below.\n\nAdditionally, you might find [jest-enzyme](https://github.com/blainekasten/enzyme-matchers) helpful to simplify your tests with readable matchers. The above `contains` code can be written more simply with jest-enzyme.\n\n```js\nexpect(wrapper).toContainReact(welcome);\n```\n\nTo enable this, install `jest-enzyme`:\n\n```sh\nnpm install --save jest-enzyme\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add jest-enzyme\n```\n\nImport it in [`src/setupTests.js`](#initializing-test-environment) to make its matchers available in every test:\n\n```js\nimport 'jest-enzyme';\n```\n\n### Using Third Party Assertion Libraries\n\nWe recommend that you use `expect()` for assertions and `jest.fn()` for spies. If you are having issues with them please [file those against Jest](https://github.com/facebook/jest/issues/new), and we’ll fix them. We intend to keep making them better for React, supporting, for example, [pretty-printing React elements as JSX](https://github.com/facebook/jest/pull/1566).\n\nHowever, if you are used to other libraries, such as [Chai](http://chaijs.com/) and [Sinon](http://sinonjs.org/), or if you have existing code using them that you’d like to port over, you can import them normally like this:\n\n```js\nimport sinon from 'sinon';\nimport { expect } from 'chai';\n```\n\nand then use them in your tests like you normally do.\n\n### Initializing Test Environment\n\n> Note: this feature is available with `react-scripts@0.4.0` and higher.\n\nIf your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.js` to your project. It will be automatically executed before running your tests.\n\nFor example:\n\n#### `src/setupTests.js`\n\n```js\nconst localStorageMock = {\n  getItem: jest.fn(),\n  setItem: jest.fn(),\n  clear: jest.fn(),\n};\nglobal.localStorage = localStorageMock;\n```\n\n> Note: Keep in mind that if you decide to \"eject\" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it, so you should manually create the property `setupTestFrameworkScriptFile` in the configuration for Jest, something like the following:\n\n> ```js\n> \"jest\": {\n>   // ...\n>   \"setupTestFrameworkScriptFile\": \"<rootDir>/src/setupTests.js\"\n>  }\n> ```\n\n### Focusing and Excluding Tests\n\nYou can replace `it()` with `xit()` to temporarily exclude a test from being executed.<br>\nSimilarly, `fit()` lets you focus on a specific test without running any other tests.\n\n### Coverage Reporting\n\nJest has an integrated coverage reporter that works well with ES6 and requires no configuration.<br>\nRun `npm test -- --coverage` (note extra `--` in the middle) to include a coverage report like this:\n\n![coverage report](http://i.imgur.com/5bFhnTS.png)\n\nNote that tests run much slower with coverage so it is recommended to run it separately from your normal workflow.\n\n#### Configuration\n\nThe default Jest coverage configuration can be overridden by adding any of the following supported keys to a Jest config in your package.json.\n\nSupported overrides:\n\n* [`collectCoverageFrom`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array)\n* [`coverageReporters`](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string)\n* [`coverageThreshold`](https://facebook.github.io/jest/docs/en/configuration.html#coveragethreshold-object)\n* [`snapshotSerializers`](https://facebook.github.io/jest/docs/en/configuration.html#snapshotserializers-array-string)\n\nExample package.json:\n\n```json\n{\n  \"name\": \"your-package\",\n  \"jest\": {\n    \"collectCoverageFrom\": [\n      \"src/**/*.{js,jsx}\",\n      \"!<rootDir>/node_modules/\",\n      \"!<rootDir>/path/to/dir/\"\n    ],\n    \"coverageThreshold\": {\n      \"global\": {\n        \"branches\": 90,\n        \"functions\": 90,\n        \"lines\": 90,\n        \"statements\": 90\n      }\n    },\n    \"coverageReporters\": [\"text\"],\n    \"snapshotSerializers\": [\"my-serializer-module\"]\n  }\n}\n```\n\n### Continuous Integration\n\nBy default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`.\n\nWhen creating a build of your application with `npm run build` linter warnings are not checked by default. Like `npm test`, you can force the build to perform a linter warning check by setting the environment variable `CI`. If any warnings are encountered then the build fails.\n\nPopular CI servers already set the environment variable `CI` by default but you can do this yourself too:\n\n### On CI servers\n\n#### Travis CI\n\n1. Following the [Travis Getting started](https://docs.travis-ci.com/user/getting-started/) guide for syncing your GitHub repository with Travis. You may need to initialize some settings manually in your [profile](https://travis-ci.org/profile) page.\n1. Add a `.travis.yml` file to your git repository.\n\n```\nlanguage: node_js\nnode_js:\n  - 8\ncache:\n  directories:\n    - node_modules\nscript:\n  - npm run build\n  - npm test\n```\n\n1. Trigger your first build with a git push.\n1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed.\n\n#### CircleCI\n\nFollow [this article](https://medium.com/@knowbody/circleci-and-zeits-now-sh-c9b7eebcd3c1) to set up CircleCI with a Create React App project.\n\n### On your own environment\n\n##### Windows (cmd.exe)\n\n```cmd\nset CI=true&&npm test\n```\n\n```cmd\nset CI=true&&npm run build\n```\n\n(Note: the lack of whitespace is intentional.)\n\n##### Windows (Powershell)\n\n```Powershell\n($env:CI = $true) -and (npm test)\n```\n\n```Powershell\n($env:CI = $true) -and (npm run build)\n```\n\n##### Linux, macOS (Bash)\n\n```bash\nCI=true npm test\n```\n\n```bash\nCI=true npm run build\n```\n\nThe test command will force Jest to run tests once instead of launching the watcher.\n\n> If you find yourself doing this often in development, please [file an issue](https://github.com/facebook/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows.\n\nThe build command will check for linter warnings and fail if any are found.\n\n### Disabling jsdom\n\nIf you know that none of your tests depend on [jsdom](https://github.com/tmpvar/jsdom), you can safely set `--env=node`, and your tests will run faster:\n\n```diff\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n-   \"test\": \"react-scripts test\"\n+   \"test\": \"react-scripts test --env=node\"\n```\n\nTo help you make up your mind, here is a list of APIs that **need jsdom**:\n\n* Any browser globals like `window` and `document`\n* [`ReactDOM.render()`](https://facebook.github.io/react/docs/top-level-api.html#reactdom.render)\n* [`TestUtils.renderIntoDocument()`](https://facebook.github.io/react/docs/test-utils.html#renderintodocument) ([a shortcut](https://github.com/facebook/react/blob/34761cf9a252964abfaab6faf74d473ad95d1f21/src/test/ReactTestUtils.js#L83-L91) for the above)\n* [`mount()`](http://airbnb.io/enzyme/docs/api/mount.html) in [Enzyme](http://airbnb.io/enzyme/index.html)\n\nIn contrast, **jsdom is not needed** for the following APIs:\n\n* [`TestUtils.createRenderer()`](https://facebook.github.io/react/docs/test-utils.html#shallow-rendering) (shallow rendering)\n* [`shallow()`](http://airbnb.io/enzyme/docs/api/shallow.html) in [Enzyme](http://airbnb.io/enzyme/index.html)\n\nFinally, jsdom is also not needed for [snapshot testing](http://facebook.github.io/jest/blog/2016/07/27/jest-14.html).\n\n### Snapshot Testing\n\nSnapshot testing is a feature of Jest that automatically generates text snapshots of your components and saves them on the disk so if the UI output changes, you get notified without manually writing any assertions on the component output. [Read more about snapshot testing.](http://facebook.github.io/jest/blog/2016/07/27/jest-14.html)\n\n### Editor Integration\n\nIf you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest extension](https://github.com/orta/vscode-jest) which works with Create React App out of the box. This provides a lot of IDE-like features while using a text editor: showing the status of a test run with potential fail messages inline, starting and stopping the watcher automatically, and offering one-click snapshot updates.\n\n![VS Code Jest Preview](https://cloud.githubusercontent.com/assets/49038/20795349/a032308a-b7c8-11e6-9b34-7eeac781003f.png)\n\n## Debugging Tests\n\nThere are various ways to setup a debugger for your Jest tests. We cover debugging in Chrome and [Visual Studio Code](https://code.visualstudio.com/).\n\n> Note: debugging tests requires Node 8 or higher.\n\n### Debugging Tests in Chrome\n\nAdd the following to the `scripts` section in your project's `package.json`\n\n```json\n\"scripts\": {\n    \"test:debug\": \"react-scripts --inspect-brk test --runInBand\"\n  }\n```\n\nPlace `debugger;` statements in any test and run:\n\n```bash\n$ npm run test:debug\n```\n\nThis will start running your Jest tests, but pause before executing to allow a debugger to attach to the process.\n\nOpen the following in Chrome\n\n```\nabout:inspect\n```\n\nAfter opening that link, the Chrome Developer Tools will be displayed. Select `inspect` on your process and a breakpoint will be set at the first line of the react script (this is done simply to give you time to open the developer tools and to prevent Jest from executing before you have time to do so). Click the button that looks like a \"play\" button in the upper right hand side of the screen to continue execution. When Jest executes the test that contains the debugger statement, execution will pause and you can examine the current scope and call stack.\n\n> Note: the --runInBand cli option makes sure Jest runs test in the same process rather than spawning processes for individual tests. Normally Jest parallelizes test runs across processes but it is hard to debug many processes at the same time.\n\n### Debugging Tests in Visual Studio Code\n\nDebugging Jest tests is supported out of the box for [Visual Studio Code](https://code.visualstudio.com).\n\nUse the following [`launch.json`](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) configuration file:\n\n```\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"name\": \"Debug CRA Tests\",\n      \"type\": \"node\",\n      \"request\": \"launch\",\n      \"runtimeExecutable\": \"${workspaceRoot}/node_modules/.bin/react-scripts\",\n      \"args\": [\n        \"test\",\n        \"--runInBand\",\n        \"--no-cache\"\n      ],\n      \"cwd\": \"${workspaceRoot}\",\n      \"protocol\": \"inspector\",\n      \"console\": \"integratedTerminal\",\n      \"internalConsoleOptions\": \"neverOpen\"\n    }\n  ]\n}\n```\n\n## Developing Components in Isolation\n\nUsually, in an app, you have a lot of UI components, and each of them has many different states.\nFor an example, a simple button component could have following states:\n\n* In a regular state, with a text label.\n* In the disabled mode.\n* In a loading state.\n\nUsually, it’s hard to see these states without running a sample app or some examples.\n\nCreate React App doesn’t include any tools for this by default, but you can easily add [Storybook for React](https://storybook.js.org) ([source](https://github.com/storybooks/storybook)) or [React Styleguidist](https://react-styleguidist.js.org/) ([source](https://github.com/styleguidist/react-styleguidist)) to your project. **These are third-party tools that let you develop components and see all their states in isolation from your app**.\n\n![Storybook for React Demo](http://i.imgur.com/7CIAWpB.gif)\n\nYou can also deploy your Storybook or style guide as a static app. This way, everyone in your team can view and review different states of UI components without starting a backend server or creating an account in your app.\n\n### Getting Started with Storybook\n\nStorybook is a development environment for React UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components.\n\nFirst, install the following npm package globally:\n\n```sh\nnpm install -g @storybook/cli\n```\n\nThen, run the following command inside your app’s directory:\n\n```sh\ngetstorybook\n```\n\nAfter that, follow the instructions on the screen.\n\nLearn more about React Storybook:\n\n* [Learn Storybook (tutorial)](https://learnstorybook.com)\n* [Documentation](https://storybook.js.org/basics/introduction/)\n* [GitHub Repo](https://github.com/storybooks/storybook)\n* [Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot\n\n### Getting Started with Styleguidist\n\nStyleguidist combines a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground.\n\nFirst, install Styleguidist:\n\n```sh\nnpm install --save react-styleguidist\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-styleguidist\n```\n\nThen, add these scripts to your `package.json`:\n\n```diff\n   \"scripts\": {\n+    \"styleguide\": \"styleguidist server\",\n+    \"styleguide:build\": \"styleguidist build\",\n     \"start\": \"react-scripts start\",\n```\n\nThen, run the following command inside your app’s directory:\n\n```sh\nnpm run styleguide\n```\n\nAfter that, follow the instructions on the screen.\n\nLearn more about React Styleguidist:\n\n* [GitHub Repo](https://github.com/styleguidist/react-styleguidist)\n* [Documentation](https://react-styleguidist.js.org/docs/getting-started.html)\n\n## Publishing Components to npm\n\nCreate React App doesn't provide any built-in functionality to publish a component to npm. If you're ready to extract a component from your project so other people can use it, we recommend moving it to a separate directory outside of your project and then using a tool like [nwb](https://github.com/insin/nwb#react-components-and-libraries) to prepare it for publishing.\n\n## Making a Progressive Web App\n\nThe production build has all the tools necessary to generate a first-class\n[Progressive Web App](https://developers.google.com/web/progressive-web-apps/),\nbut **the offline/cache-first behavior is opt-in only**. By default,\nthe build process will generate a service worker file, but it will not be\nregistered, so it will not take control of your production web app.\n\nIn order to opt-in to the offline-first behavior, developers should look for the\nfollowing in their [`src/index.js`](src/index.js) file:\n\n```js\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: http://bit.ly/CRA-PWA\nserviceWorker.unregister();\n```\n\nAs the comment states, switching `serviceWorker.unregister()` to\n`serviceWorker.register()` will opt you in to using the service worker.\n\n### Why Opt-in?\n\nOffline-first Progressive Web Apps are faster and more reliable than traditional web pages, and provide an engaging mobile experience:\n\n* All static site assets are cached so that your page loads fast on subsequent visits, regardless of network connectivity (such as 2G or 3G). Updates are downloaded in the background.\n* Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the subway.\n* On mobile devices, your app can be added directly to the user's home screen, app icon and all. This eliminates the need for the app store.\n\nHowever, they [can make debugging deployments more challenging](https://github.com/facebook/create-react-app/issues/2398) so, starting with Create React App 2, service workers are opt-in.\n\nThe [`workbox-webpack-plugin`](https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin)\nis integrated into production configuration,\nand it will take care of generating a service worker file that will automatically\nprecache all of your local assets and keep them up to date as you deploy updates.\nThe service worker will use a [cache-first strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network)\nfor handling all requests for local assets, including\n[navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests)\nfor your HTML, ensuring that your web app is consistently fast, even on a slow\nor unreliable network.\n\n### Offline-First Considerations\n\nIf you do decide to opt-in to service worker registration, please take the\nfollowing into account:\n\n1. Service workers [require HTTPS](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers#you_need_https),\n   although to facilitate local testing, that policy\n   [does not apply to `localhost`](http://stackoverflow.com/questions/34160509/options-for-testing-service-workers-via-http/34161385#34161385).\n   If your production web server does not support HTTPS, then the service worker\n   registration will fail, but the rest of your web app will remain functional.\n\n1. Service workers are [not supported](https://jakearchibald.github.io/isserviceworkerready/#moar)\n   in older web browsers. Service worker registration [won't be attempted](src/registerServiceWorker.js)\n   on browsers that lack support.\n\n1. The service worker is only enabled in the [production environment](#deployment),\n   e.g. the output of `npm run build`. It's recommended that you do not enable an\n   offline-first service worker in a development environment, as it can lead to\n   frustration when previously cached assets are used and do not include the latest\n   changes you've made locally.\n\n1. If you _need_ to test your offline-first service worker locally, build\n   the application (using `npm run build`) and run a simple http server from your\n   build directory. After running the build script, `create-react-app` will give\n   instructions for one way to test your production build locally and the [deployment instructions](#deployment) have\n   instructions for using other methods. _Be sure to always use an\n   incognito window to avoid complications with your browser cache._\n\n1. Users aren't always familiar with offline-first web apps. It can be useful to\n   [let the user know](https://developers.google.com/web/fundamentals/instant-and-offline/offline-ux#inform_the_user_when_the_app_is_ready_for_offline_consumption)\n   when the service worker has finished populating your caches (showing a \"This web\n   app works offline!\" message) and also let them know when the service worker has\n   fetched the latest updates that will be available the next time they load the\n   page (showing a \"New content is available; please refresh.\" message). Showing\n   this messages is currently left as an exercise to the developer, but as a\n   starting point, you can make use of the logic included in [`src/registerServiceWorker.js`](src/registerServiceWorker.js), which\n   demonstrates which service worker lifecycle events to listen for to detect each\n   scenario, and which as a default, just logs appropriate messages to the\n   JavaScript console.\n\n1. By default, the generated service worker file will not intercept or cache any\n   cross-origin traffic, like HTTP [API requests](#integrating-with-an-api-backend),\n   images, or embeds loaded from a different domain.\n\n### Progressive Web App Metadata\n\nThe default configuration includes a web app manifest located at\n[`public/manifest.json`](public/manifest.json), that you can customize with\ndetails specific to your web application.\n\nWhen a user adds a web app to their homescreen using Chrome or Firefox on\nAndroid, the metadata in [`manifest.json`](public/manifest.json) determines what\nicons, names, and branding colors to use when the web app is displayed.\n[The Web App Manifest guide](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/)\nprovides more context about what each field means, and how your customizations\nwill affect your users' experience.\n\nProgressive web apps that have been added to the homescreen will load faster and\nwork offline when there's an active service worker. That being said, the\nmetadata from the web app manifest will still be used regardless of whether or\nnot you opt-in to service worker registration.\n\n## Analyzing the Bundle Size\n\n[Source map explorer](https://www.npmjs.com/package/source-map-explorer) analyzes\nJavaScript bundles using the source maps. This helps you understand where code\nbloat is coming from.\n\nTo add Source map explorer to a Create React App project, follow these steps:\n\n```sh\nnpm install --save source-map-explorer\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add source-map-explorer\n```\n\nThen in `package.json`, add the following line to `scripts`:\n\n```diff\n   \"scripts\": {\n+    \"analyze\": \"source-map-explorer build/static/js/main.*\",\n     \"start\": \"react-scripts start\",\n     \"build\": \"react-scripts build\",\n     \"test\": \"react-scripts test\",\n```\n\nThen to analyze the bundle run the production build then run the analyze\nscript.\n\n```\nnpm run build\nnpm run analyze\n```\n\n## Deployment\n\n`npm run build` creates a `build` directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served `index.html`, and requests to static paths like `/static/js/main.<hash>.js` are served with the contents of the `/static/js/main.<hash>.js` file.\n\n### Static Server\n\nFor environments using [Node](https://nodejs.org/), the easiest way to handle this would be to install [serve](https://github.com/zeit/serve) and let it handle the rest:\n\n```sh\nnpm install -g serve\nserve -s build\n```\n\nThe last command shown above will serve your static site on the port **5000**. Like many of [serve](https://github.com/zeit/serve)’s internal settings, the port can be adjusted using the `-p` or `--port` flags.\n\nRun this command to get a full list of the options available:\n\n```sh\nserve -h\n```\n\n### Other Solutions\n\nYou don’t necessarily need a static server in order to run a Create React App project in production. It works just as fine integrated into an existing dynamic one.\n\nHere’s a programmatic example using [Node](https://nodejs.org/) and [Express](http://expressjs.com/):\n\n```javascript\nconst express = require('express');\nconst path = require('path');\nconst app = express();\n\napp.use(express.static(path.join(__dirname, 'build')));\n\napp.get('/', function(req, res) {\n  res.sendFile(path.join(__dirname, 'build', 'index.html'));\n});\n\napp.listen(9000);\n```\n\nThe choice of your server software isn’t important either. Since Create React App is completely platform-agnostic, there’s no need to explicitly use Node.\n\nThe `build` folder with static assets is the only output produced by Create React App.\n\nHowever this is not quite enough if you use client-side routing. Read the next section if you want to support URLs like `/todos/42` in your single-page app.\n\n### Serving Apps with Client-Side Routing\n\nIf you use routers that use the HTML5 [`pushState` history API](https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries) under the hood (for example, [React Router](https://github.com/ReactTraining/react-router) with `browserHistory`), many static file servers will fail. For example, if you used React Router with a route for `/todos/42`, the development server will respond to `localhost:3000/todos/42` properly, but an Express serving a production build as above will not.\n\nThis is because when there is a fresh page load for a `/todos/42`, the server looks for the file `build/todos/42` and does not find it. The server needs to be configured to respond to a request to `/todos/42` by serving `index.html`. For example, we can amend our Express example above to serve `index.html` for any unknown paths:\n\n```diff\n app.use(express.static(path.join(__dirname, 'build')));\n\n-app.get('/', function (req, res) {\n+app.get('/*', function (req, res) {\n   res.sendFile(path.join(__dirname, 'build', 'index.html'));\n });\n```\n\nIf you’re using [Apache HTTP Server](https://httpd.apache.org/), you need to create a `.htaccess` file in the `public` folder that looks like this:\n\n```\n    Options -MultiViews\n    RewriteEngine On\n    RewriteCond %{REQUEST_FILENAME} !-f\n    RewriteRule ^ index.html [QSA,L]\n```\n\nIt will get copied to the `build` folder when you run `npm run build`.\n\nIf you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow [this Stack Overflow answer](https://stackoverflow.com/a/41249464/4878474).\n\nNow requests to `/todos/42` will be handled correctly both in development and in production.\n\nOn a production build, and when you've [opted-in](#why-opt-in),\na [service worker](https://developers.google.com/web/fundamentals/primers/service-workers/) will automatically handle all navigation requests, like for\n`/todos/42`, by serving the cached copy of your `index.html`. This\nservice worker navigation routing can be configured or disabled by\n[`eject`ing](#npm-run-eject) and then modifying the\n[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string)\nand [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp)\noptions of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js).\n\nWhen users install your app to the homescreen of their device the default configuration will make a shortcut to `/index.html`. This may not work for client-side routers which expect the app to be served from `/`. Edit the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to match the required URL scheme, for example:\n\n```js\n  \"start_url\": \".\",\n```\n\n### Building for Relative Paths\n\nBy default, Create React App produces a build assuming your app is hosted at the server root.<br>\nTo override this, specify the `homepage` in your `package.json`, for example:\n\n```js\n  \"homepage\": \"http://mywebsite.com/relativepath\",\n```\n\nThis will let Create React App correctly infer the root path to use in the generated HTML file.\n\n**Note**: If you are using `react-router@^4`, you can root `<Link>`s using the `basename` prop on any `<Router>`.<br>\nMore information [here](https://reacttraining.com/react-router/web/api/BrowserRouter/basename-string).<br>\n<br>\nFor example:\n\n```js\n<BrowserRouter basename=\"/calendar\"/>\n<Link to=\"/today\"/> // renders <a href=\"/calendar/today\">\n```\n\n#### Serving the Same Build from Different Paths\n\n> Note: this feature is available with `react-scripts@0.9.0` and higher.\n\nIf you are not using the HTML5 `pushState` history API or not using client-side routing at all, it is unnecessary to specify the URL from which your app will be served. Instead, you can put this in your `package.json`:\n\n```js\n  \"homepage\": \".\",\n```\n\nThis will make sure that all the asset paths are relative to `index.html`. You will then be able to move your app from `http://mywebsite.com` to `http://mywebsite.com/relativepath` or even `http://mywebsite.com/relative/path` without having to rebuild it.\n\n### Customizing Environment Variables for Arbitrary Build Environments\n\nYou can create an arbitrary build environment by creating a custom `.env` file and loading it using [env-cmd](https://www.npmjs.com/package/env-cmd).\n\nFor example, to create a build environment for a staging environment:\n\n1. Create a file called `.env.staging`\n1. Set environment variables as you would any other `.env` file (e.g. `REACT_APP_API_URL=http://api-staging.example.com`)\n1. Install [env-cmd](https://www.npmjs.com/package/env-cmd)\n   ```sh\n   $ npm install env-cmd --save\n   $ # or\n   $ yarn add env-cmd\n   ```\n1. Add a new script to your `package.json`, building with your new environment:\n   ```json\n   {\n     \"scripts\": {\n       \"build:staging\": \"env-cmd .env.staging npm run build\"\n     }\n   }\n   ```\n\nNow you can run `npm run build:staging` to build with the staging environment config.\nYou can specify other environments in the same way.\n\nVariables in `.env.production` will be used as fallback because `NODE_ENV` will always be set to `production` for a build.\n\n### [Azure](https://azure.microsoft.com/)\n\nSee [this](https://medium.com/@to_pe/deploying-create-react-app-on-microsoft-azure-c0f6686a4321) blog post on how to deploy your React app to Microsoft Azure.\n\nSee [this](https://medium.com/@strid/host-create-react-app-on-azure-986bc40d5bf2#.pycfnafbg) blog post or [this](https://github.com/ulrikaugustsson/azure-appservice-static) repo for a way to use automatic deployment to Azure App Service.\n\n### [Firebase](https://firebase.google.com/)\n\nInstall the Firebase CLI if you haven’t already by running `npm install -g firebase-tools`. Sign up for a [Firebase account](https://console.firebase.google.com/) and create a new project. Run `firebase login` and login with your previous created Firebase account.\n\nThen run the `firebase init` command from your project’s root. You need to choose the **Hosting: Configure and deploy Firebase Hosting sites** and choose the Firebase project you created in the previous step. You will need to agree with `database.rules.json` being created, choose `build` as the public directory, and also agree to **Configure as a single-page app** by replying with `y`.\n\n```sh\n    === Project Setup\n\n    First, let's associate this project directory with a Firebase project.\n    You can create multiple project aliases by running firebase use --add,\n    but for now we'll just set up a default project.\n\n    ? What Firebase project do you want to associate as default? Example app (example-app-fd690)\n\n    === Database Setup\n\n    Firebase Realtime Database Rules allow you to define how your data should be\n    structured and when your data can be read from and written to.\n\n    ? What file should be used for Database Rules? database.rules.json\n    ✔  Database Rules for example-app-fd690 have been downloaded to database.rules.json.\n    Future modifications to database.rules.json will update Database Rules when you run\n    firebase deploy.\n\n    === Hosting Setup\n\n    Your public directory is the folder (relative to your project directory) that\n    will contain Hosting assets to uploaded with firebase deploy. If you\n    have a build process for your assets, use your build's output directory.\n\n    ? What do you want to use as your public directory? build\n    ? Configure as a single-page app (rewrite all urls to /index.html)? Yes\n    ✔  Wrote build/index.html\n\n    i  Writing configuration info to firebase.json...\n    i  Writing project information to .firebaserc...\n\n    ✔  Firebase initialization complete!\n```\n\nIMPORTANT: you need to set proper HTTP caching headers for `service-worker.js` file in `firebase.json` file or you will not be able to see changes after first deployment ([issue #2440](https://github.com/facebook/create-react-app/issues/2440)). It should be added inside `\"hosting\"` key like next:\n\n```\n{\n  \"hosting\": {\n    ...\n    \"headers\": [\n      {\"source\": \"/service-worker.js\", \"headers\": [{\"key\": \"Cache-Control\", \"value\": \"no-cache\"}]}\n    ]\n    ...\n```\n\nNow, after you create a production build with `npm run build`, you can deploy it by running `firebase deploy`.\n\n```sh\n    === Deploying to 'example-app-fd690'...\n\n    i  deploying database, hosting\n    ✔  database: rules ready to deploy.\n    i  hosting: preparing build directory for upload...\n    Uploading: [==============================          ] 75%✔  hosting: build folder uploaded successfully\n    ✔  hosting: 8 files uploaded successfully\n    i  starting release process (may take several minutes)...\n\n    ✔  Deploy complete!\n\n    Project Console: https://console.firebase.google.com/project/example-app-fd690/overview\n    Hosting URL: https://example-app-fd690.firebaseapp.com\n```\n\nFor more information see [Add Firebase to your JavaScript Project](https://firebase.google.com/docs/web/setup).\n\n### [GitHub Pages](https://pages.github.com/)\n\n> Note: this feature is available with `react-scripts@0.2.0` and higher.\n\n#### Step 1: Add `homepage` to `package.json`\n\n**The step below is important!**<br>\n**If you skip it, your app will not deploy correctly.**\n\nOpen your `package.json` and add a `homepage` field for your project:\n\n```json\n  \"homepage\": \"https://myusername.github.io/my-app\",\n```\n\nor for a GitHub user page:\n\n```json\n  \"homepage\": \"https://myusername.github.io\",\n```\n\nor for a custom domain page:\n\n```json\n  \"homepage\": \"https://mywebsite.com\",\n```\n\nCreate React App uses the `homepage` field to determine the root URL in the built HTML file.\n\n#### Step 2: Install `gh-pages` and add `deploy` to `scripts` in `package.json`\n\nNow, whenever you run `npm run build`, you will see a cheat sheet with instructions on how to deploy to GitHub Pages.\n\nTo publish it at [https://myusername.github.io/my-app](https://myusername.github.io/my-app), run:\n\n```sh\nnpm install --save gh-pages\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add gh-pages\n```\n\nAdd the following scripts in your `package.json`:\n\n```diff\n  \"scripts\": {\n+   \"predeploy\": \"npm run build\",\n+   \"deploy\": \"gh-pages -d build\",\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n```\n\nThe `predeploy` script will run automatically before `deploy` is run.\n\nIf you are deploying to a GitHub user page instead of a project page you'll need to make two\nadditional modifications:\n\n1. First, change your repository's source branch to be any branch other than **master**.\n1. Additionally, tweak your `package.json` scripts to push deployments to **master**:\n\n```diff\n  \"scripts\": {\n    \"predeploy\": \"npm run build\",\n-   \"deploy\": \"gh-pages -d build\",\n+   \"deploy\": \"gh-pages -b master -d build\",\n```\n\n#### Step 3: Deploy the site by running `npm run deploy`\n\nThen run:\n\n```sh\nnpm run deploy\n```\n\n#### Step 4: Ensure your project’s settings use `gh-pages`\n\nFinally, make sure **GitHub Pages** option in your GitHub project settings is set to use the `gh-pages` branch:\n\n<img src=\"http://i.imgur.com/HUjEr9l.png\" width=\"500\" alt=\"gh-pages branch setting\">\n\n#### Step 5: Optionally, configure the domain\n\nYou can configure a custom domain with GitHub Pages by adding a `CNAME` file to the `public/` folder.\n\nYour CNAME file should look like this:\n\n```\nmywebsite.com\n```\n\n#### Notes on client-side routing\n\nGitHub Pages doesn’t support routers that use the HTML5 `pushState` history API under the hood (for example, React Router using `browserHistory`). This is because when there is a fresh page load for a url like `http://user.github.io/todomvc/todos/42`, where `/todos/42` is a frontend route, the GitHub Pages server returns 404 because it knows nothing of `/todos/42`. If you want to add a router to a project hosted on GitHub Pages, here are a couple of solutions:\n\n* You could switch from using HTML5 history API to routing with hashes. If you use React Router, you can switch to `hashHistory` for this effect, but the URL will be longer and more verbose (for example, `http://user.github.io/todomvc/#/todos/42?_k=yknaj`). [Read more](https://reacttraining.com/react-router/web/api/Router) about different history implementations in React Router.\n* Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your `index.html` page with a special redirect parameter. You would need to add a `404.html` file with the redirection code to the `build` folder before deploying your project, and you’ll need to add code handling the redirect parameter to `index.html`. You can find a detailed explanation of this technique [in this guide](https://github.com/rafrex/spa-github-pages).\n\n#### Troubleshooting\n\n##### \"/dev/tty: No such a device or address\"\n\nIf, when deploying, you get `/dev/tty: No such a device or address` or a similar error, try the following:\n\n1. Create a new [Personal Access Token](https://github.com/settings/tokens)\n2. `git remote set-url origin https://<user>:<token>@github.com/<user>/<repo>` .\n3. Try `npm run deploy` again\n\n##### \"Cannot read property 'email' of null\"\n\nIf, when deploying, you get `Cannot read property 'email' of null`, try the following:\n\n1. `git config --global user.name '<your_name>'`\n2. `git config --global user.email '<your_email>'`\n3. Try `npm run deploy` again\n\n### [Heroku](https://www.heroku.com/)\n\nUse the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).<br>\nYou can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).\n\n#### Resolving Heroku Deployment Errors\n\nSometimes `npm run build` works locally but fails during deploy via Heroku. Following are the most common cases.\n\n##### \"Module not found: Error: Cannot resolve 'file' or 'directory'\"\n\nIf you get something like this:\n\n```\nremote: Failed to create a production build. Reason:\nremote: Module not found: Error: Cannot resolve 'file' or 'directory'\nMyDirectory in /tmp/build_1234/src\n```\n\nIt means you need to ensure that the lettercase of the file or directory you `import` matches the one you see on your filesystem or on GitHub.\n\nThis is important because Linux (the operating system used by Heroku) is case sensitive. So `MyDirectory` and `mydirectory` are two distinct directories and thus, even though the project builds locally, the difference in case breaks the `import` statements on Heroku remotes.\n\n##### \"Could not find a required file.\"\n\nIf you exclude or ignore necessary files from the package you will see a error similar this one:\n\n```\nremote: Could not find a required file.\nremote:   Name: `index.html`\nremote:   Searched in: /tmp/build_a2875fc163b209225122d68916f1d4df/public\nremote:\nremote: npm ERR! Linux 3.13.0-105-generic\nremote: npm ERR! argv \"/tmp/build_a2875fc163b209225122d68916f1d4df/.heroku/node/bin/node\" \"/tmp/build_a2875fc163b209225122d68916f1d4df/.heroku/node/bin/npm\" \"run\" \"build\"\n```\n\nIn this case, ensure that the file is there with the proper lettercase and that’s not ignored on your local `.gitignore` or `~/.gitignore_global`.\n\n### [Netlify](https://www.netlify.com/)\n\n**To do a manual deploy to Netlify’s CDN:**\n\n```sh\nnpm install netlify-cli -g\nnetlify deploy\n```\n\nChoose `build` as the path to deploy.\n\n**To setup continuous delivery:**\n\nWith this setup Netlify will build and deploy when you push to git or open a pull request:\n\n1. [Start a new netlify project](https://app.netlify.com/signup)\n2. Pick your Git hosting service and select your repository\n3. Click `Build your site`\n\n**Support for client-side routing:**\n\nTo support `pushState`, make sure to create a `public/_redirects` file with the following rewrite rules:\n\n```\n/*  /index.html  200\n```\n\nWhen you build the project, Create React App will place the `public` folder contents into the build output.\n\n### [Now](https://zeit.co/now)\n\nNow offers a zero-configuration single-command deployment. You can use `now` to deploy your app for free.\n\n1. Install the `now` command-line tool either via the recommended [desktop tool](https://zeit.co/download) or via node with `npm install -g now`.\n\n2. Build your app by running `npm run build`.\n\n3. Move into the build directory by running `cd build`.\n\n4. Run `now --name your-project-name` from within the build directory. You will see a **now.sh** URL in your output like this:\n\n   ```\n   > Ready! https://your-project-name-tpspyhtdtk.now.sh (copied to clipboard)\n   ```\n\n   Paste that URL into your browser when the build is complete, and you will see your deployed app.\n\nDetails are available in [this article.](https://zeit.co/blog/unlimited-static)\n\n### [S3](https://aws.amazon.com/s3) and [CloudFront](https://aws.amazon.com/cloudfront/)\n\nSee this [blog post](https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af) on how to deploy your React app to Amazon Web Services S3 and CloudFront.\n\n### [Surge](https://surge.sh/)\n\nInstall the Surge CLI if you haven’t already by running `npm install -g surge`. Run the `surge` command and log in you or create a new account.\n\nWhen asked about the project path, make sure to specify the `build` folder, for example:\n\n```sh\n       project path: /path/to/project/build\n```\n\nNote that in order to support routers that use HTML5 `pushState` API, you may want to rename the `index.html` in your build folder to `200.html` before deploying to Surge. This [ensures that every URL falls back to that file](https://surge.sh/help/adding-a-200-page-for-client-side-routing).\n\n## Advanced Configuration\n\nYou can adjust various development and production settings by setting environment variables in your shell or with [.env](#adding-development-environment-variables-in-env).\n\n| Variable            |      Development       |     Production     | Usage                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| :------------------ | :--------------------: | :----------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| BROWSER             |   :white_check_mark:   |        :x:         | By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a [browser](https://github.com/sindresorhus/opn#app) to override this behavior, or set it to `none` to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to `npm start` will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the `.js` extension.                                                                                                                                       |\n| HOST                |   :white_check_mark:   |        :x:         | By default, the development web server binds to `localhost`. You may use this variable to specify a different host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| PORT                |   :white_check_mark:   |        :x:         | By default, the development web server will attempt to listen on port 3000 or prompt you to attempt the next available port. You may use this variable to specify a different port.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| HTTPS               |   :white_check_mark:   |        :x:         | When set to `true`, Create React App will run the development server in `https` mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| PUBLIC_URL          |          :x:           | :white_check_mark: | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application.                                                                                                                                                                                                                                               |\n| CI                  | :large_orange_diamond: | :white_check_mark: | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| REACT_EDITOR        |   :white_check_mark:   |        :x:         | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebook/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](<https://en.wikipedia.org/wiki/PATH_(variable)>) environment variable points to your editor’s bin folder. You can also set it to `none` to disable it completely. |\n| CHOKIDAR_USEPOLLING |   :white_check_mark:   |        :x:         | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| GENERATE_SOURCEMAP  |          :x:           | :white_check_mark: | When set to `false`, source maps are not generated for a production build. This solves OOM issues on some smaller machines.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| NODE_PATH           |   :white_check_mark:   | :white_check_mark: | Same as [`NODE_PATH` in Node.js](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders), but only relative folders are allowed. Can be handy for emulating a monorepo setup by setting `NODE_PATH=src`.                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n\n## Troubleshooting\n\n### `npm start` doesn’t detect changes\n\nWhen you save a file while `npm start` is running, the browser should refresh with the updated code.<br>\nIf this doesn’t happen, try one of the following workarounds:\n\n* If your project is in a Dropbox folder, try moving it out.\n* If the watcher doesn’t see a file called `index.js` and you’re referencing it by the folder name, you [need to restart the watcher](https://github.com/facebook/create-react-app/issues/1164) due to a Webpack bug.\n* Some editors like Vim and IntelliJ have a “safe write” feature that currently breaks the watcher. You will need to disable it. Follow the instructions in [“Adjusting Your Text Editor”](https://webpack.js.org/guides/development/#adjusting-your-text-editor).\n* If your project path contains parentheses, try moving the project to a path without them. This is caused by a [Webpack watcher bug](https://github.com/webpack/watchpack/issues/42).\n* On Linux and macOS, you might need to [tweak system settings](https://github.com/webpack/docs/wiki/troubleshooting#not-enough-watchers) to allow more watchers.\n* If the project runs inside a virtual machine such as (a Vagrant provisioned) VirtualBox, create an `.env` file in your project directory if it doesn’t exist, and add `CHOKIDAR_USEPOLLING=true` to it. This ensures that the next time you run `npm start`, the watcher uses the polling mode, as necessary inside a VM.\n\nIf none of these solutions help please leave a comment [in this thread](https://github.com/facebook/create-react-app/issues/659).\n\n### `npm test` hangs or crashes on macOS Sierra\n\nIf you run `npm test` and the console gets stuck after printing `react-scripts test` to the console there might be a problem with your [Watchman](https://facebook.github.io/watchman/) installation as described in [facebook/create-react-app#713](https://github.com/facebook/create-react-app/issues/713).\n\nWe recommend deleting `node_modules` in your project and running `npm install` (or `yarn` if you use it) first. If it doesn't help, you can try one of the numerous workarounds mentioned in these issues:\n\n* [facebook/jest#1767](https://github.com/facebook/jest/issues/1767)\n* [facebook/watchman#358](https://github.com/facebook/watchman/issues/358)\n* [ember-cli/ember-cli#6259](https://github.com/ember-cli/ember-cli/issues/6259)\n\nIt is reported that installing Watchman 4.7.0 or newer fixes the issue. If you use [Homebrew](http://brew.sh/), you can run these commands to update it:\n\n```\nwatchman shutdown-server\nbrew update\nbrew reinstall watchman\n```\n\nYou can find [other installation methods](https://facebook.github.io/watchman/docs/install.html#build-install) on the Watchman documentation page.\n\nIf this still doesn’t help, try running `launchctl unload -F ~/Library/LaunchAgents/com.github.facebook.watchman.plist`.\n\nThere are also reports that _uninstalling_ Watchman fixes the issue. So if nothing else helps, remove it from your system and try again.\n\n### `npm run build` exits too early\n\nIt is reported that `npm run build` can fail on machines with limited memory and no swap space, which is common in cloud environments. Even with small projects this command can increase RAM usage in your system by hundreds of megabytes, so if you have less than 1 GB of available memory your build is likely to fail with the following message:\n\n> The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.\n\nIf you are completely sure that you didn't terminate the process, consider [adding some swap space](https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04) to the machine you’re building on, or build the project locally.\n\n### `npm run build` fails on Heroku\n\nThis may be a problem with case sensitive filenames.\nPlease refer to [this section](#resolving-heroku-deployment-errors).\n\n### Moment.js locales are missing\n\nIf you use a [Moment.js](https://momentjs.com/), you might notice that only the English locale is available by default. This is because the locale files are large, and you probably only need a subset of [all the locales provided by Moment.js](https://momentjs.com/#multiple-locale-support).\n\nTo add a specific Moment.js locale to your bundle, you need to import it explicitly.<br>\nFor example:\n\n```js\nimport moment from 'moment';\nimport 'moment/locale/fr';\n```\n\nIf you are importing multiple locales this way, you can later switch between them by calling `moment.locale()` with the locale name:\n\n```js\nimport moment from 'moment';\nimport 'moment/locale/fr';\nimport 'moment/locale/es';\n\n// ...\n\nmoment.locale('fr');\n```\n\nThis will only work for locales that have been explicitly imported before.\n\n### `npm run build` fails to minify\n\nBefore `react-scripts@2.0.0`, this problem was caused by third party `node_modules` using modern JavaScript features because the minifier couldn't handle them during the build. This has been solved by compiling standard modern JavaScript features inside `node_modules` in `react-scripts@2.0.0` and higher.\n\nIf you're seeing this error, you're likely using an old version of `react-scripts`. You can either fix it by avoiding a dependency that uses modern syntax, or by upgrading to `react-scripts@>=2.0.0` and following the migration instructions in the changelog.\n\n## Alternatives to Ejecting\n\n[Ejecting](#npm-run-eject) lets you customize anything, but from that point on you have to maintain the configuration and scripts yourself. This can be daunting if you have many similar projects. In such cases instead of ejecting we recommend to _fork_ `react-scripts` and any other packages you need. [This article](https://auth0.com/blog/how-to-configure-create-react-app/) dives into how to do it in depth. You can find more discussion in [this issue](https://github.com/facebook/create-react-app/issues/682).\n\n## Something Missing?\n\nIf you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebook/create-react-app/issues) or [contribute some!](https://github.com/facebook/create-react-app/edit/master/packages/react-scripts/template/README.md)\n"
  },
  {
    "path": "integration/package.json",
    "content": "{\n  \"name\": \"tic-tac-toe\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"react\": \"^16.7.0\",\n    \"react-dom\": \"^16.7.0\",\n    \"react-scripts\": \"^2.1.3\"\n  },\n  \"devDependencies\": {\n    \"cross-env\": \"^7.0.2\"\n  },\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n    \"test\": \"cross-env CI=true react-scripts test\",\n    \"eject\": \"react-scripts eject\"\n  },\n  \"eslintConfig\": {\n    \"extends\": \"react-app\"\n  },\n  \"browserslist\": [\n    \">0.2%\",\n    \"not dead\",\n    \"not ie <= 11\",\n    \"not op_mini all\"\n  ]\n}\n"
  },
  {
    "path": "integration/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <link rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n    <meta name=\"theme-color\" content=\"#000000\">\n    <!--\n      manifest.json provides metadata used when your web app is added to the\n      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/\n    -->\n    <link rel=\"manifest\" href=\"%PUBLIC_URL%/manifest.json\">\n    <!--\n      Notice the use of %PUBLIC_URL% in the tags above.\n      It will be replaced with the URL of the `public` folder during the build.\n      Only files inside the `public` folder can be referenced from the HTML.\n\n      Unlike \"/favicon.ico\" or \"favicon.ico\", \"%PUBLIC_URL%/favicon.ico\" will\n      work correctly both with client-side routing and a non-root public URL.\n      Learn how to configure a non-root public URL by running `npm run build`.\n    -->\n    <title>React App</title>\n  </head>\n  <body>\n    <noscript>\n      You need to enable JavaScript to run this app.\n    </noscript>\n    <div id=\"root\"></div>\n    <!--\n      This HTML file is a template.\n      If you open it directly in the browser, you will see an empty page.\n\n      You can add webfonts, meta tags, or analytics to this file.\n      The build step will place the bundled scripts into the <body> tag.\n\n      To begin the development, run `npm start` or `yarn start`.\n      To create a production bundle, use `npm run build` or `yarn build`.\n    -->\n  </body>\n</html>\n"
  },
  {
    "path": "integration/src/App.css",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n.App {\n  text-align: center;\n}\n\n.App-logo {\n  animation: App-logo-spin infinite 20s linear;\n  height: 40vmin;\n}\n\n.App-header {\n  background-color: #282c34;\n  min-height: 100vh;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  font-size: calc(10px + 2vmin);\n  color: white;\n}\n\n.App-link {\n  color: #61dafb;\n}\n\n@keyframes App-logo-spin {\n  from {\n    transform: rotate(0deg);\n  }\n  to {\n    transform: rotate(360deg);\n  }\n}\n"
  },
  {
    "path": "integration/src/App.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport { Client } from 'boardgame.io/react';\nimport TicTacToe from './game';\nimport Board from './board';\n\nconst App = Client({\n  game: TicTacToe,\n  board: Board,\n  debug: false,\n  ai: {\n    enumerate: G => {\n      let moves = [];\n      for (let i = 0; i < 9; i++) {\n        if (G.cells[i] === null) {\n          moves.push({ move: 'clickCell', args: [i] });\n        }\n      }\n      return moves;\n    },\n  },\n});\n\nconst Runner = () => (\n  <div style={{ padding: 50 }}>\n    <div className=\"runner\">\n      <App />\n    </div>\n  </div>\n);\n\nexport default Runner;\n"
  },
  {
    "path": "integration/src/App.test.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nit('renders without crashing', () => {\n  const div = document.createElement('div');\n  ReactDOM.render(<App />, div);\n});\n"
  },
  {
    "path": "integration/src/board.css",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n#board {\n  border-collapse: collapse;\n}\n\n#winner {\n  margin-top: 25px;\n  width: 168px;\n  text-align: center;\n}\n\ntd {\n  text-align: center;\n  font-weight: bold;\n  font-size: 25px;\n  color: #555;\n  width: 50px;\n  height: 50px;\n  line-height: 50px;\n  border: 3px solid #aaa;\n  background: #fff;\n}\n\ntd.active {\n  cursor: pointer;\n  background: #eeffe9;\n}\n\ntd.active:hover {\n  background: #eeffff;\n}\n"
  },
  {
    "path": "integration/src/board.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport './board.css';\n\nclass Board extends React.Component {\n  static propTypes = {\n    G: PropTypes.any.isRequired,\n    ctx: PropTypes.any.isRequired,\n    moves: PropTypes.any.isRequired,\n    playerID: PropTypes.string,\n    isActive: PropTypes.bool,\n    isMultiplayer: PropTypes.bool,\n    isConnected: PropTypes.bool,\n    isPreview: PropTypes.bool,\n  };\n\n  onClick = id => {\n    if (this.isActive(id)) {\n      this.props.moves.clickCell(id);\n    }\n  };\n\n  isActive(id) {\n    return this.props.isActive && this.props.G.cells[id] === null;\n  }\n\n  render() {\n    let tbody = [];\n    for (let i = 0; i < 3; i++) {\n      let cells = [];\n      for (let j = 0; j < 3; j++) {\n        const id = 3 * i + j;\n        cells.push(\n          <td\n            key={id}\n            className={this.isActive(id) ? 'active' : ''}\n            onClick={() => this.onClick(id)}\n          >\n            {this.props.G.cells[id]}\n          </td>\n        );\n      }\n      tbody.push(<tr key={i}>{cells}</tr>);\n    }\n\n    let disconnected = null;\n    if (this.props.isMultiplayer && !this.props.isConnected) {\n      disconnected = <div>Disconnected!</div>;\n    }\n\n    let winner = null;\n    if (this.props.ctx.gameover) {\n      winner =\n        this.props.ctx.gameover.winner !== undefined ? (\n          <div id=\"winner\">Winner: {this.props.ctx.gameover.winner}</div>\n        ) : (\n          <div id=\"winner\">Draw!</div>\n        );\n    }\n\n    let player = null;\n    if (this.props.playerID) {\n      player = <div id=\"player\">Player: {this.props.playerID}</div>;\n    }\n\n    if (this.props.isPreview) {\n      disconnected = player = null;\n    }\n\n    return (\n      <div>\n        <table id=\"board\">\n          <tbody>{tbody}</tbody>\n        </table>\n        {player}\n        {winner}\n        {disconnected}\n      </div>\n    );\n  }\n}\n\nexport default Board;\n"
  },
  {
    "path": "integration/src/game.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  for (let pos of positions) {\n    const symbol = cells[pos[0]];\n    let winner = symbol;\n    for (let i of pos) {\n      if (cells[i] !== symbol) {\n        winner = null;\n        break;\n      }\n    }\n    if (winner != null) return true;\n  }\n\n  return false;\n}\n\nconst TicTacToe = {\n  name: 'tic-tac-toe',\n\n  setup: () => ({\n    cells: Array(9).fill(null),\n  }),\n\n  moves: {\n    clickCell({ G, ctx }, id) {\n      const cells = [...G.cells];\n\n      if (cells[id] === null) {\n        cells[id] = ctx.currentPlayer;\n        return { ...G, cells };\n      }\n    },\n  },\n\n  turn: {\n    minMoves: 1,\n    maxMoves: 1,\n  },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n    if (G.cells.filter((c) => c === null).length === 0) {\n      return { draw: true };\n    }\n  },\n};\n\nexport default TicTacToe;\n"
  },
  {
    "path": "integration/src/index.css",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nbody {\n  margin: 0;\n  padding: 0;\n  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n    sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n    monospace;\n}\n"
  },
  {
    "path": "integration/src/index.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nReactDOM.render(<App />, document.getElementById('root'));\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"boardgame.io\",\n  \"version\": \"0.50.2\",\n  \"description\": \"library for turn-based games\",\n  \"repository\": \"https://github.com/boardgameio/boardgame.io\",\n  \"scripts\": {\n    \"prestart\": \"run-p examples:install build\",\n    \"start\": \"run-p dev:server dev:client\",\n    \"predev\": \"npm run examples:install\",\n    \"dev\": \"run-p build:watch dev:server dev:client\",\n    \"dev:client\": \"node scripts/dev-client.js\",\n    \"dev:server\": \"cross-env NODE_ENV=development nodemon -w src -w examples -e js,ts --exec babel-node --extensions \\\".ts,.js\\\" --ignore \\\"src/**/*.test.ts\\\" --presets @babel/preset-env examples/react-web/server.js\",\n    \"build\": \"cross-env BABEL_ENV=rollup rollup --config rollup.config.js  --silent\",\n    \"build:watch\": \"cross-env BABEL_ENV=rollup rollup -w --config rollup.config.js\",\n    \"benchmark\": \"babel-node --extensions .ts,.js --presets @babel/preset-env,@babel/preset-typescript benchmark/index.js\",\n    \"docs\": \"docsify serve docs\",\n    \"examples\": \"npm run start\",\n    \"examples:install\": \"node scripts/install-examples.js\",\n    \"pretest\": \"npm run lint\",\n    \"test\": \"cross-env NODE_ENV=test jest\",\n    \"test:watch\": \"npm test -- --watch\",\n    \"test:coverage\": \"npm test -- --coverage --collectCoverageFrom=\\\"src/**\\\"\",\n    \"test:coveralls\": \"coveralls < coverage/lcov.info\",\n    \"test:integration\": \"node ./scripts/integration.js\",\n    \"ts\": \"tsc --noEmit\",\n    \"ts:watch\": \"tsc --noEmit --watch\",\n    \"lint\": \"eslint .\",\n    \"lint:fix\": \"eslint --fix .\",\n    \"prepublishOnly\": \"npm run clean\",\n    \"proxydirs\": \"node scripts/proxy-dirs.js\",\n    \"prepack\": \"run-s build proxydirs\",\n    \"postpack\": \"npm run clean\",\n    \"prettier\": \"prettier --write \\\"{examples,src,benchmark}/**/*.{ts,tsx,js,jsx,css,md}\\\"\",\n    \"changelog\": \"node ./scripts/changelog.js\",\n    \"clean\": \"node ./scripts/clean.js\"\n  },\n  \"sideEffects\": false,\n  \"main\": \"dist/boardgameio.js\",\n  \"unpkg\": \"dist/boardgameio.min.js\",\n  \"module\": \"dist/boardgameio.es.js\",\n  \"types\": \"dist/types/src/types.d.ts\",\n  \"files\": [\n    \"src\",\n    \"dist/boardgameio.js\",\n    \"dist/boardgameio.min.js\",\n    \"dist/boardgameio.es.js\",\n    \"dist/esm\",\n    \"dist/cjs\",\n    \"dist/types\",\n    \"client\",\n    \"core\",\n    \"debug\",\n    \"react\",\n    \"react-native\",\n    \"server\",\n    \"ai\",\n    \"plugins\",\n    \"master\",\n    \"multiplayer\",\n    \"internal\",\n    \"testing\"\n  ],\n  \"keywords\": [\n    \"board games\",\n    \"card games\",\n    \"tabletop games\",\n    \"game engine\"\n  ],\n  \"engines\": {\n    \"node\": \">=10.0\",\n    \"npm\": \">=6.0\"\n  },\n  \"author\": \"nicolodavis@gmail.com\",\n  \"license\": \"MIT\",\n  \"funding\": [\n    \"https://github.com/boardgameio/boardgame.io?sponsor=1\",\n    {\n      \"type\": \"opencollective\",\n      \"url\": \"https://opencollective.com/boardgameio\"\n    }\n  ],\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.16.0\",\n    \"@babel/core\": \"^7.16.0\",\n    \"@babel/node\": \"^7.16.0\",\n    \"@babel/plugin-proposal-class-properties\": \"^7.16.0\",\n    \"@babel/plugin-proposal-object-rest-spread\": \"^7.16.0\",\n    \"@babel/plugin-transform-modules-commonjs\": \"^7.16.0\",\n    \"@babel/preset-env\": \"^7.16.0\",\n    \"@babel/preset-react\": \"^7.16.0\",\n    \"@babel/preset-typescript\": \"^7.16.0\",\n    \"@testing-library/jest-dom\": \"^5.14.1\",\n    \"@testing-library/svelte\": \"^3.0.3\",\n    \"@types/enzyme\": \"^3.10.9\",\n    \"@types/jest\": \"^27.0.1\",\n    \"@types/koa__cors\": \"^3.0.3\",\n    \"@types/node\": \"^14.0.24\",\n    \"@types/react\": \"^16.14.11\",\n    \"@types/react-dom\": \"^16.9.14\",\n    \"@types/supertest\": \"^2.0.11\",\n    \"@typescript-eslint/eslint-plugin\": \"^4.29.3\",\n    \"@typescript-eslint/parser\": \"^4.29.3\",\n    \"babel-plugin-module-resolver\": \"^4.1.0\",\n    \"benchmark\": \"^2.1.4\",\n    \"cross-env\": \"^7.0.3\",\n    \"docsify-cli\": \"^4.4.4\",\n    \"enzyme\": \"^3.11.0\",\n    \"enzyme-adapter-react-16\": \"^1.15.6\",\n    \"eslint\": \"^7.31.0\",\n    \"eslint-config-prettier\": \"^8.3.0\",\n    \"eslint-plugin-jest\": \"^24.4.0\",\n    \"eslint-plugin-prettier\": \"^3.4.0\",\n    \"eslint-plugin-react\": \"^7.24.0\",\n    \"eslint-plugin-unicorn\": \"^30.0.0\",\n    \"husky\": \"^4.3.8\",\n    \"identity-obj-proxy\": \"^3.0.0\",\n    \"jest\": \"^27.1.0\",\n    \"jest-date-mock\": \"^1.0.8\",\n    \"jest-transform-svelte\": \"^2.1.1\",\n    \"lint-staged\": \"^10.5.4\",\n    \"node-persist\": \"^3.1.0\",\n    \"nodemon\": \"^2.0.12\",\n    \"npm-run-all\": \"^4.1.5\",\n    \"prettier\": \"^2.3.2\",\n    \"raf\": \"^3.4.1\",\n    \"react\": \"^16.14.0\",\n    \"react-dom\": \"^16.14.0\",\n    \"rollup\": \"^2.79.2\",\n    \"rollup-plugin-babel\": \"^4.2.0\",\n    \"rollup-plugin-commonjs\": \"^9.2.0\",\n    \"rollup-plugin-filesize\": \"^6.0.0\",\n    \"rollup-plugin-node-builtins\": \"^2.1.2\",\n    \"rollup-plugin-node-resolve\": \"^4.0.0\",\n    \"rollup-plugin-replace\": \"^2.1.0\",\n    \"rollup-plugin-svelte\": \"^6.1.1\",\n    \"rollup-plugin-terser\": \"^5.3.0\",\n    \"rollup-plugin-typescript2\": \"^0.22.0\",\n    \"shelljs\": \"^0.8.4\",\n    \"supertest\": \"^3.1.0\",\n    \"svelte-icons\": \"^2.1.0\",\n    \"tempy\": \"^1.0.1\",\n    \"ts-jest\": \"^27.0.5\",\n    \"ts-transformer-imports\": \"^0.4.3\",\n    \"ttypescript\": \"^1.5.12\",\n    \"typescript\": \"^3.8.2\"\n  },\n  \"dependencies\": {\n    \"@koa/cors\": \"^3.1.0\",\n    \"@koa/router\": \"^10.1.1\",\n    \"@types/koa\": \"^2.13.4\",\n    \"@types/koa__router\": \"^8.0.8\",\n    \"flatted\": \"^3.2.1\",\n    \"immer\": \"^9.0.5\",\n    \"koa\": \"^2.13.3\",\n    \"koa-body\": \"^5.0.0\",\n    \"koa-socket-2\": \"^2.0.0\",\n    \"lodash.isplainobject\": \"^4.0.6\",\n    \"nanoid\": \"^3.1.30\",\n    \"p-queue\": \"^6.6.2\",\n    \"prop-types\": \"^15.5.10\",\n    \"react-cookies\": \"^0.1.0\",\n    \"redux\": \"^4.1.0\",\n    \"rfc6902\": \"^5.0.0\",\n    \"setimmediate\": \"^1.0.5\",\n    \"socket.io\": \"^4.5.0\",\n    \"socket.io-client\": \"^4.1.3\",\n    \"svelte\": \"^3.41.0\",\n    \"svelte-json-tree-auto\": \"^0.1.0\",\n    \"ts-toolbelt\": \"^6.3.6\"\n  },\n  \"jest\": {\n    \"preset\": \"ts-jest/presets/js-with-babel\",\n    \"testEnvironment\": \"jsdom\",\n    \"moduleNameMapper\": {\n      \"\\\\.(css)$\": \"identity-obj-proxy\",\n      \"\\\\.(svg)$\": \"<rootDir>/.empty_module.js\",\n      \"svelte-json-tree-auto\": \"<rootDir>/src/client/debug/tests/JSONTree.mock.svelte\"\n    },\n    \"coveragePathIgnorePatterns\": [\n      \"/node_modules/\",\n      \"src/client/transport/dummy\",\n      \"src/client/debug/.*\",\n      \"src/types.ts\"\n    ],\n    \"setupFiles\": [\n      \"raf/polyfill\",\n      \"jest-date-mock\"\n    ],\n    \"setupFilesAfterEnv\": [\n      \"@testing-library/jest-dom/extend-expect\"\n    ],\n    \"transform\": {\n      \"^.+\\\\.svelte$\": \"jest-transform-svelte\"\n    },\n    \"transformIgnorePatterns\": [\n      \"node_modules/(?!(boardgame.io|flatted|svelte-icons)/)\"\n    ],\n    \"testPathIgnorePatterns\": [\n      \"examples/\",\n      \"integration/\",\n      \"node_modules/\",\n      \".npm/\"\n    ]\n  },\n  \"husky\": {\n    \"hooks\": {\n      \"pre-commit\": \"lint-staged\",\n      \"pre-push\": \"npm run test:coverage\"\n    }\n  }\n}\n"
  },
  {
    "path": "packages/ai.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Step, Simulate } from '../src/ai/ai';\nimport { Bot } from '../src/ai/bot';\nimport { RandomBot } from '../src/ai/random-bot';\nimport { MCTSBot } from '../src/ai/mcts-bot';\n\nexport { Bot, RandomBot, MCTSBot, Step, Simulate };\n"
  },
  {
    "path": "packages/client.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client } from '../src/client/client';\nimport { LobbyClient, LobbyClientError } from '../src/lobby/client';\n\nexport { Client, LobbyClient, LobbyClientError };\n"
  },
  {
    "path": "packages/core.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { INVALID_MOVE } from '../src/core/constants';\nimport { GameMethod } from '../src/core/game-methods';\nimport { ActivePlayers, TurnOrder, Stage } from '../src/core/turn-order';\nimport { PlayerView } from '../src/core/player-view';\n\nexport {\n  ActivePlayers,\n  GameMethod,\n  Stage,\n  TurnOrder,\n  PlayerView,\n  INVALID_MOVE,\n};\n"
  },
  {
    "path": "packages/debug.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Debug from '../src/client/debug/Debug.svelte';\n\nexport { Debug };\n"
  },
  {
    "path": "packages/internal.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { InitializeGame } from '../src/core/initialize';\nimport { ProcessGameConfig } from '../src/core/game';\nimport { CreateGameReducer } from '../src/core/reducer';\nimport { getFilterPlayerView } from '../src/master/filter-player-view';\nimport { Async, Sync } from '../src/server/db/base';\nimport { Transport } from '../src/client/transport/transport';\nimport { createMatch } from '../src/server/util';\n\nexport {\n  Async,\n  Sync,\n  Transport,\n  ProcessGameConfig,\n  InitializeGame,\n  CreateGameReducer,\n  createMatch,\n  getFilterPlayerView,\n};\n"
  },
  {
    "path": "packages/main.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client } from '../src/client/client';\nimport { Client as ReactClient } from '../src/client/react';\nimport { Client as ReactNativeClient } from '../src/client/react-native';\nimport { TurnOrder } from '../src/core/turn-order';\nimport { Step, Simulate } from '../src/ai/ai';\nimport { RandomBot } from '../src/ai/random-bot';\nimport { MCTSBot } from '../src/ai/mcts-bot';\nimport { Local } from '../src/client/transport/local';\nimport { SocketIO } from '../src/client/transport/socketio';\n\nexport {\n  Client,\n  Local,\n  MCTSBot,\n  RandomBot,\n  ReactClient,\n  ReactNativeClient,\n  Simulate,\n  SocketIO,\n  Step,\n  TurnOrder,\n};\n"
  },
  {
    "path": "packages/master.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Master } from '../src/master/master';\n\nexport { Master };\n"
  },
  {
    "path": "packages/multiplayer.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Local } from '../src/client/transport/local';\nimport { SocketIO } from '../src/client/transport/socketio';\n\nexport { Local, SocketIO };\n"
  },
  {
    "path": "packages/plugins.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport PluginPlayer from '../src/plugins/plugin-player';\nimport { PlayerPlugin } from '../src/plugins/plugin-player';\n\nexport { PluginPlayer, PlayerPlugin };\n"
  },
  {
    "path": "packages/react-native.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client } from '../src/client/react-native';\n\nexport { Client };\n"
  },
  {
    "path": "packages/react.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client, BoardProps } from '../src/client/react';\nimport Lobby from '../src/lobby/react';\n\nexport { Client, BoardProps, Lobby };\n"
  },
  {
    "path": "packages/server.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Server } from '../src/server';\nimport { Origins } from '../src/server/cors';\nimport { FlatFile } from '../src/server/db';\nimport { SocketIO } from '../src/server/transport/socketio';\nimport { GenericPubSub } from '../src/server/transport/pubsub/generic-pub-sub';\n\nexport { Server, Origins, FlatFile, SocketIO, GenericPubSub };\n"
  },
  {
    "path": "packages/testing.ts",
    "content": "export { MockRandom } from '../src/testing/mock-random';\n"
  },
  {
    "path": "python/.gitignore",
    "content": "*.pyc\n.cache\n.coverage\nhtmlcov\n"
  },
  {
    "path": "python/boardgameio.py",
    "content": "#\n# Copyright 2018 The boardgame.io Authors\n#\n# Use of this source code is governed by a MIT-style\n# license that can be found in the LICENSE file or at\n# https://opensource.org/licenses/MIT.\n#\n# pylint: disable=invalid-name,import-error,no-self-use\n\n\"\"\"\nBoardgame.io python client.\n\"\"\"\n\nimport logging\nimport socketIO_client_nexus as io\n\nclass Namespace(io.BaseNamespace):\n    \"\"\"\n    SocketIO namespace providing handlers for events\n    of the connection with the boardgame.io server.\n    \"\"\"\n    log = logging.getLogger('client.namespace')\n\n    def __init__(self, *args):\n        io.BaseNamespace.__init__(self, *args)\n        self.bot = None\n        self.previous_state_id = None\n        self.actions = []\n\n    def set_bot_info(self, bot):\n        \"\"\"\n        Provides access to the Bot class that owns the connection.\n        FIXME: is made necessary since socketio does not provide (yet) a way\n        to pass extra arguments to the ctor of the namespace at creation.\n        \"\"\"\n        self.bot = bot\n        return self\n\n    def on_connect(self):\n        \"\"\" Handle connection event. \"\"\"\n        self.log.info('connected') # to game <%s>' % self.bot.game_id)\n\n    def on_disconnect(self):\n        \"\"\" Handle disconnection event. \"\"\"\n        self.log.info('disconnected')\n    def on_reconnect(self):\n        \"\"\" Handle reconnection event. \"\"\"\n        self.log.info('reconnected')\n\n    def on_update(self, *args):\n        \"\"\" Handle server 'update' event. \"\"\"\n        self.on_sync(*args)\n\n    def on_sync(self, *args):\n        \"\"\" Handle server 'sync' event. \"\"\"\n        game_id = args[0]\n        state = args[1]\n        state_id = state['_stateID']\n        ctx = state['ctx']\n\n        # is it my game and my turn to play?\n        if game_id == self.bot.game_id:\n            if not self.previous_state_id or state_id >= self.previous_state_id:\n\n                self.previous_state_id = state_id\n                self.log.debug('state = %s', str(state))\n                G = state['G']\n\n                if 'gameover' in ctx:\n                    # game over\n                    self.bot.gameover(G, ctx)\n\n                elif self.bot.player_id in ctx['actionPlayers']:\n                    self.log.info('phase is %s', ctx['phase'])\n                    if not self.actions:\n                        # plan next actions\n                        self.actions = self.bot.think(G, ctx)\n                        if not isinstance(self.actions, list):\n                            self.actions = [self.actions]\n                    if self.actions:\n                        # pop next action\n                        action = self.actions.pop(0)\n                        self.log.info('sent action: %s', action['payload'])\n                        self.emit('update', action, state_id, game_id,\n                                  self.bot.player_id)\n\n\nclass Bot(object):\n    \"\"\"\n    Base class for boardgame.io bot.\n    \"\"\"\n    log = logging.getLogger('client.bot')\n\n    def __init__(self, server='localhost', port='8000',\n                 options=None):\n        \"\"\"\n        Connect to server with given game name, id and player id.\n        Request initial synchronization.\n        \"\"\"\n        opts = {'game_name'  : 'default',\n                'game_id'    : 'default',\n                'player_id'  : '1',\n                'credentials': 'default',\n                'num_players': 2}\n        opts.update(options or {})\n        self.game_id = opts['game_name'] + ':' + opts['game_id']\n        self.player_id = opts['player_id']\n        self.credentials = opts['credentials']\n        self.num_players = opts['num_players']\n\n        # open websocket\n        socket = io.SocketIO(server, port, wait_for_connection=False)\n        self.io_namespace = socket.define(Namespace, '/'+opts['game_name'])\n        self.io_namespace.set_bot_info(self)\n        self.socket = socket\n\n        # request initial sync\n        self.io_namespace.emit('sync', self.game_id, self.player_id, self.num_players)\n\n    def _create_action(self, action, typ, args=None):\n        if not args:\n            args = []\n        return {\n            'type': action,\n            'payload': {\n                'type': typ,\n                'args': args,\n                'playerID': self.player_id,\n                'credentials': self.credentials\n            }\n        }\n\n    def make_move(self, typ, *args):\n        \"\"\" Create MAKE_MOVE action. \"\"\"\n        return self._create_action('MAKE_MOVE', typ, list(args))\n\n    def game_event(self, typ):\n        \"\"\" Create GAME_EVENT action. \"\"\"\n        return self._create_action('GAME_EVENT', typ)\n\n    def listen(self, timeout=1):\n        \"\"\"\n        Listen and handle server events: when it is the bot's turn to play,\n        method 'think' will be called with the game state and context.\n        Return after 'timeout' seconds if no events.\n        \"\"\"\n        self.socket.wait(seconds=timeout)\n\n    def think(self, _G, _ctx):\n        \"\"\"\n        To be overridden by the user.\n        Shall return a list of actions, instantiated with make_move().\n        \"\"\"\n        raise NotImplementedError\n\n    def gameover(self, _G, _ctx):\n        \"\"\"\n        To be overridden by the user.\n        Shall handle game over.\n        \"\"\"\n        raise NotImplementedError\n"
  },
  {
    "path": "python/examples/tic-tac-toe/tictactoebot.py",
    "content": "#!/usr/bin/python\n#\n# Copyright 2018 The boardgame.io Authors\n#\n# Use of this source code is governed by a MIT-style\n# license that can be found in the LICENSE file or at\n# https://opensource.org/licenses/MIT.\n#\n# pylint: disable=invalid-name,multiple-imports,global-statement\n\n# To play against this bot, start the tictactoe server from http://boardgame.io/#/multiplayer\n# and start the bot with:\n# $ python tictactoebot.py\n# (will play player '1' by default)\n\n\"\"\"\nBoardgame.io python client example: starts a bot with player id '0'\nthat plays randomly against the other player '1'.\n\"\"\"\n\nimport signal, random, logging\nfrom boardgameio import Bot\n\nclass TicTacToeBot(Bot):\n    \"\"\"\n    Example of use of base class boardgameio.Bot:\n    - the bot connects to the multiplayer server at construction\n    - each time it is the bot's turn to play, method 'think' is called\n    - when game is over, method 'gameover' is called.\n    \"\"\"\n    log = logging.getLogger('tictactoebot')\n\n    def __init__(self):\n        Bot.__init__(self, server='localhost', port=8000,\n                     options={'game_name': 'default',\n                              'num_players': 2,\n                              'player_id': '1'})\n\n    def think(self, G, _ctx):\n        \"\"\" Called when it is this bot's turn to play. \"\"\"\n        cells = G['cells']\n        # choose a random empty cell\n        idx = -1\n        while True and None in cells:\n            idx = random.randint(0, len(cells)-1)\n            if not cells[idx]:\n                break\n        self.log.debug('cell chosen: %d', idx)\n        return self.make_move('clickCell', idx)\n\n    def gameover(self, _G, ctx):\n        \"\"\" Called when game is over. \"\"\"\n        self.log.info('winner is %s', ctx['gameover'])\n\n\nrunning = False\nlog = logging.getLogger('main')\nlogging.basicConfig(level=logging.INFO)\n\ndef main():\n    \"\"\" Start bot and listen continuously for events. \"\"\"\n    log.info('starting bot... (Ctrl-C to stop)')\n    client = TicTacToeBot()\n    global running\n    running = True\n    while running:\n        client.listen()\n    log.info('stopped.')\n\ndef stop(_signum, _frame):\n    \"\"\" Stop program. \"\"\"\n    log.info('stopping...')\n    global running\n    running = False\n\n# start process\nif __name__ == '__main__':\n    signal.signal(signal.SIGINT, stop)\n    signal.signal(signal.SIGTERM, stop)\n    main()\n"
  },
  {
    "path": "python/test_boardgameio.py",
    "content": "#\n# Copyright 2018 The boardgame.io Authors\n#\n# Use of this source code is governed by a MIT-style\n# license that can be found in the LICENSE file or at\n# https://opensource.org/licenses/MIT.\n#\n# pylint: disable=invalid-name,import-error,no-self-use,missing-docstring\n\n# To run unit-tests:\n# $ python -m unittest discover\n# For coverage report:\n# $ coverage run --source=boardgameio.py test_boardgameio.py\n# $ coverage report\n\nimport unittest\nimport logging\nimport mock\nimport socketIO_client_nexus as io\nfrom boardgameio import Namespace, Bot\n\n\nlogging.basicConfig(level=logging.DEBUG)\n\n\nclass TestNamespace(unittest.TestCase):\n\n    def setUp(self):\n        self.game_state = {'_stateID': 1234, 'G': {}, 'ctx': {\n            'actionPlayers': ['1'],\n            'phase': 'phase0'\n        }}\n        self.resulting_move = {'payload': 'action0'}\n        # mock Bot instance\n        self.botmock = mock.Mock(spec=Bot)()\n        self.botmock.game_id = 'game0'\n        self.botmock.player_id = self.game_state['ctx']['actionPlayers'][0]\n        self.botmock.think.return_value = self.resulting_move\n        # mock socket\n        self.sockmock = mock.Mock(spec=io.SocketIO)()\n        # instantiate SUT\n        self.sut = Namespace(self.sockmock, 'default').set_bot_info(self.botmock)\n        self.sut.emit = mock.MagicMock(name='emit')\n\n    def test_on_sync_shall_call_think(self):\n        # call Namespace.on_sync()\n        self.sut.on_sync(self.botmock.game_id, self.game_state)\n        self.botmock.think.assert_called_once_with(self.game_state['G'], self.game_state['ctx'])\n        self.sut.emit.assert_called_once_with('update', self.resulting_move,\n                                              self.game_state['_stateID'],\n                                              self.botmock.game_id, self.botmock.player_id)\n\n    def test_on_update_shall_call_think(self):\n        # call Namespace.on_update()\n        self.sut.on_update(self.botmock.game_id, self.game_state)\n        self.botmock.think.assert_called_once_with(self.game_state['G'], self.game_state['ctx'])\n        self.sut.emit.assert_called_once_with('update', self.resulting_move,\n                                              self.game_state['_stateID'],\n                                              self.botmock.game_id, self.botmock.player_id)\n\n    def test_on_sync_shall_not_call_think_if_game_id_is_different(self):\n        # call on_sync with another game id\n        self.sut.on_sync('other-game', self.game_state)\n        self.botmock.think.assert_not_called()\n        self.sut.emit.assert_not_called()\n\n    def test_on_sync_shall_not_call_think_if_player_id_is_not_active(self):\n        # change active players in game state\n        self.game_state['ctx']['actionPlayers'] = ['0', '2']\n        # call on_sync with bot game id\n        self.sut.on_sync(self.botmock.game_id, self.game_state)\n        self.botmock.think.assert_not_called()\n        self.sut.emit.assert_not_called()\n\n    def test_on_sync_shall_call_gameover_if_game_is_over(self):\n        # activate gameover in game state\n        self.game_state['ctx']['gameover'] = ['0']\n        # call on_sync with bot game id\n        self.sut.on_sync(self.botmock.game_id, self.game_state)\n        self.botmock.gameover.assert_called_once_with(self.game_state['G'], self.game_state['ctx'])\n        self.sut.emit.assert_not_called()\n\n\nclass TestBot(unittest.TestCase):\n\n    def setUp(self):\n        self.game_state = {'_stateID': 1234, 'G': {}, 'ctx': {\n            'actionPlayers': ['1'],\n            'phase': 'phase0'\n        }}\n        self.resulting_move = {'payload': 'action0'}\n        # mock socket\n        io.SocketIO = mock.Mock(spec=io.SocketIO)\n        # instantiate SUT\n        self.sut = Bot()\n        self.sut.think = mock.MagicMock(name='think')\n        self.sut.gameover = mock.MagicMock(name='gameover')\n\n    def test_make_move_shall_return_move_action(self):\n        self.assertEqual(self.sut.make_move('type', 'foo', 'bar'),\n                         {'type': 'MAKE_MOVE',\n                          'payload': {\n                              'type': 'type',\n                              'args': ['foo', 'bar'],\n                              'playerID': self.sut.player_id,\n                              'credentials': self.sut.credentials\n                          }})\n\n    def test_game_event_shall_return_event_action(self):\n        self.assertEqual(self.sut.game_event('foobar'),\n                         {'type': 'GAME_EVENT',\n                          'payload': {\n                              'type': 'foobar',\n                              'args': [],\n                              'playerID': self.sut.player_id,\n                              'credentials': self.sut.credentials}\n                         })\n\n\nif __name__ == '__main__':\n    unittest.main()\n"
  },
  {
    "path": "roadmap.md",
    "content": "# Roadmap to v1.0\n\nThis is a living document capturing the current areas of focus, and what needs to\nget done before we are ready for a v1 release.\n\n- _Areas that need help are marked with **[help needed]**._\n- _Stuff that [nicolodavis@](https://github.com/nicolodavis) is working on is marked with **[N]**._\n\nThe issues below (and some others that are not in this document) are also available on the [v1.0 milestone](https://github.com/boardgameio/boardgame.io/milestone/2) link.\n\n### AI\n\n- [x] MCTS bot ([issue](https://github.com/boardgameio/boardgame.io/issues/7#issuecomment-389453032))\n- [x] ability to add priorities and objectives ([issue](https://github.com/boardgameio/boardgame.io/issues/7#issuecomment-389453032))\n- [ ] Bots in multiplayer games ([issue](https://github.com/boardgameio/boardgame.io/issues/383)) **[help needed]**\n\n### Lobby\n\n- [x] basic `create` and `join` API\n- [x] simple web-based lobby ([issue](https://github.com/boardgameio/boardgame.io/issues/197))\n- [ ] Lobby Improvements ([issue](https://github.com/boardgameio/boardgame.io/issues/354)) **[help needed]**\n- [ ] Migrate to Svelte ([issue](https://github.com/boardgameio/boardgame.io/issues/432)) **[help needed]**\n\n### Storage\n\n- ##### Databases\n\n  We encourage developers to contribute third-party storage connectors, implementing\n  [the `StorageAPI.Async` interface](https://github.com/boardgameio/boardgame.io/blob/main/src/server/db/base.ts).\n\n  See the [Storage docs](https://boardgame.io/documentation/#/storage) for\n  examples and details of the backends currently available.\n\n- ##### Size / Performance\n\n  - [ ] Explore MessagePack or other compression scheme\n\n### Core\n\n- [x] phases -> turns -> stages\n- [x] turn order improvements ([issue](https://github.com/boardgameio/boardgame.io/issues/154))\n- [x] log improvements ([issue](https://github.com/boardgameio/boardgame.io/issues/227))\n- [x] add immutability helper (Immer) ([issue](https://github.com/boardgameio/boardgame.io/issues/295))\n\n### Server\n\n- [x] abstract away server component ([issue](https://github.com/boardgameio/boardgame.io/issues/251))\n- [ ] server scaling ([issue](https://github.com/boardgameio/boardgame.io/issues/277))\n\n### Documentation\n\n- [ ] recipes for different game scenarios\n- [ ] code organization patterns\n- [x] deployment tutorial\n- [x] tutorial using the vanilla JS client\n"
  },
  {
    "path": "rollup.config.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport resolve from 'rollup-plugin-node-resolve';\nimport replace from 'rollup-plugin-replace';\nimport babel from 'rollup-plugin-babel';\nimport commonjs from 'rollup-plugin-commonjs';\nimport filesize from 'rollup-plugin-filesize';\nimport svelte from 'rollup-plugin-svelte';\nimport { terser } from 'rollup-plugin-terser';\nimport pkg from './package.json';\nimport typescript from 'rollup-plugin-typescript2';\nimport ts from 'typescript';\nconst subpackages = require('./subpackages');\n\nconst internalDeps = new Set(['svelte']);\nconst external = [\n  ...Object.keys(pkg.dependencies).filter((name) => !internalDeps.has(name)),\n  'react',\n  'socket.io-client',\n];\n\nconst plugins = [\n  babel({ exclude: '**/node_modules/**' }),\n  resolve({ browser: true, only: [/svelte/] }),\n  typescript({\n    typescript: ts,\n    tsconfigOverride: {\n      compilerOptions: {\n        declaration: true,\n        declarationDir: './dist/types',\n      },\n    },\n    useTsconfigDeclarationDir: true,\n  }),\n  svelte({ extensions: ['.svelte'] }),\n];\n\nconst serverPlugins = [\n  resolve(),\n  typescript({ typescript: ts }),\n  babel({ exclude: ['**/node_modules/**'] }),\n  commonjs({ include: 'node_modules/**' }),\n];\n\nconst minifiedPlugins = [\n  babel({ exclude: '**/node_modules/**' }),\n  resolve({ browser: true }),\n  typescript({ typescript: ts }),\n  svelte({ extensions: ['.svelte'] }),\n  commonjs(),\n  replace({\n    include: 'src/**',\n    'process.env.NODE_ENV': JSON.stringify('development'),\n  }),\n  replace({\n    exclude: 'src/**',\n    'process.env.NODE_ENV': JSON.stringify('production'),\n  }),\n  filesize(),\n  terser(),\n];\n\nexport default [\n  // Subpackages.\n  {\n    input: subpackages.reduce((obj, name) => {\n      obj[name] = `packages/${name}.ts`;\n      return obj;\n    }, {}),\n    external,\n    plugins,\n    output: [\n      {\n        dir: 'dist/esm',\n        format: 'esm',\n      },\n      {\n        dir: 'dist/cjs',\n        format: 'cjs',\n      },\n    ],\n  },\n\n  // Server.\n  {\n    input: 'packages/server.ts',\n    output: { dir: 'dist/cjs', format: 'cjs' },\n    external,\n    plugins: serverPlugins,\n  },\n\n  // CJS and ES versions.\n  // The subpackages are the preferred way of importing\n  // stuff from the library instead of these.\n  {\n    input: 'packages/main.js',\n    external,\n    output: [\n      { file: pkg.main, format: 'cjs' },\n      { file: pkg.module, format: 'esm' },\n    ],\n    plugins,\n  },\n\n  // Browser minified version.\n  {\n    input: 'packages/client.ts',\n    output: [\n      {\n        file: pkg.unpkg,\n        format: 'umd',\n        name: 'BoardgameIO',\n      },\n    ],\n    plugins: minifiedPlugins,\n  },\n];\n"
  },
  {
    "path": "scripts/changelog.js",
    "content": "// Generates docs/CHANGELOG.md\n// Run this right after the npm version command.\n\nconst { EOL } = require('os');\nconst shell = require('shelljs');\nconst tempy = require('tempy');\n\nshell.config.silent = true;\nconst P = EOL + EOL;\n\nconst CURRENT_TAG = shell\n  .exec('git tag --sort=v:refname')\n  .tail({ '-n': 1 })\n  .stdout.trim();\n\nconst PREVIOUS_TAG = shell\n  .exec('git tag --sort=v:refname')\n  .tail({ '-n': 2 })\n  .head({ '-n': 1 })\n  .stdout.trim();\n\n/** This is a “major” release if the version is 0.x.0 or x.0.0 */\nconst IS_MAJOR = /^v?(0\\.\\d+\\.0|\\d+.0.0)$/.test(CURRENT_TAG);\n\nconst FILE = tempy.file();\n\n/** Tests for a `feat` commit type. */\nconst isFeature = (s) => /feat(\\([^)]+\\))?:/.test(s);\n/** Tests for commit types that don’t need adding to the CHANGELOG (like `docs` or `chore`). */\nconst isUninformative = (s) =>\n  /(test|style|chore|docs|ci)(\\([\\w-]+\\))?:/.test(s);\n/** Tests if this commit just bumped the version (via `npm version`). */\nconst isVersionBump = (s) => /^\\w+\\s\\d+\\.\\d+\\.\\d+$/.test(s);\n\nconst changes = shell\n  .exec(`git log --oneline \"${PREVIOUS_TAG}\"..`)\n  .split(EOL)\n  .filter((line) => !isUninformative(line) && !isVersionBump(line));\n\n/**\n * Format an array of commit details and concatenate into a string.\n * @param {string[]} changes\n */\nconst formatChanges = (changes) =>\n  changes\n    .map((line) =>\n      line\n        // Strip standalone commit types ('feat:', 'fix:', etc.)\n        .replace(/[a-z]+: /, '')\n        // Format scoped commit types ('feat(foo):' => 'foo:', etc.)\n        .replace(/[a-z]+\\(([^)]+)\\)/, '$1')\n        // Linkify commit refs.\n        .replace(\n          /^(\\w+)/,\n          '* [[$1](https://github.com/boardgameio/boardgame.io/commit/$1)]'\n        )\n        // Linkify PR references.\n        .replace(\n          /\\(#(\\d{3,})\\)/,\n          '([#$1](https://github.com/boardgameio/boardgame.io/pull/$1))'\n        )\n    )\n    .join(EOL);\n\nconst features = formatChanges(changes.filter((line) => isFeature(line)));\nconst others = formatChanges(changes.filter((line) => !isFeature(line)));\n\nlet NOTES = (IS_MAJOR ? '## ' : '### ') + CURRENT_TAG + P;\nif (features.length > 0) NOTES += '#### Features' + P + features + P;\nif (others.length > 0) NOTES += '#### Bugfixes' + P + others + P;\nshell.ShellString(NOTES).toEnd(FILE);\nshell.echo(NOTES);\n\nshell.cat('docs/documentation/CHANGELOG.md').toEnd(FILE);\nshell.cp(FILE, 'docs/documentation/CHANGELOG.md');\n"
  },
  {
    "path": "scripts/clean.js",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nconst shell = require('shelljs');\nconst subpackages = require('../subpackages');\n\nshell.rm('-rf', 'dist');\nshell.rm('-rf', subpackages);\nshell.rm('-rf', 'server');\n"
  },
  {
    "path": "scripts/dev-client.js",
    "content": "const shell = require('shelljs');\n\nshell.cd('examples/react-web');\nshell.exec('npm start');\n"
  },
  {
    "path": "scripts/install-examples.js",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nconst path = require('path');\nconst { spawnSync } = require('child_process');\nconst { existsSync } = require('fs');\n\nconst projectRoot = path.resolve(__dirname, '../');\nconst webExamplePath = path.resolve(projectRoot, './examples/react-web');\nconst modulesPath = path.resolve(webExamplePath, './node_modules');\n\nconst hasModules = existsSync(modulesPath);\n\nif (!hasModules) {\n  installDependencies();\n}\n\nconsole.log('Starting the application...');\n\nfunction installDependencies() {\n  const isWindowsOs = process.platform === 'win32';\n  const npmCommand = isWindowsOs ? 'npm.cmd' : 'npm';\n\n  console.log('Installing web dependencies...');\n\n  spawnSync(npmCommand, ['install'], {\n    cwd: webExamplePath,\n    stdio: 'inherit',\n  });\n}\n"
  },
  {
    "path": "scripts/integration.js",
    "content": "const shell = require('shelljs');\n\nshell.rm('-rf', 'dist');\nshell.exec('npm pack');\nconst packed = shell.ls('./boardgame.io-*.tgz').stdout.trim();\n\nshell.mv(packed, 'integration');\nshell.cd('integration');\nshell.rm('-rf', 'node_modules');\nshell.exec('npm install');\nshell.exec(`npm install ${packed}`);\nshell.rm(packed);\n\nshell.set('-e');\n\n// Test\nshell.exec('npm test');\nshell.exec('npm run build');\n"
  },
  {
    "path": "scripts/proxy-dirs.js",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nconst subpackages = require('../subpackages');\nconst path = require('path');\nconst { mkdirSync, writeFileSync } = require('fs');\n\nfunction PackageJson(name, { mainDir, esmDir } = {}) {\n  const root = '../dist';\n  const pkg = {\n    name: `boardgame.io/${name}`,\n    private: true,\n    types: `../dist/types/packages/${name}.d.ts`,\n    main: path.join(root, mainDir, `${name}.js`),\n  };\n  if (esmDir) {\n    pkg.module = path.join(root, esmDir, `${name}.js`);\n  }\n  return JSON.stringify(pkg, null, 2) + '\\n';\n}\n\nfunction makeSubpackage(name, opts) {\n  const dir = path.resolve(__dirname, `../${name}`);\n  mkdirSync(dir);\n  writeFileSync(`${dir}/package.json`, PackageJson(name, opts));\n}\n\nsubpackages.forEach((name) => {\n  makeSubpackage(name, { mainDir: 'cjs', esmDir: 'esm' });\n});\n\nmakeSubpackage('server', { mainDir: 'cjs' });\n"
  },
  {
    "path": "src/ai/ai.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { InitializeGame } from '../core/initialize';\nimport { Client } from '../client/client';\nimport { MAKE_MOVE, GAME_EVENT } from '../core/action-types';\nimport { makeMove } from '../core/action-creators';\nimport { Step, Simulate } from './ai';\nimport { RandomBot } from './random-bot';\nimport { MCTSBot } from './mcts-bot';\nimport type { Node } from './mcts-bot';\nimport { ProcessGameConfig } from '../core/game';\nimport { Stage } from '../core/turn-order';\nimport type { AnyFn, Game, Ctx } from '../types';\n\nfunction IsVictory(cells) {\n  const positions = [\n    [0, 1, 2],\n    [3, 4, 5],\n    [6, 7, 8],\n    [0, 3, 6],\n    [1, 4, 7],\n    [2, 5, 8],\n    [0, 4, 8],\n    [2, 4, 6],\n  ];\n\n  const isRowComplete = (row) => {\n    const symbols = row.map((i) => cells[i]);\n    return symbols.every((i) => i !== null && i === symbols[0]);\n  };\n\n  return positions.map((row) => isRowComplete(row)).includes(true);\n}\n\nconst TicTacToe = ProcessGameConfig({\n  setup: () => ({\n    cells: Array.from({ length: 9 }).fill(null),\n  }),\n\n  moves: {\n    clickCell({ G, ctx }, id: number) {\n      const cells = [...G.cells];\n      if (cells[id] === null) {\n        cells[id] = ctx.currentPlayer;\n      }\n      return { ...G, cells };\n    },\n  },\n\n  turn: { minMoves: 1, maxMoves: 1 },\n\n  endIf: ({ G, ctx }) => {\n    if (IsVictory(G.cells)) {\n      return { winner: ctx.currentPlayer };\n    }\n\n    if (G.cells.filter((t) => t == null).length === 0) {\n      return { draw: true };\n    }\n  },\n});\n\nconst enumerate = (G: any, ctx: Ctx, playerID: string) => {\n  const r = [];\n  for (let i = 0; i < 9; i++) {\n    if (G.cells[i] === null) {\n      r.push(makeMove('clickCell', [i], playerID));\n    }\n  }\n  return r;\n};\n\ndescribe('Step', () => {\n  test('advances game state', async () => {\n    const client = Client<{ moved: boolean }>({\n      game: {\n        setup: () => ({ moved: false }),\n\n        moves: {\n          clickCell({ G }) {\n            return { moved: !G.moved };\n          },\n        },\n\n        endIf({ G }) {\n          if (G.moved) return true;\n        },\n\n        ai: {\n          enumerate: () => [{ move: 'clickCell' }],\n        },\n      },\n    });\n\n    const bot = new RandomBot({ enumerate: client.game.ai.enumerate });\n    expect(client.getState().G).toEqual({ moved: false });\n    await Step(client, bot);\n    expect(client.getState().G).toEqual({ moved: true });\n  });\n\n  test('does not crash on empty action', async () => {\n    const client = Client({\n      game: {\n        ai: {\n          enumerate: () => [],\n        },\n      },\n    });\n    const bot = new RandomBot({ enumerate: client.game.ai.enumerate });\n    await expect(Step(client, bot)).resolves.toBeUndefined();\n  });\n\n  test('works with stages', async () => {\n    const client = Client({\n      game: {\n        moves: {\n          A: ({ G }) => {\n            G.moved = true;\n          },\n        },\n\n        turn: {\n          activePlayers: { currentPlayer: 'stage' },\n        },\n\n        ai: {\n          enumerate: () => [{ move: 'A' }],\n        },\n      },\n    });\n\n    const bot = new RandomBot({ enumerate: client.game.ai.enumerate });\n    expect(client.getState().G).not.toEqual({ moved: true });\n    await Step(client, bot);\n    expect(client.getState().G).toEqual({ moved: true });\n  });\n});\n\ndescribe('Simulate', () => {\n  const bots = {\n    '0': new RandomBot({ seed: 'test', enumerate }),\n    '1': new RandomBot({ seed: 'test', enumerate }),\n  };\n\n  test('multiple bots', async () => {\n    const state = InitializeGame({ game: TicTacToe });\n    const { state: endState } = await Simulate({\n      game: TicTacToe,\n      bots,\n      state,\n    });\n    expect(endState.ctx.gameover).not.toBe(undefined);\n  });\n\n  test('single bot', async () => {\n    const bot = new RandomBot({ seed: 'test', enumerate });\n    const state = InitializeGame({ game: TicTacToe });\n    const { state: endState } = await Simulate({\n      game: TicTacToe,\n      bots: bot,\n      state,\n      depth: 10,\n    });\n    expect(endState.ctx.gameover).not.toBe(undefined);\n  });\n\n  test('with activePlayers', async () => {\n    const game = ProcessGameConfig({\n      moves: {\n        A: ({ G }) => {\n          G.moved = true;\n        },\n      },\n      turn: {\n        activePlayers: { currentPlayer: Stage.NULL },\n      },\n      endIf: ({ G }) => G.moved,\n    });\n\n    const bot = new RandomBot({\n      seed: 'test',\n      enumerate: () => [makeMove('A')],\n    });\n\n    const state = InitializeGame({ game });\n    const { state: endState } = await Simulate({\n      game,\n      bots: bot,\n      state,\n      depth: 1,\n    });\n    expect(endState.ctx.gameover).not.toBe(undefined);\n  });\n});\n\ndescribe('Bot', () => {\n  test('random', () => {\n    const b = new RandomBot({ enumerate: () => [] });\n    expect(b.random()).toBeGreaterThanOrEqual(0);\n    expect(b.random()).toBeLessThan(1);\n  });\n\n  test('enumerate - makeMove', () => {\n    const enumerate = () => [makeMove('move')];\n    const b = new RandomBot({ enumerate });\n    expect(b.enumerate(undefined, undefined, undefined)[0].type).toBe(\n      MAKE_MOVE\n    );\n  });\n\n  test('enumerate - translate to makeMove', () => {\n    const enumerate = () => [{ move: 'move' }];\n    const b = new RandomBot({ enumerate });\n    expect(b.enumerate(undefined, undefined, undefined)[0].type).toBe(\n      MAKE_MOVE\n    );\n  });\n\n  test('enumerate - translate to gameEvent', () => {\n    const enumerate = () => [{ event: 'endTurn' }];\n    const b = new RandomBot({ enumerate });\n    expect(b.enumerate(undefined, undefined, undefined)[0].type).toBe(\n      GAME_EVENT\n    );\n  });\n\n  test('enumerate - unrecognized', () => {\n    const enumerate = (() =>\n      [{ unknown: true }] as unknown) as Game['ai']['enumerate'];\n    const b = new RandomBot({ enumerate });\n    expect(b.enumerate(undefined, undefined, undefined)).toEqual([undefined]);\n  });\n});\n\ndescribe('MCTSBot', () => {\n  test('game that never ends', async () => {\n    const game: Game = {};\n    const state = InitializeGame({ game });\n    const bot = new MCTSBot({ seed: 'test', game, enumerate: () => [] });\n    const { state: endState } = await Simulate({ game, bots: bot, state });\n    expect(endState.ctx.turn).toBe(1);\n  });\n\n  test('RandomBot vs. MCTSBot', async () => {\n    const bots = {\n      '0': new RandomBot({ seed: 'test', enumerate }),\n      '1': new MCTSBot({\n        iterations: 200,\n        seed: 'test',\n        game: TicTacToe,\n        enumerate,\n      }),\n    };\n\n    const initialState = InitializeGame({ game: TicTacToe });\n\n    for (let i = 0; i < 5; i++) {\n      const state = initialState;\n      const { state: endState } = await Simulate({\n        game: TicTacToe,\n        bots,\n        state,\n      });\n      expect(endState.ctx.gameover).not.toEqual({ winner: '0' });\n    }\n  });\n\n  test('MCTSBot vs. MCTSBot', async () => {\n    const initialState = InitializeGame({ game: TicTacToe });\n    const iterations = 400;\n\n    for (let i = 0; i < 5; i++) {\n      const bots = {\n        '0': new MCTSBot({\n          seed: i,\n          game: TicTacToe,\n          enumerate,\n          iterations,\n          playoutDepth: 50,\n        }),\n        '1': new MCTSBot({\n          seed: i,\n          game: TicTacToe,\n          enumerate,\n          iterations,\n        }),\n      };\n      const state = initialState;\n      const { state: endState } = await Simulate({\n        game: TicTacToe,\n        bots,\n        state,\n      });\n      expect(endState.ctx.gameover).toEqual({ draw: true });\n    }\n  });\n\n  test('with activePlayers', async () => {\n    const game = ProcessGameConfig({\n      setup: () => ({ moves: 0 }),\n      moves: {\n        A: ({ G }) => {\n          G.moves++;\n        },\n      },\n      turn: {\n        activePlayers: { currentPlayer: Stage.NULL },\n      },\n      endIf: ({ G }) => G.moves > 5,\n    });\n\n    const bot = new MCTSBot({\n      seed: 'test',\n      game,\n      enumerate: () => [makeMove('A')],\n    });\n\n    const state = InitializeGame({ game });\n    const { state: endState } = await Simulate({\n      game,\n      bots: bot,\n      state,\n      depth: 10,\n    });\n    expect(endState.ctx.gameover).not.toBe(undefined);\n  });\n\n  test('objectives', async () => {\n    const objectives = () => ({\n      'play-on-square-0': {\n        checker: (G) => G.cells[0] !== null,\n        weight: 10,\n      },\n    });\n\n    const state = InitializeGame({ game: TicTacToe });\n\n    for (let i = 0; i < 10; i++) {\n      const bot = new MCTSBot({\n        iterations: 200,\n        seed: i,\n        game: TicTacToe,\n        enumerate,\n        objectives,\n      });\n\n      const { action } = await bot.play(state, '0');\n      expect(action.payload.args).toEqual([0]);\n    }\n  });\n\n  test('async mode', async () => {\n    const initialState = InitializeGame({ game: TicTacToe });\n    const bot = new MCTSBot({\n      seed: '0',\n      game: TicTacToe,\n      enumerate,\n      iterations: 10,\n      playoutDepth: 10,\n    });\n    bot.setOpt('async', true);\n    const action = await bot.play(initialState, '0');\n    expect(action).not.toBeUndefined();\n  });\n\n  describe('iterations & playout depth', () => {\n    test('set opts', () => {\n      const bot = new MCTSBot({ game: TicTacToe, enumerate: jest.fn() });\n      bot.setOpt('iterations', 1);\n      expect(bot.opts()['iterations'].value).toBe(1);\n    });\n\n    test('setOpt works on invalid key', () => {\n      const bot = new RandomBot({ enumerate: jest.fn() });\n      const setInvalidKey = () => bot.setOpt('unknown', 1);\n      const getInvalidKey = () => bot.getOpt('unknown');\n      expect(setInvalidKey).not.toThrow();\n      expect(getInvalidKey).toThrow();\n    });\n\n    test('functions', () => {\n      const state = InitializeGame({ game: TicTacToe });\n\n      // jump ahead in the game because the example iterations\n      // and playoutDepth functions are based on the turn\n      state.ctx.turn = 8;\n\n      const { turn, currentPlayer } = state.ctx;\n\n      const enumerateSpy = jest.fn(enumerate);\n\n      const bot = new MCTSBot({\n        game: TicTacToe,\n        enumerate: enumerateSpy,\n        iterations: (G, ctx) => ctx.turn * 100,\n        playoutDepth: (G, ctx) => ctx.turn * 10,\n      });\n\n      expect(\n        (bot.iterations as AnyFn)(null, { turn } as Ctx, currentPlayer)\n      ).toBe(turn * 100);\n      expect(\n        (bot.playoutDepth as AnyFn)(null, { turn } as Ctx, currentPlayer)\n      ).toBe(turn * 10);\n\n      // try the playout() function which requests the playoutDepth value\n      bot.playout({ state } as Node);\n\n      expect(enumerateSpy).toHaveBeenCalledWith(\n        state.G,\n        state.ctx,\n        currentPlayer\n      );\n\n      // then try the play() function which requests the iterations value\n      enumerateSpy.mockClear();\n\n      bot.play(state, currentPlayer);\n\n      expect(enumerateSpy).toHaveBeenCalledWith(\n        state.G,\n        state.ctx,\n        currentPlayer\n      );\n    });\n  });\n});\n"
  },
  {
    "path": "src/ai/ai.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { CreateGameReducer } from '../core/reducer';\nimport { Bot } from './bot';\nimport type { Game, PlayerID, State, Store } from '../types';\n\n/**\n * Make a single move on the client with a bot.\n *\n * @param {...object} client - The game client.\n * @param {...object} bot - The bot.\n */\nexport async function Step(client: { store: Store }, bot: Bot) {\n  const state = client.store.getState();\n\n  let playerID = state.ctx.currentPlayer;\n  if (state.ctx.activePlayers) {\n    playerID = Object.keys(state.ctx.activePlayers)[0];\n  }\n\n  const { action, metadata } = await bot.play(state, playerID);\n\n  if (action) {\n    const a = {\n      ...action,\n      payload: {\n        ...action.payload,\n        metadata,\n      },\n    };\n    client.store.dispatch(a);\n    return a;\n  }\n}\n\n/**\n * Simulates the game till the end or a max depth.\n *\n * @param {...object} game - The game object.\n * @param {...object} bots - An array of bots.\n * @param {...object} state - The game state to start from.\n */\nexport async function Simulate({\n  game,\n  bots,\n  state,\n  depth,\n}: {\n  game: Game;\n  bots: Bot | Record<PlayerID, Bot>;\n  state: State;\n  depth?: number;\n}) {\n  if (depth === undefined) depth = 10000;\n  const reducer = CreateGameReducer({ game });\n\n  let metadata = null;\n  let iter = 0;\n  while (state.ctx.gameover === undefined && iter < depth) {\n    let playerID = state.ctx.currentPlayer;\n    if (state.ctx.activePlayers) {\n      playerID = Object.keys(state.ctx.activePlayers)[0];\n    }\n\n    const bot = bots instanceof Bot ? bots : bots[playerID];\n    const t = await bot.play(state, playerID);\n\n    if (!t.action) {\n      break;\n    }\n\n    metadata = t.metadata;\n    state = reducer(state, t.action);\n    iter++;\n  }\n\n  return { state, metadata };\n}\n"
  },
  {
    "path": "src/ai/bot.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { makeMove, gameEvent } from '../core/action-creators';\nimport { alea } from '../plugins/random/random.alea';\nimport type { AleaState } from '../plugins/random/random.alea';\nimport type { ActionShape, Game, Ctx, PlayerID, State } from '../types';\n\nexport type BotAction = ActionShape.GameEvent | ActionShape.MakeMove;\n\n/**\n * Base class that bots can extend.\n */\nexport abstract class Bot {\n  private enumerateFn: Game['ai']['enumerate'];\n  private seed?: string | number;\n  protected iterationCounter: number;\n  private _opts: Record<\n    string,\n    {\n      range?: { min: number; max: number };\n      value: any;\n    }\n  >;\n  private prngstate?: AleaState;\n\n  constructor({\n    enumerate,\n    seed,\n  }: {\n    enumerate: Game['ai']['enumerate'];\n    seed?: string | number;\n  }) {\n    this.enumerateFn = enumerate;\n    this.seed = seed;\n    this.iterationCounter = 0;\n    this._opts = {};\n  }\n\n  abstract play(\n    state: State,\n    playerID: PlayerID\n  ): Promise<{ action: BotAction; metadata?: any }>;\n\n  addOpt({\n    key,\n    range,\n    initial,\n  }: {\n    key: string;\n    range?: { min: number; max: number };\n    initial: any;\n  }) {\n    this._opts[key] = {\n      range,\n      value: initial,\n    };\n  }\n\n  getOpt(key: string) {\n    return this._opts[key].value;\n  }\n\n  setOpt(key: string, value: any) {\n    if (key in this._opts) {\n      this._opts[key].value = value;\n    }\n  }\n\n  opts() {\n    return this._opts;\n  }\n\n  enumerate(G: any, ctx: Ctx, playerID: PlayerID) {\n    const actions = this.enumerateFn(G, ctx, playerID);\n    return actions.map((a) => {\n      if ('payload' in a) {\n        return a;\n      }\n\n      if ('move' in a) {\n        return makeMove(a.move, a.args, playerID);\n      }\n\n      if ('event' in a) {\n        return gameEvent(a.event, a.args, playerID);\n      }\n    });\n  }\n\n  random<T extends any = any>(arg: T[]): T;\n  random(arg?: number): number;\n  random<T extends any = any>(arg?: number | T[]) {\n    let number: number;\n\n    if (this.seed !== undefined) {\n      const seed = this.prngstate ? '' : this.seed;\n      const rand = alea(seed, this.prngstate);\n\n      number = rand();\n      this.prngstate = rand.state();\n    } else {\n      number = Math.random();\n    }\n\n    if (arg) {\n      if (Array.isArray(arg)) {\n        const id = Math.floor(number * arg.length);\n        return arg[id];\n      } else {\n        return Math.floor(number * arg);\n      }\n    }\n\n    return number;\n  }\n}\n"
  },
  {
    "path": "src/ai/mcts-bot.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\nimport 'setimmediate';\nimport { CreateGameReducer } from '../core/reducer';\nimport { Bot } from './bot';\nimport type { BotAction } from './bot';\nimport type { Game, PlayerID, Ctx, State, Reducer } from '../types';\n\nexport interface Node {\n  /** Game state at this node. */\n  state: State;\n  /** Parent of the node. */\n  parent?: Node;\n  /** Move used to get to this node. */\n  parentAction?: BotAction;\n  /** Unexplored actions. */\n  actions: BotAction[];\n  /** Current objectives. */\n  objectives: Objectives | Objectives[];\n  /** Children of the node. */\n  children: Node[];\n  /** Number of simulations that pass through this node. */\n  visits: number;\n  /** Number of wins for this node. */\n  value: number;\n}\n\ninterface Objective {\n  checker: (G: any, ctx: Ctx) => boolean;\n  weight: number;\n}\n\ntype Objectives = Record<string, Objective>;\n\n/**\n * The number of iterations to run before yielding to\n * the JS event loop (in async mode).\n */\nconst CHUNK_SIZE = 25;\n\n/**\n * Bot that uses Monte-Carlo Tree Search to find promising moves.\n */\nexport class MCTSBot extends Bot {\n  private objectives: (G: any, ctx: Ctx, playerID: PlayerID) => Objectives;\n  private iterationCallback: (data: {\n    iterationCounter: number;\n    numIterations: number;\n    metadata: Node;\n  }) => void;\n  private reducer: Reducer;\n  iterations: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);\n  playoutDepth?: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);\n\n  constructor({\n    enumerate,\n    seed,\n    objectives,\n    game,\n    iterations,\n    playoutDepth,\n    iterationCallback,\n  }: {\n    enumerate: Game['ai']['enumerate'];\n    seed?: string | number;\n    game: Game;\n    objectives?: (G: any, ctx: Ctx, playerID?: PlayerID) => Objectives;\n    iterations?: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);\n    playoutDepth?: number | ((G: any, ctx: Ctx, playerID?: PlayerID) => number);\n    iterationCallback?: (data: {\n      iterationCounter: number;\n      numIterations: number;\n      metadata: Node;\n    }) => void;\n  }) {\n    super({ enumerate, seed });\n\n    if (objectives === undefined) {\n      objectives = () => ({});\n    }\n\n    this.objectives = objectives;\n    this.iterationCallback = iterationCallback || (() => {});\n    this.reducer = CreateGameReducer({ game });\n    this.iterations = iterations;\n    this.playoutDepth = playoutDepth;\n\n    this.addOpt({\n      key: 'async',\n      initial: false,\n    });\n\n    this.addOpt({\n      key: 'iterations',\n      initial: typeof iterations === 'number' ? iterations : 1000,\n      range: { min: 1, max: 2000 },\n    });\n\n    this.addOpt({\n      key: 'playoutDepth',\n      initial: typeof playoutDepth === 'number' ? playoutDepth : 50,\n      range: { min: 1, max: 100 },\n    });\n  }\n\n  private createNode({\n    state,\n    parentAction,\n    parent,\n    playerID,\n  }: {\n    state: State;\n    parentAction?: BotAction;\n    parent?: Node;\n    playerID?: PlayerID;\n  }): Node {\n    const { G, ctx } = state;\n\n    let actions: BotAction[] = [];\n    let objectives: Objectives | Objectives[] = [];\n\n    if (playerID !== undefined) {\n      actions = this.enumerate(G, ctx, playerID);\n      objectives = this.objectives(G, ctx, playerID);\n    } else if (ctx.activePlayers) {\n      for (const playerID in ctx.activePlayers) {\n        actions.push(...this.enumerate(G, ctx, playerID));\n        objectives.push(this.objectives(G, ctx, playerID));\n      }\n    } else {\n      actions = this.enumerate(G, ctx, ctx.currentPlayer);\n      objectives = this.objectives(G, ctx, ctx.currentPlayer);\n    }\n\n    return {\n      state,\n      parent,\n      parentAction,\n      actions,\n      objectives,\n      children: [],\n      visits: 0,\n      value: 0,\n    };\n  }\n\n  private select(node: Node) {\n    // This node has unvisited children.\n    if (node.actions.length > 0) {\n      return node;\n    }\n\n    // This is a terminal node.\n    if (node.children.length === 0) {\n      return node;\n    }\n\n    let selectedChild = null;\n    let best = 0;\n\n    for (const child of node.children) {\n      const childVisits = child.visits + Number.EPSILON;\n      const uct =\n        child.value / childVisits +\n        Math.sqrt((2 * Math.log(node.visits)) / childVisits);\n      if (selectedChild == null || uct > best) {\n        best = uct;\n        selectedChild = child;\n      }\n    }\n\n    return this.select(selectedChild);\n  }\n\n  private expand(node: Node) {\n    const actions = node.actions;\n\n    if (actions.length === 0 || node.state.ctx.gameover !== undefined) {\n      return node;\n    }\n\n    const id = this.random(actions.length);\n    const action = actions[id];\n    node.actions.splice(id, 1);\n    const childState = this.reducer(node.state, action);\n    const childNode = this.createNode({\n      state: childState,\n      parentAction: action,\n      parent: node,\n    });\n    node.children.push(childNode);\n    return childNode;\n  }\n\n  playout({ state }: Node) {\n    let playoutDepth = this.getOpt('playoutDepth');\n    if (typeof this.playoutDepth === 'function') {\n      playoutDepth = this.playoutDepth(state.G, state.ctx);\n    }\n\n    for (let i = 0; i < playoutDepth && state.ctx.gameover === undefined; i++) {\n      const { G, ctx } = state;\n      let playerID = ctx.currentPlayer;\n      if (ctx.activePlayers) {\n        playerID = Object.keys(ctx.activePlayers)[0];\n      }\n      const moves = this.enumerate(G, ctx, playerID);\n\n      // Check if any objectives are met.\n      const objectives = this.objectives(G, ctx, playerID);\n      const score = Object.keys(objectives).reduce((score, key) => {\n        const objective = objectives[key];\n        if (objective.checker(G, ctx)) {\n          return score + objective.weight;\n        }\n        return score;\n      }, 0);\n\n      // If so, stop and return the score.\n      if (score > 0) {\n        return { score };\n      }\n\n      if (!moves || moves.length === 0) {\n        return undefined;\n      }\n\n      const id = this.random(moves.length);\n      const childState = this.reducer(state, moves[id]);\n      state = childState;\n    }\n\n    return state.ctx.gameover;\n  }\n\n  private backpropagate(\n    node: Node,\n    result: { score?: number; draw?: boolean; winner?: PlayerID } = {}\n  ) {\n    node.visits++;\n\n    if (result.score !== undefined) {\n      node.value += result.score;\n    }\n\n    if (result.draw === true) {\n      node.value += 0.5;\n    }\n\n    if (\n      node.parentAction &&\n      result.winner === node.parentAction.payload.playerID\n    ) {\n      node.value++;\n    }\n\n    if (node.parent) {\n      this.backpropagate(node.parent, result);\n    }\n  }\n\n  play(\n    state: State,\n    playerID: PlayerID\n  ): Promise<{ action: BotAction; metadata: Node }> {\n    const root = this.createNode({ state, playerID });\n\n    let numIterations = this.getOpt('iterations');\n    if (typeof this.iterations === 'function') {\n      numIterations = this.iterations(state.G, state.ctx);\n    }\n\n    const getResult = () => {\n      let selectedChild: Node | null = null;\n      for (const child of root.children) {\n        if (selectedChild == null || child.visits > selectedChild.visits) {\n          selectedChild = child;\n        }\n      }\n\n      const action = selectedChild && selectedChild.parentAction;\n      const metadata = root;\n      return { action, metadata };\n    };\n\n    return new Promise((resolve) => {\n      const iteration = () => {\n        for (\n          let i = 0;\n          i < CHUNK_SIZE && this.iterationCounter < numIterations;\n          i++\n        ) {\n          const leaf = this.select(root);\n          const child = this.expand(leaf);\n          const result = this.playout(child);\n          this.backpropagate(child, result);\n          this.iterationCounter++;\n        }\n        this.iterationCallback({\n          iterationCounter: this.iterationCounter,\n          numIterations,\n          metadata: root,\n        });\n      };\n\n      this.iterationCounter = 0;\n\n      if (this.getOpt('async')) {\n        const asyncIteration = () => {\n          if (this.iterationCounter < numIterations) {\n            iteration();\n            setImmediate(asyncIteration);\n          } else {\n            resolve(getResult());\n          }\n        };\n        asyncIteration();\n      } else {\n        while (this.iterationCounter < numIterations) {\n          iteration();\n        }\n        resolve(getResult());\n      }\n    });\n  }\n}\n"
  },
  {
    "path": "src/ai/random-bot.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Bot } from './bot';\nimport type { Ctx, PlayerID } from '../types';\n\n/**\n * Bot that picks a move at random.\n */\nexport class RandomBot extends Bot {\n  play({ G, ctx }: { G: any; ctx: Ctx }, playerID: PlayerID) {\n    const moves = this.enumerate(G, ctx, playerID);\n    return Promise.resolve({ action: this.random(moves) });\n  }\n}\n"
  },
  {
    "path": "src/client/client.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { INVALID_MOVE } from '../core/constants';\nimport { createStore } from 'redux';\nimport { CreateGameReducer } from '../core/reducer';\nimport { InitializeGame } from '../core/initialize';\nimport { Client, createMoveDispatchers } from './client';\nimport { ProcessGameConfig } from '../core/game';\nimport { Transport } from './transport/transport';\nimport { LocalTransport, Local } from './transport/local';\nimport { SocketIOTransport, SocketIO } from './transport/socketio';\nimport {\n  update,\n  sync,\n  makeMove,\n  gameEvent,\n  patch,\n} from '../core/action-creators';\nimport * as Actions from '../core/action-types';\nimport Debug from './debug/Debug.svelte';\nimport { error } from '../core/logger';\nimport type { Game, LogEntry, State, SyncInfo } from '../types';\nimport type { Operation } from 'rfc6902';\nimport type { TransportData } from '../master/master';\n\njest.mock('../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\ndescribe('basic', () => {\n  let client: ReturnType<typeof Client>;\n  const initial = { initial: true };\n\n  const game: Game = {\n    setup: () => initial,\n  };\n\n  beforeAll(() => {\n    client = Client({ game });\n  });\n\n  test('getState', () => {\n    expect(client.getState().G).toEqual(initial);\n  });\n\n  test('getInitialState', () => {\n    expect(client.getInitialState().G).toEqual(initial);\n  });\n});\n\ntest('move api', () => {\n  const client = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n  });\n\n  expect(client.getState().G).toEqual({});\n  client.moves.A(42);\n  expect(client.getState().G).toEqual({ arg: 42 });\n});\n\ndescribe('namespaced moves', () => {\n  let client: ReturnType<typeof Client>;\n  beforeAll(() => {\n    client = Client({\n      game: {\n        moves: {\n          A: () => 'A',\n        },\n\n        phases: {\n          PA: {\n            moves: {\n              B: () => 'B',\n              C: () => 'C',\n            },\n          },\n        },\n      },\n    });\n  });\n\n  test('top-level moves', () => {\n    expect(client.moves.A).toBeInstanceOf(Function);\n  });\n\n  test('phase-level moves', () => {\n    expect(client.moves.B).toBeInstanceOf(Function);\n    expect(client.moves.C).toBeInstanceOf(Function);\n  });\n\n  test('moves are allowed only when phase is active', () => {\n    client.moves.A();\n    expect(client.getState().G).toEqual('A');\n\n    client.moves.B();\n    expect(error).toHaveBeenCalledWith('disallowed move: B');\n    client.moves.C();\n    expect(error).toHaveBeenCalledWith('disallowed move: C');\n\n    client.events.setPhase('PA');\n    expect(client.getState().ctx.phase).toBe('PA');\n\n    client.moves.A();\n    expect(error).toHaveBeenCalledWith('disallowed move: A');\n    client.moves.B();\n    expect(client.getState().G).toEqual('B');\n    client.moves.C();\n    expect(client.getState().G).toEqual('C');\n  });\n});\n\ntest('isActive', () => {\n  const client = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n\n      endIf: ({ G }) => G.arg == 42,\n    },\n  });\n\n  expect(client.getState().G).toEqual({});\n  expect(client.getState().isActive).toBe(true);\n  client.moves.A(42);\n  expect(client.getState().G).toEqual({ arg: 42 });\n  expect(client.getState().isActive).toBe(false);\n});\n\ndescribe('multiplayer', () => {\n  describe('socket.io master', () => {\n    const host = 'host';\n    const port = '4321';\n    let client;\n\n    beforeAll(() => {\n      client = Client({\n        game: { moves: { A: () => {}, Invalid: () => INVALID_MOVE } },\n        multiplayer: SocketIO({ server: host + ':' + port }),\n      });\n      client.start();\n    });\n\n    afterAll(() => {\n      client.stop();\n      jest.restoreAllMocks();\n    });\n\n    test('correct transport used', () => {\n      expect(client.transport instanceof SocketIOTransport).toBe(true);\n    });\n\n    test('server set when provided', () => {\n      expect(client.transport.socket.io.engine.hostname).toEqual(host);\n      expect(client.transport.socket.io.engine.port).toEqual(port);\n    });\n\n    test('onAction called', () => {\n      jest.spyOn(client.transport, 'sendAction');\n      const state = { G: {}, ctx: { phase: '' }, plugins: {} };\n      const filteredMetadata = [];\n      client.store.dispatch(sync({ state, filteredMetadata } as SyncInfo));\n      client.moves.A();\n      expect(client.transport.sendAction).toHaveBeenCalled();\n    });\n\n    test('strip transients action not sent to transport', () => {\n      jest.spyOn(client.transport, 'sendAction');\n      const state = { G: {}, ctx: { phase: '' }, plugins: {} };\n      const filteredMetadata = [];\n      client.store.dispatch(sync({ state, filteredMetadata } as SyncInfo));\n      client.moves.Invalid();\n      expect(client.transport.sendAction).not.toHaveBeenCalledWith(\n        expect.any(Object),\n        { type: Actions.STRIP_TRANSIENTS }\n      );\n    });\n\n    test('Sends and receives chat messages', () => {\n      jest.spyOn(client.transport, 'sendAction');\n      client.updatePlayerID('0');\n      client.updateMatchID('matchID');\n      jest.spyOn(client.transport, 'sendChatMessage');\n\n      client.sendChatMessage({ message: 'foo' });\n\n      expect(client.transport.sendChatMessage).toHaveBeenCalledWith(\n        'matchID',\n        expect.objectContaining({ payload: { message: 'foo' }, sender: '0' })\n      );\n    });\n  });\n\n  describe('multiplayer: SocketIO()', () => {\n    let client;\n\n    beforeAll(() => {\n      client = Client({\n        game: {},\n        multiplayer: SocketIO(),\n      });\n      client.start();\n    });\n\n    afterAll(() => {\n      client.stop();\n    });\n\n    test('correct transport used', () => {\n      expect(client.transport instanceof SocketIOTransport).toBe(true);\n    });\n  });\n\n  describe('local master', () => {\n    let client0;\n    let client1;\n    let spec;\n\n    beforeAll(() => {\n      spec = {\n        game: { moves: { A: ({ playerID }) => ({ A: playerID }) } },\n        multiplayer: Local(),\n      };\n\n      client0 = Client({ ...spec, playerID: '0' });\n      client1 = Client({ ...spec, playerID: '1' });\n\n      client0.start();\n      client1.start();\n    });\n\n    afterAll(() => {\n      client0.stop();\n      client1.stop();\n    });\n\n    test('correct transport used', () => {\n      expect(client0.transport instanceof LocalTransport).toBe(true);\n      expect(client1.transport instanceof LocalTransport).toBe(true);\n    });\n\n    test('multiplayer interactions', () => {\n      expect(client0.getState().ctx.currentPlayer).toBe('0');\n      expect(client1.getState().ctx.currentPlayer).toBe('0');\n\n      client0.moves.A();\n\n      expect(client0.getState().G).toEqual({ A: '0' });\n      expect(client1.getState().G).toEqual({ A: '0' });\n\n      client0.events.endTurn();\n\n      expect(client0.getState().ctx.currentPlayer).toBe('1');\n      expect(client1.getState().ctx.currentPlayer).toBe('1');\n\n      client1.moves.A();\n\n      expect(client0.getState().G).toEqual({ A: '1' });\n      expect(client1.getState().G).toEqual({ A: '1' });\n\n      client0.sendChatMessage({ message: 'foo' });\n\n      expect(client0.chatMessages).toEqual([\n        expect.objectContaining({ sender: '0', payload: { message: 'foo' } }),\n      ]);\n      expect(client1.chatMessages).toEqual([\n        expect.objectContaining({ sender: '0', payload: { message: 'foo' } }),\n      ]);\n\n      client1.sendChatMessage({ message: 'bar' });\n      expect(client0.chatMessages).toEqual([\n        expect.objectContaining({ sender: '0', payload: { message: 'foo' } }),\n        expect.objectContaining({ sender: '1', payload: { message: 'bar' } }),\n      ]);\n      expect(client1.chatMessages).toEqual([\n        expect.objectContaining({ sender: '0', payload: { message: 'foo' } }),\n        expect.objectContaining({ sender: '1', payload: { message: 'bar' } }),\n      ]);\n    });\n  });\n\n  describe('custom transport', () => {\n    class CustomTransport extends Transport {\n      connect() {}\n      disconnect() {}\n      sendAction() {}\n      sendChatMessage() {}\n      requestSync() {}\n      updateMatchID() {}\n      updatePlayerID() {}\n      updateCredentials() {}\n      setMetadata(metadata) {\n        this.notifyClient({ type: 'matchData', args: ['default', metadata] });\n      }\n    }\n    const customTransport = (opts) => new CustomTransport(opts);\n\n    let client;\n\n    beforeAll(() => {\n      client = Client({\n        game: { moves: { A: () => {} } },\n        multiplayer: customTransport,\n      });\n    });\n\n    test('correct transport used', () => {\n      expect(client.transport).toBeInstanceOf(CustomTransport);\n    });\n\n    test('metadata callback', () => {\n      const metadata = { m: true };\n      client.transport.setMetadata(metadata);\n      expect(client.matchData).toEqual(metadata);\n    });\n  });\n});\n\ndescribe('receiveTransportData', () => {\n  let sendToClient: (data: TransportData) => void;\n  let client: ReturnType<typeof Client>;\n  let requestSync: jest.Mock;\n\n  beforeEach(() => {\n    requestSync = jest.fn();\n    client = Client({\n      game: {},\n      matchID: 'A',\n      debug: false,\n      // Use the multiplayer interface to extract the client callback\n      // and use it to send updates to the client directly.\n      multiplayer: ({ transportDataCallback }) => {\n        sendToClient = transportDataCallback;\n        return {\n          connect() {},\n          disconnect() {},\n          subscribe() {},\n          requestSync,\n        } as unknown as Transport;\n      },\n    });\n    client.start();\n  });\n\n  afterEach(() => {\n    client.stop();\n  });\n\n  test('discards update with wrong matchID', () => {\n    sendToClient({\n      type: 'sync',\n      args: ['wrongID', { state: { G: 'G', ctx: {} } } as SyncInfo],\n    });\n    expect(client.getState()).toBeNull();\n  });\n\n  test('applies sync', () => {\n    const state = { G: 'G', ctx: {} };\n    sendToClient({ type: 'sync', args: ['A', { state } as SyncInfo] });\n    expect(client.getState().G).toEqual(state.G);\n  });\n\n  test('applies update', () => {\n    const state1 = { G: 'G1', _stateID: 1, ctx: {} } as State;\n    const state2 = { G: 'G2', _stateID: 2, ctx: {} } as State;\n    sendToClient({ type: 'sync', args: ['A', { state: state1 } as SyncInfo] });\n    sendToClient({ type: 'update', args: ['A', state2, []] });\n    expect(client.getState().G).toEqual(state2.G);\n  });\n\n  test('ignores stale update', () => {\n    const state1 = { G: 'G1', _stateID: 1, ctx: {} } as State;\n    const state2 = { G: 'G2', _stateID: 0, ctx: {} } as State;\n    sendToClient({ type: 'sync', args: ['A', { state: state1 } as SyncInfo] });\n    sendToClient({ type: 'update', args: ['A', state2, []] });\n    expect(client.getState().G).toEqual(state1.G);\n  });\n\n  test('applies a patch', () => {\n    const state = { G: 'G1', _stateID: 1, ctx: {} } as State;\n    sendToClient({ type: 'sync', args: ['A', { state } as SyncInfo] });\n    sendToClient({\n      type: 'patch',\n      args: ['A', 1, 2, [{ op: 'replace', path: '/_stateID', value: 2 }], []],\n    });\n    expect(client.getState()._stateID).toBe(2);\n  });\n\n  test('ignores patch for different state ID', () => {\n    const state = { G: 'G1', _stateID: 1, ctx: {} } as State;\n    sendToClient({ type: 'sync', args: ['A', { state } as SyncInfo] });\n    sendToClient({\n      type: 'patch',\n      args: ['A', 2, 3, [{ op: 'replace', path: '/_stateID', value: 3 }], []],\n    });\n    expect(client.getState()._stateID).toBe(1);\n  });\n\n  test('resyncs after failed patch', () => {\n    const state = { G: 'G1', _stateID: 1, ctx: {} } as State;\n    sendToClient({ type: 'sync', args: ['A', { state } as SyncInfo] });\n    expect(requestSync).not.toHaveBeenCalled();\n    // Send bad patch.\n    sendToClient({\n      type: 'patch',\n      args: ['A', 1, 2, [{ op: 'replace', path: '/_stateIDD', value: 2 }], []],\n    });\n    // State is unchanged and the client requested to resync.\n    expect(client.getState()._stateID).toBe(1);\n    expect(requestSync).toHaveBeenCalled();\n  });\n\n  test('updates match metadata', () => {\n    expect(client.matchData).toBeUndefined();\n    const matchData = [{ id: 0 }];\n    sendToClient({ type: 'matchData', args: ['A', matchData] });\n    expect(client.matchData).toEqual(matchData);\n  });\n\n  test('appends a chat message', () => {\n    expect(client.chatMessages).toEqual([]);\n    const message = { id: 'x', sender: '0', payload: 'hi' };\n    sendToClient({ type: 'chat', args: ['A', message] });\n    expect(client.chatMessages).toEqual([message]);\n  });\n});\n\ndescribe('strip secret only on server', () => {\n  type G = { secret?: number[]; sum?: number; A?: string };\n  let client0;\n  let client1;\n  let spec: { game: Game<G>; multiplayer };\n  const initial = { secret: [1, 2, 3, 4], sum: 0 };\n  beforeAll(() => {\n    spec = {\n      game: {\n        setup: () => initial,\n        playerView: ({ G }) => {\n          const r = { ...G };\n          r.sum = r.secret.reduce((prev, curr) => prev + curr);\n          delete r.secret;\n          return r;\n        },\n        moves: { A: ({ playerID }) => ({ A: playerID }) },\n      },\n      multiplayer: Local(),\n    };\n\n    client0 = Client({ ...spec, playerID: '0' });\n    client1 = Client({ ...spec, playerID: '1' });\n\n    client0.start();\n    client1.start();\n  });\n\n  test('secret stripped', () => {\n    expect(client0.getState().G).toEqual({ sum: 10 });\n    expect(client1.getState().G).toEqual({ sum: 10 });\n  });\n\n  afterAll(() => {\n    client0.stop();\n    client1.stop();\n  });\n});\n\ntest('accepts enhancer for store', () => {\n  let spyDispatcher;\n  const spyEnhancer =\n    (vanillaCreateStore) =>\n    (...args) => {\n      const vanillaStore = vanillaCreateStore(...args);\n      return {\n        ...vanillaStore,\n        dispatch: (spyDispatcher = jest.fn(vanillaStore.dispatch)),\n      };\n    };\n  const client = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    enhancer: spyEnhancer,\n  });\n\n  expect(spyDispatcher.mock.calls).toHaveLength(0);\n  client.moves.A(42);\n  expect(spyDispatcher.mock.calls).toHaveLength(1);\n});\n\ndescribe('event dispatchers', () => {\n  const clientEvents = [\n    'endTurn',\n    'pass',\n    'endPhase',\n    'setPhase',\n    'endGame',\n    'setActivePlayers',\n    'endStage',\n    'setStage',\n  ];\n  test('default', () => {\n    const game: Game = {};\n    const client = Client({ game });\n    expect(Object.keys(client.events)).toEqual(clientEvents);\n    expect(client.getState().ctx.turn).toBe(1);\n    client.events.endTurn();\n    expect(client.getState().ctx.turn).toBe(2);\n  });\n\n  test('all events', () => {\n    const game: Game = {\n      events: {\n        endPhase: true,\n        endGame: true,\n      },\n    };\n    const client = Client({ game });\n    expect(Object.keys(client.events)).toEqual(clientEvents);\n    expect(client.getState().ctx.turn).toBe(1);\n    client.events.endTurn();\n    expect(client.getState().ctx.turn).toBe(2);\n  });\n\n  test('no events', () => {\n    const game: Game = {\n      events: {\n        endGame: false,\n        endPhase: false,\n        setPhase: false,\n        endTurn: false,\n        pass: false,\n        setActivePlayers: false,\n        endStage: false,\n        setStage: false,\n      },\n    };\n    const client = Client({ game });\n    expect(Object.keys(client.events)).toEqual([]);\n  });\n});\n\ndescribe('move dispatchers', () => {\n  const game = ProcessGameConfig({\n    moves: {\n      A: ({ G }) => G,\n      B: ({ playerID }) => ({ moved: playerID }),\n      C: () => ({ victory: true }),\n    },\n    endIf: ({ G, ctx }) => (G.victory ? ctx.currentPlayer : undefined),\n  });\n  const reducer = CreateGameReducer({ game });\n  const initialState = InitializeGame({ game });\n\n  test('basic', () => {\n    const store = createStore(reducer, initialState);\n    const api = createMoveDispatchers(game.moveNames, store);\n\n    expect(Object.getOwnPropertyNames(api)).toEqual(['A', 'B', 'C']);\n    expect(api.unknown).toBe(undefined);\n\n    api.A();\n    expect(store.getState().G).not.toMatchObject({ moved: true });\n    expect(store.getState().G).not.toMatchObject({ victory: true });\n\n    api.B();\n    expect(store.getState().G).toMatchObject({ moved: '0' });\n\n    store.dispatch(gameEvent('endTurn', null, '0'));\n\n    api.B();\n    expect(store.getState().G).toMatchObject({ moved: '1' });\n\n    api.C();\n    expect(store.getState().G).toMatchObject({ victory: true });\n  });\n\n  test('with undefined playerID - single player mode', () => {\n    const store = createStore(reducer, initialState);\n    const api = createMoveDispatchers(game.moveNames, store);\n    api.B();\n    expect(store.getState().G).toMatchObject({ moved: '0' });\n  });\n\n  test('with undefined playerID - multiplayer mode', () => {\n    const store = createStore(reducer, initialState);\n    const api = createMoveDispatchers(\n      game.moveNames,\n      store,\n      undefined,\n      null,\n      true\n    );\n    api.B();\n    expect(store.getState().G).toMatchObject({ moved: undefined });\n  });\n\n  test('with null playerID - single player mode', () => {\n    const store = createStore(reducer, initialState);\n    const api = createMoveDispatchers(game.moveNames, store, null);\n    api.B();\n    expect(store.getState().G).toMatchObject({ moved: '0' });\n  });\n\n  test('with null playerID - multiplayer mode', () => {\n    const store = createStore(reducer, initialState);\n    const api = createMoveDispatchers(game.moveNames, store, null, null, true);\n    api.B();\n    expect(store.getState().G).toMatchObject({ moved: null });\n  });\n});\n\ndescribe('transient handling', () => {\n  let client = null;\n\n  beforeEach(() => {\n    client = Client({\n      game: {\n        moves: {\n          A: () => ({}),\n          Invalid: () => INVALID_MOVE,\n        },\n      },\n    });\n  });\n\n  test('regular move', () => {\n    const result = client.moves.A();\n    // TODO(#723): Check against a successful ActionResult.\n    expect(result).toBeUndefined();\n    const state = client.store.getState();\n    // Slightly paranoid check to ensure we don't erroneously add transients.\n    expect(state).toEqual(\n      expect.not.objectContaining({ transients: expect.anything() })\n    );\n  });\n\n  test('invalid move', () => {\n    const result = client.moves.Invalid();\n    // TODO(#723): Check against an errored ActionResult.\n    expect(result).toBeUndefined();\n    const state = client.store.getState();\n    // Ensure we've stripped the transients automagically.\n    // At the time this test was written, this effectively ensures that Client\n    // hooks up the TransientHandlingMiddleware correctly.\n    expect(state).toEqual(\n      expect.not.objectContaining({ transients: expect.anything() })\n    );\n  });\n});\n\ndescribe('log handling', () => {\n  let client = null;\n\n  beforeEach(() => {\n    client = Client({\n      game: {\n        moves: {\n          A: () => ({}),\n        },\n      },\n    });\n  });\n\n  test('regular', () => {\n    client.moves.A();\n    client.moves.A();\n\n    expect(client.log).toEqual([\n      {\n        action: makeMove('A', [], '0'),\n        _stateID: 0,\n        phase: null,\n        turn: 1,\n      },\n      {\n        action: makeMove('A', [], '0'),\n        _stateID: 1,\n        phase: null,\n        turn: 1,\n      },\n    ]);\n  });\n\n  test('update', () => {\n    const state = { restore: true, _stateID: 0 } as unknown as State;\n    const deltalog = [\n      {\n        action: {},\n        _stateID: 0,\n      },\n      {\n        action: {},\n        _stateID: 1,\n      },\n    ] as LogEntry[];\n    const action = update(state, deltalog);\n\n    client.store.dispatch(action);\n    client.store.dispatch(action);\n\n    expect(client.log).toEqual(deltalog);\n  });\n\n  test('patch', () => {\n    const patches = [\n      { op: 'replace', path: '/_stateID', value: 1 },\n    ] as Operation[];\n    const deltalog = [\n      {\n        action: {},\n        _stateID: 0,\n      },\n      {\n        action: {},\n        _stateID: 1,\n      },\n    ] as LogEntry[];\n    const action = patch(0, 1, patches, deltalog);\n    client.store.dispatch(action);\n\n    expect(client.log).toEqual(deltalog);\n  });\n\n  test('sync', () => {\n    const state = { restore: true };\n    const log = ['0', '1'];\n    const action = sync({ state, log } as unknown as SyncInfo);\n\n    client.store.dispatch(action);\n    client.store.dispatch(action);\n\n    expect(client.log).toEqual(log);\n  });\n\n  test('update - log missing', () => {\n    const action = update(undefined, undefined);\n    client.store.dispatch(action);\n    expect(client.log).toEqual([]);\n  });\n\n  test('sync - log missing', () => {\n    const action = sync({} as SyncInfo);\n    client.store.dispatch(action);\n    expect(client.log).toEqual([]);\n  });\n});\n\ndescribe('undo / redo', () => {\n  const game: Game = {\n    moves: {\n      A: (_, arg) => ({ arg }),\n    },\n  };\n\n  test('basic', () => {\n    const client = Client({ game });\n\n    expect(client.getState().G).toEqual({});\n    client.moves.A(42);\n    expect(client.getState().G).toEqual({ arg: 42 });\n\n    client.undo();\n    expect(client.getState().G).toEqual({});\n\n    client.redo();\n    expect(client.getState().G).toEqual({ arg: 42 });\n  });\n});\n\ndescribe('subscribe', () => {\n  let client;\n  let fn;\n  beforeAll(() => {\n    const game: Game = {\n      moves: {\n        A: ({ G }) => {\n          G.moved = true;\n        },\n      },\n    };\n    client = Client({ game });\n    fn = jest.fn();\n    client.subscribe(fn);\n  });\n\n  test('called at the beginning', () => {\n    expect(fn).toBeCalledWith(\n      expect.objectContaining({\n        G: {},\n        ctx: expect.objectContaining({ turn: 1 }),\n      })\n    );\n  });\n\n  test('called after a move', () => {\n    fn.mockClear();\n    client.moves.A();\n    expect(fn).toBeCalledWith(\n      expect.objectContaining({\n        G: { moved: true },\n      })\n    );\n  });\n\n  test('called after an event', () => {\n    fn.mockClear();\n    client.events.endTurn();\n    expect(fn).toBeCalledWith(\n      expect.objectContaining({\n        ctx: expect.objectContaining({ turn: 2 }),\n      })\n    );\n  });\n\n  test('multiple subscriptions', () => {\n    fn.mockClear();\n\n    const fn2 = jest.fn();\n    const unsubscribe = client.subscribe(fn2);\n\n    // The subscriber that just subscribed is notified.\n    expect(fn).not.toBeCalled();\n    expect(fn2).toBeCalledWith(\n      expect.objectContaining({\n        G: { moved: true },\n      })\n    );\n\n    fn.mockClear();\n    fn2.mockClear();\n\n    client.moves.A();\n\n    // Both subscribers are notified.\n    expect(fn).toBeCalledWith(\n      expect.objectContaining({\n        G: { moved: true },\n      })\n    );\n    expect(fn2).toBeCalledWith(\n      expect.objectContaining({\n        G: { moved: true },\n      })\n    );\n\n    unsubscribe();\n\n    fn.mockClear();\n    fn2.mockClear();\n\n    // The subscriber the unsubscribed is not notified.\n    client.moves.A();\n    expect(fn).toBeCalledWith(\n      expect.objectContaining({\n        G: { moved: true },\n      })\n    );\n    expect(fn2).not.toBeCalled();\n  });\n\n  test('transport notifies subscribers', () => {\n    let transport: ReturnType<ReturnType<typeof SocketIO>>;\n    const multiplayer = (opts: any) => {\n      transport = SocketIO()(opts);\n      return transport;\n    };\n    const client = Client({ game: {}, multiplayer });\n    const fn = jest.fn();\n    client.subscribe(fn);\n    client.start();\n    fn.mockClear();\n    (transport as any).connectionStatusCallback();\n    expect(fn).toHaveBeenCalled();\n    client.stop();\n  });\n\n  describe('multiplayer', () => {\n    test('subscribe before start', () => {\n      const fn = jest.fn();\n      const client = Client({\n        game: {},\n        multiplayer: Local(),\n      });\n      client.subscribe(fn);\n      expect(fn).not.toBeCalled();\n      client.start();\n      expect(fn).toBeCalled();\n      client.stop();\n    });\n\n    test('subscribe after start', () => {\n      const fn = jest.fn();\n      const client = Client({\n        game: {},\n        multiplayer: Local(),\n      });\n      client.start();\n      client.subscribe(fn);\n      expect(fn).toBeCalled();\n      client.stop();\n    });\n  });\n});\n\ntest('override game state', () => {\n  const game: Game = {\n    moves: {\n      A: ({ G }) => {\n        G.moved = true;\n      },\n    },\n  };\n  const client = Client({ game });\n  client.moves.A();\n  expect(client.getState().G).toEqual({ moved: true });\n  client.overrideGameState({ G: { override: true }, ctx: {} });\n  expect(client.getState().G).toEqual({ override: true });\n  client.overrideGameState(null);\n  expect(client.getState().G).toEqual({ moved: true });\n});\n\n// TODO(#941): These tests should validate DOM mounting/unmounting.\ndescribe('start / stop', () => {\n  beforeEach(() => {\n    // Don't let other calls to `error` pollute this state.\n    jest.resetAllMocks();\n  });\n\n  test('mount on custom element', () => {\n    const el = document.createElement('div');\n    const client = Client({ game: {}, debug: { target: el } });\n    expect(() => {\n      client.start();\n      client.stop();\n    }).not.toThrow();\n    expect(error).not.toHaveBeenCalled();\n  });\n\n  test('no error when mounting on null element', () => {\n    const client = Client({ game: {}, debug: { target: null } }) as any;\n    expect(() => {\n      client.start();\n      client.stop();\n    }).not.toThrow();\n\n    client.start();\n    client.stop();\n    expect(client.manager.debugPanel).toBe(null);\n  });\n\n  test('override debug implementation', () => {\n    const client = Client({ game: {}, debug: { impl: Debug } });\n    expect(() => {\n      client.start();\n      client.stop();\n    }).not.toThrow();\n\n    client.start();\n    client.stop();\n    expect(error).not.toHaveBeenCalled();\n  });\n\n  test('production mode', () => {\n    process.env.NODE_ENV = 'production';\n    const client = Client({ game: {} });\n    expect(() => {\n      client.start();\n      client.stop();\n    }).not.toThrow();\n    expect(error).not.toHaveBeenCalled();\n  });\n\n  test('try to stop without starting', () => {\n    const client = Client({ game: {} });\n    expect(() => {\n      client.stop();\n    }).not.toThrow();\n    expect(error).not.toHaveBeenCalled();\n  });\n});\n"
  },
  {
    "path": "src/client/client.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { nanoid } from 'nanoid/non-secure';\nimport 'svelte';\nimport type { Dispatch, StoreEnhancer } from 'redux';\nimport { createStore, compose, applyMiddleware } from 'redux';\nimport * as Actions from '../core/action-types';\nimport * as ActionCreators from '../core/action-creators';\nimport { ProcessGameConfig } from '../core/game';\nimport type Debug from './debug/Debug.svelte';\nimport {\n  CreateGameReducer,\n  TransientHandlingMiddleware,\n} from '../core/reducer';\nimport { InitializeGame } from '../core/initialize';\nimport { PlayerView } from '../plugins/main';\nimport type { Transport, TransportOpts } from './transport/transport';\nimport { DummyTransport } from './transport/dummy';\nimport { ClientManager } from './manager';\nimport type { TransportData } from '../master/master';\nimport type {\n  ActivePlayersArg,\n  ActionShape,\n  CredentialedActionShape,\n  FilteredMetadata,\n  Game,\n  LogEntry,\n  PlayerID,\n  Reducer,\n  State,\n  Store,\n  ChatMessage,\n} from '../types';\n\ntype ClientAction =\n  | ActionShape.Reset\n  | ActionShape.Sync\n  | ActionShape.Update\n  | ActionShape.Patch;\ntype Action =\n  | CredentialedActionShape.Any\n  | ActionShape.StripTransients\n  | ClientAction;\n\nexport interface DebugOpt {\n  target?: HTMLElement;\n  impl?: typeof Debug;\n  collapseOnLoad?: boolean;\n  hideToggleButton?: boolean;\n}\n\n/**\n * Global client manager instance that all clients register with.\n */\nconst GlobalClientManager = new ClientManager();\n\n/**\n * Standardise the passed playerID, using currentPlayer if appropriate.\n */\nfunction assumedPlayerID(\n  playerID: PlayerID | null | undefined,\n  store: Store,\n  multiplayer?: unknown\n): PlayerID {\n  // In singleplayer mode, if the client does not have a playerID\n  // associated with it, we attach the currentPlayer as playerID.\n  if (!multiplayer && (playerID === null || playerID === undefined)) {\n    const state = store.getState();\n    playerID = state.ctx.currentPlayer;\n  }\n\n  return playerID;\n}\n\n/**\n * createDispatchers\n *\n * Create action dispatcher wrappers with bound playerID and credentials\n */\nfunction createDispatchers(\n  storeActionType: 'makeMove' | 'gameEvent' | 'plugin',\n  innerActionNames: string[],\n  store: Store,\n  playerID: PlayerID,\n  credentials: string,\n  multiplayer?: unknown\n) {\n  const dispatchers: Record<string, (...args: any[]) => void> = {};\n  for (const name of innerActionNames) {\n    dispatchers[name] = (...args) => {\n      const action = ActionCreators[storeActionType](\n        name,\n        args,\n        assumedPlayerID(playerID, store, multiplayer),\n        credentials\n      );\n      store.dispatch(action);\n    };\n  }\n  return dispatchers;\n}\n\n// Creates a set of dispatchers to make moves.\nexport const createMoveDispatchers = createDispatchers.bind(null, 'makeMove');\n// Creates a set of dispatchers to dispatch game flow events.\nexport const createEventDispatchers = createDispatchers.bind(null, 'gameEvent');\n// Creates a set of dispatchers to dispatch actions to plugins.\nexport const createPluginDispatchers = createDispatchers.bind(null, 'plugin');\n\nexport interface ClientOpts<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  game: Game<G, PluginAPIs>;\n  debug?: DebugOpt | boolean;\n  numPlayers?: number;\n  multiplayer?: (opts: TransportOpts) => Transport;\n  matchID?: string;\n  playerID?: PlayerID;\n  credentials?: string;\n  enhancer?: StoreEnhancer;\n}\n\nexport type ClientState<G extends any = any> =\n  | null\n  | (State<G> & {\n      isActive: boolean;\n      isConnected: boolean;\n      log: LogEntry[];\n    });\n\n/**\n * Implementation of Client (see below).\n */\nexport class _ClientImpl<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  private gameStateOverride?: any;\n  private initialState: State<G>;\n  readonly multiplayer: (opts: TransportOpts) => Transport;\n  private reducer: Reducer;\n  private _running: boolean;\n  private subscribers: Record<string, (state: State<G> | null) => void>;\n  private transport: Transport;\n  private manager: ClientManager;\n  readonly debugOpt?: DebugOpt | boolean;\n  readonly game: ReturnType<typeof ProcessGameConfig>;\n  readonly store: Store;\n  log: State['deltalog'];\n  matchID: string;\n  playerID: PlayerID | null;\n  credentials: string;\n  matchData?: FilteredMetadata;\n  moves: Record<string, (...args: any[]) => void>;\n  events: {\n    endGame?: (gameover?: any) => void;\n    endPhase?: () => void;\n    endTurn?: (arg?: { next: PlayerID }) => void;\n    setPhase?: (newPhase: string) => void;\n    endStage?: () => void;\n    setStage?: (newStage: string) => void;\n    setActivePlayers?: (arg: ActivePlayersArg) => void;\n  };\n  plugins: Record<string, (...args: any[]) => void>;\n  reset: () => void;\n  undo: () => void;\n  redo: () => void;\n  sendChatMessage: (message: any) => void;\n  chatMessages: ChatMessage[];\n\n  constructor({\n    game,\n    debug,\n    numPlayers,\n    multiplayer,\n    matchID: matchID,\n    playerID,\n    credentials,\n    enhancer,\n  }: ClientOpts<G, PluginAPIs>) {\n    this.game = ProcessGameConfig(game);\n    this.playerID = playerID;\n    this.matchID = matchID || 'default';\n    this.credentials = credentials;\n    this.multiplayer = multiplayer;\n    this.debugOpt = debug;\n    this.manager = GlobalClientManager;\n    this.gameStateOverride = null;\n    this.subscribers = {};\n    this._running = false;\n\n    this.reducer = CreateGameReducer({\n      game: this.game,\n      isClient: multiplayer !== undefined,\n    });\n\n    this.initialState = null;\n    if (!multiplayer) {\n      this.initialState = InitializeGame({ game: this.game, numPlayers });\n    }\n\n    this.reset = () => {\n      this.store.dispatch(ActionCreators.reset(this.initialState));\n    };\n    this.undo = () => {\n      const undo = ActionCreators.undo(\n        assumedPlayerID(this.playerID, this.store, this.multiplayer),\n        this.credentials\n      );\n      this.store.dispatch(undo);\n    };\n    this.redo = () => {\n      const redo = ActionCreators.redo(\n        assumedPlayerID(this.playerID, this.store, this.multiplayer),\n        this.credentials\n      );\n      this.store.dispatch(redo);\n    };\n\n    this.log = [];\n\n    /**\n     * Middleware that manages the log object.\n     * Reducers generate deltalogs, which are log events\n     * that are the result of application of a single action.\n     * The master may also send back a deltalog or the entire\n     * log depending on the type of request.\n     * The middleware below takes care of all these cases while\n     * managing the log object.\n     */\n    const LogMiddleware =\n      (store: Store) => (next: Dispatch<Action>) => (action: Action) => {\n        const result = next(action);\n        const state = store.getState();\n\n        switch (action.type) {\n          case Actions.MAKE_MOVE:\n          case Actions.GAME_EVENT:\n          case Actions.UNDO:\n          case Actions.REDO: {\n            const deltalog = state.deltalog;\n            this.log = [...this.log, ...deltalog];\n            break;\n          }\n\n          case Actions.RESET: {\n            this.log = [];\n            break;\n          }\n          case Actions.PATCH:\n          case Actions.UPDATE: {\n            let id = -1;\n            if (this.log.length > 0) {\n              id = this.log[this.log.length - 1]._stateID;\n            }\n\n            let deltalog = action.deltalog || [];\n\n            // Filter out actions that are already present\n            // in the current log. This may occur when the\n            // client adds an entry to the log followed by\n            // the update from the master here.\n            deltalog = deltalog.filter((l) => l._stateID > id);\n\n            this.log = [...this.log, ...deltalog];\n            break;\n          }\n\n          case Actions.SYNC: {\n            this.initialState = action.initialState;\n            this.log = action.log || [];\n            break;\n          }\n        }\n\n        return result;\n      };\n\n    /**\n     * Middleware that intercepts actions and sends them to the master,\n     * which keeps the authoritative version of the state.\n     */\n    const TransportMiddleware =\n      (store: Store) => (next: Dispatch<Action>) => (action: Action) => {\n        const baseState = store.getState();\n        const result = next(action);\n\n        if (\n          !('clientOnly' in action) &&\n          action.type !== Actions.STRIP_TRANSIENTS\n        ) {\n          this.transport.sendAction(baseState, action);\n        }\n\n        return result;\n      };\n\n    /**\n     * Middleware that intercepts actions and invokes the subscription callback.\n     */\n    const SubscriptionMiddleware =\n      () => (next: Dispatch<Action>) => (action: Action) => {\n        const result = next(action);\n        this.notifySubscribers();\n        return result;\n      };\n\n    const middleware = applyMiddleware(\n      TransientHandlingMiddleware,\n      SubscriptionMiddleware,\n      TransportMiddleware,\n      LogMiddleware\n    );\n\n    enhancer =\n      enhancer !== undefined ? compose(middleware, enhancer) : middleware;\n\n    this.store = createStore(this.reducer, this.initialState, enhancer);\n\n    if (!multiplayer) multiplayer = DummyTransport;\n    this.transport = multiplayer({\n      transportDataCallback: (data) => this.receiveTransportData(data),\n      gameKey: game,\n      game: this.game,\n      matchID,\n      playerID,\n      credentials,\n      gameName: this.game.name,\n      numPlayers,\n    });\n\n    this.createDispatchers();\n\n    this.chatMessages = [];\n    this.sendChatMessage = (payload) => {\n      this.transport.sendChatMessage(this.matchID, {\n        id: nanoid(7),\n        sender: this.playerID,\n        payload: payload,\n      });\n    };\n  }\n\n  /** Handle incoming match data from a multiplayer transport. */\n  private receiveMatchData(matchData: FilteredMetadata): void {\n    this.matchData = matchData;\n    this.notifySubscribers();\n  }\n\n  /** Handle an incoming chat message from a multiplayer transport. */\n  private receiveChatMessage(message: ChatMessage): void {\n    this.chatMessages = [...this.chatMessages, message];\n    this.notifySubscribers();\n  }\n\n  /** Handle all incoming updates from a multiplayer transport. */\n  private receiveTransportData(data: TransportData): void {\n    const [matchID] = data.args;\n    if (matchID !== this.matchID) return;\n    switch (data.type) {\n      case 'sync': {\n        const [, syncInfo] = data.args;\n        const action = ActionCreators.sync(syncInfo);\n        this.receiveMatchData(syncInfo.filteredMetadata);\n        this.store.dispatch(action);\n        break;\n      }\n      case 'update': {\n        const [, state, deltalog] = data.args;\n        const currentState = this.store.getState();\n        if (state._stateID >= currentState._stateID) {\n          const action = ActionCreators.update(state, deltalog);\n          this.store.dispatch(action);\n        }\n        break;\n      }\n      case 'patch': {\n        const [, prevStateID, stateID, patch, deltalog] = data.args;\n        const currentStateID = this.store.getState()._stateID;\n        if (prevStateID !== currentStateID) break;\n        const action = ActionCreators.patch(\n          prevStateID,\n          stateID,\n          patch,\n          deltalog\n        );\n        this.store.dispatch(action);\n        // Emit sync if patch apply failed.\n        if (this.store.getState()._stateID === currentStateID) {\n          this.transport.requestSync();\n        }\n        break;\n      }\n      case 'matchData': {\n        const [, matchData] = data.args;\n        this.receiveMatchData(matchData);\n        break;\n      }\n      case 'chat': {\n        const [, chatMessage] = data.args;\n        this.receiveChatMessage(chatMessage);\n        break;\n      }\n    }\n  }\n\n  private notifySubscribers() {\n    Object.values(this.subscribers).forEach((fn) => fn(this.getState()));\n  }\n\n  overrideGameState(state: any) {\n    this.gameStateOverride = state;\n    this.notifySubscribers();\n  }\n\n  start() {\n    this.transport.connect();\n    this._running = true;\n    this.manager.register(this);\n  }\n\n  stop() {\n    this.transport.disconnect();\n    this._running = false;\n    this.manager.unregister(this);\n  }\n\n  subscribe(fn: (state: ClientState<G>) => void) {\n    const id = Object.keys(this.subscribers).length;\n    this.subscribers[id] = fn;\n    this.transport.subscribeToConnectionStatus(() => this.notifySubscribers());\n\n    if (this._running || !this.multiplayer) {\n      fn(this.getState());\n    }\n\n    // Return a handle that allows the caller to unsubscribe.\n    return () => {\n      delete this.subscribers[id];\n    };\n  }\n\n  getInitialState() {\n    return this.initialState;\n  }\n\n  getState(): ClientState<G> {\n    let state = this.store.getState();\n\n    if (this.gameStateOverride !== null) {\n      state = this.gameStateOverride;\n    }\n\n    // This is the state before a sync with the game master.\n    if (state === null) {\n      return state as null;\n    }\n\n    // isActive.\n\n    let isActive = true;\n\n    const isPlayerActive = this.game.flow.isPlayerActive(\n      state.G,\n      state.ctx,\n      this.playerID\n    );\n\n    if (this.multiplayer && !isPlayerActive) {\n      isActive = false;\n    }\n\n    if (\n      !this.multiplayer &&\n      this.playerID !== null &&\n      this.playerID !== undefined &&\n      !isPlayerActive\n    ) {\n      isActive = false;\n    }\n\n    if (state.ctx.gameover !== undefined) {\n      isActive = false;\n    }\n\n    // Secrets are normally stripped on the server,\n    // but we also strip them here so that game developers\n    // can see their effects while prototyping.\n    // Do not strip again if this is a multiplayer game\n    // since the server has already stripped secret info. (issue #818)\n    if (!this.multiplayer) {\n      state = {\n        ...state,\n        G: this.game.playerView({\n          G: state.G,\n          ctx: state.ctx,\n          playerID: this.playerID,\n        }),\n        plugins: PlayerView(state, this),\n      };\n    }\n\n    // Combine into return value.\n    return {\n      ...state,\n      log: this.log,\n      isActive,\n      isConnected: this.transport.isConnected,\n    };\n  }\n\n  private createDispatchers() {\n    this.moves = createMoveDispatchers(\n      this.game.moveNames,\n      this.store,\n      this.playerID,\n      this.credentials,\n      this.multiplayer\n    );\n\n    this.events = createEventDispatchers(\n      this.game.flow.enabledEventNames,\n      this.store,\n      this.playerID,\n      this.credentials,\n      this.multiplayer\n    );\n\n    this.plugins = createPluginDispatchers(\n      this.game.pluginNames,\n      this.store,\n      this.playerID,\n      this.credentials,\n      this.multiplayer\n    );\n  }\n\n  updatePlayerID(playerID: PlayerID | null) {\n    this.playerID = playerID;\n    this.createDispatchers();\n    this.transport.updatePlayerID(playerID);\n    this.notifySubscribers();\n  }\n\n  updateMatchID(matchID: string) {\n    this.matchID = matchID;\n    this.createDispatchers();\n    this.transport.updateMatchID(matchID);\n    this.notifySubscribers();\n  }\n\n  updateCredentials(credentials: string) {\n    this.credentials = credentials;\n    this.createDispatchers();\n    this.transport.updateCredentials(credentials);\n    this.notifySubscribers();\n  }\n}\n\n/**\n * Client\n *\n * boardgame.io JS client.\n *\n * @param {...object} game - The return value of `Game`.\n * @param {...object} numPlayers - The number of players.\n * @param {...object} multiplayer - Set to a falsy value or a transportFactory, e.g., SocketIO()\n * @param {...object} matchID - The matchID that you want to connect to.\n * @param {...object} playerID - The playerID associated with this client.\n * @param {...string} credentials - The authentication credentials associated with this client.\n *\n * Returns:\n *   A JS object that provides an API to interact with the\n *   game by dispatching moves and events.\n */\nexport function Client<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n>(opts: ClientOpts<G, PluginAPIs>) {\n  return new _ClientImpl<G, PluginAPIs>(opts);\n}\n"
  },
  {
    "path": "src/client/debug/Debug.svelte",
    "content": "<script>\n  export let clientManager;\n  $: client = $clientManager.client;\n\n  import { writable } from 'svelte/store';\n  import { setContext } from 'svelte';\n  import { crossfade, fly } from 'svelte/transition';\n  import { cubicOut } from 'svelte/easing';\n  import Chevron from 'svelte-icons/fa/FaChevronRight.svelte';\n  import Menu from './Menu.svelte';\n  import Main from './main/Main.svelte';\n  import Info from './info/Info.svelte';\n  import Log from './log/Log.svelte';\n  import AI from './ai/AI.svelte';\n\n  const panes = {\n    main: { label: 'Main', shortcut: 'm', component: Main },\n    log: { label: 'Log', shortcut: 'l', component: Log },\n    info: { label: 'Info', shortcut: 'i', component: Info },\n    ai: { label: 'AI', shortcut: 'a', component: AI },\n  };\n\n  const disableHotkeys = writable(false);\n  const secondaryPane = writable(null);\n\n  setContext('hotkeys', { disableHotkeys });\n  setContext('secondaryPane', { secondaryPane });\n\n  let paneDiv;\n  let pane = 'main';\n  function MenuChange(e) {\n    pane = e.detail;\n    paneDiv.focus();\n  }\n\n  // Toggle debugger visibilty\n  function ToggleVisibility() {\n    visible = !visible;\n  }\n\n  const debugOpt = $clientManager.client.debugOpt\n  let visible = !debugOpt || !debugOpt.collapseOnLoad;\n  const showToggleButton = !debugOpt || !debugOpt.hideToggleButton\n\n  function Keypress(e) {\n    if (e.key == '.') {\n      ToggleVisibility();\n      return;\n    }\n    // Set displayed pane\n    if (!visible) return;\n    Object.entries(panes).forEach(([key, { shortcut }]) => {\n      if (e.key == shortcut) {\n        pane = key;\n      }\n    });\n  }\n\n  const transitionOpts = {\n    duration: 150,\n    easing: cubicOut,\n  };\n  const [send, receive] = crossfade(transitionOpts);\n</script>\n\n<style>\n  .debug-panel {\n    position: fixed;\n    color: #555;\n    font-family: monospace;\n    right: 0;\n    top: 0;\n    height: 100%;\n    font-size: 14px;\n    opacity: 0.9;\n    /* we want the debug panel to be above any other elements */\n    z-index: 99999;\n  }\n\n  .panel {\n    display: flex;\n    position: relative;\n    flex-direction: row;\n    height: 100%;\n  }\n\n  .visibility-toggle {\n    position: absolute;\n    box-sizing: border-box;\n    top: 7px;\n    border: 1px solid #ccc;\n    border-radius: 5px;\n    width: 48px;\n    height: 48px;\n    padding: 8px;\n    background: white;\n    color: #555;\n    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n  }\n\n  .visibility-toggle:hover,\n  .visibility-toggle:focus {\n    background: #eee;\n  }\n\n  .opener {\n    right: 10px;\n  }\n\n  .closer {\n    left: -326px;\n  }\n\n  /* Rotate chevron icon on toggle. */\n  @keyframes rotateFromZero {\n    from {\n      transform: rotateZ(0deg);\n    }\n    to {\n      transform: rotateZ(180deg);\n    }\n  }\n\n  .icon {\n    display: flex;\n    height: 100%;\n    animation: rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1\n      normal forwards;\n  }\n\n  .closer .icon {\n    animation-direction: reverse;\n  }\n\n  .pane {\n    flex-grow: 2;\n    overflow-x: hidden;\n    overflow-y: scroll;\n    background: #fefefe;\n    padding: 20px;\n    border-left: 1px solid #ccc;\n    box-shadow: -1px 0 5px rgba(0, 0, 0, 0.2);\n    box-sizing: border-box;\n    width: 280px;\n  }\n\n  .secondary-pane {\n    background: #fefefe;\n    overflow-y: scroll;\n  }\n\n  .debug-panel :global(button),\n  .debug-panel :global(select) {\n    cursor: pointer;\n    font-size: 14px;\n    font-family: monospace;\n  }\n\n  .debug-panel :global(select) {\n    background: #eee;\n    border: 1px solid #bbb;\n    color: #555;\n    padding: 3px;\n    border-radius: 3px;\n  }\n\n  .debug-panel :global(section) {\n    margin-bottom: 20px;\n  }\n\n  .debug-panel :global(.screen-reader-only) {\n    clip: rect(0 0 0 0);\n    clip-path: inset(50%);\n    height: 1px;\n    overflow: hidden;\n    position: absolute;\n    white-space: nowrap;\n    width: 1px;\n  }\n</style>\n\n<svelte:window on:keypress={Keypress} />\n\n<section aria-label=\"boardgame.io Debug Panel\" class=\"debug-panel\">\n  {#if !visible}\n    {#if showToggleButton}\n    <button\n      on:click={ToggleVisibility}\n      class=\"visibility-toggle opener\"\n      title=\"Show Debug Panel\"\n      in:receive={{ key: 'toggle' }}\n      out:send={{ key: 'toggle' }}\n    >\n      <span class=\"icon\" aria-hidden=\"true\">\n        <Chevron />\n      </span>\n    </button>\n    {/if}\n  {:else}\n    <div transition:fly={{ x: 400, ...transitionOpts }} class=\"panel\">\n      {#if showToggleButton}\n      <button\n        on:click={ToggleVisibility}\n        class=\"visibility-toggle closer\"\n        title=\"Hide Debug Panel\"\n        in:receive={{ key: 'toggle' }}\n        out:send={{ key: 'toggle' }}\n      >\n        <span class=\"icon\" aria-hidden=\"true\">\n          <Chevron />\n        </span>\n      </button>\n      {/if}\n      <Menu on:change={MenuChange} {panes} {pane} />\n      <div\n        bind:this={paneDiv}\n        class=\"pane\"\n        role=\"region\"\n        aria-label={pane}\n        tabindex=\"-1\"\n      >\n        <svelte:component\n          this={panes[pane].component}\n          {client}\n          {clientManager}\n          {ToggleVisibility}\n        />\n      </div>\n      {#if $secondaryPane}\n        <div class=\"secondary-pane\">\n          <svelte:component\n            this={$secondaryPane.component}\n            metadata={$secondaryPane.metadata}\n          />\n        </div>\n      {/if}\n    </div>\n  {/if}\n</section>\n"
  },
  {
    "path": "src/client/debug/Menu.svelte",
    "content": "<script>\n  export let pane;\n  export let panes;\n\n  import { createEventDispatcher } from 'svelte';\n  const dispatch = createEventDispatcher();\n</script>\n\n<style>\n  .menu {\n    display: flex;\n    margin-top: 43px;\n    flex-direction: row-reverse;\n    border: 1px solid #ccc;\n    border-radius: 5px 5px 0 0;\n    height: 25px;\n    line-height: 25px;\n    margin-right: -500px;\n    transform-origin: bottom right;\n    transform: rotate(-90deg) translate(0, -500px);\n  }\n\n  .menu-item {\n    line-height: 25px;\n    cursor: pointer;\n    border: 0;\n    background: #fefefe;\n    color: #555;\n    padding-left: 15px;\n    padding-right: 15px;\n    text-align: center;\n  }\n\n  .menu-item:first-child {\n    border-radius: 0 5px 0 0;\n  }\n\n  .menu-item:last-child {\n    border-radius: 5px 0 0 0;\n  }\n\n  .menu-item.active {\n    cursor: default;\n    font-weight: bold;\n    background: #ddd;\n    color: #555;\n  }\n\n  .menu-item:hover,\n  .menu-item:focus {\n    background: #eee;\n    color: #555;\n  }\n</style>\n\n<nav class=\"menu\">\n  {#each Object.entries(panes) as [key, {label}]}\n    <button\n      class=\"menu-item\"\n      class:active={pane == key}\n      on:click={() => dispatch('change', key)}>\n      {label}\n    </button>\n  {/each}\n</nav>\n"
  },
  {
    "path": "src/client/debug/ai/AI.svelte",
    "content": "<script>\n  export let client;\n  export let clientManager;\n  export let ToggleVisibility;\n\n  import { MAKE_MOVE } from '../../../core/action-types';\n  import Hotkey from '../main/Hotkey.svelte';\n  import Options from './Options.svelte';\n  import { MCTSBot } from '../../../ai/mcts-bot';\n  import { RandomBot } from '../../../ai/random-bot';\n  import MCTS from '../mcts/MCTS.svelte';\n  import { Step as _Step } from '../../../ai/ai';\n  import { getContext, onDestroy } from 'svelte';\n\n  const { secondaryPane } = getContext('secondaryPane');\n\n  const bots = {\n    'MCTS': MCTSBot,\n    'Random': RandomBot,\n  };\n\n  let debug = false;\n  let progress = null;\n  let iterationCounter = 0;\n  let metadata = null;\n  const iterationCallback = ({ iterationCounter: c, numIterations, metadata: m }) => {\n    iterationCounter = c;\n    progress = c / numIterations;\n    metadata = m;\n\n    if (debug && metadata) {\n      secondaryPane.set({ component: MCTS, metadata });\n    }\n  }\n\n  function OnDebug() {\n    if (debug && metadata) {\n      secondaryPane.set({ component: MCTS, metadata });\n    } else {\n      secondaryPane.set(null);\n    }\n  }\n\n  let bot;\n  if (client.game.ai) {\n    bot = new MCTSBot({\n      game: client.game,\n      enumerate: client.game.ai.enumerate,\n      iterationCallback,\n    });\n    bot.setOpt('async', true);\n  }\n\n  let selectedBot;\n  let botAction;\n  let botActionArgs;\n  function ChangeBot() {\n    const botConstructor = bots[selectedBot];\n    bot = new botConstructor({\n      game: client.game,\n      enumerate: client.game.ai.enumerate,\n      iterationCallback,\n    });\n    bot.setOpt('async', true);\n    botAction = null;\n    metadata = null;\n    secondaryPane.set(null);\n    iterationCounter = 0;\n  }\n\n  async function Step() {\n    botAction = null;\n    metadata = null;\n    iterationCounter = 0;\n\n    const t = await _Step(client, bot);\n\n    if (t) {\n      botAction = t.payload.type;\n      botActionArgs = t.payload.args;\n    }\n  }\n\n  function Simulate(iterations = 10000, sleepTimeout = 100) {\n    botAction = null;\n    metadata = null;\n    iterationCounter = 0;\n    const step = async () => {\n      for (let i = 0; i < iterations; i++) {\n        const action = await _Step(client, bot);\n        if (!action) break;\n        await new Promise(resolve => setTimeout(resolve, sleepTimeout));\n      }\n    };\n\n    return step();\n  }\n\n  function Exit() {\n    client.overrideGameState(null);\n    secondaryPane.set(null);\n    debug = false;\n  }\n\n  function Reset() {\n    client.reset();\n    botAction = null;\n    metadata = null;\n    iterationCounter = 0;\n    Exit();\n  }\n\n  function OnKeyDown(e) {\n    // ESC.\n    if (e.keyCode == 27) {\n      Exit();\n    }\n  }\n\n  onDestroy(Exit);\n</script>\n\n<style>\n  ul {\n    padding-left: 0;\n  }\n\n  li {\n    list-style: none;\n    margin: 0;\n    margin-bottom: 5px;\n  }\n\n  h3 {\n    text-transform: uppercase;\n  }\n\n  label {\n    color: #666;\n  }\n\n  input[type='checkbox'] {\n    vertical-align: middle;\n  }\n</style>\n\n<svelte:window on:keydown={OnKeyDown}/>\n\n<section>\n  {#if client.game.ai && !client.multiplayer}\n    <section>\n      <h3>Controls</h3>\n      <ul>\n        <li>\n          <Hotkey value=\"1\" onPress={Reset} label=\"reset\" />\n        </li>\n        <li>\n          <Hotkey value=\"2\" onPress={Step} label=\"play\" />\n        </li>\n        <li>\n          <Hotkey value=\"3\" onPress={Simulate} label=\"simulate\" />\n        </li>\n      </ul>\n    </section>\n\n    <section>\n      <h3>Bot</h3>\n      <select bind:value={selectedBot} on:change={ChangeBot}>\n        {#each Object.keys(bots) as bot}\n          <option value={bot}>{bot}</option>\n        {/each}\n      </select>\n    </section>\n\n    {#if Object.keys(bot.opts()).length}\n      <section>\n        <h3>Options</h3>\n        <label for=\"ai-option-debug\">debug</label>\n        <input id=\"ai-option-debug\" type=checkbox bind:checked={debug} on:change={OnDebug}>\n        <Options bot={bot}/>\n      </section>\n    {/if}\n\n    {#if botAction || iterationCounter}\n    <section>\n      <h3>Result</h3>\n      {#if progress && progress < 1.0}\n        <progress value={progress}></progress>\n      {/if}\n\n      {#if botAction}\n        <ul>\n          <li>Action: {botAction}</li>\n          <li>Args: {JSON.stringify(botActionArgs)}</li>\n        </ul>\n      {/if}\n    </section>\n    {/if}\n  {:else}\n    {#if client.multiplayer}\n      <p>The bot debugger is only available in singleplayer mode.</p>\n    {:else}\n      <p>No bots available.</p>\n\n      <p>\n        Follow the instructions\n        <a\n          href=\"https://boardgame.io/documentation/#/tutorial?id=bots\"\n          target=\"_blank\">\n          here</a>\n        to set up bots.\n      </p>\n    {/if}\n  {/if}\n</section>\n"
  },
  {
    "path": "src/client/debug/ai/Options.svelte",
    "content": "<script>\n  export let bot;\n\n  let values = {};\n  for (let [key, value] of Object.entries(bot.opts())) {\n    values[key] = value.value;\n  }\n\n  function OnChange() {\n    for (let [key, value] of Object.entries(values)) {\n      bot.setOpt(key, value);\n    }\n  }\n\n  const makeID = (key) => 'ai-option-' + key;\n</script>\n\n<style>\n  label {\n    color: #666;\n  }\n\n  .option {\n    margin-bottom: 20px;\n  }\n\n  .value {\n    font-weight: bold;\n    color: #000;\n  }\n\n  input[type='checkbox'] {\n    vertical-align: middle;\n  }\n</style>\n\n{#each Object.entries(bot.opts()) as [key, value]}\n  <div class=\"option\">\n    <label for={makeID(key)}>{key}</label>\n\n    {#if value.range}\n      <span class=\"value\">{values[key]}</span>\n      <input id={makeID(key)} type=range bind:value={values[key]} min={value.range.min} max={value.range.max} on:change={OnChange}>\n    {:else if typeof value.value === 'boolean'}\n      <input id={makeID(key)} type=checkbox bind:checked={values[key]} on:change={OnChange}>\n    {/if}\n  </div>\n{/each}\n"
  },
  {
    "path": "src/client/debug/info/Info.svelte",
    "content": "<script>\n  export let client;\n  export let clientManager;\n  export let ToggleVisibility;\n\n  import Item from './Item.svelte';\n</script>\n\n<style>\n.gameinfo {\n  padding: 10px;\n}\n</style>\n\n<section class=\"gameinfo\">\n  <Item name=\"matchID\" value={client.matchID} />\n  <Item name=\"playerID\" value={client.playerID} />\n  <Item name=\"isActive\" value={$client.isActive} />\n  {#if client.multiplayer}\n    <Item name=\"isConnected\" value={$client.isConnected} />\n  {/if}\n</section>\n"
  },
  {
    "path": "src/client/debug/info/Item.svelte",
    "content": "<script>\n  export let name;\n  export let value;\n</script>\n\n<style>\n.item {\n  padding: 10px;\n}\n\n.item:not(:first-child) {\n  border-top: 1px dashed #aaa;\n}\n\n.item div {\n  float: right;\n  text-align: right;\n}\n</style>\n\n<div class=\"item\">\n  <strong>{name} </strong>\n  <div>{JSON.stringify(value)}</div>\n</div>\n"
  },
  {
    "path": "src/client/debug/log/Log.svelte",
    "content": "<script>\n  export let client;\n\n  import { getContext, onDestroy } from 'svelte';\n\n  const { secondaryPane } = getContext('secondaryPane');\n\n  import { CreateGameReducer } from '../../../core/reducer';\n  import TurnMarker from './TurnMarker.svelte';\n  import PhaseMarker from './PhaseMarker.svelte';\n  import LogEvent from './LogEvent.svelte';\n  import MCTS from '../mcts/MCTS.svelte';\n\n  const reducer = CreateGameReducer({ game: client.game });\n  const initialState = client.getInitialState();\n  let { log } = $client;\n  let pinned = null;\n\n  function rewind(logIndex) {\n    let state = initialState;\n    for (let i = 0; i < log.length; i++) {\n      const { action, automatic } = log[i];\n\n      if (!automatic) {\n        state = reducer(state, action);\n\n        if (logIndex == 0) {\n          break;\n        }\n\n        logIndex--;\n      }\n    }\n    return { G: state.G, ctx: state.ctx, plugins: state.plugins };\n  }\n\n  function OnLogClick(e) {\n    const { logIndex } = e.detail;\n    const state = rewind(logIndex);\n    const renderedLogEntries = log.filter(e => !e.automatic);\n    client.overrideGameState(state);\n\n    if (pinned == logIndex) {\n      pinned = null;\n      secondaryPane.set(null);\n    } else {\n      pinned = logIndex;\n      const { metadata } = renderedLogEntries[logIndex].action.payload;\n      if (metadata) {\n        secondaryPane.set({ component: MCTS, metadata });\n      }\n    }\n  }\n\n  function OnMouseEnter(e) {\n    const { logIndex } = e.detail;\n    if (pinned === null) {\n      const state = rewind(logIndex);\n      client.overrideGameState(state);\n    }\n  }\n\n  function OnMouseLeave() {\n    if (pinned === null) {\n      client.overrideGameState(null);\n    }\n  }\n\n  function Reset() {\n    pinned = null;\n    client.overrideGameState(null);\n    secondaryPane.set(null);\n  }\n\n  onDestroy(Reset);\n\n  function OnKeyDown(e) {\n    // ESC.\n    if (e.keyCode == 27) {\n      Reset();\n    }\n  }\n\n  let renderedLogEntries;\n  let turnBoundaries = {};\n  let phaseBoundaries = {};\n\n  $: {\n    log = $client.log;\n    renderedLogEntries = log.filter(e => !e.automatic);\n\n    let eventsInCurrentPhase = 0;\n    let eventsInCurrentTurn = 0;\n\n    turnBoundaries = {};\n    phaseBoundaries = {};\n\n    for (let i = 0; i < renderedLogEntries.length; i++) {\n      const { action, payload, turn, phase } = renderedLogEntries[i];\n\n      eventsInCurrentTurn++;\n      eventsInCurrentPhase++;\n\n      if (\n        i == renderedLogEntries.length - 1 ||\n        renderedLogEntries[i + 1].turn != turn\n      ) {\n        turnBoundaries[i] = eventsInCurrentTurn;\n        eventsInCurrentTurn = 0;\n      }\n\n      if (\n        i == renderedLogEntries.length - 1 ||\n        renderedLogEntries[i + 1].phase != phase\n      ) {\n        phaseBoundaries[i] = eventsInCurrentPhase;\n        eventsInCurrentPhase = 0;\n      }\n    }\n  }\n</script>\n\n<style>\n  .gamelog {\n    display: grid;\n    grid-template-columns: 30px 1fr 30px;\n    grid-auto-rows: auto;\n    grid-auto-flow: column;\n  }\n</style>\n\n<svelte:window on:keydown={OnKeyDown}/>\n\n<div class=\"gamelog\" class:pinned>\n  {#each renderedLogEntries as { turn }, i}\n    {#if i in turnBoundaries}\n      <TurnMarker {turn} numEvents={turnBoundaries[i]} />\n    {/if}\n  {/each}\n\n  {#each renderedLogEntries as { action, metadata }, i}\n    <LogEvent\n      pinned={i === pinned}\n      logIndex={i}\n      on:click={OnLogClick}\n      on:mouseenter={OnMouseEnter}\n      on:mouseleave={OnMouseLeave}\n      {action}\n      {metadata} />\n  {/each}\n\n  {#each renderedLogEntries as { phase }, i}\n    {#if i in phaseBoundaries}\n      <PhaseMarker {phase} numEvents={phaseBoundaries[i]} />\n    {/if}\n  {/each}\n</div>\n"
  },
  {
    "path": "src/client/debug/log/LogEvent.svelte",
    "content": "<script>\n  export let logIndex;\n  export let action;\n  export let pinned;\n  export let metadata;\n  export let metadataComponent;\n\n  import LogMetadata from './LogMetadata.svelte';\n  import { createEventDispatcher } from 'svelte';\n\n  const dispatch = createEventDispatcher();\n\n  const args = action.payload.args;\n  const renderedArgs = Array.isArray(args)\n    ? args.map(arg => JSON.stringify(arg, null, 2)).join(',')\n    : JSON.stringify(args, null, 2) || '';\n  const playerID = action.payload.playerID;\n  let actionType;\n  switch (action.type) {\n    case 'UNDO':\n      actionType = 'undo';\n      break;\n    case 'REDO':\n      actionType = 'redo';\n    case 'GAME_EVENT':\n    case 'MAKE_MOVE':\n    default:\n      actionType = action.payload.type;\n      break;\n  }\n</script>\n\n<style>\n  .log-event {\n    grid-column: 2;\n    cursor: pointer;\n    overflow: hidden;\n    display: flex;\n    flex-direction: column;\n    justify-content: center;\n    background: #fff;\n    border: 1px dotted #ccc;\n    border-left: 5px solid #ccc;\n    padding: 5px;\n    text-align: center;\n    color: #666;\n    font-size: 14px;\n    min-height: 25px;\n    line-height: 25px;\n  }\n\n  .log-event:hover,\n  .log-event:focus {\n    border-style: solid;\n    background: #eee;\n  }\n\n  .log-event.pinned {\n    border-style: solid;\n    background: #eee;\n    opacity: 1;\n  }\n\n  .args {\n    text-align: left;\n    white-space: pre-wrap;\n  }\n\n  .player0 {\n    border-left-color: #ff851b;\n  }\n\n  .player1 {\n    border-left-color: #7fdbff;\n  }\n\n  .player2 {\n    border-left-color: #0074d9;\n  }\n\n  .player3 {\n    border-left-color: #39cccc;\n  }\n\n  .player4 {\n    border-left-color: #3d9970;\n  }\n\n  .player5 {\n    border-left-color: #2ecc40;\n  }\n\n  .player6 {\n    border-left-color: #01ff70;\n  }\n\n  .player7 {\n    border-left-color: #ffdc00;\n  }\n\n  .player8 {\n    border-left-color: #001f3f;\n  }\n\n  .player9 {\n    border-left-color: #ff4136;\n  }\n\n  .player10 {\n    border-left-color: #85144b;\n  }\n\n  .player11 {\n    border-left-color: #f012be;\n  }\n\n  .player12 {\n    border-left-color: #b10dc9;\n  }\n\n  .player13 {\n    border-left-color: #111111;\n  }\n\n  .player14 {\n    border-left-color: #aaaaaa;\n  }\n\n  .player15 {\n    border-left-color: #dddddd;\n  }\n</style>\n\n<button\n  class=\"log-event player{playerID}\"\n  class:pinned\n  on:click={() => dispatch('click', { logIndex })}\n  on:mouseenter={() => dispatch('mouseenter', { logIndex })}\n  on:focus={() => dispatch('mouseenter', { logIndex })}\n  on:mouseleave={() => dispatch('mouseleave')}\n  on:blur={() => dispatch('mouseleave')}\n>\n  <div class=\"args\">{actionType}({renderedArgs})</div>\n  {#if metadataComponent}\n    <svelte:component this={metadataComponent} {metadata} />\n  {:else}\n    <LogMetadata {metadata} />\n  {/if}\n</button>\n"
  },
  {
    "path": "src/client/debug/log/LogMetadata.svelte",
    "content": "<script>\n  export let metadata;\n  const renderedMetadata =\n    metadata !== undefined ? JSON.stringify(metadata, null, 4) : '';\n</script>\n\n<div>{renderedMetadata}</div>\n"
  },
  {
    "path": "src/client/debug/log/PhaseMarker.svelte",
    "content": "<script>\n  export let phase;\n  export let numEvents;\n\n  const style = `grid-row: span ${numEvents}`;\n</script>\n\n<style>\n.phase-marker {\n  grid-column: 3;\n  background: #555;\n  border: 1px solid #888;\n  color: #eee;\n  text-align: center;\n  font-weight: bold;\n  padding-top: 10px;\n  padding-bottom: 10px;\n  text-orientation: sideways;\n  writing-mode: vertical-rl;\n  line-height: 30px;\n  width: 100%;\n}\n</style>\n\n<div class=\"phase-marker\" style={style}>\n  {phase || ''}\n</div>\n"
  },
  {
    "path": "src/client/debug/log/TurnMarker.svelte",
    "content": "<script>\n  export let turn;\n  export let numEvents;\n  const style = `grid-row: span ${numEvents}`;\n</script>\n\n<style>\n.turn-marker {\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  grid-column: 1;\n  background: #555;\n  color: #eee;\n  text-align: center;\n  font-weight: bold;\n  border: 1px solid #888;\n}\n</style>\n\n<div class=\"turn-marker\" style={style}>\n  {turn}\n</div>\n"
  },
  {
    "path": "src/client/debug/main/ClientSwitcher.svelte",
    "content": "<script>\nexport let clientManager;\n\n$: ({ client, debuggableClients } = $clientManager);\n$: selected = debuggableClients.indexOf(client);\n\nconst selectId = 'bgio-debug-select-client';\nconst handleSelection = (e) => {\n  // Request to switch to the selected client.\n  const selectedClient = debuggableClients[e.target.value];\n  clientManager.switchToClient(selectedClient);\n  // Maintain focus on the client select menu after switching clients.\n  // Necessary because switching clients will usually trigger a mount/unmount.\n  const select = document.getElementById(selectId);\n  if (select) select.focus();\n};\n</script>\n\n<style>\n  * { box-sizing: border-box; }\n\n  section.switcher {\n    position: sticky;\n    bottom: 0;\n    transform: translateY(20px);\n    margin: 40px -20px 0;\n    border-top: 1px solid #999;\n    padding: 20px;\n    background: #fff;\n  }\n\n  label {\n    display: flex;\n    align-items: baseline;\n    gap: 5px;\n    font-weight: bold;\n  }\n\n  select { min-width: 140px; }\n</style>\n\n{#if debuggableClients.length > 1}\n  <section class=\"switcher\">\n    <label>\n      Client\n      <!-- svelte-ignore a11y-no-onchange -->\n      <select id={selectId} on:change={handleSelection} bind:value={selected}>\n        {#each debuggableClients as clientOption, index}\n          <option value={index}>\n            {index} —\n            playerID: {JSON.stringify(clientOption.playerID)},\n            matchID: {JSON.stringify(clientOption.matchID)}\n            ({clientOption.game.name})\n          </option>\n        {/each}\n      </select>\n    </label>\n  </section>\n{/if}\n"
  },
  {
    "path": "src/client/debug/main/Controls.svelte",
    "content": "<script>\n  export let client;\n  export let ToggleVisibility;\n\n  import Hotkey from './Hotkey.svelte';\n  import { sync } from '../../../core/action-creators';\n  import { parse, stringify } from 'flatted';\n\n  function Save() {\n    // get state to persist and overwrite deltalog, _undo, and _redo\n    const state = client.getState();\n    const json = stringify({\n      ...state,\n      _undo: [],\n      _redo: [],\n      deltalog: [],\n    });\n    window.localStorage.setItem('gamestate', json);\n    window.localStorage.setItem('initialState', stringify(client.initialState));\n  }\n\n  function Restore() {\n    const gamestateJSON = window.localStorage.getItem('gamestate');\n    const initialStateJSON = window.localStorage.getItem('initialState');\n    if (gamestateJSON !== null && initialStateJSON !== null) {\n      const gamestate = parse(gamestateJSON);\n      const initialState = parse(initialStateJSON);\n      client.store.dispatch(sync({ state: gamestate, initialState }));\n    }\n  }\n</script>\n\n<style>\n  ul {\n    padding-left: 0;\n  }\n\n  li {\n    list-style: none;\n    margin: 0;\n    margin-bottom: 5px;\n  }\n</style>\n\n<ul id=\"debug-controls\" class=\"controls\">\n  <li>\n    <Hotkey value=\"1\" onPress={client.reset} label=\"reset\" />\n  </li>\n  <li>\n    <Hotkey value=\"2\" onPress={Save} label=\"save\" />\n  </li>\n  <li>\n    <Hotkey value=\"3\" onPress={Restore} label=\"restore\" />\n  </li>\n  <li>\n    <Hotkey value=\".\" onPress={ToggleVisibility} label=\"hide\" />\n  </li>\n</ul>\n"
  },
  {
    "path": "src/client/debug/main/Hotkey.svelte",
    "content": "<script>\n  export let value;\n  export let onPress = null;\n  export let label = null;\n  export let disable = false;\n\n  import { getContext } from 'svelte';\n\n  const { disableHotkeys } = getContext('hotkeys');\n\n  let active = false;\n  let id = `key-${value}`;\n\n  function Deactivate() {\n    active = false;\n  }\n\n  function Activate() {\n    active = true;\n    setTimeout(Deactivate, 200);\n    if (onPress) {\n      setTimeout(onPress, 1);\n    }\n  }\n\n  function Keypress(e) {\n    if (\n      !$disableHotkeys && !disable &&\n      !e.ctrlKey && !e.metaKey &&\n      e.key == value\n    ) {\n      e.preventDefault();\n      Activate();\n    }\n  }\n</script>\n\n<style>\n  .key {\n    display: flex;\n    flex-direction: row;\n    align-items: center;\n  }\n\n  button {\n    cursor: pointer;\n    min-width: 10px;\n    padding-left: 5px;\n    padding-right: 5px;\n    height: 20px;\n    line-height: 20px;\n    text-align: center;\n    border: 1px solid #ccc;\n    box-shadow: 1px 1px 1px #888;\n    background: #eee;\n    color: #444;\n  }\n\n  button:hover {\n    background: #ddd;\n  }\n\n  .key.active button {\n    background: #ddd;\n    border: 1px solid #999;\n    box-shadow: none;\n  }\n\n  label {\n    margin-left: 10px;\n  }\n</style>\n\n<svelte:window on:keydown={Keypress} />\n\n<div class=\"key\" class:active>\n  <button {id} on:click={Activate} disabled={disable}>{value}</button>\n  {#if label}\n    <label for={id}>\n      {label}\n      <span class=\"screen-reader-only\">{`(shortcut: ${value})`}</span>\n    </label>\n  {/if}\n</div>\n"
  },
  {
    "path": "src/client/debug/main/InteractiveFunction.svelte",
    "content": "<script>\n  export let Activate;\n  export let Deactivate;\n  export let name;\n  export let active;\n  let value;\n  let span;\n\n  import { afterUpdate, createEventDispatcher } from 'svelte';\n  const dispatch = createEventDispatcher();\n\n  function Submit() {\n    try {\n      const value = span.innerText;\n      let argArray = new Function(`return [${value}]`)();\n      dispatch('submit', argArray);\n    } catch (error) {\n      dispatch('error', error);\n    }\n    span.innerText = '';\n  }\n\n  function OnKeyDown(e) {\n    if (e.key == 'Enter') {\n      e.preventDefault();\n      Submit();\n    }\n\n    if (e.key == 'Escape') {\n      e.preventDefault();\n      Deactivate();\n    }\n  }\n\n  afterUpdate(() => {\n    if (active) {\n      span.focus();\n    } else {\n      span.blur();\n    }\n  });\n</script>\n\n<style>\n  .move {\n    display: flex;\n    flex-direction: row;\n    cursor: pointer;\n    margin-left: 10px;\n    color: #666;\n  }\n\n  .move:hover {\n    color: #333;\n  }\n\n  .move.active {\n    color: #111;\n    font-weight: bold;\n  }\n\n  .move-error {\n    color: #a00;\n    font-weight: bold;\n  }\n\n  .arg-field {\n    outline: none;\n    font-family: monospace;\n  }\n</style>\n\n<div class=\"move\" class:active on:click={Activate}>\n  <span>{name}</span>\n  <span>(</span>\n  <span\n    class=\"arg-field\"\n    bind:this={span}\n    on:focus={Activate}\n    on:blur={Deactivate}\n    on:keypress|stopPropagation={() => {}}\n    on:keydown={OnKeyDown}\n    contentEditable />\n  <span>)</span>\n</div>\n"
  },
  {
    "path": "src/client/debug/main/Main.svelte",
    "content": "<script>\n  export let client;\n  export let clientManager;\n  export let ToggleVisibility;\n\n  import { onDestroy } from 'svelte';\n  import JSONTree from 'svelte-json-tree-auto/src/Root.svelte';\n  import ClientSwitcher from './ClientSwitcher.svelte';\n  import Move from './Move.svelte';\n  import Controls from './Controls.svelte';\n  import PlayerInfo from './PlayerInfo.svelte';\n  import { AssignShortcuts } from '../utils/shortcuts';\n\n  const shortcuts = AssignShortcuts(client.moves, 'mlia');\n\n  function SanitizeCtx(ctx) {\n    let r = {};\n    for (const key in ctx) {\n      if (!key.startsWith('_')) {\n        r[key] = ctx[key];\n      }\n    }\n    return r;\n  }\n\n  let { playerID, moves, events } = client;\n  let ctx = {};\n  let G = {};\n  const unsubscribe = client.subscribe((state) => {\n    if (state) ({ G, ctx } = state);\n    ({ playerID, moves, events } = client);\n  });\n\n  onDestroy(unsubscribe);\n</script>\n\n<style>\n  .tree {\n    --json-tree-font-family: monospace;\n    --json-tree-font-size: 14px;\n    --json-tree-null-color: #757575;\n  }\n\n  .label {\n    margin-bottom: 0;\n    text-transform: none;\n  }\n\n  h3 {\n    text-transform: uppercase;\n  }\n\n  ul {\n    padding-left: 0;\n  }\n\n  li {\n    list-style: none;\n    margin: 0;\n    margin-bottom: 5px;\n  }\n</style>\n\n<section>\n  <h3>Controls</h3>\n  <Controls {client} {ToggleVisibility} />\n</section>\n\n<section>\n  <h3>Players</h3>\n  <PlayerInfo\n    on:change={(e) => clientManager.switchPlayerID(e.detail.playerID)}\n    ctx={ctx}\n    playerID={playerID}\n  />\n</section>\n\n<section>\n  <h3>Moves</h3>\n  <ul>\n    {#each Object.entries(moves) as [name, fn]}\n    <li>\n      <Move shortcut={shortcuts[name]} {fn} {name} />\n    </li>\n    {/each}\n  </ul>\n</section>\n\n<section>\n  <h3>Events</h3>\n\n  <ul>\n  {#if ctx.activePlayers && events.endStage}\n    <li>\n      <Move name=\"endStage\" shortcut={7} fn={events.endStage} />\n    </li>\n  {/if}\n  {#if events.endTurn}\n    <li>\n      <Move name=\"endTurn\" shortcut={8} fn={events.endTurn} />\n    </li>\n  {/if}\n  {#if ctx.phase && events.endPhase}\n    <li>\n      <Move name=\"endPhase\" shortcut={9} fn={events.endPhase} />\n    </li>\n  {/if}\n  </ul>\n</section>\n\n<section class=\"tree\">\n  <h3 class=\"label\">G</h3>\n  <JSONTree value={G} />\n</section>\n\n<section class=\"tree\">\n  <h3 class=\"label\">ctx</h3>\n  <JSONTree value={SanitizeCtx(ctx)} />\n</section>\n\n<ClientSwitcher {clientManager} />\n"
  },
  {
    "path": "src/client/debug/main/Move.svelte",
    "content": "<script>\n  export let shortcut;\n  export let name;\n  export let fn;\n\n  import Hotkey from './Hotkey.svelte';\n  import InteractiveFunction from './InteractiveFunction.svelte';\n  import * as logger from '../../../core/logger';\n  import {getContext} from 'svelte';\n\n  const {disableHotkeys} = getContext('hotkeys');\n\n  let error = '';\n  let focus = false;\n  let enterArg = false;\n  let active = false;\n\n  function Activate() {\n    disableHotkeys.set(true);\n    active = true;\n  }\n\n  function Deactivate() {\n    disableHotkeys.set(false);\n    error = '';\n    active = false;\n  }\n\n  function Submit(e) {\n    error = '';\n    Deactivate();\n    fn.apply(this, e.detail);\n  }\n\n  function Error(e) {\n    error = e.detail;\n    logger.error(e.detail);\n  }\n</script>\n\n<style>\n  .move-error {\n    color: #a00;\n    font-weight: bold;\n  }\n\n  .wrapper {\n    display: flex;\n    flex-direction: row;\n    align-items: center;\n  }\n</style>\n\n<div>\n  <div class=\"wrapper\">\n    <Hotkey value={shortcut} onPress={Activate} />\n    <InteractiveFunction\n      {Activate}\n      {Deactivate}\n      {name}\n      {active}\n      on:submit={Submit}\n      on:error={Error} />\n  </div>\n  {#if error}\n    <span class=\"move-error\">{error}</span>\n  {/if}\n</div>\n"
  },
  {
    "path": "src/client/debug/main/PlayerInfo.svelte",
    "content": "<script>\n  export let ctx;\n  export let playerID;\n\n  import { createEventDispatcher } from 'svelte';\n\n  const dispatch = createEventDispatcher();\n  function OnClick(player) {\n    if (player == playerID) {\n      dispatch(\"change\", { playerID: null });\n    } else {\n      dispatch(\"change\", { playerID: player });\n    }\n  }\n\n  function playerLabel(player) {\n    const properties = [];\n    if (player == ctx.currentPlayer) properties.push('current');\n    if (player == playerID) properties.push('active');\n    let label = `Player ${player}`;\n    if (properties.length) label += ` (${properties.join(', ')})`;\n    return label;\n  }\n\n  let players;\n  $: players = ctx ? [...Array(ctx.numPlayers).keys()].map(i => i.toString()) : [];\n</script>\n\n<style>\n  .player-box {\n    display: flex;\n    flex-direction: row;\n  }\n\n  .player {\n    cursor: pointer;\n    text-align: center;\n    width: 30px;\n    height: 30px;\n    line-height: 30px;\n    background: #eee;\n    border: 3px solid #fefefe;\n    box-sizing: content-box;\n    padding: 0;\n  }\n\n  .player.current {\n    background: #555;\n    color: #eee;\n    font-weight: bold;\n  }\n\n  .player.active {\n    border: 3px solid #ff7f50;\n  }\n</style>\n\n<div class=\"player-box\">\n  {#each players as player}\n    <button\n      class=\"player\"\n      class:current={player == ctx.currentPlayer}\n      class:active={player == playerID}\n      on:click={() => OnClick(player)}\n      aria-label={playerLabel(player)}\n    >\n      {player}\n    </button>\n  {/each}\n</div>\n"
  },
  {
    "path": "src/client/debug/mcts/Action.svelte",
    "content": "<script>\n  export let action;\n\n  let text;\n\n  $: {\n    const { type, args } = action.payload;\n    const argsFormatted = (args || []).join(',');\n    text = `${type}(${argsFormatted})`;\n  }\n</script>\n\n<style>\n  div {\n    white-space: nowrap;\n    text-overflow: ellipsis;\n    overflow: hidden;\n    max-width: 500px;\n  }\n</style>\n\n<div alt={text}>{text}</div>\n"
  },
  {
    "path": "src/client/debug/mcts/MCTS.svelte",
    "content": "<script>\n  export let metadata;\n\n  import Arrow from 'svelte-icons/fa/FaArrowAltCircleDown.svelte'\n\n  let nodes = [];\n  let prevNodes = [];\n  let preview = null;\n\n  import Table from './Table.svelte';\n\n  $: {\n    prevNodes = [];\n    nodes = [{ node: metadata }];\n  }\n\n  function SelectNode({ node, selectedIndex }, i) {\n    preview = null;\n    nodes[i].selectedIndex = selectedIndex;\n    nodes = [...nodes.slice(0, i + 1), { node }];\n  }\n\n  function PreviewNode({ node }, i) {\n    preview = node;\n  }\n</script>\n\n<style>\n.visualizer {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  padding: 50px;\n}\n\n.preview {\n  opacity: 0.5;\n}\n\n.icon {\n  color: #777;\n  width: 32px;\n  height: 32px;\n  margin-bottom: 20px;\n}\n</style>\n\n<div class=\"visualizer\">\n  {#each nodes as { node, selectedIndex }, i}\n    {#if i !== 0}\n    <div class=\"icon\">\n      <Arrow/>\n    </div>\n    {/if}\n\n    <section>\n      {#if i === nodes.length - 1}\n        <Table on:select={e => SelectNode(e.detail, i)}\n               on:preview={e => PreviewNode(e.detail, i)}\n               root={node}/>\n      {:else}\n        <Table on:select={e => SelectNode(e.detail, i)}\n          root={node}\n          selectedIndex={selectedIndex}/>\n      {/if}\n    </section>\n  {/each}\n\n  {#if preview}\n    <div class=\"icon\">\n      <Arrow/>\n    </div>\n\n    <section class=\"preview\">\n      <Table root={preview}/>\n    </section>\n  {/if}\n</div>\n"
  },
  {
    "path": "src/client/debug/mcts/Table.svelte",
    "content": "<script>\n  export let root;\n  export let selectedIndex = null;\n\n  import Action from './Action.svelte';\n  import { createEventDispatcher } from 'svelte';\n\n  const dispatch = createEventDispatcher();\n\n  let parents = [];\n  let children = [];\n\n  $: {\n    let t = root;\n    parents = [];\n    while (t.parent) {\n      const parent = t.parent;\n      const { type, args } = t.parentAction.payload;\n      const argsFormatted = (args || []).join(',');\n      const arrowText = `${type}(${argsFormatted})`;\n      parents.push({ parent, arrowText });\n      t = parent;\n    }\n    parents.reverse();\n\n    children = [...root.children]\n                   .sort((a, b) => (a.visits < b.visits ? 1 : -1))\n                   .slice(0, 50);\n  }\n\n  function Select(node, i) {\n    dispatch('select', { node, selectedIndex: i });\n  }\n\n  function Preview(node, i) {\n    if (selectedIndex === null) {\n      dispatch('preview', { node });\n    }\n  }\n</script>\n\n<style>\n  table {\n    font-size: 12px;\n    border-collapse: collapse;\n    border: 1px solid #ddd;\n    padding: 0;\n  }\n\n  tr {\n    cursor: pointer;\n  }\n\n  tr:hover td {\n    background: #eee;\n  }\n\n  tr.selected td {\n    background: #eee;\n  }\n\n  td {\n    padding: 10px;\n    height: 10px;\n    line-height: 10px;\n    font-size: 12px;\n    border: none;\n  }\n\n  th {\n    background: #888;\n    color: #fff;\n    padding: 10px;\n    text-align: center;\n  }\n</style>\n\n<table>\n  <thead>\n    <th>Value</th>\n    <th>Visits</th>\n    <th>Action</th>\n  </thead>\n\n  <tbody>\n  {#each children as child, i}\n    <tr class:clickable={children.length > 0}\n        class:selected={i === selectedIndex}\n        on:click={() => Select(child, i)}\n        on:mouseout={() => Preview(null, i)}\n        on:mouseover={() => Preview(child, i)}>\n      <td>{child.value}</td>\n      <td>{child.visits}</td>\n      <td><Action action={child.parentAction}/></td>\n    </tr>\n  {/each}\n  </tbody>\n</table>\n"
  },
  {
    "path": "src/client/debug/tests/JSONTree.mock.svelte",
    "content": "<script>\n  export let value;\n</script>\n"
  },
  {
    "path": "src/client/debug/tests/debug.test.ts",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport '@testing-library/jest-dom/extend-expect';\nimport { screen, fireEvent, waitFor } from '@testing-library/svelte';\nimport { Client } from '../../client';\nimport { Local } from '../../transport/local';\n\ntest('sanity', () => {\n  const client = Client({ game: {} });\n  client.start();\n  expect(screen.getByText('Controls')).toBeInTheDocument();\n  expect(screen.getByText('Players')).toBeInTheDocument();\n  expect(screen.getByText('G')).toBeInTheDocument();\n  expect(screen.getByText('ctx')).toBeInTheDocument();\n  client.stop();\n});\n\ntest('switching panels', async () => {\n  const client = Client({ game: {} });\n  client.start();\n\n  // switch to info tab\n  const InfoTab = screen.getByText('Info');\n  await fireEvent.click(InfoTab);\n  expect(screen.getByText('matchID')).toBeInTheDocument();\n  expect(screen.getByText('playerID')).toBeInTheDocument();\n  expect(screen.getByText('isActive')).toBeInTheDocument();\n\n  // switch to AI tab\n  const AITab = screen.getByText('AI');\n  await fireEvent.click(AITab);\n  expect(screen.getByText('No bots available.')).toBeInTheDocument();\n  client.stop();\n});\n\ntest('visibility toggle', async () => {\n  const client = Client({ game: {} });\n  client.start();\n\n  // Visibility toggle button & debug panel are rendered\n  const hideButton = screen.getByTitle('Hide Debug Panel');\n  expect(hideButton).toBeInTheDocument();\n  expect(screen.getByRole('heading', { name: 'Controls' })).toBeInTheDocument();\n\n  // Hide debug panel\n  await fireEvent.click(hideButton);\n  await waitFor(() => expect(hideButton).not.toBeInTheDocument());\n\n  // Show button is rendered & debug panel is not.\n  const showButton = screen.getByTitle('Show Debug Panel');\n  expect(showButton).toBeInTheDocument();\n  expect(\n    screen.queryByRole('heading', { name: 'Controls' })\n  ).not.toBeInTheDocument();\n\n  // Show debug panel\n  await fireEvent.click(showButton);\n  await waitFor(() => expect(showButton).not.toBeInTheDocument());\n\n  // Hide button & debug panel are rendered.\n  expect(screen.getByTitle('Hide Debug Panel')).toBeInTheDocument();\n  expect(screen.getByRole('heading', { name: 'Controls' })).toBeInTheDocument();\n\n  client.stop();\n});\n\ntest('panel options', async () => {\n  const client = Client({\n    game: {},\n    debug: { hideToggleButton: true, collapseOnLoad: true },\n  });\n  client.start();\n\n  const hideButton = screen.queryByTitle('Hide Debug Panel');\n  expect(hideButton).not.toBeInTheDocument();\n\n  expect(\n    screen.queryByRole('heading', { name: 'Controls' })\n  ).not.toBeInTheDocument();\n\n  client.stop();\n});\n\ndescribe('multiple clients', () => {\n  const client0 = Client({\n    game: { name: 'game1' },\n    playerID: '0',\n    matchID: 'A',\n  });\n  const multiplayer = Local();\n  const client1 = Client({\n    game: { name: 'game2' },\n    playerID: '0',\n    matchID: 'B',\n    multiplayer,\n  });\n  const client2 = Client({\n    game: { name: 'game2' },\n    playerID: '1',\n    matchID: 'B',\n    multiplayer,\n  });\n\n  beforeEach(() => {\n    client0.start();\n    client1.start();\n    client2.start();\n  });\n\n  afterEach(() => {\n    client0.stop();\n    client1.stop();\n    client2.stop();\n  });\n\n  test('switching clients', async () => {\n    // Check if the client switcher is displayed.\n    await waitFor(() => screen.getByText('Client'));\n    // Get the client switcher select element.\n    const select = screen.getByLabelText('Client');\n    // Check it is displaying details for the client that rendered first.\n    expect(\n      screen.getByDisplayValue('0 — playerID: \"0\", matchID: \"A\" (game1)')\n    ).toBeInTheDocument();\n    // Switch to client1.\n    await fireEvent.change(select, { target: { value: 1 } });\n    // Check the client switcher now shows details for client1.\n    expect(\n      screen.getByDisplayValue('1 — playerID: \"0\", matchID: \"B\" (game2)')\n    ).toBeInTheDocument();\n\n    // Switch to the info tab and check if the matchID for client1 is displayed.\n    const InfoTab = screen.getByText('Info');\n    await fireEvent.click(InfoTab);\n    expect(screen.getByText('\"B\"')).toBeInTheDocument();\n  });\n\n  test('switching playerID for a solo client', async () => {\n    expect(client0.playerID).toBe('0');\n    // Toggle to playerID 1 by clicking on the “1” button.\n    await fireEvent.click(screen.getByRole('button', { name: 'Player 1' }));\n    // Check client0’s playerID was updated.\n    expect(\n      screen.getByDisplayValue('0 — playerID: \"1\", matchID: \"A\" (game1)')\n    ).toBeInTheDocument();\n    expect(client0.playerID).toBe('1');\n  });\n\n  test('switching playerID with multiplayer clients', async () => {\n    expect(client1.playerID).toBe('0');\n    expect(client2.playerID).toBe('1');\n    // Switch to client1.\n    const select = screen.getByLabelText('Client');\n    await fireEvent.change(select, { target: { value: 1 } });\n    // Check the client switcher now shows details for client1.\n    expect(\n      screen.getByDisplayValue('1 — playerID: \"0\", matchID: \"B\" (game2)')\n    ).toBeInTheDocument();\n    // Toggle to playerID 1 by clicking on the “1” button.\n    await fireEvent.click(screen.getByRole('button', { name: 'Player 1' }));\n    // Check the client switcher now shows details for client2.\n    expect(\n      screen.getByDisplayValue('2 — playerID: \"1\", matchID: \"B\" (game2)')\n    ).toBeInTheDocument();\n    // Client playerIDs have not changed.\n    expect(client1.playerID).toBe('0');\n    expect(client2.playerID).toBe('1');\n  });\n\n  test('switching to current client', async () => {\n    const select = screen.getByLabelText('Client');\n    await fireEvent.change(select, { target: { value: 0 } });\n    expect(\n      screen.getByDisplayValue('0 — playerID: \"1\", matchID: \"A\" (game1)')\n    ).toBeInTheDocument();\n  });\n});\n"
  },
  {
    "path": "src/client/debug/utils/shortcuts.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nexport function AssignShortcuts(moveNames, blacklist) {\n  let shortcuts = {};\n\n  const taken = {};\n  for (const c of blacklist) {\n    taken[c] = true;\n  }\n\n  // Try assigning the first char of each move as the shortcut.\n  let t = taken;\n  let canUseFirstChar = true;\n  for (const name in moveNames) {\n    const shortcut = name[0];\n    if (t[shortcut]) {\n      canUseFirstChar = false;\n      break;\n    }\n\n    t[shortcut] = true;\n    shortcuts[name] = shortcut;\n  }\n  if (canUseFirstChar) {\n    return shortcuts;\n  }\n\n  // If those aren't unique, use a-z.\n  t = taken;\n  let next = 97;\n  shortcuts = {};\n  for (const name in moveNames) {\n    let shortcut = String.fromCharCode(next);\n\n    while (t[shortcut]) {\n      next++;\n      shortcut = String.fromCharCode(next);\n    }\n\n    t[shortcut] = true;\n    shortcuts[name] = shortcut;\n  }\n  return shortcuts;\n}\n"
  },
  {
    "path": "src/client/debug/utils/shortcuts.test.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { AssignShortcuts } from './shortcuts';\n\ntest('first char is used', () => {\n  const moves = {\n    clickCell: () => {},\n    playCard: () => {},\n  };\n\n  const shortcuts = AssignShortcuts(moves, '');\n\n  expect(shortcuts).toEqual({\n    clickCell: 'c',\n    playCard: 'p',\n  });\n});\n\ntest('a-z if cannot use first char', () => {\n  const moves = {\n    takeCard: () => {},\n    takeToken: () => {},\n  };\n\n  const shortcuts = AssignShortcuts(moves, '');\n\n  expect(shortcuts).toEqual({\n    takeCard: 'a',\n    takeToken: 'b',\n  });\n});\n\ntest('a-z if blacklist prevents using first char', () => {\n  const moves = {\n    clickCell: () => {},\n  };\n\n  const shortcuts = AssignShortcuts(moves, 'c');\n\n  expect(shortcuts).toEqual({\n    clickCell: 'a',\n  });\n});\n"
  },
  {
    "path": "src/client/manager.ts",
    "content": "import Debug from './debug/Debug.svelte';\nimport type { _ClientImpl } from './client';\n\ntype SubscriptionState = {\n  client: _ClientImpl;\n  debuggableClients: _ClientImpl[];\n};\ntype SubscribeCallback = (arg: SubscriptionState) => void;\ntype UnsubscribeCallback = () => void;\n\n/**\n * Class to manage boardgame.io clients and limit debug panel rendering.\n */\nexport class ClientManager {\n  private debugPanel: Debug | null;\n  private currentClient: _ClientImpl | null;\n  private clients: Map<_ClientImpl, _ClientImpl>;\n  private subscribers: Map<symbol, SubscribeCallback>;\n\n  constructor() {\n    this.debugPanel = null;\n    this.currentClient = null;\n    this.clients = new Map();\n    this.subscribers = new Map();\n  }\n\n  /**\n   * Register a client with the client manager.\n   */\n  register(client: _ClientImpl): void {\n    // Add client to clients map.\n    this.clients.set(client, client);\n    // Mount debug for this client (no-op if another debug is already mounted).\n    this.mountDebug(client);\n    this.notifySubscribers();\n  }\n\n  /**\n   * Unregister a client from the client manager.\n   */\n  unregister(client: _ClientImpl): void {\n    // Remove client from clients map.\n    this.clients.delete(client);\n\n    if (this.currentClient === client) {\n      // If the removed client owned the debug panel, unmount it.\n      this.unmountDebug();\n      // Mount debug panel for next available client.\n      for (const [client] of this.clients) {\n        if (this.debugPanel) break;\n        this.mountDebug(client);\n      }\n    }\n\n    this.notifySubscribers();\n  }\n\n  /**\n   * Subscribe to the client manager state.\n   * Calls the passed callback each time the current client changes or a client\n   * registers/unregisters.\n   * Returns a function to unsubscribe from the state updates.\n   */\n  subscribe(callback: SubscribeCallback): UnsubscribeCallback {\n    const id = Symbol();\n    this.subscribers.set(id, callback);\n    callback(this.getState());\n    return () => {\n      this.subscribers.delete(id);\n    };\n  }\n\n  /**\n   * Switch to a client with a matching playerID.\n   */\n  switchPlayerID(playerID: string): void {\n    // For multiplayer clients, try switching control to a different client\n    // that is using the same transport layer.\n    if (this.currentClient.multiplayer) {\n      for (const [client] of this.clients) {\n        if (\n          client.playerID === playerID &&\n          client.debugOpt !== false &&\n          client.multiplayer === this.currentClient.multiplayer\n        ) {\n          this.switchToClient(client);\n          return;\n        }\n      }\n    }\n\n    // If no client matches, update the playerID for the current client.\n    this.currentClient.updatePlayerID(playerID);\n    this.notifySubscribers();\n  }\n\n  /**\n   * Set the passed client as the active client for debugging.\n   */\n  switchToClient(client: _ClientImpl): void {\n    if (client === this.currentClient) return;\n    this.unmountDebug();\n    this.mountDebug(client);\n    this.notifySubscribers();\n  }\n\n  /**\n   * Notify all subscribers of changes to the client manager state.\n   */\n  private notifySubscribers(): void {\n    const arg = this.getState();\n    this.subscribers.forEach((cb) => {\n      cb(arg);\n    });\n  }\n\n  /**\n   * Get the client manager state.\n   */\n  private getState(): SubscriptionState {\n    return {\n      client: this.currentClient,\n      debuggableClients: this.getDebuggableClients(),\n    };\n  }\n\n  /**\n   * Get an array of the registered clients that haven’t disabled the debug panel.\n   */\n  private getDebuggableClients(): _ClientImpl[] {\n    return [...this.clients.values()].filter(\n      (client) => client.debugOpt !== false\n    );\n  }\n\n  /**\n   * Mount the debug panel using the passed client.\n   */\n  private mountDebug(client: _ClientImpl): void {\n    if (\n      client.debugOpt === false ||\n      this.debugPanel !== null ||\n      typeof document === 'undefined'\n    ) {\n      return;\n    }\n\n    let DebugImpl: typeof Debug | undefined;\n    let target = document.body;\n\n    if (process.env.NODE_ENV !== 'production') {\n      DebugImpl = Debug;\n    }\n\n    if (client.debugOpt && client.debugOpt !== true) {\n      DebugImpl = client.debugOpt.impl || DebugImpl;\n      target = client.debugOpt.target || target;\n    }\n\n    if (DebugImpl) {\n      this.currentClient = client;\n      this.debugPanel = new DebugImpl({\n        target,\n        props: { clientManager: this },\n      });\n    }\n  }\n\n  /**\n   * Unmount the debug panel.\n   */\n  private unmountDebug(): void {\n    this.debugPanel.$destroy();\n    this.debugPanel = null;\n    this.currentClient = null;\n  }\n}\n"
  },
  {
    "path": "src/client/react-native.js",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { Client as RawClient } from './client';\n\n/**\n * Client\n *\n * boardgame.io React Native client.\n *\n * @param {...object} game - The return value of `Game`.\n * @param {...object} numPlayers - The number of players.\n * @param {...object} board - The React component for the game.\n * @param {...object} loading - (optional) The React component for the loading state.\n * @param {...object} multiplayer - Set to a falsy value or a transportFactory, e.g., SocketIO()\n * @param {...object} enhancer - Optional enhancer to send to the Redux store\n *\n * Returns:\n *   A React Native component that wraps board and provides an\n *   API through props for it to interact with the framework\n *   and dispatch actions such as MAKE_MOVE.\n */\nexport function Client(opts) {\n  const { game, numPlayers, board, multiplayer, enhancer } = opts;\n  let { loading } = opts;\n\n  // Component that is displayed before the client has synced\n  // with the game master.\n  if (loading === undefined) {\n    const Loading = () => <></>;\n    loading = Loading;\n  }\n\n  /*\n   * WrappedBoard\n   *\n   * The main React component that wraps the passed in\n   * board component and adds the API to its props.\n   */\n  return class WrappedBoard extends React.Component {\n    static propTypes = {\n      // The ID of a game to connect to.\n      // Only relevant in multiplayer.\n      matchID: PropTypes.string,\n      // The ID of the player associated with this client.\n      // Only relevant in multiplayer.\n      playerID: PropTypes.string,\n      // This client's authentication credentials.\n      // Only relevant in multiplayer.\n      credentials: PropTypes.string,\n    };\n\n    static defaultProps = {\n      matchID: 'default',\n      playerID: null,\n      credentials: null,\n    };\n\n    constructor(props) {\n      super(props);\n\n      this.client = RawClient({\n        game,\n        numPlayers,\n        multiplayer,\n        matchID: props.matchID,\n        playerID: props.playerID,\n        credentials: props.credentials,\n        debug: false,\n        enhancer,\n      });\n    }\n\n    componentDidMount() {\n      this.unsubscribe = this.client.subscribe(() => this.forceUpdate());\n      this.client.start();\n    }\n\n    componentWillUnmount() {\n      this.client.stop();\n      this.unsubscribe();\n    }\n\n    componentDidUpdate(prevProps) {\n      if (prevProps.matchID != this.props.matchID) {\n        this.client.updateMatchID(this.props.matchID);\n      }\n      if (prevProps.playerID != this.props.playerID) {\n        this.client.updatePlayerID(this.props.playerID);\n      }\n      if (prevProps.credentials != this.props.credentials) {\n        this.client.updateCredentials(this.props.credentials);\n      }\n    }\n\n    render() {\n      let _board = null;\n\n      const state = this.client.getState();\n\n      if (state === null) {\n        return React.createElement(loading);\n      }\n\n      const { matchID, playerID, ...rest } = this.props;\n\n      if (board) {\n        _board = React.createElement(board, {\n          ...state,\n          ...rest,\n          matchID,\n          playerID,\n          isMultiplayer: !!multiplayer,\n          moves: this.client.moves,\n          events: this.client.events,\n          step: this.client.step,\n          reset: this.client.reset,\n          undo: this.client.undo,\n          redo: this.client.redo,\n          matchData: this.client.matchData,\n          sendChatMessage: this.client.sendChatMessage,\n          chatMessages: this.client.chatMessages,\n        });\n      }\n\n      return _board;\n    }\n  };\n}\n"
  },
  {
    "path": "src/client/react-native.test.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n/* eslint-disable unicorn/no-array-callback-reference */\n\nimport React from 'react';\nimport { Client } from './react-native';\nimport Enzyme from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\nimport { Local } from './transport/local';\nimport { Transport } from './transport/transport';\n\nclass NoConnectionTransport extends Transport {\n  connect() {}\n  disconnect() {}\n  sendAction() {}\n  sendChatMessage() {}\n  requestSync() {}\n  updateMatchID() {}\n  updatePlayerID() {}\n  updateCredentials() {}\n}\n\nEnzyme.configure({ adapter: new Adapter() });\n\nclass TestBoard extends React.Component {\n  render() {\n    return <div id=\"board\">Board</div>;\n  }\n}\n\ntest('board is rendered', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const board = game.find(TestBoard);\n\n  expect(board.props().isActive).toBe(true);\n  expect(board.text()).toBe('Board');\n\n  game.unmount();\n});\n\ntest('board is rendered with custom loading', () => {\n  const Loading = () => <>connecting...</>;\n\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n    loading: Loading,\n    multiplayer: (opts) => new NoConnectionTransport(opts),\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const loadingComponent = game.find(Loading);\n\n  expect(loadingComponent.props()).toEqual({});\n  expect(loadingComponent.text()).toBe('connecting...');\n\n  game.unmount();\n});\n\ntest('board props', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n  const board = Enzyme.mount(<Board />).find(TestBoard);\n  expect(board.props().isMultiplayer).toEqual(false);\n  expect(board.props().isActive).toBe(true);\n});\n\ntest('can pass extra props to Client', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n  const board = Enzyme.mount(\n    <Board doStuff={() => true} extraValue={55} />\n  ).find(TestBoard);\n  expect(board.props().doStuff()).toBe(true);\n  expect(board.props().extraValue).toBe(55);\n});\n\ntest('can pass empty board', () => {\n  const Board = Client({\n    game: {},\n  });\n\n  const game = Enzyme.mount(<Board />);\n  expect(game).not.toBe(undefined);\n});\n\ntest('move api', () => {\n  const Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const board = game.find('TestBoard').instance();\n\n  expect(board.props.G).toEqual({});\n  board.props.moves.A(42);\n  expect(board.props.G).toEqual({ arg: 42 });\n});\n\ntest('update matchID / playerID', () => {\n  let Board = null;\n  let game = null;\n\n  // No multiplayer.\n\n  Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n  });\n  game = Enzyme.mount(<Board />);\n  game.setProps({ matchID: 'a' });\n  game.setProps({ playerID: '3' });\n  expect(game.instance().transport).toBe(undefined);\n\n  // Multiplayer.\n\n  Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n    multiplayer: Local(),\n  });\n  game = Enzyme.mount(<Board matchID=\"a\" playerID=\"1\" credentials=\"foo\" />);\n  const m = game.instance().client.transport;\n  const g = game.instance().client;\n\n  const spy1 = jest.spyOn(m, 'updateMatchID');\n  const spy2 = jest.spyOn(m, 'updatePlayerID');\n  const spy3 = jest.spyOn(g, 'updateCredentials');\n\n  expect(m.matchID).toBe('a');\n  expect(m.playerID).toBe('1');\n\n  game.setProps({ matchID: 'a' });\n  game.setProps({ playerID: '1' });\n  game.setProps({ credentials: 'foo' });\n\n  expect(m.matchID).toBe('a');\n  expect(m.playerID).toBe('1');\n  expect(spy1).not.toHaveBeenCalled();\n  expect(spy2).not.toHaveBeenCalled();\n  expect(spy3).not.toHaveBeenCalled();\n\n  game.setProps({ matchID: 'next' });\n  game.setProps({ playerID: 'next' });\n  game.setProps({ credentials: 'bar' });\n\n  expect(m.matchID).toBe('next');\n  expect(m.playerID).toBe('next');\n  expect(spy1).toHaveBeenCalled();\n  expect(spy2).toHaveBeenCalled();\n  expect(spy3).toHaveBeenCalled();\n});\n\ntest('local playerView', () => {\n  const Board = Client({\n    game: {\n      setup: () => ({ secret: true }),\n      playerView: ({ playerID }) => ({ stripped: playerID }),\n    },\n    board: TestBoard,\n    numPlayers: 2,\n  });\n\n  const game = Enzyme.mount(<Board playerID=\"1\" />);\n  const board = game.find('TestBoard').instance();\n  expect(board.props.G).toEqual({ stripped: '1' });\n});\n\ntest('reset Game', () => {\n  const Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const board = game.find('TestBoard').instance();\n\n  const initial = { G: { ...board.props.G }, ctx: { ...board.props.ctx } };\n\n  expect(board.props.G).toEqual({});\n  board.props.moves.A(42);\n  expect(board.props.G).toEqual({ arg: 42 });\n  board.props.reset();\n  expect(board.props.G).toEqual(initial.G);\n  expect(board.props.ctx).toEqual(initial.ctx);\n});\n\ntest('can receive enhancer', () => {\n  const enhancer = jest.fn().mockImplementation((next) => next);\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n    enhancer,\n  });\n\n  Enzyme.mount(<Board />);\n  expect(enhancer).toBeCalled();\n});\n"
  },
  {
    "path": "src/client/react.ssr.test.tsx",
    "content": "/**\n * @jest-environment node\n */\n\nimport React from 'react';\nimport type { BoardProps } from './react';\nimport { Client } from './react';\nimport ReactDOMServer from 'react-dom/server';\n\nclass TestBoard extends React.Component<BoardProps> {\n  render() {\n    return <div id=\"my-board\">Board</div>;\n  }\n}\n\ntest('board is rendered - ssr', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n  const ssrRender = ReactDOMServer.renderToString(<Board />);\n  expect(ssrRender).toContain('bgio-client');\n  expect(ssrRender).toContain('my-board');\n});\n"
  },
  {
    "path": "src/client/react.test.tsx",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n/* eslint-disable unicorn/no-array-callback-reference */\n\nimport React from 'react';\nimport type { BoardProps } from './react';\nimport { Client } from './react';\nimport Enzyme from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\nimport { Local } from './transport/local';\nimport { SocketIO } from './transport/socketio';\n\nEnzyme.configure({ adapter: new Adapter() });\n\nclass TestBoard extends React.Component<\n  BoardProps & { doStuff?; extraValue? }\n> {\n  render() {\n    return <div id=\"board\">Board</div>;\n  }\n}\n\ntest('board is rendered', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const board = game.find(TestBoard);\n\n  expect(board.props().isActive).toBe(true);\n  expect(board.text()).toBe('Board');\n\n  game.unmount();\n});\n\ntest('board props', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n  const board = Enzyme.mount(<Board />).find(TestBoard);\n  expect(board.props().isMultiplayer).toEqual(false);\n  expect(board.props().isActive).toBe(true);\n});\n\ntest('can pass extra props to Client', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n  });\n  const board = Enzyme.mount(\n    <Board doStuff={() => true} extraValue={55} />\n  ).find(TestBoard);\n  expect(board.props().doStuff()).toBe(true);\n  expect(board.props().extraValue).toBe(55);\n});\n\ntest('debug ui can be turned off', () => {\n  const Board = Client({\n    game: {},\n    board: TestBoard,\n    debug: false,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  expect(game.find('.debug-ui')).toHaveLength(0);\n});\n\ntest('custom loading component', () => {\n  const Loading = () => <div>custom</div>;\n  const Board = Client({\n    game: {},\n    loading: Loading,\n    board: TestBoard,\n    multiplayer: SocketIO(),\n  });\n  const board = Enzyme.mount(<Board />);\n  expect(board.html()).toContain('custom');\n});\n\ntest('can pass empty board', () => {\n  const Board = Client({\n    game: {},\n  });\n\n  const game = Enzyme.mount(<Board />);\n  expect(game).not.toBe(undefined);\n});\n\ntest('move api', () => {\n  const Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const board = game.find('TestBoard').instance() as TestBoard;\n\n  expect(board.props.G).toEqual({});\n  board.props.moves.A(42);\n  expect(board.props.G).toEqual({ arg: 42 });\n});\n\ntest('update matchID / playerID', () => {\n  let Board = null;\n  let game = null;\n\n  // No multiplayer.\n\n  Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n  });\n  game = Enzyme.mount(<Board />);\n  game.setProps({ matchID: 'a' });\n  game.setProps({ playerID: '3' });\n  expect(game.instance().transport).toBe(undefined);\n\n  // Multiplayer.\n\n  Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n    multiplayer: Local(),\n  });\n  game = Enzyme.mount(<Board matchID=\"a\" playerID=\"1\" credentials=\"foo\" />);\n  const m = game.instance().client.transport;\n  const g = game.instance().client;\n\n  const spy1 = jest.spyOn(m, 'updateMatchID');\n  const spy2 = jest.spyOn(m, 'updatePlayerID');\n  const spy3 = jest.spyOn(g, 'updateCredentials');\n\n  expect(m.matchID).toBe('a');\n  expect(m.playerID).toBe('1');\n\n  game.setProps({ matchID: 'a' });\n  game.setProps({ playerID: '1' });\n  game.setProps({ credentials: 'foo' });\n\n  expect(m.matchID).toBe('a');\n  expect(m.playerID).toBe('1');\n  expect(spy1).not.toHaveBeenCalled();\n  expect(spy2).not.toHaveBeenCalled();\n  expect(spy3).not.toHaveBeenCalled();\n\n  game.setProps({ matchID: 'next' });\n  game.setProps({ playerID: 'next' });\n  game.setProps({ credentials: 'bar' });\n\n  expect(m.matchID).toBe('next');\n  expect(m.playerID).toBe('next');\n  expect(spy1).toHaveBeenCalled();\n  expect(spy2).toHaveBeenCalled();\n  expect(spy3).toHaveBeenCalled();\n});\n\ntest('local playerView', () => {\n  const Board = Client({\n    game: {\n      setup: () => ({ secret: true }),\n      playerView: ({ playerID }) => ({ stripped: playerID }),\n    },\n    board: TestBoard,\n    numPlayers: 2,\n  });\n\n  const game = Enzyme.mount(<Board playerID=\"1\" />);\n  const board = game.find('TestBoard').instance() as TestBoard;\n  expect(board.props.G).toEqual({ stripped: '1' });\n});\n\ntest('reset Game', () => {\n  const Board = Client({\n    game: {\n      moves: {\n        A: (_, arg) => ({ arg }),\n      },\n    },\n    board: TestBoard,\n  });\n\n  const game = Enzyme.mount(<Board />);\n  const board = game.find('TestBoard').instance() as TestBoard;\n\n  const initial = { G: { ...board.props.G }, ctx: { ...board.props.ctx } };\n\n  expect(board.props.G).toEqual({});\n  board.props.moves.A(42);\n  expect(board.props.G).toEqual({ arg: 42 });\n  board.props.reset();\n  expect(board.props.G).toEqual(initial.G);\n  expect(board.props.ctx).toEqual(initial.ctx);\n});\n"
  },
  {
    "path": "src/client/react.tsx",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { Client as RawClient } from './client';\nimport type { ClientOpts, ClientState, _ClientImpl } from './client';\n\ntype WrappedBoardDelegates = 'matchID' | 'playerID' | 'credentials';\n\nexport type WrappedBoardProps = Pick<\n  ClientOpts,\n  WrappedBoardDelegates | 'debug'\n>;\n\ntype ExposedClientProps<G extends any = any> = Pick<\n  _ClientImpl<G>,\n  | 'log'\n  | 'moves'\n  | 'events'\n  | 'reset'\n  | 'undo'\n  | 'redo'\n  | 'playerID'\n  | 'matchID'\n  | 'matchData'\n  | 'sendChatMessage'\n  | 'chatMessages'\n>;\n\nexport type BoardProps<G extends any = any> = ClientState<G> &\n  Omit<WrappedBoardProps, keyof ExposedClientProps<G>> &\n  ExposedClientProps<G> & {\n    isMultiplayer: boolean;\n  };\n\ntype ReactClientOpts<\n  G extends any = any,\n  P extends BoardProps<G> = BoardProps<G>,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> = Omit<ClientOpts<G, PluginAPIs>, WrappedBoardDelegates> & {\n  board?: React.ComponentType<P>;\n  loading?: React.ComponentType;\n};\n\n/**\n * Client\n *\n * boardgame.io React client.\n *\n * @param {...object} game - The return value of `Game`.\n * @param {...object} numPlayers - The number of players.\n * @param {...object} board - The React component for the game.\n * @param {...object} loading - (optional) The React component for the loading state.\n * @param {...object} multiplayer - Set to a falsy value or a transportFactory, e.g., SocketIO()\n * @param {...object} debug - Enables the Debug UI.\n * @param {...object} enhancer - Optional enhancer to send to the Redux store\n *\n * Returns:\n *   A React component that wraps board and provides an\n *   API through props for it to interact with the framework\n *   and dispatch actions such as MAKE_MOVE, GAME_EVENT, RESET,\n *   UNDO and REDO.\n */\nexport function Client<\n  G extends any = any,\n  P extends BoardProps<G> = BoardProps<G>,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n>(opts: ReactClientOpts<G, P, PluginAPIs>) {\n  const { game, numPlayers, board, multiplayer, enhancer } = opts;\n  let { loading, debug } = opts;\n\n  // Component that is displayed before the client has synced\n  // with the game master.\n  if (loading === undefined) {\n    const Loading = () => <div className=\"bgio-loading\">connecting...</div>;\n    loading = Loading;\n  }\n\n  type AdditionalProps = Omit<P, keyof BoardProps<G>>;\n\n  /*\n   * WrappedBoard\n   *\n   * The main React component that wraps the passed in\n   * board component and adds the API to its props.\n   */\n  return class WrappedBoard extends React.Component<\n    WrappedBoardProps & AdditionalProps\n  > {\n    client: _ClientImpl<G>;\n    unsubscribe?: () => void;\n\n    static propTypes = {\n      // The ID of a game to connect to.\n      // Only relevant in multiplayer.\n      matchID: PropTypes.string,\n      // The ID of the player associated with this client.\n      // Only relevant in multiplayer.\n      playerID: PropTypes.string,\n      // This client's authentication credentials.\n      // Only relevant in multiplayer.\n      credentials: PropTypes.string,\n      // Enable / disable the Debug UI.\n      debug: PropTypes.any,\n    };\n\n    static defaultProps = {\n      matchID: 'default',\n      playerID: null,\n      credentials: null,\n      debug: true,\n    };\n\n    constructor(props: WrappedBoardProps & AdditionalProps) {\n      super(props);\n\n      if (debug === undefined) {\n        debug = props.debug;\n      }\n\n      this.client = RawClient({\n        game,\n        debug,\n        numPlayers,\n        multiplayer,\n        matchID: props.matchID,\n        playerID: props.playerID,\n        credentials: props.credentials,\n        enhancer,\n      });\n    }\n\n    componentDidMount() {\n      this.unsubscribe = this.client.subscribe(() => this.forceUpdate());\n      this.client.start();\n    }\n\n    componentWillUnmount() {\n      this.client.stop();\n      this.unsubscribe();\n    }\n\n    componentDidUpdate(prevProps: WrappedBoardProps & AdditionalProps) {\n      if (this.props.matchID != prevProps.matchID) {\n        this.client.updateMatchID(this.props.matchID);\n      }\n      if (this.props.playerID != prevProps.playerID) {\n        this.client.updatePlayerID(this.props.playerID);\n      }\n      if (this.props.credentials != prevProps.credentials) {\n        this.client.updateCredentials(this.props.credentials);\n      }\n    }\n\n    render() {\n      const state = this.client.getState();\n\n      if (state === null) {\n        return React.createElement(loading);\n      }\n\n      let _board = null;\n\n      if (board) {\n        _board = React.createElement(board, {\n          ...state,\n          ...(this.props as P),\n          isMultiplayer: !!multiplayer,\n          moves: this.client.moves,\n          events: this.client.events,\n          matchID: this.client.matchID,\n          playerID: this.client.playerID,\n          reset: this.client.reset,\n          undo: this.client.undo,\n          redo: this.client.redo,\n          log: this.client.log,\n          matchData: this.client.matchData,\n          sendChatMessage: this.client.sendChatMessage,\n          chatMessages: this.client.chatMessages,\n        });\n      }\n\n      return <div className=\"bgio-client\">{_board}</div>;\n    }\n  };\n}\n"
  },
  {
    "path": "src/client/transport/dummy.ts",
    "content": "import { Transport } from './transport';\nimport type { TransportOpts } from './transport';\n\n/**\n * This class doesn’t do anything, but simplifies the client class by providing\n * dummy functions to call, so we don’t need to mock them in the client.\n */\nclass DummyImpl extends Transport {\n  connect() {}\n  disconnect() {}\n  sendAction() {}\n  sendChatMessage() {}\n  requestSync() {}\n  updateCredentials() {}\n  updateMatchID() {}\n  updatePlayerID() {}\n}\n\nexport const DummyTransport = (opts: TransportOpts) => new DummyImpl(opts);\n"
  },
  {
    "path": "src/client/transport/local.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { LocalTransport, LocalMaster, Local, GetBotPlayer } from './local';\nimport { gameEvent } from '../../core/action-creators';\nimport { ProcessGameConfig } from '../../core/game';\nimport { Client } from '../client';\nimport { RandomBot } from '../../ai/random-bot';\nimport { Stage } from '../../core/turn-order';\nimport type { Game, State } from '../../types';\n\nconst sleep = (ms = 500) => new Promise((resolve) => setTimeout(resolve, ms));\n\ndescribe('bots', () => {\n  const game: Game = {\n    moves: {\n      A: ({ events }) => {\n        events.endTurn();\n      },\n    },\n    ai: {\n      enumerate: () => [{ move: 'A' }],\n    },\n  };\n\n  test('make bot move', async () => {\n    const client = Client({\n      game: { ...game },\n      playerID: '0',\n      multiplayer: Local({ bots: { '1': RandomBot } }),\n    });\n\n    client.start();\n    expect(client.getState().ctx.turn).toBe(1);\n\n    // Make it Player 1's turn and trigger the bot move.\n    client.events.endTurn();\n    expect(client.getState().ctx.turn).toBe(2);\n\n    // Wait until the bot has hopefully completed its move.\n    await sleep();\n    expect(client.getState().ctx.turn).toBe(3);\n  });\n\n  test('no bot move', async () => {\n    const client = Client({\n      numPlayers: 3,\n      game: { ...game },\n      playerID: '0',\n      multiplayer: Local({ bots: { '2': RandomBot } }),\n    });\n\n    client.start();\n    expect(client.getState().ctx.turn).toBe(1);\n\n    // Make it Player 1's turn. No bot move.\n    client.events.endTurn();\n    expect(client.getState().ctx.currentPlayer).toBe('1');\n\n    // Wait until the bot has hopefully completed its move.\n    await sleep();\n    expect(client.getState().ctx.currentPlayer).toBe('1');\n    expect(client.getState().ctx.numMoves).toBe(0);\n  });\n});\n\ndescribe('GetBotPlayer', () => {\n  test('stages', () => {\n    const result = GetBotPlayer(\n      {\n        ctx: {\n          activePlayers: {\n            '1': Stage.NULL,\n          },\n        },\n      } as unknown as State,\n      {\n        '0': {},\n        '1': {},\n      }\n    );\n    expect(result).toEqual('1');\n  });\n\n  test('no stages', () => {\n    const result = GetBotPlayer(\n      {\n        ctx: {\n          currentPlayer: '0',\n        },\n      } as unknown as State,\n      { '0': {} }\n    );\n    expect(result).toEqual('0');\n  });\n\n  test('null', () => {\n    const result = GetBotPlayer(\n      {\n        ctx: {\n          currentPlayer: '1',\n        },\n      } as unknown as State,\n      { '0': {} }\n    );\n    expect(result).toEqual(null);\n  });\n\n  test('gameover', () => {\n    const result = GetBotPlayer(\n      {\n        ctx: {\n          currentPlayer: '0',\n          gameover: true,\n        },\n      } as unknown as State,\n      { '0': {} }\n    );\n    expect(result).toEqual(null);\n  });\n});\n\ndescribe('Local', () => {\n  test('transports for same game use shared master', () => {\n    const gameKey = {};\n    const game = ProcessGameConfig(gameKey);\n    const transport1 = Local()({\n      game,\n      gameKey,\n      transportDataCallback: () => {},\n    });\n    const transport2 = Local()({\n      game,\n      gameKey,\n      transportDataCallback: () => {},\n    });\n    expect(transport1.master).toBe(transport2.master);\n  });\n\n  test('transports use shared master with bots', () => {\n    const gameKey = {};\n    const game = ProcessGameConfig(gameKey);\n    const bots = {};\n    const transport1 = Local({ bots })({\n      game,\n      gameKey,\n      transportDataCallback: () => {},\n    });\n    const transport2 = Local({ bots })({\n      game,\n      gameKey,\n      transportDataCallback: () => {},\n    });\n    expect(transport1.master).toBe(transport2.master);\n  });\n\n  test('transports use different master for different bots', () => {\n    const gameKey = {};\n    const game = ProcessGameConfig(gameKey);\n    const transport1 = Local({ bots: {} })({\n      game,\n      gameKey,\n      transportDataCallback: () => {},\n    });\n    const transport2 = Local({ bots: {} })({\n      game,\n      gameKey,\n      transportDataCallback: () => {},\n    });\n    expect(transport1.master).not.toBe(transport2.master);\n  });\n\n  describe('with localStorage persistence', () => {\n    const game: Game = {\n      setup: () => ({ count: 0 }),\n      moves: {\n        A: ({ G }) => {\n          G.count++;\n        },\n      },\n    };\n\n    afterEach(() => {\n      localStorage.clear();\n    });\n\n    test('writes to localStorage', () => {\n      const matchID = 'persists-to-ls';\n      const multiplayer = Local({ persist: true });\n      const client = Client({ playerID: '0', matchID, game, multiplayer });\n      client.start();\n      expect(client.getState().G).toEqual({ count: 0 });\n      client.moves.A();\n      expect(client.getState().G).toEqual({ count: 1 });\n      client.stop();\n      const stored = JSON.parse(localStorage.getItem('bgio_state'));\n      const [id, state] = stored.find(([id]) => id === matchID);\n      expect(id).toBe(matchID);\n      expect(state.G).toEqual({ count: 1 });\n    });\n\n    test('reads from localStorage', () => {\n      const matchID = 'reads-from-ls';\n      const storageKey = 'rfls';\n      const stateMap = {\n        [matchID]: {\n          G: { count: 'foo' },\n          ctx: {},\n        },\n      };\n      const entriesString = JSON.stringify(Object.entries(stateMap));\n      localStorage.setItem(`${storageKey}_state`, entriesString);\n      const multiplayer = Local({ persist: true, storageKey });\n      const client = Client({ playerID: '0', matchID, game, multiplayer });\n      client.start();\n      expect(client.getState().G).toEqual({ count: 'foo' });\n      client.stop();\n    });\n  });\n});\n\ndescribe('LocalMaster', () => {\n  let master: LocalMaster;\n  let player0Callback: jest.Mock;\n  let player1Callback: jest.Mock;\n\n  beforeEach(() => {\n    master = new LocalMaster({ game: {} });\n    player0Callback = jest.fn();\n    player1Callback = jest.fn();\n    master.connect('0', player0Callback);\n    master.connect('1', player1Callback);\n    master.onSync('matchID', '0');\n    master.onSync('matchID', '1');\n  });\n\n  test('sync', () => {\n    expect(player0Callback).toHaveBeenCalledWith(\n      expect.objectContaining({ type: 'sync' })\n    );\n    expect(player1Callback).toHaveBeenCalledWith(\n      expect.objectContaining({ type: 'sync' })\n    );\n  });\n\n  test('update', () => {\n    master.onUpdate(gameEvent('endTurn'), 0, 'matchID', '0');\n    expect(player0Callback).toBeCalledWith(\n      expect.objectContaining({ type: 'update' })\n    );\n    expect(player1Callback).toBeCalledWith(\n      expect.objectContaining({ type: 'update' })\n    );\n  });\n\n  test('connect without callback', () => {\n    expect(() => {\n      master.connect('0', undefined);\n      master.onSync('matchID', '0');\n    }).not.toThrow();\n  });\n});\n\ndescribe('LocalTransport', () => {\n  describe('update matchID / playerID', () => {\n    const master = {\n      connect: jest.fn(),\n      onSync: jest.fn(),\n    } as unknown as LocalMaster;\n    class WrappedLocalTransport extends LocalTransport {\n      getMatchID() {\n        return this.matchID;\n      }\n      getPlayerID() {\n        return this.playerID;\n      }\n    }\n    const transport = new WrappedLocalTransport({\n      master,\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    jest.spyOn(transport, 'requestSync');\n\n    beforeEach(() => {\n      jest.resetAllMocks();\n    });\n\n    test('matchID', () => {\n      transport.updateMatchID('test');\n      expect(transport.getMatchID()).toBe('test');\n      expect(transport.requestSync).toBeCalled();\n    });\n\n    test('playerID', () => {\n      transport.updatePlayerID('player');\n      expect(transport.getPlayerID()).toBe('player');\n      expect(master.connect).toBeCalled();\n    });\n  });\n\n  describe('multiplayer', () => {\n    const game: Game = {\n      setup: () => ({ initial: true }),\n      moves: {\n        A: () => ({ A: true }),\n      },\n    };\n    const multiplayer = Local();\n    const matchID = 'local-multiplayer';\n    const client1 = Client({ game, multiplayer, matchID, playerID: '0' });\n    const client2 = Client({ game, multiplayer, matchID, playerID: '1' });\n\n    beforeAll(() => {\n      client1.start();\n      client2.start();\n    });\n\n    afterAll(() => {\n      client1.stop();\n      client2.stop();\n    });\n\n    test('send/receive update', () => {\n      expect(client1.getState().G).toStrictEqual({ initial: true });\n      expect(client2.getState().G).toStrictEqual({ initial: true });\n      client1.moves.A();\n      expect(client1.getState().G).toStrictEqual({ A: true });\n      expect(client2.getState().G).toStrictEqual({ A: true });\n    });\n\n    test('receive sync', () => {\n      const newClient = Client({ game, multiplayer, matchID });\n      newClient.start();\n      expect(newClient.getState().G).toStrictEqual({ A: true });\n      newClient.stop();\n    });\n\n    test('send chat-message', () => {\n      const payload = { message: 'foo' };\n      client1.sendChatMessage(payload);\n      expect(client2.chatMessages).toStrictEqual([\n        { id: expect.any(String), sender: '0', payload },\n      ]);\n    });\n  });\n});\n"
  },
  {
    "path": "src/client/transport/local.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { InMemory } from '../../server/db/inmemory';\nimport { LocalStorage } from '../../server/db/localstorage';\nimport { Master } from '../../master/master';\nimport type { TransportAPI, TransportData } from '../../master/master';\nimport { Transport } from './transport';\nimport type { TransportOpts } from './transport';\nimport type {\n  ChatMessage,\n  CredentialedActionShape,\n  Game,\n  PlayerID,\n  State,\n} from '../../types';\nimport { getFilterPlayerView } from '../../master/filter-player-view';\n\n/**\n * Returns null if it is not a bot's turn.\n * Otherwise, returns a playerID of a bot that may play now.\n */\nexport function GetBotPlayer(state: State, bots: Record<PlayerID, any>) {\n  if (state.ctx.gameover !== undefined) {\n    return null;\n  }\n\n  if (state.ctx.activePlayers) {\n    for (const key of Object.keys(bots)) {\n      if (key in state.ctx.activePlayers) {\n        return key;\n      }\n    }\n  } else if (state.ctx.currentPlayer in bots) {\n    return state.ctx.currentPlayer;\n  }\n\n  return null;\n}\n\ninterface LocalOpts {\n  bots?: Record<PlayerID, any>;\n  persist?: boolean;\n  storageKey?: string;\n}\n\ntype LocalMasterOpts = LocalOpts & {\n  game: Game;\n};\n\n/**\n * Creates a local version of the master that the client\n * can interact with.\n */\nexport class LocalMaster extends Master {\n  connect: (\n    playerID: PlayerID,\n    callback: (data: TransportData) => void\n  ) => void;\n\n  constructor({ game, bots, storageKey, persist }: LocalMasterOpts) {\n    const clientCallbacks: Record<PlayerID, (data: TransportData) => void> = {};\n    const initializedBots = {};\n\n    if (game && game.ai && bots) {\n      for (const playerID in bots) {\n        const bot = bots[playerID];\n        initializedBots[playerID] = new bot({\n          game,\n          enumerate: game.ai.enumerate,\n          seed: game.seed,\n        });\n      }\n    }\n\n    const send: TransportAPI['send'] = ({ playerID, ...data }) => {\n      const callback = clientCallbacks[playerID];\n      if (callback !== undefined) {\n        callback(filterPlayerView(playerID, data));\n      }\n    };\n\n    const filterPlayerView = getFilterPlayerView(game);\n    const transportAPI: TransportAPI = {\n      send,\n      sendAll: (payload) => {\n        for (const playerID in clientCallbacks) {\n          send({ playerID, ...payload });\n        }\n      },\n    };\n    const storage = persist ? new LocalStorage(storageKey) : new InMemory();\n    super(game, storage, transportAPI);\n\n    this.connect = (playerID, callback) => {\n      clientCallbacks[playerID] = callback;\n    };\n\n    this.subscribe(({ state, matchID }) => {\n      if (!bots) {\n        return;\n      }\n      const botPlayer = GetBotPlayer(state, initializedBots);\n      if (botPlayer !== null) {\n        setTimeout(async () => {\n          const botAction = await initializedBots[botPlayer].play(\n            state,\n            botPlayer\n          );\n          await this.onUpdate(\n            botAction.action,\n            state._stateID,\n            matchID,\n            botAction.action.payload.playerID\n          );\n        }, 100);\n      }\n    });\n  }\n}\n\ntype LocalTransportOpts = TransportOpts & {\n  master?: LocalMaster;\n};\n\n/**\n * Local\n *\n * Transport interface that embeds a GameMaster within it\n * that you can connect multiple clients to.\n */\nexport class LocalTransport extends Transport {\n  master: LocalMaster;\n\n  /**\n   * Creates a new Mutiplayer instance.\n   * @param {string} matchID - The game ID to connect to.\n   * @param {string} playerID - The player ID associated with this client.\n   * @param {string} gameName - The game type (the `name` field in `Game`).\n   * @param {string} numPlayers - The number of players.\n   */\n  constructor({ master, ...opts }: LocalTransportOpts) {\n    super(opts);\n    this.master = master;\n  }\n\n  sendChatMessage(matchID: string, chatMessage: ChatMessage): void {\n    const args: Parameters<Master['onChatMessage']> = [\n      matchID,\n      chatMessage,\n      this.credentials,\n    ];\n    this.master.onChatMessage(...args);\n  }\n\n  sendAction(state: State, action: CredentialedActionShape.Any): void {\n    this.master.onUpdate(action, state._stateID, this.matchID, this.playerID);\n  }\n\n  requestSync(): void {\n    this.master.onSync(\n      this.matchID,\n      this.playerID,\n      this.credentials,\n      this.numPlayers\n    );\n  }\n\n  connect(): void {\n    this.setConnectionStatus(true);\n    this.master.connect(this.playerID, (data) => this.notifyClient(data));\n    this.requestSync();\n  }\n\n  disconnect(): void {\n    this.setConnectionStatus(false);\n  }\n\n  updateMatchID(id: string): void {\n    this.matchID = id;\n    this.connect();\n  }\n\n  updatePlayerID(id: PlayerID): void {\n    this.playerID = id;\n    this.connect();\n  }\n\n  updateCredentials(credentials?: string): void {\n    this.credentials = credentials;\n    this.connect();\n  }\n}\n\n/**\n * Global map storing local master instances.\n */\nconst localMasters: Map<Game, { master: LocalMaster } & LocalOpts> = new Map();\n\n/**\n * Create a local transport.\n */\nexport function Local({ bots, persist, storageKey }: LocalOpts = {}) {\n  return (transportOpts: TransportOpts) => {\n    const { gameKey, game } = transportOpts;\n    let master: LocalMaster;\n\n    const instance = localMasters.get(gameKey);\n    if (\n      instance &&\n      instance.bots === bots &&\n      instance.storageKey === storageKey &&\n      instance.persist === persist\n    ) {\n      master = instance.master;\n    }\n\n    if (!master) {\n      master = new LocalMaster({ game, bots, persist, storageKey });\n      localMasters.set(gameKey, { master, bots, persist, storageKey });\n    }\n\n    return new LocalTransport({ master, ...transportOpts });\n  };\n}\n"
  },
  {
    "path": "src/client/transport/socketio.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { SocketIOTransport } from './socketio';\nimport type * as ioNamespace from 'socket.io-client';\nimport { makeMove } from '../../core/action-creators';\nimport type { Master } from '../../master/master';\nimport type { ChatMessage, State } from '../../types';\nimport { ProcessGameConfig } from '../../core/game';\n\njest.mock('../../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\ntype UpdateArgs = Parameters<Master['onUpdate']>;\ntype SyncArgs = Parameters<Master['onSync']>;\n\nclass MockSocket {\n  callbacks: Record<string, (arg0?: any, arg1?: any) => void>;\n  emit: jest.Mock;\n\n  constructor() {\n    this.callbacks = {};\n    this.emit = jest.fn();\n  }\n\n  receive(type: string, ...args) {\n    this.callbacks[type](...args);\n  }\n\n  on(type: string, callback: (arg0?: any, arg1?: any) => void) {\n    this.callbacks[type] = callback;\n  }\n\n  close() {}\n}\n\ntest('defaults', () => {\n  const m = new SocketIOTransport({\n    transportDataCallback: () => {},\n    game: ProcessGameConfig({}),\n    gameKey: {},\n  });\n  expect(typeof (m as any).connectionStatusCallback).toBe('function');\n  (m as any).connectionStatusCallback();\n});\n\nclass TransportAdapter extends SocketIOTransport {\n  declare socket: ioNamespace.Socket & {\n    io: { engine: any };\n  };\n\n  getMatchID() {\n    return this.matchID;\n  }\n\n  getPlayerID() {\n    return this.playerID;\n  }\n\n  getCredentials() {\n    return this.credentials;\n  }\n}\n\ndescribe('update matchID / playerID / credentials', () => {\n  const socket = new MockSocket();\n  const m = new TransportAdapter({\n    socket,\n    transportDataCallback: () => {},\n    game: ProcessGameConfig({}),\n    gameKey: {},\n  });\n\n  beforeEach(() => (socket.emit = jest.fn()));\n\n  test('matchID', () => {\n    m.updateMatchID('test');\n    expect(m.getMatchID()).toBe('test');\n    const args: SyncArgs = ['test', null, undefined, 2];\n    expect(socket.emit).lastCalledWith('sync', ...args);\n  });\n\n  test('playerID', () => {\n    m.updatePlayerID('player');\n    expect(m.getPlayerID()).toBe('player');\n    const args: SyncArgs = ['test', 'player', undefined, 2];\n    expect(socket.emit).lastCalledWith('sync', ...args);\n  });\n\n  test('credentials', () => {\n    m.updateCredentials('1234');\n    expect(m.getCredentials()).toBe('1234');\n    const args: SyncArgs = ['test', 'player', '1234', 2];\n    expect(socket.emit).lastCalledWith('sync', ...args);\n  });\n});\n\ndescribe('connection status', () => {\n  let onChangeMock: jest.Mock;\n  let mockSocket: MockSocket;\n  let m: SocketIOTransport;\n\n  beforeEach(() => {\n    onChangeMock = jest.fn();\n    mockSocket = new MockSocket();\n    m = new SocketIOTransport({\n      socket: mockSocket,\n      matchID: '0',\n      playerID: '0',\n      gameName: 'foo',\n      game: ProcessGameConfig({}),\n      gameKey: {},\n      numPlayers: 2,\n      transportDataCallback: () => {},\n    });\n    m.subscribeToConnectionStatus(onChangeMock);\n    m.connect();\n  });\n\n  test('connect', () => {\n    mockSocket.callbacks['connect']();\n    expect(onChangeMock).toHaveBeenCalled();\n    expect(m.isConnected).toBe(true);\n  });\n\n  test('disconnect', () => {\n    mockSocket.callbacks['disconnect']();\n    expect(onChangeMock).toHaveBeenCalled();\n    expect(m.isConnected).toBe(false);\n  });\n\n  test('close socket', () => {\n    mockSocket.callbacks['connect']();\n    expect(m.isConnected).toBe(true);\n    m.disconnect();\n    expect(m.isConnected).toBe(false);\n  });\n\n  test('doesn’t crash if syncing before connecting', () => {\n    const transportDataCallback = jest.fn();\n    const transport = new SocketIOTransport({\n      transportDataCallback,\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    transport.requestSync();\n    expect(transportDataCallback).not.toHaveBeenCalled();\n  });\n});\n\ndescribe('multiplayer', () => {\n  const mockSocket = new MockSocket();\n  const transportDataCallback = jest.fn();\n  const transport = new TransportAdapter({\n    socket: mockSocket,\n    transportDataCallback,\n    game: ProcessGameConfig({}),\n    gameKey: {},\n  });\n  transport.connect();\n\n  beforeEach(jest.clearAllMocks);\n\n  test('receive update', () => {\n    const restored: { restore: boolean; _stateID?: number } = { restore: true };\n    mockSocket.receive('update', 'default', restored);\n    expect(transportDataCallback).toHaveBeenCalledWith({\n      type: 'update',\n      args: ['default', restored, undefined],\n    });\n  });\n\n  test('receive sync', () => {\n    const restored = { restore: true };\n    mockSocket.receive('sync', 'default', { state: restored });\n    expect(transportDataCallback).toHaveBeenCalledWith({\n      type: 'sync',\n      args: ['default', { state: restored }],\n    });\n  });\n\n  test('receive matchData', () => {\n    const matchData = [{ id: '0', name: 'Alice' }];\n    mockSocket.receive('matchData', 'default', matchData);\n    expect(transportDataCallback).toHaveBeenCalledWith({\n      type: 'matchData',\n      args: ['default', matchData],\n    });\n  });\n\n  test('send update', () => {\n    const action = makeMove(undefined, undefined, undefined);\n    const state = { _stateID: 0 } as State;\n    transport.sendAction(state, action);\n    const args: UpdateArgs = [action, state._stateID, 'default', null];\n    expect(mockSocket.emit).lastCalledWith('update', ...args);\n  });\n\n  test('receive chat-message', () => {\n    const chatData = { message: 'foo' };\n    mockSocket.receive('chat', 'default', chatData);\n    expect(transportDataCallback).toHaveBeenCalledWith({\n      type: 'chat',\n      args: ['default', chatData],\n    });\n  });\n\n  test('send chat-message', () => {\n    const message: ChatMessage = {\n      id: '0',\n      sender: '0',\n      payload: { message: 'foo' },\n    };\n    transport.sendChatMessage('matchID', message);\n    expect(mockSocket.emit).lastCalledWith(\n      'chat',\n      'matchID',\n      message,\n      transport.getCredentials()\n    );\n  });\n});\n\ndescribe('multiplayer delta state', () => {\n  const mockSocket = new MockSocket();\n  const transportDataCallback = jest.fn();\n  const transport = new TransportAdapter({\n    socket: mockSocket,\n    transportDataCallback,\n    game: ProcessGameConfig({}),\n    gameKey: {},\n  });\n  transport.connect();\n\n  beforeEach(jest.clearAllMocks);\n\n  test('receive patch', () => {\n    const patch1 = [\n      'default',\n      0,\n      1,\n      [{ op: 'replace', path: '/_stateID', value: 1 }],\n      [],\n    ];\n    mockSocket.receive('patch', ...patch1);\n    expect(transportDataCallback).toHaveBeenCalledWith({\n      type: 'patch',\n      args: patch1,\n    });\n  });\n});\n\ndescribe('server option', () => {\n  const hostname = 'host';\n  const port = '1234';\n\n  test('without protocol', () => {\n    const server = hostname + ':' + port;\n    const m = new TransportAdapter({\n      server,\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    m.connect();\n    expect(m.socket.io.engine.hostname).toEqual(hostname);\n    expect(m.socket.io.engine.port).toEqual(port);\n    expect(m.socket.io.engine.secure).toEqual(false);\n  });\n\n  test('without trailing slash', () => {\n    const server = 'http://' + hostname + ':' + port;\n    const m = new SocketIOTransport({\n      server,\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    m.connect();\n    expect((m.socket.io as any).uri).toEqual(server + '/default');\n  });\n\n  test('https', () => {\n    const serverWithProtocol = 'https://' + hostname + ':' + port + '/';\n    const m = new TransportAdapter({\n      server: serverWithProtocol,\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    m.connect();\n    expect(m.socket.io.engine.hostname).toEqual(hostname);\n    expect(m.socket.io.engine.port).toEqual(port);\n    expect(m.socket.io.engine.secure).toEqual(true);\n  });\n\n  test('http', () => {\n    const serverWithProtocol = 'http://' + hostname + ':' + port + '/';\n    const m = new TransportAdapter({\n      server: serverWithProtocol,\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    m.connect();\n    expect(m.socket.io.engine.hostname).toEqual(hostname);\n    expect(m.socket.io.engine.port).toEqual(port);\n    expect(m.socket.io.engine.secure).toEqual(false);\n  });\n\n  test('no server set', () => {\n    const m = new TransportAdapter({\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    m.connect();\n    expect(m.socket.io.engine.hostname).not.toEqual(hostname);\n    expect(m.socket.io.engine.port).not.toEqual(port);\n  });\n});\n"
  },
  {
    "path": "src/client/transport/socketio.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport * as ioNamespace from 'socket.io-client';\n\nconst io = ioNamespace.default;\n\nimport type { Master } from '../../master/master';\nimport { Transport } from './transport';\nimport type { Operation } from 'rfc6902';\nimport type { TransportOpts } from './transport';\nimport type {\n  CredentialedActionShape,\n  FilteredMetadata,\n  LogEntry,\n  PlayerID,\n  State,\n  SyncInfo,\n  ChatMessage,\n} from '../../types';\n\ntype SocketOpts = Partial<\n  ioNamespace.SocketOptions & ioNamespace.ManagerOptions\n>;\n\ninterface SocketIOOpts {\n  server?: string;\n  socketOpts?: SocketOpts;\n}\n\ntype SocketIOTransportOpts = TransportOpts &\n  SocketIOOpts & {\n    socket?;\n  };\n\n/**\n * SocketIO\n *\n * Transport interface that interacts with the Master via socket.io.\n */\nexport class SocketIOTransport extends Transport {\n  server: string;\n  socket: ioNamespace.Socket;\n  socketOpts: SocketOpts;\n\n  /**\n   * Creates a new Multiplayer instance.\n   * @param {object} socket - Override for unit tests.\n   * @param {object} socketOpts - Options to pass to socket.io.\n   * @param {object} store - Redux store\n   * @param {string} matchID - The game ID to connect to.\n   * @param {string} playerID - The player ID associated with this client.\n   * @param {string} credentials - Authentication credentials\n   * @param {string} gameName - The game type (the `name` field in `Game`).\n   * @param {string} numPlayers - The number of players.\n   * @param {string} server - The game server in the form of 'hostname:port'. Defaults to the server serving the client if not provided.\n   */\n  constructor({ socket, socketOpts, server, ...opts }: SocketIOTransportOpts) {\n    super(opts);\n\n    this.server = server;\n    this.socket = socket;\n    this.socketOpts = socketOpts;\n  }\n\n  sendAction(state: State, action: CredentialedActionShape.Any): void {\n    const args: Parameters<Master['onUpdate']> = [\n      action,\n      state._stateID,\n      this.matchID,\n      this.playerID,\n    ];\n    this.socket.emit('update', ...args);\n  }\n\n  sendChatMessage(matchID: string, chatMessage: ChatMessage): void {\n    const args: Parameters<Master['onChatMessage']> = [\n      matchID,\n      chatMessage,\n      this.credentials,\n    ];\n    this.socket.emit('chat', ...args);\n  }\n\n  connect(): void {\n    if (!this.socket) {\n      if (this.server) {\n        let server = this.server;\n        if (server.search(/^https?:\\/\\//) == -1) {\n          server = 'http://' + this.server;\n        }\n        if (server.slice(-1) != '/') {\n          // add trailing slash if not already present\n          server = server + '/';\n        }\n        this.socket = io(server + this.gameName, this.socketOpts);\n      } else {\n        this.socket = io('/' + this.gameName, this.socketOpts);\n      }\n    }\n\n    // Called when another player makes a move and the\n    // master broadcasts the update as a patch to other clients (including\n    // this one).\n    this.socket.on(\n      'patch',\n      (\n        matchID: string,\n        prevStateID: number,\n        stateID: number,\n        patch: Operation[],\n        deltalog: LogEntry[]\n      ) => {\n        this.notifyClient({\n          type: 'patch',\n          args: [matchID, prevStateID, stateID, patch, deltalog],\n        });\n      }\n    );\n\n    // Called when another player makes a move and the\n    // master broadcasts the update to other clients (including\n    // this one).\n    this.socket.on(\n      'update',\n      (matchID: string, state: State, deltalog: LogEntry[]) => {\n        this.notifyClient({\n          type: 'update',\n          args: [matchID, state, deltalog],\n        });\n      }\n    );\n\n    // Called when the client first connects to the master\n    // and requests the current game state.\n    this.socket.on('sync', (matchID: string, syncInfo: SyncInfo) => {\n      this.notifyClient({ type: 'sync', args: [matchID, syncInfo] });\n    });\n\n    // Called when new player joins the match or changes\n    // it's connection status\n    this.socket.on(\n      'matchData',\n      (matchID: string, matchData: FilteredMetadata) => {\n        this.notifyClient({ type: 'matchData', args: [matchID, matchData] });\n      }\n    );\n\n    this.socket.on('chat', (matchID: string, chatMessage: ChatMessage) => {\n      this.notifyClient({ type: 'chat', args: [matchID, chatMessage] });\n    });\n\n    // Keep track of connection status.\n    this.socket.on('connect', () => {\n      // Initial sync to get game state.\n      this.requestSync();\n      this.setConnectionStatus(true);\n    });\n    this.socket.on('disconnect', () => {\n      this.setConnectionStatus(false);\n    });\n  }\n\n  disconnect(): void {\n    this.socket.close();\n    this.socket = null;\n    this.setConnectionStatus(false);\n  }\n\n  requestSync(): void {\n    if (this.socket) {\n      const args: Parameters<Master['onSync']> = [\n        this.matchID,\n        this.playerID,\n        this.credentials,\n        this.numPlayers,\n      ];\n      this.socket.emit('sync', ...args);\n    }\n  }\n\n  updateMatchID(id: string): void {\n    this.matchID = id;\n    this.requestSync();\n  }\n\n  updatePlayerID(id: PlayerID): void {\n    this.playerID = id;\n    this.requestSync();\n  }\n\n  updateCredentials(credentials?: string): void {\n    this.credentials = credentials;\n    this.requestSync();\n  }\n}\n\nexport function SocketIO({ server, socketOpts }: SocketIOOpts = {}) {\n  return (transportOpts: SocketIOTransportOpts) =>\n    new SocketIOTransport({\n      server,\n      socketOpts,\n      ...transportOpts,\n    });\n}\n"
  },
  {
    "path": "src/client/transport/transport.test.ts",
    "content": "import { Transport } from './transport';\nimport { ProcessGameConfig } from '../../core/game';\n\ndescribe('Transport', () => {\n  class SimpleTransport extends Transport {\n    connect() {}\n    disconnect() {}\n    sendAction() {}\n    sendChatMessage() {}\n    requestSync() {}\n    updateMatchID() {}\n    updatePlayerID() {}\n    updateCredentials() {}\n    get(key: 'connectionStatusCallback') {\n      return this[key].bind(this);\n    }\n  }\n\n  test('base class sets up callbacks', () => {\n    const transport = new SimpleTransport({\n      transportDataCallback: () => {},\n      game: ProcessGameConfig({}),\n      gameKey: {},\n    });\n    expect(transport.get('connectionStatusCallback')()).toBeUndefined();\n  });\n});\n"
  },
  {
    "path": "src/client/transport/transport.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { ProcessGameConfig } from '../../core/game';\nimport type { TransportData } from '../../master/master';\nimport type {\n  Game,\n  PlayerID,\n  CredentialedActionShape,\n  State,\n  SyncInfo,\n  ChatMessage,\n} from '../../types';\n\nexport type MetadataCallback = (metadata: SyncInfo['filteredMetadata']) => void;\n\nexport type ChatCallback = (message: ChatMessage) => void;\n\nexport interface TransportOpts {\n  transportDataCallback: (data: TransportData) => void;\n  gameName?: string;\n  gameKey: Game;\n  game: ReturnType<typeof ProcessGameConfig>;\n  playerID?: PlayerID;\n  matchID?: string;\n  credentials?: string;\n  numPlayers?: number;\n}\n\nexport abstract class Transport {\n  protected gameName: string;\n  protected playerID: PlayerID | null;\n  protected matchID: string;\n  protected credentials?: string;\n  protected numPlayers: number;\n  /** Callback to pass transport data back to the client. */\n  private transportDataCallback: (data: TransportData) => void;\n  /** Callback to let the client know when the connection status has changed. */\n  private connectionStatusCallback: () => void = () => {};\n  isConnected = false;\n\n  constructor({\n    transportDataCallback,\n    gameName,\n    playerID,\n    matchID,\n    credentials,\n    numPlayers,\n  }: TransportOpts) {\n    this.transportDataCallback = transportDataCallback;\n    this.gameName = gameName || 'default';\n    this.playerID = playerID || null;\n    this.matchID = matchID || 'default';\n    this.credentials = credentials;\n    this.numPlayers = numPlayers || 2;\n  }\n\n  /** Subscribe to connection state changes. */\n  subscribeToConnectionStatus(fn: () => void): void {\n    this.connectionStatusCallback = fn;\n  }\n\n  /** Transport implementations should call this when they connect/disconnect. */\n  protected setConnectionStatus(isConnected: boolean): void {\n    this.isConnected = isConnected;\n    this.connectionStatusCallback();\n  }\n\n  /** Transport implementations should call this when they receive data from a master. */\n  protected notifyClient(data: TransportData): void {\n    this.transportDataCallback(data);\n  }\n\n  /** Called by the client to connect the transport. */\n  abstract connect(): void;\n  /** Called by the client to disconnect the transport. */\n  abstract disconnect(): void;\n  /** Called by the client to dispatch an action via the transport. */\n  abstract sendAction(state: State, action: CredentialedActionShape.Any): void;\n  /** Called by the client to dispatch a chat message via the transport. */\n  abstract sendChatMessage(matchID: string, chatMessage: ChatMessage): void;\n  /** Called by the client to request a sync action from the transport. */\n  abstract requestSync(): void;\n  /** Called by the client to update the matchID it wants to connect to. */\n  abstract updateMatchID(id: string): void;\n  /** Called by the client to update the playerID it is playing as. */\n  abstract updatePlayerID(id: PlayerID): void;\n  /** Called by the client to update the credentials it is using. */\n  abstract updateCredentials(credentials?: string): void;\n}\n"
  },
  {
    "path": "src/core/action-creators.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport * as Actions from './action-types';\nimport type { SyncInfo, State, LogEntry } from '../types';\nimport type { Operation } from 'rfc6902';\n\n/**\n * Generate a move to be dispatched to the game move reducer.\n *\n * @param {string} type - The move type.\n * @param {Array}  args - Additional arguments.\n * @param {string}  playerID - The ID of the player making this action.\n * @param {string}  credentials - (optional) The credentials for the player making this action.\n */\nexport const makeMove = (\n  type: string,\n  args?: any,\n  playerID?: string | null,\n  credentials?: string\n) => ({\n  type: Actions.MAKE_MOVE as typeof Actions.MAKE_MOVE,\n  payload: { type, args, playerID, credentials },\n});\n\n/**\n * Generate a game event to be dispatched to the flow reducer.\n *\n * @param {string} type - The event type.\n * @param {Array}  args - Additional arguments.\n * @param {string}  playerID - The ID of the player making this action.\n * @param {string}  credentials - (optional) The credentials for the player making this action.\n */\nexport const gameEvent = (\n  type: string,\n  args?: any,\n  playerID?: string | null,\n  credentials?: string\n) => ({\n  type: Actions.GAME_EVENT as typeof Actions.GAME_EVENT,\n  payload: { type, args, playerID, credentials },\n});\n\n/**\n * Generate an automatic game event that is a side-effect of a move.\n * @param {string} type - The event type.\n * @param {Array}  args - Additional arguments.\n * @param {string}  playerID - The ID of the player making this action.\n * @param {string}  credentials - (optional) The credentials for the player making this action.\n */\nexport const automaticGameEvent = (\n  type: string,\n  args: any,\n  playerID?: string | null,\n  credentials?: string\n) => ({\n  type: Actions.GAME_EVENT as typeof Actions.GAME_EVENT,\n  payload: { type, args, playerID, credentials },\n  automatic: true,\n});\n\nexport const sync = (info: SyncInfo) => ({\n  type: Actions.SYNC as typeof Actions.SYNC,\n  state: info.state,\n  log: info.log,\n  initialState: info.initialState,\n  clientOnly: true as const,\n});\n\n/**\n * Used to update the Redux store's state with patch in response to\n * an action coming from another player.\n * @param prevStateID previous stateID\n * @param stateID stateID after this patch\n * @param {Operation[]} patch - The patch to apply.\n * @param {LogEntry[]} deltalog - A log delta.\n */\nexport const patch = (\n  prevStateID: number,\n  stateID: number,\n  patch: Operation[],\n  deltalog: LogEntry[]\n) => ({\n  type: Actions.PATCH as typeof Actions.PATCH,\n  prevStateID,\n  stateID,\n  patch,\n  deltalog,\n  clientOnly: true as const,\n});\n\n/**\n * Used to update the Redux store's state in response to\n * an action coming from another player.\n * @param {object} state - The state to restore.\n * @param {Array} deltalog - A log delta.\n */\nexport const update = (state: State, deltalog: LogEntry[]) => ({\n  type: Actions.UPDATE as typeof Actions.UPDATE,\n  state,\n  deltalog,\n  clientOnly: true as const,\n});\n\n/**\n * Used to reset the game state.\n * @param {object} state - The initial state.\n */\nexport const reset = (state: State) => ({\n  type: Actions.RESET as typeof Actions.RESET,\n  state,\n  clientOnly: true as const,\n});\n\n/**\n * Used to undo the last move.\n * @param {string}  playerID - The ID of the player making this action.\n * @param {string}  credentials - (optional) The credentials for the player making this action.\n */\nexport const undo = (playerID?: string | null, credentials?: string) => ({\n  type: Actions.UNDO as typeof Actions.UNDO,\n  payload: { type: null, args: null, playerID, credentials },\n});\n\n/**\n * Used to redo the last undone move.\n * @param {string}  playerID - The ID of the player making this action.\n * @param {string}  credentials - (optional) The credentials for the player making this action.\n */\nexport const redo = (playerID?: string | null, credentials?: string) => ({\n  type: Actions.REDO as typeof Actions.REDO,\n  payload: { type: null, args: null, playerID, credentials },\n});\n\n/**\n * Allows plugins to define their own actions and intercept them.\n */\nexport const plugin = (\n  type: string,\n  args?: any,\n  playerID?: string | null,\n  credentials?: string\n) => ({\n  type: Actions.PLUGIN as typeof Actions.PLUGIN,\n  payload: { type, args, playerID, credentials },\n});\n\n/**\n * Private action used to strip transient metadata (e.g. errors) from the game\n * state.\n */\nexport const stripTransients = () => ({\n  type: Actions.STRIP_TRANSIENTS as typeof Actions.STRIP_TRANSIENTS,\n});\n"
  },
  {
    "path": "src/core/action-types.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nexport const MAKE_MOVE = 'MAKE_MOVE';\nexport const GAME_EVENT = 'GAME_EVENT';\nexport const REDO = 'REDO';\nexport const RESET = 'RESET';\nexport const SYNC = 'SYNC';\nexport const UNDO = 'UNDO';\nexport const UPDATE = 'UPDATE';\nexport const PATCH = 'PATCH';\nexport const PLUGIN = 'PLUGIN';\nexport const STRIP_TRANSIENTS = 'STRIP_TRANSIENTS';\n"
  },
  {
    "path": "src/core/backwards-compatibility.ts",
    "content": "type MoveLimitOptions = {\n  minMoves?: number;\n  maxMoves?: number;\n  moveLimit?: number;\n};\n\n/**\n * Adjust the given options to use the new minMoves/maxMoves if a legacy moveLimit was given\n * @param options The options object to apply backwards compatibility to\n * @param enforceMinMoves Use moveLimit to set both minMoves and maxMoves\n */\nexport function supportDeprecatedMoveLimit(\n  options: MoveLimitOptions,\n  enforceMinMoves = false\n) {\n  if (options.moveLimit) {\n    if (enforceMinMoves) {\n      options.minMoves = options.moveLimit;\n    }\n    options.maxMoves = options.moveLimit;\n    delete options.moveLimit;\n  }\n}\n"
  },
  {
    "path": "src/core/constants.ts",
    "content": "/**\n * Moves can return this when they want to indicate\n * that the combination of arguments is illegal and\n * the move ought to be discarded.\n */\nexport const INVALID_MOVE = 'INVALID_MOVE';\n"
  },
  {
    "path": "src/core/errors.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nexport enum UpdateErrorType {\n  // The action’s credentials were missing or invalid\n  UnauthorizedAction = 'update/unauthorized_action',\n  // The action’s matchID was not found\n  MatchNotFound = 'update/match_not_found',\n  // Could not apply Patch operation (rfc6902).\n  PatchFailed = 'update/patch_failed',\n}\n\nexport enum ActionErrorType {\n  // The action contained a stale state ID\n  StaleStateId = 'action/stale_state_id',\n  // The requested move is unknown or not currently available\n  UnavailableMove = 'action/unavailable_move',\n  // The move declared it was invalid (INVALID_MOVE constant)\n  InvalidMove = 'action/invalid_move',\n  // The player making the action is not currently active\n  InactivePlayer = 'action/inactive_player',\n  // The game has finished\n  GameOver = 'action/gameover',\n  // The requested action is disabled (e.g. undo/redo, events)\n  ActionDisabled = 'action/action_disabled',\n  // The requested action is not currently possible\n  ActionInvalid = 'action/action_invalid',\n  // The requested action was declared invalid by a plugin\n  PluginActionInvalid = 'action/plugin_invalid',\n}\n"
  },
  {
    "path": "src/core/flow.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { makeMove, gameEvent } from './action-creators';\nimport { Client } from '../client/client';\nimport { Flow } from './flow';\nimport { TurnOrder } from './turn-order';\nimport { error } from '../core/logger';\nimport type { Ctx, State, Game, PlayerID, MoveFn } from '../types';\n\njest.mock('../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\nafterEach(jest.clearAllMocks);\n\ndescribe('phases', () => {\n  test('invalid phase name', () => {\n    const flow = Flow({\n      phases: { '': {} },\n    });\n    flow.init({ ctx: flow.ctx(2) } as State);\n    expect(error).toHaveBeenCalledWith('cannot specify phase with empty name');\n  });\n\n  test('onBegin / onEnd', () => {\n    const flow = Flow({\n      phases: {\n        A: {\n          start: true,\n          onBegin: ({ G }) => ({ ...G, setupA: true }),\n          onEnd: ({ G }) => ({ ...G, cleanupA: true }),\n          next: 'B',\n        },\n        B: {\n          onBegin: ({ G }) => ({ ...G, setupB: true }),\n          onEnd: ({ G }) => ({ ...G, cleanupB: true }),\n          next: 'A',\n        },\n      },\n\n      turn: {\n        order: {\n          first: ({ G }) => {\n            if (G.setupB && !G.cleanupB) return 1;\n            return 0;\n          },\n          next: ({ ctx }) => (ctx.playOrderPos + 1) % ctx.playOrder.length,\n        },\n      },\n    });\n\n    let state = { G: {}, ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n    expect(state.G).toMatchObject({ setupA: true });\n    expect(state.ctx.currentPlayer).toBe('0');\n\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.G).toMatchObject({\n      setupA: true,\n      cleanupA: true,\n      setupB: true,\n    });\n    expect(state.ctx.currentPlayer).toBe('1');\n\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.G).toMatchObject({\n      setupA: true,\n      cleanupA: true,\n      setupB: true,\n      cleanupB: true,\n    });\n    expect(state.ctx.currentPlayer).toBe('0');\n  });\n\n  test('endIf', () => {\n    const flow = Flow({\n      phases: { A: { start: true, endIf: () => true, next: 'B' }, B: {} },\n    });\n\n    const state = { ctx: flow.ctx(2) } as State;\n\n    {\n      const t = flow.processEvent(state, gameEvent('endPhase'));\n      expect(t.ctx.phase).toBe('B');\n    }\n\n    {\n      const t = flow.processEvent(state, gameEvent('endTurn'));\n      expect(t.ctx.phase).toBe('B');\n    }\n\n    {\n      const t = flow.processMove(state, makeMove('').payload);\n      expect(t.ctx.phase).toBe('B');\n    }\n  });\n\n  describe('onEnd', () => {\n    let client: ReturnType<typeof Client>;\n\n    beforeAll(() => {\n      const game: Game = {\n        endIf: () => true,\n        onEnd: ({ G }) => {\n          G.onEnd = true;\n        },\n      };\n      client = Client({ game });\n    });\n\n    test('works', () => {\n      expect(client.getState().G).toEqual({\n        onEnd: true,\n      });\n    });\n  });\n\n  test('end phase on move', () => {\n    let endPhaseACount = 0;\n    let endPhaseBCount = 0;\n\n    const flow = Flow({\n      phases: {\n        A: {\n          start: true,\n          endIf: () => true,\n          onEnd: () => ++endPhaseACount,\n          next: 'B',\n        },\n        B: {\n          endIf: () => false,\n          onEnd: () => ++endPhaseBCount,\n        },\n      },\n    });\n    let state = { G: {}, ctx: flow.ctx(2) } as State;\n\n    expect(state.ctx.phase).toBe('A');\n    state = flow.processMove(state, makeMove('').payload);\n    expect(state.ctx.phase).toBe('B');\n\n    expect(endPhaseACount).toEqual(1);\n    expect(endPhaseBCount).toEqual(0);\n  });\n\n  test('endPhase returns to null phase', () => {\n    const flow = Flow({\n      phases: { A: { start: true }, B: {}, C: {} },\n    });\n    let state = { G: {}, ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n\n    expect(state.ctx.phase).toBe('A');\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.ctx.phase).toBe(null);\n  });\n\n  test('increment playOrderPos on phase end', () => {\n    const flow = Flow({\n      phases: { A: { start: true, next: 'B' }, B: { next: 'A' } },\n    });\n    let state = { G: {}, ctx: flow.ctx(3) } as State;\n    state = flow.init(state);\n\n    expect(state.ctx.playOrderPos).toBe(0);\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.playOrderPos).toBe(1);\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.ctx.playOrderPos).toBe(2);\n  });\n\n  describe('setPhase', () => {\n    let flow: ReturnType<typeof Flow>;\n    beforeEach(() => {\n      flow = Flow({\n        phases: { A: { start: true }, B: {} },\n      });\n    });\n\n    test('basic', () => {\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.phase).toBe('A');\n      state = flow.processEvent(state, gameEvent('setPhase', 'B'));\n      expect(state.ctx.phase).toBe('B');\n    });\n\n    test('invalid arg', () => {\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.phase).toBe('A');\n      state = flow.processEvent(state, gameEvent('setPhase', 'C'));\n      expect(error).toBeCalledWith('invalid phase: C');\n      expect(state.ctx.phase).toBe(null);\n    });\n  });\n});\n\ndescribe('turn', () => {\n  test('onEnd', () => {\n    const onEnd = jest.fn(({ G }) => G);\n    const flow = Flow({\n      turn: { onEnd },\n    });\n    const state = { ctx: flow.ctx(2) } as State;\n    flow.init(state);\n\n    expect(onEnd).not.toHaveBeenCalled();\n    flow.processEvent(state, gameEvent('endTurn'));\n    expect(onEnd).toHaveBeenCalled();\n  });\n\n  describe('onMove', () => {\n    const onMove = () => ({ A: true });\n\n    test('top level callback', () => {\n      const flow = Flow({ turn: { onMove } });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.processMove(state, makeMove('').payload);\n      expect(state.G).toEqual({ A: true });\n    });\n\n    test('phase specific callback', () => {\n      const flow = Flow({\n        turn: { onMove },\n        phases: { B: { turn: { onMove: () => ({ B: true }) } } },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.processMove(state, makeMove('').payload);\n      expect(state.G).toEqual({ A: true });\n      state = flow.processEvent(state, gameEvent('setPhase', 'B'));\n      state = flow.processMove(state, makeMove('').payload);\n      expect(state.G).toEqual({ B: true });\n    });\n\n    test('ctx with playerID', () => {\n      const playerID = 'playerID';\n      const flow = Flow({\n        turn: { onMove: ({ playerID }) => ({ playerID }) },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.processMove(\n        state,\n        makeMove('', undefined, 'playerID').payload\n      );\n      expect(state.G.playerID).toEqual(playerID);\n    });\n  });\n\n  describe('minMoves', () => {\n    describe('without phases', () => {\n      const flow = Flow({\n        turn: {\n          minMoves: 2,\n        },\n      });\n\n      test('player cannot endTurn if not enough moves were made', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n      });\n\n      test('player can endTurn after enough moves were made', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n    });\n\n    describe('with phases', () => {\n      const flow = Flow({\n        turn: { minMoves: 2 },\n        phases: {\n          B: {\n            turn: {\n              minMoves: 1,\n            },\n          },\n        },\n      });\n\n      test('player cannot endTurn if not enough moves were made in default phase', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n      });\n\n      test('player can endTurn after enough moves were made in default phase', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n\n      test('player cannot endTurn if no move was made in explicit phase', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n        state = flow.processMove(state, makeMove('move', null, '1').payload);\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n\n        state = flow.processEvent(state, gameEvent('setPhase', 'B'));\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(3);\n        expect(state.ctx.currentPlayer).toBe('0');\n      });\n\n      test('player can endTurn after having made a move, fewer moves needed in explicit phase', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n        state = flow.processMove(state, makeMove('move', null, '1').payload);\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n\n        state = flow.processEvent(state, gameEvent('setPhase', 'B'));\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(4);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n    });\n  });\n\n  describe('maxMoves', () => {\n    describe('without phases', () => {\n      const flow = Flow({\n        turn: {\n          maxMoves: 2,\n        },\n      });\n\n      test('manual endTurn works, even if not enough moves were made', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n\n      test('turn automatically ends after making enough moves', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n    });\n\n    describe('with phases', () => {\n      const flow = Flow({\n        turn: { maxMoves: 2 },\n        phases: {\n          B: {\n            turn: { maxMoves: 1 },\n          },\n        },\n      });\n\n      test('manual endTurn works in all phases, even if fewer than maxMoves have been made', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n\n        state = flow.processEvent(state, gameEvent('setPhase', 'B'));\n\n        expect(state.ctx.turn).toBe(3);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processEvent(state, gameEvent('endTurn'));\n\n        expect(state.ctx.turn).toBe(4);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n\n      test('automatic endTurn triggers after fewer moves in different phase', () => {\n        let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n        expect(state.ctx.turn).toBe(1);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n\n        expect(state.ctx.turn).toBe(2);\n        expect(state.ctx.currentPlayer).toBe('1');\n\n        state = flow.processEvent(state, gameEvent('setPhase', 'B'));\n\n        expect(state.ctx.turn).toBe(3);\n        expect(state.ctx.currentPlayer).toBe('0');\n\n        state = flow.processMove(state, makeMove('move', null, '0').payload);\n\n        expect(state.ctx.turn).toBe(4);\n        expect(state.ctx.currentPlayer).toBe('1');\n      });\n    });\n\n    test('with noLimit moves', () => {\n      const flow = Flow({\n        turn: {\n          maxMoves: 2,\n        },\n        moves: {\n          A: () => {},\n          B: {\n            move: () => {},\n            noLimit: true,\n          },\n        },\n      });\n      let state = flow.init({ ctx: flow.ctx(2) } as State);\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.numMoves).toBe(0);\n      state = flow.processMove(state, makeMove('A', null, '0').payload);\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.numMoves).toBe(1);\n      state = flow.processMove(state, makeMove('B', null, '0').payload);\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.numMoves).toBe(1);\n      state = flow.processMove(state, makeMove('A', null, '0').payload);\n      expect(state.ctx.turn).toBe(2);\n      expect(state.ctx.numMoves).toBe(0);\n    });\n  });\n\n  describe('endIf', () => {\n    test('global', () => {\n      const game: Game = {\n        moves: {\n          A: () => ({ endTurn: true }),\n          B: ({ G }) => G,\n        },\n        turn: { endIf: ({ G }) => G.endTurn },\n      };\n      const client = Client({ game });\n\n      expect(client.getState().ctx.currentPlayer).toBe('0');\n      client.moves.B();\n      expect(client.getState().ctx.currentPlayer).toBe('0');\n      client.moves.A();\n      expect(client.getState().ctx.currentPlayer).toBe('1');\n    });\n\n    test('phase specific', () => {\n      const game: Game = {\n        moves: {\n          A: () => ({ endTurn: true }),\n          B: ({ G }) => G,\n        },\n        phases: {\n          A: { start: true, turn: { endIf: ({ G }) => G.endTurn } },\n        },\n      };\n      const client = Client({ game });\n\n      expect(client.getState().ctx.currentPlayer).toBe('0');\n      client.moves.B();\n      expect(client.getState().ctx.currentPlayer).toBe('0');\n      client.moves.A();\n      expect(client.getState().ctx.currentPlayer).toBe('1');\n    });\n\n    test('return value', () => {\n      const game: Game = {\n        moves: {\n          A: ({ G }) => G,\n        },\n        turn: { endIf: () => ({ next: '2' }) },\n      };\n      const client = Client({ game, numPlayers: 3 });\n\n      expect(client.getState().ctx.currentPlayer).toBe('0');\n      client.moves.A();\n      expect(client.getState().ctx.currentPlayer).toBe('2');\n    });\n  });\n\n  test('endTurn is not called twice in one move', () => {\n    const flow = Flow({\n      turn: { endIf: () => true },\n      phases: {\n        A: { start: true, endIf: ({ G }) => G.endPhase, next: 'B' },\n        B: {},\n      },\n    });\n\n    let state = flow.init({ G: {}, ctx: flow.ctx(2) } as State);\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.turn).toBe(1);\n\n    state = flow.processMove(state, makeMove('').payload);\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.turn).toBe(2);\n\n    state.G = { endPhase: true };\n\n    state = flow.processMove(state, makeMove('').payload);\n\n    expect(state.ctx.phase).toBe('B');\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.turn).toBe(3);\n  });\n});\n\ndescribe('stages', () => {\n  let client: ReturnType<typeof Client>;\n\n  beforeAll(() => {\n    const A = () => {};\n    const B = () => {};\n\n    const game: Game = {\n      moves: { A },\n      turn: {\n        stages: {\n          B: { moves: { B } },\n          C: {},\n        },\n      },\n    };\n\n    client = Client({ game });\n  });\n\n  beforeEach(() => {\n    jest.resetAllMocks();\n  });\n\n  describe('no stage', () => {\n    test('A is allowed', () => {\n      client.moves.A();\n      expect(error).not.toBeCalled();\n    });\n\n    test('B is not allowed', () => {\n      client.moves.B();\n      expect(error).toBeCalledWith('disallowed move: B');\n    });\n  });\n\n  describe('stage B', () => {\n    beforeAll(() => {\n      client.events.setStage('B');\n    });\n\n    test('A is not allowed', () => {\n      client.moves.A();\n      expect(error).toBeCalledWith('disallowed move: A');\n    });\n\n    test('B is allowed', () => {\n      client.moves.B();\n      expect(error).not.toBeCalled();\n    });\n  });\n\n  describe('stage C', () => {\n    beforeAll(() => {\n      client.events.setStage('C');\n    });\n\n    test('A is allowed', () => {\n      client.moves.A();\n      expect(error).not.toBeCalled();\n    });\n\n    test('B is not allowed', () => {\n      client.moves.B();\n      expect(error).toBeCalledWith('disallowed move: B');\n    });\n  });\n\n  test('stage updates can be reacted to in turn.endIf', () => {\n    const client = Client({\n      game: {\n        turn: {\n          activePlayers: {\n            all: 'A',\n          },\n          stages: {\n            A: {\n              moves: {\n                leaveStage: ({ events }) => void events.endStage(),\n              },\n            },\n          },\n          endIf: ({ ctx }) => ctx.activePlayers === null,\n        },\n      },\n    });\n\n    let state = client.getState();\n    expect(state.ctx.turn).toBe(1);\n    expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A' });\n\n    client.updatePlayerID('0');\n\n    client.moves.leaveStage();\n    state = client.getState();\n    expect(state.ctx.turn).toBe(1);\n    expect(state.ctx.activePlayers).toEqual({ '1': 'A' });\n\n    client.updatePlayerID('1');\n    client.moves.leaveStage();\n    state = client.getState();\n    expect(state.ctx.turn).toBe(2);\n    expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A' });\n  });\n\n  test('stage changes due to move limits are seen by turn.endIf', () => {\n    const client = Client({\n      game: {\n        turn: {\n          activePlayers: {\n            currentPlayer: 'A',\n            maxMoves: 1,\n          },\n          endIf: ({ ctx }) => ctx.activePlayers === null,\n          stages: {\n            A: {\n              moves: {\n                A: () => ({ moved: true }),\n              },\n            },\n          },\n        },\n      },\n    });\n\n    let state = client.getState();\n    expect(state.ctx.activePlayers).toEqual({ '0': 'A' });\n    client.moves.A();\n    state = client.getState();\n    expect(state.ctx.activePlayers).toEqual({ '1': 'A' });\n  });\n});\n\ndescribe('stage events', () => {\n  describe('setStage', () => {\n    test('basic', () => {\n      const flow = Flow({});\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toBeNull();\n      state = flow.processEvent(state, gameEvent('setStage', 'A'));\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A' });\n    });\n\n    test('object syntax', () => {\n      const flow = Flow({});\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toBeNull();\n      state = flow.processEvent(state, gameEvent('setStage', { stage: 'A' }));\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A' });\n    });\n\n    test('with multiple active players', () => {\n      const flow = Flow({\n        turn: {\n          activePlayers: { all: 'A', minMoves: 2, maxMoves: 5 },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(3) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A', '2': 'A' });\n      state = flow.processEvent(\n        state,\n        gameEvent('setStage', { stage: 'B', minMoves: 1 })\n      );\n      expect(state.ctx.activePlayers).toEqual({ '0': 'B', '1': 'A', '2': 'A' });\n\n      state = flow.processEvent(\n        state,\n        gameEvent('setStage', { stage: 'B', maxMoves: 1 }, '1')\n      );\n      expect(state.ctx.activePlayers).toEqual({ '0': 'B', '1': 'B', '2': 'A' });\n    });\n\n    test('resets move count', () => {\n      const flow = Flow({\n        moves: { A: () => {} },\n        turn: {\n          activePlayers: { currentPlayer: 'A' },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx._activePlayersNumMoves).toMatchObject({ '0': 0 });\n      state = flow.processMove(state, makeMove('A', null, '0').payload);\n      expect(state.ctx._activePlayersNumMoves).toMatchObject({ '0': 1 });\n      state = flow.processEvent(state, gameEvent('setStage', 'B'));\n      expect(state.ctx._activePlayersNumMoves).toMatchObject({ '0': 0 });\n    });\n\n    test('with min moves', () => {\n      const flow = Flow({});\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx._activePlayersMinMoves).toBeNull();\n      expect(state.ctx._activePlayersMaxMoves).toBeNull();\n      state = flow.processEvent(\n        state,\n        gameEvent('setStage', { stage: 'A', minMoves: 1 })\n      );\n      expect(state.ctx._activePlayersMinMoves).toEqual({ '0': 1 });\n      expect(state.ctx._activePlayersMaxMoves).toBeNull();\n    });\n\n    test('with max moves', () => {\n      const flow = Flow({});\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx._activePlayersMinMoves).toBeNull();\n      expect(state.ctx._activePlayersMaxMoves).toBeNull();\n      state = flow.processEvent(\n        state,\n        gameEvent('setStage', { stage: 'A', maxMoves: 1 })\n      );\n      expect(state.ctx._activePlayersMinMoves).toBeNull();\n      expect(state.ctx._activePlayersMaxMoves).toEqual({ '0': 1 });\n    });\n\n    test('empty argument ends stage', () => {\n      const flow = Flow({ turn: { activePlayers: { currentPlayer: 'A' } } });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A' });\n      state = flow.processEvent(state, gameEvent('setStage', {}));\n      expect(state.ctx.activePlayers).toBeNull();\n    });\n\n    describe('disallowed in hooks', () => {\n      const setStage: MoveFn = ({ events }) => {\n        events.setStage('A');\n      };\n\n      test('phase.onBegin', () => {\n        const game: Game = {\n          phases: {\n            A: {\n              start: true,\n              onBegin: setStage,\n            },\n          },\n        };\n        Client({ game });\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in a phase’s `onBegin` hook/);\n      });\n\n      test('phase.onEnd', () => {\n        const game: Game = {\n          phases: {\n            A: {\n              start: true,\n              onEnd: setStage,\n            },\n          },\n        };\n        const client = Client({ game });\n        expect(error).not.toHaveBeenCalled();\n        client.events.endPhase();\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `onEnd` hooks/);\n      });\n\n      test('turn.onBegin', () => {\n        const game: Game = {\n          turn: {\n            onBegin: setStage,\n          },\n        };\n        Client({ game });\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `turn.onBegin`/);\n      });\n\n      test('turn.onEnd', () => {\n        const game: Game = {\n          turn: {\n            onEnd: setStage,\n          },\n        };\n        const client = Client({ game });\n        expect(error).not.toHaveBeenCalled();\n        client.events.endTurn();\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `onEnd` hooks/);\n      });\n    });\n  });\n\n  describe('endStage', () => {\n    test('basic', () => {\n      const flow = Flow({\n        turn: {\n          activePlayers: { currentPlayer: 'A' },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A' });\n      state = flow.processEvent(state, gameEvent('endStage'));\n      expect(state.ctx.activePlayers).toBeNull();\n    });\n\n    test('with multiple active players', () => {\n      const flow = Flow({\n        turn: {\n          activePlayers: { all: 'A', maxMoves: 5 },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(3) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A', '2': 'A' });\n      state = flow.processEvent(state, gameEvent('endStage'));\n      expect(state.ctx.activePlayers).toEqual({ '1': 'A', '2': 'A' });\n    });\n\n    test('with min moves', () => {\n      const flow = Flow({\n        turn: {\n          activePlayers: { all: 'A', minMoves: 2 },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A' });\n\n      state = flow.processEvent(state, gameEvent('endStage'));\n\n      // player 0 is not allowed to end the stage, they haven't made any move yet\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A' });\n\n      state = flow.processMove(state, makeMove('move', null, '0').payload);\n      state = flow.processEvent(state, gameEvent('endStage'));\n\n      // player 0 is still not allowed to end the stage, they haven't made the minimum number of moves\n      expect(state.ctx.activePlayers).toEqual({ '0': 'A', '1': 'A' });\n\n      state = flow.processMove(state, makeMove('move', null, '0').payload);\n      state = flow.processEvent(state, gameEvent('endStage'));\n\n      // having made 2 moves, player 0 was allowed to end the stage\n      expect(state.ctx.activePlayers).toEqual({ '1': 'A' });\n    });\n\n    test('maintains move count', () => {\n      const flow = Flow({\n        moves: { A: () => {} },\n        turn: {\n          activePlayers: { currentPlayer: 'A' },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx._activePlayersNumMoves).toMatchObject({ '0': 0 });\n      state = flow.processMove(state, makeMove('A', null, '0').payload);\n      expect(state.ctx._activePlayersNumMoves).toMatchObject({ '0': 1 });\n      state = flow.processEvent(state, gameEvent('endStage'));\n      expect(state.ctx._activePlayersNumMoves).toMatchObject({ '0': 1 });\n    });\n\n    test('sets to next', () => {\n      const flow = Flow({\n        turn: {\n          activePlayers: { currentPlayer: 'A1', others: 'B1' },\n          stages: {\n            A1: { next: 'A2' },\n            B1: { next: 'B2' },\n          },\n        },\n      });\n      let state = { G: {}, ctx: flow.ctx(2) } as State;\n      state = flow.init(state);\n\n      expect(state.ctx.activePlayers).toMatchObject({\n        '0': 'A1',\n        '1': 'B1',\n      });\n\n      state = flow.processEvent(state, gameEvent('endStage', null, '0'));\n\n      expect(state.ctx.activePlayers).toMatchObject({\n        '0': 'A2',\n        '1': 'B1',\n      });\n\n      state = flow.processEvent(state, gameEvent('endStage', null, '1'));\n\n      expect(state.ctx.activePlayers).toMatchObject({\n        '0': 'A2',\n        '1': 'B2',\n      });\n    });\n\n    describe('disallowed in hooks', () => {\n      const endStage: MoveFn = ({ events }) => {\n        events.endStage();\n      };\n\n      test('phase.onBegin', () => {\n        const game: Game = {\n          phases: {\n            A: {\n              start: true,\n              onBegin: endStage,\n            },\n          },\n        };\n        Client({ game });\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in a phase’s `onBegin` hook/);\n      });\n\n      test('phase.onEnd', () => {\n        const game: Game = {\n          phases: {\n            A: {\n              start: true,\n              onEnd: endStage,\n            },\n          },\n        };\n        const client = Client({ game });\n        expect(error).not.toHaveBeenCalled();\n        client.events.endPhase();\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `onEnd` hooks/);\n      });\n\n      test('turn.onBegin', () => {\n        const game: Game = {\n          turn: {\n            onBegin: endStage,\n          },\n        };\n        Client({ game });\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `turn.onBegin`/);\n      });\n\n      test('turn.onEnd', () => {\n        const game: Game = {\n          turn: {\n            onEnd: endStage,\n          },\n        };\n        const client = Client({ game });\n        expect(error).not.toHaveBeenCalled();\n        client.events.endTurn();\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `onEnd` hooks/);\n      });\n    });\n  });\n\n  describe('setActivePlayers', () => {\n    test('basic', () => {\n      const client = Client({\n        numPlayers: 3,\n        game: {\n          turn: {\n            onBegin: ({ events }) => {\n              events.setActivePlayers({ currentPlayer: 'A' });\n            },\n          },\n          moves: {\n            updateActivePlayers: ({ events }) => {\n              events.setActivePlayers({ others: 'B' });\n            },\n          },\n        },\n      });\n      expect(client.getState().ctx.activePlayers).toEqual({ '0': 'A' });\n      client.moves.updateActivePlayers();\n      expect(client.getState().ctx.activePlayers).toEqual({\n        '1': 'B',\n        '2': 'B',\n      });\n    });\n\n    describe('in hooks', () => {\n      const setActivePlayers: MoveFn = ({ events }) => {\n        events.setActivePlayers({ currentPlayer: 'A' });\n      };\n\n      test('disallowed in phase.onBegin', () => {\n        const game: Game = {\n          phases: {\n            A: {\n              start: true,\n              onBegin: setActivePlayers,\n            },\n          },\n        };\n        Client({ game });\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in a phase’s `onBegin` hook/);\n      });\n\n      test('disallowed in phase.onEnd', () => {\n        const game: Game = {\n          phases: {\n            A: {\n              start: true,\n              onEnd: setActivePlayers,\n            },\n          },\n        };\n        const client = Client({ game });\n        expect(error).not.toHaveBeenCalled();\n        client.events.endPhase();\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `onEnd` hooks/);\n      });\n\n      test('allowed in turn.onBegin', () => {\n        const client = Client({\n          game: {\n            turn: { onBegin: setActivePlayers },\n          },\n        });\n        expect(client.getState().ctx.activePlayers).toEqual({ '0': 'A' });\n        expect(error).not.toHaveBeenCalled();\n      });\n\n      test('disallowed in turn.onEnd', () => {\n        const game: Game = {\n          turn: {\n            onEnd: setActivePlayers,\n          },\n        };\n        const client = Client({ game });\n        expect(error).not.toHaveBeenCalled();\n        client.events.endTurn();\n        expect(error).toHaveBeenCalled();\n        const errorMessage = (error as jest.Mock).mock.calls[0][0];\n        expect(errorMessage).toMatch(/events plugin declared action invalid/);\n        expect(errorMessage).toMatch(/disallowed in `onEnd` hooks/);\n      });\n    });\n  });\n});\n\ntest('init', () => {\n  let flow = Flow({\n    phases: { A: { start: true, onEnd: () => ({ done: true }) } },\n  });\n\n  const orig = flow.ctx(2);\n  let state = { G: {}, ctx: orig } as State;\n  state = flow.processEvent(state, gameEvent('init'));\n  expect(state).toEqual({ G: {}, ctx: orig });\n\n  flow = Flow({\n    phases: { A: { start: true, onBegin: () => ({ done: true }) } },\n  });\n\n  state = { ctx: orig } as State;\n  state = flow.init(state);\n  expect(state.G).toMatchObject({ done: true });\n});\n\ntest('next', () => {\n  const flow = Flow({\n    phases: {\n      A: { start: true, next: () => 'C' },\n      B: {},\n      C: {},\n    },\n  });\n\n  let state = { ctx: flow.ctx(3) } as State;\n  state = flow.processEvent(state, gameEvent('endPhase'));\n\n  expect(state.ctx.phase).toEqual('C');\n});\n\ndescribe('endIf', () => {\n  test('basic', () => {\n    const flow = Flow({ endIf: ({ G }) => G.win });\n\n    let state = flow.init({ G: {}, ctx: flow.ctx(2) } as State);\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.gameover).toBe(undefined);\n\n    state.G = { win: 'A' };\n\n    {\n      const t = flow.processEvent(state, gameEvent('endTurn'));\n      expect(t.ctx.gameover).toBe('A');\n    }\n\n    {\n      const t = flow.processMove(state, makeMove('move').payload);\n      expect(t.ctx.gameover).toBe('A');\n    }\n  });\n\n  test('phase automatically ends', () => {\n    const game: Game = {\n      phases: {\n        A: {\n          start: true,\n          moves: {\n            A: () => ({ win: 'A' }),\n            B: ({ G }) => G,\n          },\n        },\n      },\n      endIf: ({ G }) => G.win,\n    };\n    const client = Client({ game });\n\n    expect(client.getState().ctx.currentPlayer).toBe('0');\n    client.moves.B();\n    expect(client.getState().ctx.gameover).toBe(undefined);\n\n    expect(client.getState().ctx.currentPlayer).toBe('0');\n    client.moves.A();\n    expect(client.getState().ctx.gameover).toBe('A');\n    expect(\n      client.getState().deltalog[client.getState().deltalog.length - 1].action\n        .payload.type\n    ).toBe('endPhase');\n  });\n\n  test('during game initialization with phases', () => {\n    const flow = Flow({\n      phases: {\n        A: {\n          start: true,\n        },\n      },\n      endIf: () => 'gameover',\n    });\n\n    const state = flow.init({ G: {}, ctx: flow.ctx(2) } as State);\n    expect(state.ctx.gameover).toBe('gameover');\n  });\n});\n\ntest('isPlayerActive', () => {\n  const playerID = '0';\n\n  const flow = Flow({});\n  expect(flow.isPlayerActive({}, {} as Ctx, playerID)).toBe(false);\n  expect(\n    flow.isPlayerActive(\n      {},\n      { currentPlayer: '0', activePlayers: { '1': '' } } as unknown as Ctx,\n      playerID\n    )\n  ).toBe(false);\n  expect(flow.isPlayerActive({}, { currentPlayer: '0' } as Ctx, playerID)).toBe(\n    true\n  );\n});\n\ndescribe('endGame', () => {\n  let client: ReturnType<typeof Client>;\n  beforeEach(() => {\n    const game: Game = {\n      events: { endGame: true },\n    };\n    client = Client({ game });\n  });\n\n  test('without arguments', () => {\n    client.events.endGame();\n    expect(client.getState().ctx.gameover).toBe(true);\n  });\n\n  test('with arguments', () => {\n    client.events.endGame(42);\n    expect(client.getState().ctx.gameover).toBe(42);\n  });\n});\n\ndescribe('endTurn args', () => {\n  const flow = Flow({\n    phases: { A: { start: true, next: 'B' }, B: {}, C: {} },\n  });\n\n  const state = { ctx: flow.ctx(3) } as State;\n\n  beforeEach(() => {\n    jest.resetAllMocks();\n  });\n\n  test('no args', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('endPhase'));\n    t = flow.processEvent(t, gameEvent('endTurn'));\n    expect(t.ctx.playOrderPos).toBe(1);\n    expect(t.ctx.currentPlayer).toBe('1');\n    expect(t.ctx.phase).toBe('B');\n  });\n\n  test('invalid arg to endTurn', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('endTurn', '2'));\n    expect(error).toBeCalledWith(`invalid argument to endTurn: 2`);\n    expect(t.ctx.currentPlayer).toBe('0');\n  });\n\n  test('valid args', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('endTurn', { next: '2' }));\n    expect(t.ctx.playOrderPos).toBe(2);\n    expect(t.ctx.currentPlayer).toBe('2');\n  });\n});\n\ndescribe('pass args', () => {\n  const flow = Flow({\n    phases: { A: { start: true, next: 'B' }, B: {}, C: {} },\n  });\n\n  const state = { ctx: flow.ctx(3) } as State;\n\n  beforeEach(() => {\n    jest.resetAllMocks();\n  });\n\n  test('no args', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('pass'));\n    expect(t.ctx.turn).toBe(1);\n    expect(t.ctx.playOrderPos).toBe(1);\n    expect(t.ctx.currentPlayer).toBe('1');\n  });\n\n  test('invalid arg to pass', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('pass', '2'));\n    expect(error).toBeCalledWith(`invalid argument to endTurn: 2`);\n    expect(t.ctx.currentPlayer).toBe('0');\n  });\n\n  test('valid args', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('pass', { remove: true }));\n    expect(t.ctx.turn).toBe(1);\n    expect(t.ctx.playOrderPos).toBe(0);\n    expect(t.ctx.currentPlayer).toBe('1');\n  });\n\n  test('removing all players ends phase', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('pass', { remove: true }));\n    t = flow.processEvent(t, gameEvent('pass', { remove: true }));\n    t = flow.processEvent(t, gameEvent('pass', { remove: true }));\n    expect(t.ctx.playOrderPos).toBe(0);\n    expect(t.ctx.currentPlayer).toBe('0');\n    expect(t.ctx.phase).toBe('B');\n  });\n\n  test('playOrderPos does not go out of bounds when passing at the end of the list', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('pass'));\n    t = flow.processEvent(t, gameEvent('pass'));\n    t = flow.processEvent(t, gameEvent('pass', { remove: true }));\n    expect(t.ctx.currentPlayer).toBe('0');\n  });\n\n  test('removing a player deeper into play order returns correct updated playOrder', () => {\n    let t = state;\n    t = flow.processEvent(t, gameEvent('pass'));\n    t = flow.processEvent(t, gameEvent('pass', { remove: true }));\n    expect(t.ctx.playOrderPos).toBe(1);\n    expect(t.ctx.currentPlayer).toBe('2');\n  });\n});\n\ntest('undoable moves', () => {\n  const game: Game = {\n    moves: {\n      A: {\n        move: () => ({ A: true }),\n        undoable: ({ ctx }) => {\n          return ctx.phase == 'A';\n        },\n      },\n      B: {\n        move: () => ({ B: true }),\n        undoable: false,\n      },\n      C: () => ({ C: true }),\n    },\n\n    phases: {\n      A: { start: true },\n      B: {},\n    },\n  };\n\n  const client = Client({ game });\n\n  client.moves.A();\n  expect(client.getState().G).toEqual({ A: true });\n  client.undo();\n  expect(client.getState().G).toEqual({});\n  client.moves.B();\n  expect(client.getState().G).toEqual({ B: true });\n  client.undo();\n  expect(client.getState().G).toEqual({ B: true });\n  client.moves.C();\n  expect(client.getState().G).toEqual({ C: true });\n  client.undo();\n  expect(client.getState().G).toEqual({ B: true });\n\n  client.reset();\n  client.events.setPhase('B');\n  expect(client.getState().ctx.phase).toBe('B');\n\n  client.moves.A();\n  expect(client.getState().G).toEqual({ A: true });\n  client.undo();\n  expect(client.getState().G).toEqual({ A: true });\n  client.moves.B();\n  expect(client.getState().G).toEqual({ B: true });\n  client.undo();\n  expect(client.getState().G).toEqual({ B: true });\n  client.moves.C();\n  expect(client.getState().G).toEqual({ C: true });\n  client.undo();\n  expect(client.getState().G).toEqual({ B: true });\n});\n\ndescribe('moveMap', () => {\n  const game: Game = {\n    moves: { A: () => {} },\n\n    turn: {\n      stages: {\n        SA: {\n          moves: {\n            A: () => {},\n          },\n        },\n      },\n    },\n\n    phases: {\n      PA: {\n        moves: {\n          A: () => {},\n        },\n\n        turn: {\n          stages: {\n            SB: {\n              moves: {\n                A: () => {},\n              },\n            },\n          },\n        },\n      },\n    },\n  };\n\n  test('basic', () => {\n    const { moveMap } = Flow(game);\n    expect(Object.keys(moveMap)).toEqual(['PA.A', 'PA.SB.A', '.SA.A']);\n  });\n});\n\ndescribe('infinite loops', () => {\n  test('infinite loop of self-ending phases via endIf', () => {\n    const endIf = () => true;\n    const game: Game = {\n      phases: {\n        A: { endIf, next: 'B', start: true },\n        B: { endIf, next: 'A' },\n      },\n    };\n    const client = Client({ game });\n    expect(client.getState().ctx.phase).toBe(null);\n  });\n\n  test('infinite endPhase loop from phase.onBegin', () => {\n    const onBegin = ({ events }) => void events.endPhase();\n    const game: Game = {\n      phases: {\n        A: {\n          onBegin,\n          next: 'B',\n          start: true,\n          moves: {\n            a: ({ events }) => void events.endPhase(),\n          },\n        },\n        B: { onBegin, next: 'C' },\n        C: { onBegin, next: 'A' },\n      },\n    };\n\n    // The onBegin fails to end the phase during initialisation.\n    const client = Client({ game, numPlayers: 3 });\n    let state = client.getState();\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.turn).toBe(1);\n    expect(error).toHaveBeenCalled();\n    {\n      const errorMessage = (error as jest.Mock).mock.calls[0][0];\n      expect(errorMessage).toMatch(/events plugin declared action invalid/);\n      expect(errorMessage).toMatch(/Maximum number of turn endings exceeded/);\n    }\n    jest.clearAllMocks();\n\n    // Moves also fail because of the infinite loop (the game is stuck).\n    client.moves.a();\n    state = client.getState();\n    expect(error).toHaveBeenCalled();\n    {\n      const errorMessage = (error as jest.Mock).mock.calls[0][0];\n      expect(errorMessage).toMatch(/events plugin declared action invalid/);\n      expect(errorMessage).toMatch(/Maximum number of turn endings exceeded/);\n    }\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.turn).toBe(1);\n  });\n\n  test('double phase ending from client event and turn.onEnd', () => {\n    const game: Game = {\n      turn: {\n        onEnd: ({ events }) => void events.endPhase(),\n      },\n      phases: {\n        A: { next: 'B', start: true },\n        B: { next: 'C' },\n        C: { next: 'A' },\n      },\n    };\n    const client = Client({ game });\n\n    let state = client.getState();\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.turn).toBe(1);\n    client.events.endPhase();\n\n    state = client.getState();\n    expect(state.ctx.phase).toBe('B');\n    expect(state.ctx.turn).toBe(2);\n  });\n\n  test('infinite turn endings from turn.onBegin', () => {\n    const game: Game = {\n      moves: {\n        endTurn: ({ events }) => {\n          events.endTurn();\n        },\n      },\n      turn: {\n        onBegin: ({ events }) => void events.endTurn(),\n      },\n    };\n    const client = Client({ game });\n    const initialState = client.getState();\n    expect(client.getState().ctx.currentPlayer).toBe('0');\n\n    // Trigger infinite loop\n    client.moves.endTurn();\n\n    // Expect state to be unchanged and error to be logged.\n    expect(error).toHaveBeenCalled();\n    const errorMessage = (error as jest.Mock).mock.calls[0][0];\n    expect(errorMessage).toMatch(/events plugin declared action invalid/);\n    expect(errorMessage).toMatch(/Maximum number of turn endings exceeded/);\n    expect(client.getState().ctx.currentPlayer).toBe('0');\n    expect(client.getState()).toEqual({ ...initialState, deltalog: [] });\n  });\n\n  test('double turn ending from event and endIf', () => {\n    const game: Game = {\n      moves: {\n        endTurn: ({ events }) => {\n          events.endTurn();\n        },\n      },\n      turn: {\n        endIf: () => true,\n      },\n    };\n    const client = Client({ game });\n\n    // turn.endIf is ignored during game setup.\n    let state = client.getState();\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.turn).toBe(1);\n\n    // turn.endIf is ignored when the turn was just ended.\n    client.moves.endTurn();\n    state = client.getState();\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.turn).toBe(2);\n  });\n\n  test('endIf that triggers endIf', () => {\n    const game: Game = {\n      phases: {\n        A: {\n          endIf: ({ events }) => {\n            events.setActivePlayers({ currentPlayer: 'A' });\n          },\n        },\n      },\n    };\n    const client = Client({ game });\n    client.events.setPhase('A');\n    expect(error).toHaveBeenCalled();\n    const errorMessage = (error as jest.Mock).mock.calls[0][0];\n    expect(errorMessage).toMatch(/events plugin declared action invalid/);\n    expect(errorMessage).toMatch(\n      /Events must be called from moves or the `.+` hooks./\n    );\n  });\n});\n\ndescribe('events in hooks', () => {\n  const moves = {\n    setAutoEnd: () => ({ shouldEnd: true }),\n  };\n\n  describe('endTurn', () => {\n    const conditionalEndTurn = ({ G, events }) => {\n      if (!G.shouldEnd) return;\n      G.shouldEnd = false;\n      events.endTurn();\n    };\n\n    test('can end turn from turn.onBegin', () => {\n      const client = Client({\n        game: { moves, turn: { onBegin: conditionalEndTurn } },\n      });\n\n      client.moves.setAutoEnd();\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n\n      client.events.endTurn();\n      state = client.getState();\n      expect(state.ctx.turn).toBe(3);\n      expect(state.ctx.currentPlayer).toBe('0');\n    });\n\n    test('cannot end turn from phase.onBegin', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: { onBegin: conditionalEndTurn },\n          },\n        },\n      });\n\n      client.moves.setAutoEnd();\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBeNull();\n\n      client.events.setPhase('A');\n      state = client.getState();\n      expect(state.ctx.turn).toBe(2);\n      expect(state.ctx.currentPlayer).toBe('1');\n      expect(state.ctx.phase).toBe('A');\n    });\n\n    test('can end turn from turn.onBegin at start of phase', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: {\n              turn: { onBegin: conditionalEndTurn },\n            },\n          },\n        },\n      });\n\n      client.moves.setAutoEnd();\n\n      let state = client.getState();\n      expect(state.ctx.phase).toBeNull();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n\n      client.events.setPhase('A');\n      state = client.getState();\n      expect(state.ctx.phase).toBe('A');\n      expect(state.ctx.turn).toBe(3);\n      expect(state.ctx.currentPlayer).toBe('0');\n    });\n\n    test('cannot end turn from turn.onEnd', () => {\n      const client = Client({\n        game: {\n          moves,\n          turn: { onEnd: conditionalEndTurn },\n        },\n      });\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n\n      client.moves.setAutoEnd();\n      client.events.endTurn();\n      state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(error).toHaveBeenCalled();\n      const errorMessage = (error as jest.Mock).mock.calls[0][0];\n      expect(errorMessage).toMatch(/events plugin declared action invalid/);\n      expect(errorMessage).toMatch(/`endTurn` is disallowed in `onEnd` hooks/);\n    });\n\n    test('cannot end turn from phase.onEnd', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: {\n              start: true,\n              onEnd: conditionalEndTurn,\n            },\n          },\n        },\n      });\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBe('A');\n\n      client.moves.setAutoEnd();\n      client.events.endPhase();\n      state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBe('A');\n      expect(error).toHaveBeenCalled();\n      const errorMessage = (error as jest.Mock).mock.calls[0][0];\n      expect(errorMessage).toMatch(/events plugin declared action invalid/);\n      expect(errorMessage).toMatch(/`endTurn` is disallowed in `onEnd` hooks/);\n    });\n  });\n\n  describe('endPhase', () => {\n    const conditionalEndPhase = ({ G, events }) => {\n      if (!G.shouldEnd) return;\n      G.shouldEnd = false;\n      events.endPhase();\n    };\n\n    test('can end phase from turn.onBegin', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: {\n              start: true,\n              turn: { onBegin: conditionalEndPhase },\n            },\n          },\n        },\n      });\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBe('A');\n\n      client.moves.setAutoEnd();\n      client.events.endTurn();\n      state = client.getState();\n      expect(state.ctx.turn).toBe(3);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBeNull();\n    });\n\n    test('can end phase from phase.onBegin', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: { onBegin: conditionalEndPhase },\n          },\n        },\n      });\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBeNull();\n\n      client.moves.setAutoEnd();\n      client.events.setPhase('A');\n      state = client.getState();\n      expect(state.ctx.turn).toBe(3);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBeNull();\n    });\n\n    test('can end phase from turn.onEnd', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: {\n              start: true,\n              turn: { onEnd: conditionalEndPhase },\n            },\n          },\n        },\n      });\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBe('A');\n\n      client.moves.setAutoEnd();\n      client.events.endTurn();\n      state = client.getState();\n      // TODO: This is likely not the desired behaviour. Turn 1 is ended,\n      // then the phase is ended, automatically ending turn 2, ending up in turn 3.\n      // Turn 2 is effectively skipped. Works better with TurnOrder.CONTINUE.\n      expect(state.ctx.turn).toBe(3);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBeNull();\n    });\n\n    test('cannot end phase from phase.onEnd', () => {\n      const client = Client({\n        game: {\n          moves,\n          phases: {\n            A: {\n              start: true,\n              next: 'B',\n              onEnd: conditionalEndPhase,\n            },\n            B: {},\n          },\n        },\n      });\n\n      let state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBe('A');\n\n      client.moves.setAutoEnd();\n      client.events.endPhase();\n      state = client.getState();\n      expect(state.ctx.turn).toBe(1);\n      expect(state.ctx.currentPlayer).toBe('0');\n      expect(state.ctx.phase).toBe('A');\n      expect(error).toHaveBeenCalled();\n      const errorMessage = (error as jest.Mock).mock.calls[0][0];\n      expect(errorMessage).toMatch(/events plugin declared action invalid/);\n      expect(errorMessage).toMatch(\n        /`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook/\n      );\n    });\n  });\n});\n\ndescribe('activePlayers', () => {\n  test('sets activePlayers at each turn', () => {\n    const game: Game = {\n      turn: {\n        stages: { A: {}, B: {} },\n        activePlayers: {\n          currentPlayer: 'A',\n          others: 'B',\n        },\n      },\n    };\n\n    const client = Client({ game, numPlayers: 3 });\n\n    expect(client.getState().ctx.currentPlayer).toBe('0');\n    expect(client.getState().ctx.activePlayers).toEqual({\n      '0': 'A',\n      '1': 'B',\n      '2': 'B',\n    });\n\n    client.events.endTurn();\n\n    expect(client.getState().ctx.currentPlayer).toBe('1');\n    expect(client.getState().ctx.activePlayers).toEqual({\n      '0': 'B',\n      '1': 'A',\n      '2': 'B',\n    });\n  });\n});\n\ntest('events in hooks triggered by moves should be processed', () => {\n  const game: Game = {\n    turn: {\n      onBegin: ({ events }) => {\n        events.setActivePlayers({ currentPlayer: 'A' });\n      },\n    },\n    moves: {\n      endTurn: ({ events }) => {\n        events.endTurn();\n      },\n    },\n  };\n\n  const client = Client({ game, numPlayers: 3 });\n\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n  expect(client.getState().ctx.activePlayers).toEqual({\n    '0': 'A',\n  });\n\n  client.moves.endTurn();\n\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n  expect(client.getState().ctx.activePlayers).toEqual({\n    '1': 'A',\n  });\n});\n\ntest('stage events should not be processed out of turn', () => {\n  const game: Game = {\n    phases: {\n      A: {\n        start: true,\n        turn: {\n          activePlayers: {\n            all: 'A1',\n          },\n          stages: {\n            A1: {\n              moves: {\n                endStage: ({ G, events }) => {\n                  G.endStage = true;\n                  events.endStage();\n                },\n              },\n            },\n          },\n        },\n        endIf: ({ G }) => G.endStage,\n        next: 'B',\n      },\n      B: {\n        turn: {\n          activePlayers: {\n            all: 'B1',\n          },\n          stages: {\n            B1: {},\n          },\n        },\n      },\n    },\n  };\n\n  const client = Client({ game, numPlayers: 3 });\n\n  expect(client.getState().ctx.activePlayers).toEqual({\n    '0': 'A1',\n    '1': 'A1',\n    '2': 'A1',\n  });\n\n  client.moves.endStage();\n\n  expect(client.getState().ctx.activePlayers).toEqual({\n    '0': 'B1',\n    '1': 'B1',\n    '2': 'B1',\n  });\n});\n\ndescribe('backwards compatibility for moveLimit', () => {\n  test('turn config maps moveLimit to minMoves/maxMoves', () => {\n    const flow = Flow({\n      moves: {\n        pass: () => {},\n      },\n      turn: {\n        moveLimit: 2,\n      },\n    });\n    let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n    expect(state.ctx.turn).toBe(1);\n    expect(state.ctx.currentPlayer).toBe('0');\n\n    state = flow.processMove(state, makeMove('pass', null, '0').payload);\n    state = flow.processMove(state, makeMove('pass', null, '0').payload);\n\n    expect(state.ctx.turn).toBe(2);\n    expect(state.ctx.currentPlayer).toBe('1');\n\n    state = flow.processMove(state, makeMove('pass', null, '1').payload);\n\n    state = flow.processEvent(state, gameEvent('endTurn', null, '1'));\n\n    // player should not be able to endTurn because they haven't made minMoves yet\n\n    expect(state.ctx.turn).toBe(2);\n    expect(state.ctx.currentPlayer).toBe('1');\n  });\n\n  test('setActivePlayers maps moveLimit to maxMoves only', () => {\n    const flow = Flow({});\n    let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n    expect(state.ctx._activePlayersMinMoves).toBeNull();\n    expect(state.ctx._activePlayersMaxMoves).toBeNull();\n\n    state = flow.processEvent(\n      state,\n      gameEvent('setActivePlayers', { all: 'A', moveLimit: 1 })\n    );\n\n    expect(state.ctx._activePlayersMinMoves).toBeNull();\n    expect(state.ctx._activePlayersMaxMoves).toEqual({ '0': 1, '1': 1 });\n  });\n\n  test('setStage maps moveLimit to maxMoves only', () => {\n    const flow = Flow({});\n    let state = flow.init({ ctx: flow.ctx(2) } as State);\n\n    expect(state.ctx._activePlayersMinMoves).toBeNull();\n    expect(state.ctx._activePlayersMaxMoves).toBeNull();\n    state = flow.processEvent(\n      state,\n      gameEvent('setStage', { stage: 'A', moveLimit: 2 })\n    );\n    expect(state.ctx._activePlayersMinMoves).toBeNull();\n    expect(state.ctx._activePlayersMaxMoves).toEqual({ '0': 2 });\n  });\n});\n\n// These tests serve to document the order in which the various game hooks\n// are executed and also to catch any potential breaking changes.\ndescribe('hook execution order', () => {\n  const calls: string[] = [];\n  afterEach(() => {\n    calls.length = 0;\n  });\n\n  const client = Client({\n    playerID: '0',\n    game: {\n      moves: {\n        move: () => void calls.push('move'),\n        setStage: ({ events }) => {\n          events.setStage('A');\n          calls.push('moves.setStage');\n        },\n        endStage: ({ events }) => {\n          events.endStage();\n          calls.push('moves.endStage');\n        },\n        setActivePlayers: ({ events }) => {\n          events.setActivePlayers({ all: 'A', minMoves: 1, maxMoves: 1 });\n          calls.push('moves.setActivePlayers');\n        },\n      },\n      endIf: () => void calls.push('game.endIf'),\n      onEnd: () => void calls.push('game.onEnd'),\n      turn: {\n        activePlayers: { all: 'A' },\n        endIf: () => void calls.push('turn.endIf'),\n        onBegin: () => void calls.push('turn.onBegin'),\n        onMove: () => void calls.push('turn.onMove'),\n        onEnd: () => void calls.push('turn.onEnd'),\n        order: {\n          first: () => calls.push('turn.order.first') && 0,\n          next: () => calls.push('turn.order.next') && 0,\n          playOrder: () => calls.push('turn.order.playOrder') && ['0', '1'],\n        },\n      },\n      phases: {\n        A: {\n          start: true,\n          next: 'B',\n          endIf: () => void calls.push('phaseA.endIf'),\n          onBegin: () => void calls.push('phaseA.onBegin'),\n          onEnd: () => void calls.push('phaseA.onEnd'),\n        },\n        B: {\n          next: 'A',\n          endIf: () => void calls.push('phaseB.endIf'),\n          onBegin: () => void calls.push('phaseB.onBegin'),\n          onEnd: () => void calls.push('phaseB.onEnd'),\n        },\n      },\n    },\n  });\n\n  test('hooks called during setup', () => {\n    expect(calls).toEqual([\n      'game.endIf',\n      'phaseA.endIf',\n      'phaseA.onBegin',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.order.playOrder',\n      'turn.order.first',\n      'turn.onBegin',\n      'game.endIf',\n      'phaseA.endIf',\n    ]);\n  });\n\n  test('hooks called on move', () => {\n    client.moves.move();\n    expect(calls).toEqual([\n      'move',\n      'turn.onMove',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on setStage', () => {\n    client.events.setStage('B');\n    expect(calls).toEqual([\n      'game.endIf',\n      'phaseA.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on endStage', () => {\n    client.updatePlayerID('1');\n    client.events.endStage();\n    client.updatePlayerID('0');\n    expect(calls).toEqual([\n      'game.endIf',\n      'phaseA.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on setActivePlayers', () => {\n    client.events.setActivePlayers({});\n    expect(calls).toEqual(['game.endIf', 'phaseA.endIf', 'turn.endIf']);\n  });\n\n  test('hooks called on setStage triggered by move', () => {\n    client.moves.setStage();\n    expect(calls).toEqual([\n      'moves.setStage',\n      'turn.onMove',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on endStage triggered by move', () => {\n    client.moves.endStage();\n    expect(calls).toEqual([\n      'moves.endStage',\n      'turn.onMove',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on setActivePlayers triggered by move', () => {\n    client.moves.setActivePlayers();\n    expect(calls).toEqual([\n      'moves.setActivePlayers',\n      'turn.onMove',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on stage end triggered by maxMoves', () => {\n    client.updatePlayerID('1');\n    client.moves.move();\n    client.updatePlayerID('0');\n    expect(calls).toEqual([\n      'move',\n      'turn.onMove',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.endIf',\n    ]);\n  });\n\n  test('hooks called on endTurn', () => {\n    client.events.endTurn();\n    expect(calls).toEqual([\n      'turn.onEnd',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.order.next',\n      'game.endIf',\n      'phaseA.endIf',\n      'turn.onBegin',\n      'game.endIf',\n      'phaseA.endIf',\n    ]);\n  });\n\n  test('hooks called on endPhase', () => {\n    client.events.endPhase();\n    expect(calls).toEqual([\n      'turn.onEnd',\n      'phaseA.onEnd',\n      'game.endIf',\n      'game.endIf',\n      'phaseB.endIf',\n      'phaseB.onBegin',\n      'game.endIf',\n      'phaseB.endIf',\n      'turn.order.playOrder',\n      'turn.order.first',\n      'turn.onBegin',\n      'game.endIf',\n      'phaseB.endIf',\n    ]);\n  });\n\n  test('hooks called on endGame', () => {\n    client.events.endGame(5);\n    expect(calls).toEqual(['phaseB.onEnd', 'game.onEnd']);\n  });\n});\n\ndescribe('game function signatures', () => {\n  const moveA = jest.fn();\n  let game: Game;\n\n  let client: ReturnType<typeof Client>;\n\n  // Helpers to check the objects game functions are called with.\n  const expectCtx = expect.objectContaining({ numPlayers: 2 });\n  const expectEvents = expect.objectContaining({\n    endTurn: expect.any(Function),\n  });\n  const expectRandom = expect.objectContaining({\n    D6: expect.any(Function),\n  });\n  const FnContext = ({\n    playerID,\n    G = 'G',\n  }: { playerID?: PlayerID; G?: any } = {}) => {\n    const context: any = {\n      G,\n      ctx: expectCtx,\n      events: expectEvents,\n      random: expectRandom,\n      testPluginAPI: { foo: 'bar' },\n    };\n    if (playerID !== undefined) context.playerID = playerID;\n    return expect.objectContaining(context);\n  };\n\n  beforeEach(() => {\n    game = {\n      setup: jest.fn(() => 'G'),\n\n      plugins: [\n        {\n          name: 'testPluginAPI',\n          api: () => ({ foo: 'bar' }),\n        },\n      ],\n\n      onEnd: jest.fn(),\n      endIf: jest.fn(({ G }) => G == 'gameover'),\n\n      moves: {\n        A: (...args) => moveA(...args),\n        endGame: () => 'gameover',\n      },\n\n      turn: {\n        order: {\n          playOrder: jest.fn(({ ctx }) =>\n            [...Array.from({ length: ctx.numPlayers })].map((_, i) => i + '')\n          ),\n          first: jest.fn(TurnOrder.DEFAULT.first),\n          next: jest.fn(TurnOrder.DEFAULT.next),\n        },\n        onBegin: jest.fn(),\n        onMove: jest.fn(),\n        onEnd: jest.fn(),\n        endIf: jest.fn(),\n      },\n\n      phases: {\n        A: {\n          onBegin: jest.fn(),\n          onEnd: jest.fn(),\n          endIf: jest.fn(),\n        },\n      },\n\n      events: {\n        endPhase: true,\n      },\n    };\n\n    client = Client({ game, playerID: '0' });\n  });\n\n  afterEach(() => {\n    jest.resetAllMocks();\n  });\n\n  test('game.setup', () => {\n    expect(game.setup).lastCalledWith(\n      // setup context object\n      expect.objectContaining({\n        ctx: expectCtx,\n        events: expectEvents,\n        random: expectRandom,\n      }),\n      // setupData\n      undefined\n    );\n  });\n\n  test('game.onEnd', () => {\n    client.events.endGame();\n    expect(game.onEnd).lastCalledWith(FnContext());\n  });\n\n  test('game.endIf', () => {\n    client.moves.endGame();\n    expect(game.endIf).lastCalledWith(FnContext({ G: 'gameover' }));\n  });\n\n  test('game.turn.order.playOrder', () => {\n    expect(game.turn.order.playOrder).lastCalledWith(FnContext());\n  });\n\n  test('game.turn.order.first', () => {\n    expect(game.turn.order.first).lastCalledWith(FnContext());\n  });\n\n  test('game.turn.order.next', () => {\n    client.events.endTurn();\n    expect(game.turn.order.next).lastCalledWith(FnContext());\n  });\n\n  test('game.turn.onBegin', () => {\n    expect(game.turn.onBegin).lastCalledWith(FnContext());\n  });\n\n  test('game.turn.onMove', () => {\n    client.moves.A();\n    expect(game.turn.onMove).lastCalledWith(FnContext());\n  });\n\n  test('game.turn.onEnd', () => {\n    client.events.endTurn();\n    expect(game.turn.onEnd).lastCalledWith(FnContext());\n  });\n\n  test('game.turn.endIf', () => {\n    client.moves.A();\n    expect(game.turn.endIf).lastCalledWith(FnContext());\n  });\n\n  test('move', () => {\n    client.moves.A('arg');\n    expect(moveA).lastCalledWith(FnContext({ playerID: '0' }), 'arg');\n    client.moves.A(2, 'args');\n    expect(moveA).lastCalledWith(FnContext({ playerID: '0' }), 2, 'args');\n  });\n\n  test('game.phases.phase.onBegin', () => {\n    client.events.setPhase('A');\n    expect(game.phases.A.onBegin).lastCalledWith(FnContext());\n  });\n\n  test('game.phases.phase.onEnd', () => {\n    client.events.setPhase('A');\n    client.updatePlayerID('1');\n    client.events.endPhase();\n    expect(game.phases.A.onEnd).lastCalledWith(FnContext());\n  });\n\n  test('game.phases.phase.endIf', () => {\n    client.events.setPhase('A');\n    expect(game.phases.A.endIf).lastCalledWith(FnContext());\n  });\n});\n"
  },
  {
    "path": "src/core/flow.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport {\n  SetActivePlayers,\n  UpdateActivePlayersOnceEmpty,\n  InitTurnOrderState,\n  UpdateTurnOrderState,\n  Stage,\n  TurnOrder,\n} from './turn-order';\nimport { gameEvent } from './action-creators';\nimport * as plugin from '../plugins/main';\nimport * as logging from './logger';\nimport type {\n  ActionPayload,\n  ActionShape,\n  ActivePlayersArg,\n  State,\n  Ctx,\n  FnContext,\n  LogEntry,\n  Game,\n  PhaseConfig,\n  PlayerID,\n  Move,\n} from '../types';\nimport { GameMethod } from './game-methods';\nimport { supportDeprecatedMoveLimit } from './backwards-compatibility';\n\n/**\n * Flow\n *\n * Creates a reducer that updates ctx (analogous to how moves update G).\n */\nexport function Flow({\n  moves,\n  phases,\n  endIf,\n  onEnd,\n  turn,\n  events,\n  plugins,\n}: Game) {\n  // Attach defaults.\n  if (moves === undefined) {\n    moves = {};\n  }\n  if (events === undefined) {\n    events = {};\n  }\n  if (plugins === undefined) {\n    plugins = [];\n  }\n  if (phases === undefined) {\n    phases = {};\n  }\n\n  if (!endIf) endIf = () => undefined;\n  if (!onEnd) onEnd = ({ G }) => G;\n  if (!turn) turn = {};\n\n  const phaseMap = { ...phases };\n\n  if ('' in phaseMap) {\n    logging.error('cannot specify phase with empty name');\n  }\n\n  phaseMap[''] = {};\n\n  const moveMap = {};\n  const moveNames = new Set();\n  let startingPhase = null;\n\n  Object.keys(moves).forEach((name) => moveNames.add(name));\n\n  const HookWrapper = (\n    hook: (context: FnContext) => any,\n    hookType: GameMethod\n  ) => {\n    const withPlugins = plugin.FnWrap(hook, hookType, plugins);\n    return (state: State & { playerID?: PlayerID }) => {\n      const pluginAPIs = plugin.GetAPIs(state);\n      return withPlugins({\n        ...pluginAPIs,\n        G: state.G,\n        ctx: state.ctx,\n        playerID: state.playerID,\n      });\n    };\n  };\n\n  const TriggerWrapper = (trigger: (context: FnContext) => any) => {\n    return (state: State) => {\n      const pluginAPIs = plugin.GetAPIs(state);\n      return trigger({\n        ...pluginAPIs,\n        G: state.G,\n        ctx: state.ctx,\n      });\n    };\n  };\n\n  const wrapped = {\n    onEnd: HookWrapper(onEnd, GameMethod.GAME_ON_END),\n    endIf: TriggerWrapper(endIf),\n  };\n\n  for (const phase in phaseMap) {\n    const phaseConfig = phaseMap[phase];\n\n    if (phaseConfig.start === true) {\n      startingPhase = phase;\n    }\n\n    if (phaseConfig.moves !== undefined) {\n      for (const move of Object.keys(phaseConfig.moves)) {\n        moveMap[phase + '.' + move] = phaseConfig.moves[move];\n        moveNames.add(move);\n      }\n    }\n\n    if (phaseConfig.endIf === undefined) {\n      phaseConfig.endIf = () => undefined;\n    }\n    if (phaseConfig.onBegin === undefined) {\n      phaseConfig.onBegin = ({ G }) => G;\n    }\n    if (phaseConfig.onEnd === undefined) {\n      phaseConfig.onEnd = ({ G }) => G;\n    }\n    if (phaseConfig.turn === undefined) {\n      phaseConfig.turn = turn;\n    }\n    if (phaseConfig.turn.order === undefined) {\n      phaseConfig.turn.order = TurnOrder.DEFAULT;\n    }\n    if (phaseConfig.turn.onBegin === undefined) {\n      phaseConfig.turn.onBegin = ({ G }) => G;\n    }\n    if (phaseConfig.turn.onEnd === undefined) {\n      phaseConfig.turn.onEnd = ({ G }) => G;\n    }\n    if (phaseConfig.turn.endIf === undefined) {\n      phaseConfig.turn.endIf = () => false;\n    }\n    if (phaseConfig.turn.onMove === undefined) {\n      phaseConfig.turn.onMove = ({ G }) => G;\n    }\n    if (phaseConfig.turn.stages === undefined) {\n      phaseConfig.turn.stages = {};\n    }\n\n    // turns previously treated moveLimit as both minMoves and maxMoves, this behaviour is kept intentionally\n    supportDeprecatedMoveLimit(phaseConfig.turn, true);\n\n    for (const stage in phaseConfig.turn.stages) {\n      const stageConfig = phaseConfig.turn.stages[stage];\n      const moves = stageConfig.moves || {};\n      for (const move of Object.keys(moves)) {\n        const key = phase + '.' + stage + '.' + move;\n        moveMap[key] = moves[move];\n        moveNames.add(move);\n      }\n    }\n\n    phaseConfig.wrapped = {\n      onBegin: HookWrapper(phaseConfig.onBegin, GameMethod.PHASE_ON_BEGIN),\n      onEnd: HookWrapper(phaseConfig.onEnd, GameMethod.PHASE_ON_END),\n      endIf: TriggerWrapper(phaseConfig.endIf),\n    };\n\n    phaseConfig.turn.wrapped = {\n      onMove: HookWrapper(phaseConfig.turn.onMove, GameMethod.TURN_ON_MOVE),\n      onBegin: HookWrapper(phaseConfig.turn.onBegin, GameMethod.TURN_ON_BEGIN),\n      onEnd: HookWrapper(phaseConfig.turn.onEnd, GameMethod.TURN_ON_END),\n      endIf: TriggerWrapper(phaseConfig.turn.endIf),\n    };\n\n    if (typeof phaseConfig.next !== 'function') {\n      const { next } = phaseConfig;\n      phaseConfig.next = () => next || null;\n    }\n    phaseConfig.wrapped.next = TriggerWrapper(phaseConfig.next);\n  }\n\n  function GetPhase(ctx: { phase: string }): PhaseConfig {\n    return ctx.phase ? phaseMap[ctx.phase] : phaseMap[''];\n  }\n\n  function OnMove(state: State) {\n    return state;\n  }\n\n  function Process(\n    state: State,\n    events: {\n      fn: (state: State, opts: any) => State;\n      arg?: any;\n      turn?: Ctx['turn'];\n      phase?: Ctx['phase'];\n      automatic?: boolean;\n      playerID?: PlayerID;\n      force?: boolean;\n    }[]\n  ): State {\n    const phasesEnded = new Set();\n    const turnsEnded = new Set();\n\n    for (let i = 0; i < events.length; i++) {\n      const { fn, arg, ...rest } = events[i];\n\n      // Detect a loop of EndPhase calls.\n      // This could potentially even be an infinite loop\n      // if the endIf condition of each phase blindly\n      // returns true. The moment we detect a single\n      // loop, we just bail out of all phases.\n      if (fn === EndPhase) {\n        turnsEnded.clear();\n        const phase = state.ctx.phase;\n        if (phasesEnded.has(phase)) {\n          const ctx = { ...state.ctx, phase: null };\n          return { ...state, ctx };\n        }\n        phasesEnded.add(phase);\n      }\n\n      // Process event.\n      const next = [];\n      state = fn(state, {\n        ...rest,\n        arg,\n        next,\n      });\n\n      if (fn === EndGame) {\n        break;\n      }\n\n      // Check if we should end the game.\n      const shouldEndGame = ShouldEndGame(state);\n      if (shouldEndGame) {\n        events.push({\n          fn: EndGame,\n          arg: shouldEndGame,\n          turn: state.ctx.turn,\n          phase: state.ctx.phase,\n          automatic: true,\n        });\n        continue;\n      }\n\n      // Check if we should end the phase.\n      const shouldEndPhase = ShouldEndPhase(state);\n      if (shouldEndPhase) {\n        events.push({\n          fn: EndPhase,\n          arg: shouldEndPhase,\n          turn: state.ctx.turn,\n          phase: state.ctx.phase,\n          automatic: true,\n        });\n        continue;\n      }\n\n      // Check if we should end the turn.\n      if ([OnMove, UpdateStage, UpdateActivePlayers].includes(fn)) {\n        const shouldEndTurn = ShouldEndTurn(state);\n        if (shouldEndTurn) {\n          events.push({\n            fn: EndTurn,\n            arg: shouldEndTurn,\n            turn: state.ctx.turn,\n            phase: state.ctx.phase,\n            automatic: true,\n          });\n          continue;\n        }\n      }\n\n      events.push(...next);\n    }\n\n    return state;\n  }\n\n  ///////////\n  // Start //\n  ///////////\n\n  function StartGame(state: State, { next }): State {\n    next.push({ fn: StartPhase });\n    return state;\n  }\n\n  function StartPhase(state: State, { next }): State {\n    let { G, ctx } = state;\n    const phaseConfig = GetPhase(ctx);\n\n    // Run any phase setup code provided by the user.\n    G = phaseConfig.wrapped.onBegin(state);\n\n    next.push({ fn: StartTurn });\n\n    return { ...state, G, ctx };\n  }\n\n  function StartTurn(state: State, { currentPlayer }): State {\n    let { ctx } = state;\n    const phaseConfig = GetPhase(ctx);\n\n    // Initialize the turn order state.\n    if (currentPlayer) {\n      ctx = { ...ctx, currentPlayer };\n      if (phaseConfig.turn.activePlayers) {\n        ctx = SetActivePlayers(ctx, phaseConfig.turn.activePlayers);\n      }\n    } else {\n      // This is only called at the beginning of the phase\n      // when there is no currentPlayer yet.\n      ctx = InitTurnOrderState(state, phaseConfig.turn);\n    }\n\n    const turn = ctx.turn + 1;\n    ctx = { ...ctx, turn, numMoves: 0, _prevActivePlayers: [] };\n\n    const G = phaseConfig.turn.wrapped.onBegin({ ...state, ctx });\n\n    return { ...state, G, ctx, _undo: [], _redo: [] } as State;\n  }\n\n  ////////////\n  // Update //\n  ////////////\n\n  function UpdatePhase(state: State, { arg, next, phase }): State {\n    const phaseConfig = GetPhase({ phase });\n    let { ctx } = state;\n\n    if (arg && arg.next) {\n      if (arg.next in phaseMap) {\n        ctx = { ...ctx, phase: arg.next };\n      } else {\n        logging.error('invalid phase: ' + arg.next);\n        return state;\n      }\n    } else {\n      ctx = { ...ctx, phase: phaseConfig.wrapped.next(state) || null };\n    }\n\n    state = { ...state, ctx };\n\n    // Start the new phase.\n    next.push({ fn: StartPhase });\n\n    return state;\n  }\n\n  function UpdateTurn(state: State, { arg, currentPlayer, next }): State {\n    let { G, ctx } = state;\n    const phaseConfig = GetPhase(ctx);\n\n    // Update turn order state.\n    const { endPhase, ctx: newCtx } = UpdateTurnOrderState(\n      state,\n      currentPlayer,\n      phaseConfig.turn,\n      arg\n    );\n    ctx = newCtx;\n\n    state = { ...state, G, ctx };\n\n    if (endPhase) {\n      next.push({ fn: EndPhase, turn: ctx.turn, phase: ctx.phase });\n    } else {\n      next.push({ fn: StartTurn, currentPlayer: ctx.currentPlayer });\n    }\n\n    return state;\n  }\n\n  function UpdateStage(state: State, { arg, playerID }): State {\n    if (typeof arg === 'string' || arg === Stage.NULL) {\n      arg = { stage: arg };\n    }\n    if (typeof arg !== 'object') return state;\n\n    // `arg` should be of type `StageArg`, loose typing as `any` here for historic reasons\n    // stages previously did not enforce minMoves, this behaviour is kept intentionally\n    supportDeprecatedMoveLimit(arg);\n\n    let { ctx } = state;\n    let {\n      activePlayers,\n      _activePlayersMinMoves,\n      _activePlayersMaxMoves,\n      _activePlayersNumMoves,\n    } = ctx;\n\n    // Checking if stage is valid, even Stage.NULL\n    if (arg.stage !== undefined) {\n      if (activePlayers === null) {\n        activePlayers = {};\n      }\n      activePlayers[playerID] = arg.stage;\n      _activePlayersNumMoves[playerID] = 0;\n\n      if (arg.minMoves) {\n        if (_activePlayersMinMoves === null) {\n          _activePlayersMinMoves = {};\n        }\n        _activePlayersMinMoves[playerID] = arg.minMoves;\n      }\n\n      if (arg.maxMoves) {\n        if (_activePlayersMaxMoves === null) {\n          _activePlayersMaxMoves = {};\n        }\n        _activePlayersMaxMoves[playerID] = arg.maxMoves;\n      }\n    }\n\n    ctx = {\n      ...ctx,\n      activePlayers,\n      _activePlayersMinMoves,\n      _activePlayersMaxMoves,\n      _activePlayersNumMoves,\n    };\n\n    return { ...state, ctx };\n  }\n\n  function UpdateActivePlayers(state: State, { arg }): State {\n    return { ...state, ctx: SetActivePlayers(state.ctx, arg) };\n  }\n\n  ///////////////\n  // ShouldEnd //\n  ///////////////\n\n  function ShouldEndGame(state: State): boolean {\n    return wrapped.endIf(state);\n  }\n\n  function ShouldEndPhase(state: State): boolean | void | { next: string } {\n    const phaseConfig = GetPhase(state.ctx);\n    return phaseConfig.wrapped.endIf(state);\n  }\n\n  function ShouldEndTurn(state: State): boolean | void | { next: PlayerID } {\n    const phaseConfig = GetPhase(state.ctx);\n\n    // End the turn if the required number of moves has been made.\n    const currentPlayerMoves = state.ctx.numMoves || 0;\n    if (\n      phaseConfig.turn.maxMoves &&\n      currentPlayerMoves >= phaseConfig.turn.maxMoves\n    ) {\n      return true;\n    }\n\n    return phaseConfig.turn.wrapped.endIf(state);\n  }\n\n  /////////\n  // End //\n  /////////\n\n  function EndGame(state: State, { arg, phase }): State {\n    state = EndPhase(state, { phase });\n\n    if (arg === undefined) {\n      arg = true;\n    }\n\n    state = { ...state, ctx: { ...state.ctx, gameover: arg } };\n\n    // Run game end hook.\n    const G = wrapped.onEnd(state);\n\n    return { ...state, G };\n  }\n\n  function EndPhase(\n    state: State,\n    { arg, next, turn: initialTurn, automatic }: any\n  ): State {\n    // End the turn first.\n    state = EndTurn(state, { turn: initialTurn, force: true, automatic: true });\n\n    const { phase, turn } = state.ctx;\n\n    if (next) {\n      next.push({ fn: UpdatePhase, arg, phase });\n    }\n\n    // If we aren't in a phase, there is nothing else to do.\n    if (phase === null) {\n      return state;\n    }\n\n    // Run any cleanup code for the phase that is about to end.\n    const phaseConfig = GetPhase(state.ctx);\n    const G = phaseConfig.wrapped.onEnd(state);\n\n    // Reset the phase.\n    const ctx = { ...state.ctx, phase: null };\n\n    // Add log entry.\n    const action = gameEvent('endPhase', arg);\n    const { _stateID } = state;\n    const logEntry: LogEntry = { action, _stateID, turn, phase };\n    if (automatic) logEntry.automatic = true;\n\n    const deltalog = [...(state.deltalog || []), logEntry];\n\n    return { ...state, G, ctx, deltalog };\n  }\n\n  function EndTurn(\n    state: State,\n    { arg, next, turn: initialTurn, force, automatic, playerID }: any\n  ): State {\n    // This is not the turn that EndTurn was originally\n    // called for. The turn was probably ended some other way.\n    if (initialTurn !== state.ctx.turn) {\n      return state;\n    }\n\n    const { currentPlayer, numMoves, phase, turn } = state.ctx;\n    const phaseConfig = GetPhase(state.ctx);\n\n    // Prevent ending the turn if minMoves haven't been reached.\n    const currentPlayerMoves = numMoves || 0;\n    if (\n      !force &&\n      phaseConfig.turn.minMoves &&\n      currentPlayerMoves < phaseConfig.turn.minMoves\n    ) {\n      logging.info(\n        `cannot end turn before making ${phaseConfig.turn.minMoves} moves`\n      );\n      return state;\n    }\n\n    // Run turn-end triggers.\n    const G = phaseConfig.turn.wrapped.onEnd(state);\n\n    if (next) {\n      next.push({ fn: UpdateTurn, arg, currentPlayer });\n    }\n\n    // Reset activePlayers.\n    let ctx = { ...state.ctx, activePlayers: null };\n\n    // Remove player from playerOrder\n    if (arg && arg.remove) {\n      playerID = playerID || currentPlayer;\n\n      const playOrder = ctx.playOrder.filter((i) => i != playerID);\n\n      const playOrderPos =\n        ctx.playOrderPos > playOrder.length - 1 ? 0 : ctx.playOrderPos;\n\n      ctx = { ...ctx, playOrder, playOrderPos };\n\n      if (playOrder.length === 0) {\n        next.push({ fn: EndPhase, turn, phase });\n        return state;\n      }\n    }\n\n    // Create log entry.\n    const action = gameEvent('endTurn', arg);\n    const { _stateID } = state;\n    const logEntry: LogEntry = { action, _stateID, turn, phase };\n    if (automatic) logEntry.automatic = true;\n\n    const deltalog = [...(state.deltalog || []), logEntry];\n\n    return { ...state, G, ctx, deltalog, _undo: [], _redo: [] };\n  }\n\n  function EndStage(\n    state: State,\n    { arg, next, automatic, playerID }: any\n  ): State {\n    playerID = playerID || state.ctx.currentPlayer;\n\n    let { ctx, _stateID } = state;\n    let {\n      activePlayers,\n      _activePlayersNumMoves,\n      _activePlayersMinMoves,\n      _activePlayersMaxMoves,\n      phase,\n      turn,\n    } = ctx;\n\n    const playerInStage = activePlayers !== null && playerID in activePlayers;\n\n    const phaseConfig = GetPhase(ctx);\n\n    if (!arg && playerInStage) {\n      const stage = phaseConfig.turn.stages[activePlayers[playerID]];\n      if (stage && stage.next) {\n        arg = stage.next;\n      }\n    }\n\n    // Checking if arg is a valid stage, even Stage.NULL\n    if (next) {\n      next.push({ fn: UpdateStage, arg, playerID });\n    }\n\n    // If player isn’t in a stage, there is nothing else to do.\n    if (!playerInStage) return state;\n\n    // Prevent ending the stage if minMoves haven't been reached.\n    const currentPlayerMoves = _activePlayersNumMoves[playerID] || 0;\n    if (\n      _activePlayersMinMoves &&\n      _activePlayersMinMoves[playerID] &&\n      currentPlayerMoves < _activePlayersMinMoves[playerID]\n    ) {\n      logging.info(\n        `cannot end stage before making ${_activePlayersMinMoves[playerID]} moves`\n      );\n      return state;\n    }\n\n    // Remove player from activePlayers.\n    activePlayers = { ...activePlayers };\n    delete activePlayers[playerID];\n\n    if (_activePlayersMinMoves) {\n      // Remove player from _activePlayersMinMoves.\n      _activePlayersMinMoves = { ..._activePlayersMinMoves };\n      delete _activePlayersMinMoves[playerID];\n    }\n\n    if (_activePlayersMaxMoves) {\n      // Remove player from _activePlayersMaxMoves.\n      _activePlayersMaxMoves = { ..._activePlayersMaxMoves };\n      delete _activePlayersMaxMoves[playerID];\n    }\n\n    ctx = UpdateActivePlayersOnceEmpty({\n      ...ctx,\n      activePlayers,\n      _activePlayersMinMoves,\n      _activePlayersMaxMoves,\n    });\n\n    // Create log entry.\n    const action = gameEvent('endStage', arg);\n    const logEntry: LogEntry = { action, _stateID, turn, phase };\n    if (automatic) logEntry.automatic = true;\n\n    const deltalog = [...(state.deltalog || []), logEntry];\n\n    return { ...state, ctx, deltalog };\n  }\n\n  /**\n   * Retrieves the relevant move that can be played by playerID.\n   *\n   * If ctx.activePlayers is set (i.e. one or more players are in some stage),\n   * then it attempts to find the move inside the stages config for\n   * that turn. If the stage for a player is '', then the player is\n   * allowed to make a move (as determined by the phase config), but\n   * isn't restricted to a particular set as defined in the stage config.\n   *\n   * If not, it then looks for the move inside the phase.\n   *\n   * If it doesn't find the move there, it looks at the global move definition.\n   *\n   * @param {object} ctx\n   * @param {string} name\n   * @param {string} playerID\n   */\n  function GetMove(ctx: Ctx, name: string, playerID: PlayerID): null | Move {\n    const phaseConfig = GetPhase(ctx);\n    const stages = phaseConfig.turn.stages;\n    const { activePlayers } = ctx;\n\n    if (\n      activePlayers &&\n      activePlayers[playerID] !== undefined &&\n      activePlayers[playerID] !== Stage.NULL &&\n      stages[activePlayers[playerID]] !== undefined &&\n      stages[activePlayers[playerID]].moves !== undefined\n    ) {\n      // Check if moves are defined for the player's stage.\n      const stage = stages[activePlayers[playerID]];\n      const moves = stage.moves;\n      if (name in moves) {\n        return moves[name];\n      }\n    } else if (phaseConfig.moves) {\n      // Check if moves are defined for the current phase.\n      if (name in phaseConfig.moves) {\n        return phaseConfig.moves[name];\n      }\n    } else if (name in moves) {\n      // Check for the move globally.\n      return moves[name];\n    }\n\n    return null;\n  }\n\n  function ProcessMove(state: State, action: ActionPayload.MakeMove): State {\n    const { playerID, type } = action;\n    const { currentPlayer, activePlayers, _activePlayersMaxMoves } = state.ctx;\n    const move = GetMove(state.ctx, type, playerID);\n    const shouldCount =\n      !move || typeof move === 'function' || move.noLimit !== true;\n\n    let { numMoves, _activePlayersNumMoves } = state.ctx;\n    if (shouldCount) {\n      if (playerID === currentPlayer) numMoves++;\n      if (activePlayers) _activePlayersNumMoves[playerID]++;\n    }\n\n    state = {\n      ...state,\n      ctx: {\n        ...state.ctx,\n        numMoves,\n        _activePlayersNumMoves,\n      },\n    };\n\n    if (\n      _activePlayersMaxMoves &&\n      _activePlayersNumMoves[playerID] >= _activePlayersMaxMoves[playerID]\n    ) {\n      state = EndStage(state, { playerID, automatic: true });\n    }\n\n    const phaseConfig = GetPhase(state.ctx);\n    const G = phaseConfig.turn.wrapped.onMove({ ...state, playerID });\n    state = { ...state, G };\n\n    const events = [{ fn: OnMove }];\n\n    return Process(state, events);\n  }\n\n  function SetStageEvent(state: State, playerID: PlayerID, arg: any): State {\n    return Process(state, [{ fn: EndStage, arg, playerID }]);\n  }\n\n  function EndStageEvent(state: State, playerID: PlayerID): State {\n    return Process(state, [{ fn: EndStage, playerID }]);\n  }\n\n  function SetActivePlayersEvent(\n    state: State,\n    _playerID: PlayerID,\n    arg: ActivePlayersArg\n  ): State {\n    return Process(state, [{ fn: UpdateActivePlayers, arg }]);\n  }\n\n  function SetPhaseEvent(\n    state: State,\n    _playerID: PlayerID,\n    newPhase: string\n  ): State {\n    return Process(state, [\n      {\n        fn: EndPhase,\n        phase: state.ctx.phase,\n        turn: state.ctx.turn,\n        arg: { next: newPhase },\n      },\n    ]);\n  }\n\n  function EndPhaseEvent(state: State): State {\n    return Process(state, [\n      { fn: EndPhase, phase: state.ctx.phase, turn: state.ctx.turn },\n    ]);\n  }\n\n  function EndTurnEvent(state: State, _playerID: PlayerID, arg: any): State {\n    return Process(state, [\n      { fn: EndTurn, turn: state.ctx.turn, phase: state.ctx.phase, arg },\n    ]);\n  }\n\n  function PassEvent(state: State, _playerID: PlayerID, arg: any): State {\n    return Process(state, [\n      {\n        fn: EndTurn,\n        turn: state.ctx.turn,\n        phase: state.ctx.phase,\n        force: true,\n        arg,\n      },\n    ]);\n  }\n\n  function EndGameEvent(state: State, _playerID: PlayerID, arg: any): State {\n    return Process(state, [\n      { fn: EndGame, turn: state.ctx.turn, phase: state.ctx.phase, arg },\n    ]);\n  }\n\n  const eventHandlers = {\n    endStage: EndStageEvent,\n    setStage: SetStageEvent,\n    endTurn: EndTurnEvent,\n    pass: PassEvent,\n    endPhase: EndPhaseEvent,\n    setPhase: SetPhaseEvent,\n    endGame: EndGameEvent,\n    setActivePlayers: SetActivePlayersEvent,\n  };\n\n  const enabledEventNames = [];\n\n  if (events.endTurn !== false) {\n    enabledEventNames.push('endTurn');\n  }\n  if (events.pass !== false) {\n    enabledEventNames.push('pass');\n  }\n  if (events.endPhase !== false) {\n    enabledEventNames.push('endPhase');\n  }\n  if (events.setPhase !== false) {\n    enabledEventNames.push('setPhase');\n  }\n  if (events.endGame !== false) {\n    enabledEventNames.push('endGame');\n  }\n  if (events.setActivePlayers !== false) {\n    enabledEventNames.push('setActivePlayers');\n  }\n  if (events.endStage !== false) {\n    enabledEventNames.push('endStage');\n  }\n  if (events.setStage !== false) {\n    enabledEventNames.push('setStage');\n  }\n\n  function ProcessEvent(state: State, action: ActionShape.GameEvent): State {\n    const { type, playerID, args } = action.payload;\n    if (typeof eventHandlers[type] !== 'function') return state;\n    return eventHandlers[type](\n      state,\n      playerID,\n      ...(Array.isArray(args) ? args : [args])\n    );\n  }\n\n  function IsPlayerActive(_G: any, ctx: Ctx, playerID: PlayerID): boolean {\n    if (ctx.activePlayers) {\n      return playerID in ctx.activePlayers;\n    }\n    return ctx.currentPlayer === playerID;\n  }\n\n  return {\n    ctx: (numPlayers: number): Ctx => ({\n      numPlayers,\n      turn: 0,\n      currentPlayer: '0',\n      playOrder: [...Array.from({ length: numPlayers })].map((_, i) => i + ''),\n      playOrderPos: 0,\n      phase: startingPhase,\n      activePlayers: null,\n    }),\n    init: (state: State): State => {\n      return Process(state, [{ fn: StartGame }]);\n    },\n    isPlayerActive: IsPlayerActive,\n    eventHandlers,\n    eventNames: Object.keys(eventHandlers),\n    enabledEventNames,\n    moveMap,\n    moveNames: [...moveNames.values()],\n    processMove: ProcessMove,\n    processEvent: ProcessEvent,\n    getMove: GetMove,\n  };\n}\n"
  },
  {
    "path": "src/core/game-methods.ts",
    "content": "export enum GameMethod {\n  MOVE = 'MOVE',\n  GAME_ON_END = 'GAME_ON_END',\n  PHASE_ON_BEGIN = 'PHASE_ON_BEGIN',\n  PHASE_ON_END = 'PHASE_ON_END',\n  TURN_ON_BEGIN = 'TURN_ON_BEGIN',\n  TURN_ON_MOVE = 'TURN_ON_MOVE',\n  TURN_ON_END = 'TURN_ON_END',\n}\n"
  },
  {
    "path": "src/core/game.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { ProcessGameConfig } from './game';\nimport { Client } from '../client/client';\nimport { error } from '../core/logger';\nimport { InitializeGame } from './initialize';\nimport type { Game } from '../types';\n\njest.mock('../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\ndescribe('basic', () => {\n  let game;\n  beforeAll(() => {\n    game = ProcessGameConfig({\n      moves: {\n        A: ({ G }) => G,\n        B: () => null,\n        C: {\n          move: () => 'C',\n        },\n      },\n\n      phases: {\n        PA: {\n          moves: {\n            A: () => 'PA.A',\n          },\n        },\n      },\n    });\n  });\n\n  test('sanity', () => {\n    expect(game.moveNames).toEqual(['A', 'B', 'C']);\n    expect(typeof game.processMove).toEqual('function');\n  });\n\n  test('processMove', () => {\n    const G = { test: true };\n    const ctx = { phase: '' };\n    const state = { G, ctx, plugins: {} };\n\n    expect(game.processMove(state, { type: 'A' })).toEqual(G);\n    expect(game.processMove(state, { type: 'D' })).toEqual(G);\n    expect(game.processMove(state, { type: 'B' })).toEqual(null);\n\n    state.ctx.phase = 'PA';\n    expect(game.processMove(state, { type: 'A' })).toEqual('PA.A');\n  });\n\n  test('long-form move syntax', () => {\n    expect(\n      game.processMove({ ctx: { phase: '' }, plugins: {} }, { type: 'C' })\n    ).toEqual('C');\n  });\n});\n\n// Following turn order is often used in worker placement games like Agricola and Viticulture.\ntest('rounds with starting player token', () => {\n  const game: Game = {\n    setup: () => ({ startingPlayerToken: 0 }),\n\n    moves: {\n      takeStartingPlayerToken: ({ G, ctx }) => {\n        G.startingPlayerToken = ctx.currentPlayer;\n      },\n    },\n\n    phases: {\n      main: {\n        start: true,\n        turn: {\n          order: {\n            first: ({ G }) => G.startingPlayerToken,\n            next: ({ ctx }) => (+ctx.playOrderPos + 1) % ctx.playOrder.length,\n          },\n        },\n      },\n    },\n  };\n\n  const client = Client({ game, numPlayers: 4 });\n\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('2');\n\n  client.moves.takeStartingPlayerToken();\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('3');\n\n  client.events.endTurn();\n  client.events.setPhase('main');\n  expect(client.getState().ctx.currentPlayer).toBe('2');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('3');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n});\n\n// The following pattern is used in Catan, Twilight Imperium, and (sort of) Powergrid.\ntest('serpentine setup phases', () => {\n  const game: Game = {\n    phases: {\n      'first setup round': {\n        start: true,\n        turn: {\n          order: {\n            first: () => 0,\n            next: ({ ctx }) => (+ctx.playOrderPos + 1) % ctx.playOrder.length,\n          },\n        },\n        next: 'second setup round',\n      },\n      'second setup round': {\n        turn: {\n          order: {\n            first: ({ ctx }) => ctx.playOrder.length - 1,\n            next: ({ ctx }) => (+ctx.playOrderPos - 1) % ctx.playOrder.length,\n          },\n        },\n        next: 'main phase',\n      },\n      'main phase': {\n        turn: {\n          order: {\n            first: () => 0,\n            next: ({ ctx }) => (+ctx.playOrderPos + 1) % ctx.playOrder.length,\n          },\n        },\n      },\n    },\n  };\n\n  const numPlayers = 4;\n  const client = Client({ game, numPlayers });\n\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n  expect(client.getState().ctx.phase).toBe('first setup round');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n  expect(client.getState().ctx.phase).toBe('first setup round');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('2');\n  expect(client.getState().ctx.phase).toBe('first setup round');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('3');\n  expect(client.getState().ctx.phase).toBe('first setup round');\n\n  client.events.endTurn();\n  client.events.endPhase();\n  expect(client.getState().ctx.currentPlayer).toBe('3');\n  expect(client.getState().ctx.phase).toBe('second setup round');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('2');\n  expect(client.getState().ctx.phase).toBe('second setup round');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n  expect(client.getState().ctx.phase).toBe('second setup round');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n  expect(client.getState().ctx.phase).toBe('second setup round');\n\n  client.events.endTurn();\n  client.events.endPhase();\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('2');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('3');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('2');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('3');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('0');\n  expect(client.getState().ctx.phase).toBe('main phase');\n\n  client.events.endTurn();\n  expect(client.getState().ctx.currentPlayer).toBe('1');\n  expect(client.getState().ctx.phase).toBe('main phase');\n});\n\ndescribe('config errors', () => {\n  test('game name with spaces', () => {\n    const game = () => {\n      ProcessGameConfig({ name: 'tic tac toe' });\n    };\n    expect(game).toThrow();\n  });\n\n  test('plugin name with spaces', () => {\n    const plugins = [\n      {\n        name: 'my cool plugin',\n        api: () => {},\n      },\n    ];\n    const game = () => {\n      ProcessGameConfig({ plugins });\n    };\n    expect(game).toThrow();\n  });\n\n  test('plugin name missing', () => {\n    const plugins = [\n      {\n        api: () => {},\n      },\n    ];\n    const game = () => {\n      ProcessGameConfig({ plugins } as unknown as Game);\n    };\n    expect(game).toThrow();\n  });\n\n  test('invalid move object', () => {\n    const game = ProcessGameConfig({ moves: { A: 1 } } as unknown as Game);\n    const state = InitializeGame({ game });\n    game.processMove(state, { type: 'A', args: null, playerID: '0' });\n    expect(error).toBeCalledWith(\n      expect.stringContaining('invalid move object')\n    );\n  });\n});\n\ndescribe('disableUndo', () => {\n  test('set disableUndo to false by default', () => {\n    const game = ProcessGameConfig({\n      moves: {},\n    });\n    expect(game.disableUndo).toBeFalsy();\n  });\n\n  test('set disableUndo to true', () => {\n    const game = ProcessGameConfig({\n      moves: {},\n      disableUndo: true,\n    });\n\n    expect(game.disableUndo).toBeTruthy();\n  });\n});\n"
  },
  {
    "path": "src/core/game.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport * as plugins from '../plugins/main';\nimport { Flow } from './flow';\nimport type { INVALID_MOVE } from './constants';\nimport type { ActionPayload, Game, Move, LongFormMove, State } from '../types';\nimport * as logging from './logger';\nimport { GameMethod } from './game-methods';\n\ntype ProcessedGame = Game & {\n  flow: ReturnType<typeof Flow>;\n  moveNames: string[];\n  pluginNames: string[];\n  processMove: (\n    state: State,\n    action: ActionPayload.MakeMove\n  ) => State | typeof INVALID_MOVE;\n};\n\nfunction IsProcessed(game: Game | ProcessedGame): game is ProcessedGame {\n  return game.processMove !== undefined;\n}\n\n/**\n * Helper to generate the game move reducer. The returned\n * reducer has the following signature:\n *\n * (G, action, ctx) => {}\n *\n * You can roll your own if you like, or use any Redux\n * addon to generate such a reducer.\n *\n * The convention used in this framework is to\n * have action.type contain the name of the move, and\n * action.args contain any additional arguments as an\n * Array.\n */\nexport function ProcessGameConfig(game: Game | ProcessedGame): ProcessedGame {\n  // The Game() function has already been called on this\n  // config object, so just pass it through.\n  if (IsProcessed(game)) {\n    return game;\n  }\n\n  if (game.name === undefined) game.name = 'default';\n  if (game.deltaState === undefined) game.deltaState = false;\n  if (game.disableUndo === undefined) game.disableUndo = false;\n  if (game.setup === undefined) game.setup = () => ({});\n  if (game.moves === undefined) game.moves = {};\n  if (game.playerView === undefined) game.playerView = ({ G }) => G;\n  if (game.plugins === undefined) game.plugins = [];\n\n  game.plugins.forEach((plugin) => {\n    if (plugin.name === undefined) {\n      throw new Error('Plugin missing name attribute');\n    }\n    if (plugin.name.includes(' ')) {\n      throw new Error(plugin.name + ': Plugin name must not include spaces');\n    }\n  });\n\n  if (game.name.includes(' ')) {\n    throw new Error(game.name + ': Game name must not include spaces');\n  }\n\n  const flow = Flow(game);\n\n  return {\n    ...game,\n\n    flow,\n\n    moveNames: flow.moveNames as string[],\n\n    pluginNames: game.plugins.map((p) => p.name) as string[],\n\n    processMove: (state: State, action: ActionPayload.MakeMove) => {\n      let moveFn = flow.getMove(state.ctx, action.type, action.playerID);\n\n      if (IsLongFormMove(moveFn)) {\n        moveFn = moveFn.move;\n      }\n\n      if (moveFn instanceof Function) {\n        const fn = plugins.FnWrap(moveFn, GameMethod.MOVE, game.plugins);\n        let args = [];\n        if (action.args !== undefined) {\n          args = Array.isArray(action.args) ? action.args : [action.args];\n        }\n        const context = {\n          ...plugins.GetAPIs(state),\n          G: state.G,\n          ctx: state.ctx,\n          playerID: action.playerID,\n        };\n        return fn(context, ...args);\n      }\n\n      logging.error(`invalid move object: ${action.type}`);\n\n      return state.G;\n    },\n  };\n}\n\nexport function IsLongFormMove(move: Move): move is LongFormMove {\n  return move instanceof Object && (move as LongFormMove).move !== undefined;\n}\n"
  },
  {
    "path": "src/core/initialize.ts",
    "content": "/*\n * Copyright 2020 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { ProcessGameConfig } from './game';\nimport * as plugins from '../plugins/main';\nimport type { Ctx, Game, PartialGameState, State } from '../types';\n\n/**\n * Creates the initial game state.\n */\nexport function InitializeGame({\n  game,\n  numPlayers,\n  setupData,\n}: {\n  game: Game;\n  numPlayers?: number;\n  setupData?: any;\n}) {\n  game = ProcessGameConfig(game);\n\n  if (!numPlayers) {\n    numPlayers = 2;\n  }\n\n  const ctx: Ctx = game.flow.ctx(numPlayers);\n\n  let state: PartialGameState = {\n    // User managed state.\n    G: {},\n    // Framework managed state.\n    ctx,\n    // Plugin related state.\n    plugins: {},\n  };\n\n  // Run plugins over initial state.\n  state = plugins.Setup(state, { game });\n  state = plugins.Enhance(state, { game, playerID: undefined });\n\n  const pluginAPIs = plugins.GetAPIs(state);\n  state.G = game.setup({ ...pluginAPIs, ctx: state.ctx }, setupData);\n\n  let initial: State = {\n    ...state,\n\n    // List of {G, ctx} pairs that can be undone.\n    _undo: [],\n    // List of {G, ctx} pairs that can be redone.\n    _redo: [],\n    // A monotonically non-decreasing ID to ensure that\n    // state updates are only allowed from clients that\n    // are at the same version that the server.\n    _stateID: 0,\n  };\n\n  initial = game.flow.init(initial);\n  [initial] = plugins.FlushAndValidate(initial, { game });\n\n  // Initialize undo stack.\n  if (!game.disableUndo) {\n    initial._undo = [\n      {\n        G: initial.G,\n        ctx: initial.ctx,\n        plugins: initial.plugins,\n      },\n    ];\n  }\n\n  return initial;\n}\n"
  },
  {
    "path": "src/core/logger.test.js",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\ndescribe('logging', () => {\n  const oldConsoleLog = console.log;\n  const oldConsoleError = console.error;\n  const oldNodeEnv = process.env.NODE_ENV;\n\n  beforeEach(() => {\n    console.log.mockReset();\n    console.error.mockReset();\n  });\n\n  afterAll(() => {\n    console.log = oldConsoleLog;\n    console.error = oldConsoleError;\n    process.env.NODE_ENV = oldNodeEnv;\n  });\n\n  console.log = jest.fn();\n  console.error = jest.fn();\n\n  describe('dev', () => {\n    let logging;\n\n    beforeAll(() => {\n      logging = require('./logger');\n    });\n\n    test('error', () => {\n      logging.error('msg1');\n      expect(console.error).toHaveBeenCalledWith('ERROR:', 'msg1');\n    });\n\n    test('info', () => {\n      logging.info('msg2');\n      expect(console.log).toHaveBeenCalledWith('INFO: msg2');\n    });\n  });\n\n  describe('production', () => {\n    let logging;\n\n    beforeAll(() => {\n      process.env.NODE_ENV = 'production';\n      jest.resetModules();\n      logging = require('./logger');\n    });\n    afterAll(() => {\n      process.env.NODE_ENV = oldNodeEnv;\n    });\n\n    test('info stripped', () => {\n      logging.info('msg2');\n      expect(console.log).not.toHaveBeenCalled();\n    });\n\n    test('error not stripped', () => {\n      logging.error('msg1');\n      expect(console.error).toHaveBeenCalled();\n    });\n  });\n\n  describe('spying after load', () => {\n    let logging;\n\n    beforeAll(() => {\n      jest.resetModules();\n      console.log = oldConsoleLog;\n      console.error = oldConsoleError;\n      logging = require('./logger');\n      console.log = jest.fn();\n      console.error = jest.fn();\n    });\n\n    test('should allow console log to be spied', () => {\n      logging.info('test');\n      expect(console.log).toHaveBeenCalledWith('INFO: test');\n    });\n    test('should allow console error to be spied', () => {\n      logging.error('test');\n      expect(console.error).toHaveBeenCalledWith('ERROR:', 'test');\n    });\n  });\n});\n"
  },
  {
    "path": "src/core/logger.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nconst production = process.env.NODE_ENV === 'production';\nconst logfn = production ? () => {} : (...msg) => console.log(...msg);\nconst errorfn = (...msg) => console.error(...msg);\n\nexport function info(msg: string) {\n  logfn(`INFO: ${msg}`);\n}\nexport function error(error: string) {\n  errorfn('ERROR:', error);\n}\n"
  },
  {
    "path": "src/core/player-view.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { PlayerView } from './player-view';\nimport type { Ctx } from '../types';\n\ntest('no change', () => {\n  const G = { test: true };\n  const newG = PlayerView.STRIP_SECRETS({ G, ctx: {} as Ctx, playerID: '0' });\n  expect(newG).toEqual(G);\n});\n\ntest('secret', () => {\n  const G = { secret: true };\n  const newG = PlayerView.STRIP_SECRETS({ G, ctx: {} as Ctx, playerID: '0' });\n  expect(newG).toEqual({});\n});\n\ndescribe('players', () => {\n  const G = {\n    players: {\n      '0': {},\n      '1': {},\n    },\n  };\n\n  test('playerID: \"0\"', () => {\n    const newG = PlayerView.STRIP_SECRETS({ G, ctx: {} as Ctx, playerID: '0' });\n    expect(newG.players).toEqual({ '0': {} });\n  });\n\n  test('playerID: \"1\"', () => {\n    const newG = PlayerView.STRIP_SECRETS({ G, ctx: {} as Ctx, playerID: '1' });\n    expect(newG.players).toEqual({ '1': {} });\n  });\n\n  test('playerID: null', () => {\n    const newG = PlayerView.STRIP_SECRETS({\n      G,\n      ctx: {} as Ctx,\n      playerID: null,\n    });\n    expect(newG.players).toEqual({});\n  });\n});\n"
  },
  {
    "path": "src/core/player-view.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { Game, PlayerID } from '../types';\n\n/**\n * PlayerView reducers.\n */\nexport const PlayerView: { STRIP_SECRETS: Game['playerView'] } = {\n  /**\n   * STRIP_SECRETS\n   *\n   * Reducer which removes a key named `secret` and\n   * removes all the keys in `players`, except for the one\n   * corresponding to the current playerID.\n   */\n  STRIP_SECRETS: ({ G, playerID }: { G: any; playerID: PlayerID | null }) => {\n    const r = { ...G };\n\n    if (r.secret !== undefined) {\n      delete r.secret;\n    }\n\n    if (r.players) {\n      r.players = playerID\n        ? {\n            [playerID]: r.players[playerID],\n          }\n        : {};\n    }\n\n    return r;\n  },\n};\n"
  },
  {
    "path": "src/core/reducer.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { INVALID_MOVE } from './constants';\nimport { applyMiddleware, createStore } from 'redux';\nimport { CreateGameReducer, TransientHandlingMiddleware } from './reducer';\nimport { InitializeGame } from './initialize';\nimport {\n  makeMove,\n  gameEvent,\n  sync,\n  update,\n  reset,\n  undo,\n  redo,\n  patch,\n} from './action-creators';\nimport { error } from '../core/logger';\nimport type { Game, State, SyncInfo } from '../types';\n\njest.mock('../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\nconst game: Game = {\n  moves: {\n    A: ({ G }) => G,\n    B: () => ({ moved: true }),\n    C: () => ({ victory: true }),\n    Invalid: () => INVALID_MOVE,\n  },\n  endIf: ({ G, ctx }) => (G.victory ? ctx.currentPlayer : undefined),\n};\nconst reducer = CreateGameReducer({ game });\nconst initialState = InitializeGame({ game });\n\ntest('_stateID is incremented', () => {\n  let state = initialState;\n  state = reducer(state, makeMove('A'));\n  expect(state._stateID).toBe(1);\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state._stateID).toBe(2);\n});\n\ntest('move returns INVALID_MOVE', () => {\n  const game: Game = {\n    moves: {\n      A: () => INVALID_MOVE,\n    },\n  };\n  const reducer = CreateGameReducer({ game });\n  const state = reducer(initialState, makeMove('A'));\n  expect(error).toBeCalledWith('invalid move: A args: undefined');\n  expect(state._stateID).toBe(0);\n});\n\ntest('makeMove', () => {\n  let state = initialState;\n  expect(state._stateID).toBe(0);\n\n  state = reducer(state, makeMove('unknown'));\n  expect(state._stateID).toBe(0);\n  expect(state.G).not.toMatchObject({ moved: true });\n  expect(error).toBeCalledWith('disallowed move: unknown');\n\n  state = reducer(state, makeMove('A'));\n  expect(state._stateID).toBe(1);\n  expect(state.G).not.toMatchObject({ moved: true });\n\n  state = reducer(state, makeMove('B'));\n  expect(state._stateID).toBe(2);\n  expect(state.G).toMatchObject({ moved: true });\n\n  state.ctx.gameover = true;\n\n  state = reducer(state, makeMove('B'));\n  expect(state._stateID).toBe(2);\n  expect(error).toBeCalledWith('cannot make move after game end');\n\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state._stateID).toBe(2);\n  expect(error).toBeCalledWith('cannot call event after game end');\n});\n\ntest('disable move by invalid playerIDs', () => {\n  let state = initialState;\n  expect(state._stateID).toBe(0);\n\n  // playerID=\"1\" cannot move right now.\n  state = reducer(state, makeMove('A', null, '1'));\n  expect(state._stateID).toBe(0);\n\n  // playerID=\"1\" cannot call events right now.\n  state = reducer(state, gameEvent('endTurn', null, '1'));\n  expect(state._stateID).toBe(0);\n\n  // playerID=\"0\" can move.\n  state = reducer(state, makeMove('A', null, '0'));\n  expect(state._stateID).toBe(1);\n\n  // playerID=undefined can always move.\n  state = reducer(state, makeMove('A'));\n  expect(state._stateID).toBe(2);\n});\n\ntest('sync', () => {\n  const state = reducer(\n    undefined,\n    sync({ state: { G: 'restored' } } as SyncInfo)\n  );\n  expect(state).toEqual({ G: 'restored' });\n});\n\ntest('update', () => {\n  const state = reducer(undefined, update({ G: 'restored' } as State, []));\n  expect(state).toEqual({ G: 'restored' });\n});\n\ntest('valid patch', () => {\n  const originalState = { _stateID: 0, G: 'patch' } as State;\n  const state = reducer(\n    originalState,\n    patch(0, 1, [{ op: 'replace', path: '/_stateID', value: 1 }], [])\n  );\n  expect(state).toEqual({ _stateID: 1, G: 'patch' });\n});\n\ntest('invalid patch', () => {\n  const originalState = { _stateID: 0, G: 'patch' } as State;\n  const { transients, ...state } = reducer(\n    originalState,\n    patch(0, 1, [{ op: 'replace', path: '/_stateIDD', value: 1 }], [])\n  );\n  expect(state).toEqual(originalState);\n  expect(transients.error.type).toEqual('update/patch_failed');\n  // It's an array.\n  expect(transients.error.payload.length).toEqual(1);\n  // It looks like the standard rfc6902 error language.\n  expect(transients.error.payload[0].toString()).toContain('/_stateIDD');\n});\n\ntest('reset', () => {\n  let state = reducer(initialState, makeMove('A'));\n  expect(state).not.toEqual(initialState);\n  state = reducer(state, reset(initialState));\n  expect(state).toEqual(initialState);\n});\n\ntest('victory', () => {\n  let state = reducer(initialState, makeMove('A'));\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state.ctx.gameover).toEqual(undefined);\n  state = reducer(state, makeMove('B'));\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state.ctx.gameover).toEqual(undefined);\n  state = reducer(state, makeMove('C'));\n  expect(state.ctx.gameover).toEqual('0');\n});\n\ntest('endTurn', () => {\n  {\n    const state = reducer(initialState, gameEvent('endTurn'));\n    expect(state.ctx.turn).toBe(2);\n  }\n\n  {\n    const reducer = CreateGameReducer({ game, isClient: true });\n    const state = reducer(initialState, gameEvent('endTurn'));\n    expect(state.ctx.turn).toBe(1);\n  }\n});\n\ntest('light client when multiplayer=true', () => {\n  const game: Game = {\n    moves: { A: () => ({ win: true }) },\n    endIf: ({ G }) => G.win,\n  };\n\n  {\n    const reducer = CreateGameReducer({ game });\n    let state = InitializeGame({ game });\n    expect(state.ctx.gameover).toBe(undefined);\n    state = reducer(state, makeMove('A'));\n    expect(state.ctx.gameover).toBe(true);\n  }\n\n  {\n    const reducer = CreateGameReducer({ game, isClient: true });\n    let state = InitializeGame({ game });\n    expect(state.ctx.gameover).toBe(undefined);\n    state = reducer(state, makeMove('A'));\n    expect(state.ctx.gameover).toBe(undefined);\n  }\n});\n\ntest('disable optimistic updates', () => {\n  const game: Game = {\n    moves: {\n      A: {\n        move: () => ({ A: true }),\n        client: false,\n      },\n    },\n  };\n\n  {\n    const reducer = CreateGameReducer({ game });\n    let state = InitializeGame({ game });\n    expect(state.G).not.toMatchObject({ A: true });\n    state = reducer(state, makeMove('A'));\n    expect(state.G).toMatchObject({ A: true });\n  }\n\n  {\n    const reducer = CreateGameReducer({ game, isClient: true });\n    let state = InitializeGame({ game });\n    expect(state.G).not.toMatchObject({ A: true });\n    state = reducer(state, makeMove('A'));\n    expect(state.G).not.toMatchObject({ A: true });\n  }\n});\n\ntest('numPlayers', () => {\n  const numPlayers = 4;\n  const state = InitializeGame({ game, numPlayers });\n  expect(state.ctx.numPlayers).toBe(4);\n});\n\ntest('deltalog', () => {\n  let state = initialState;\n\n  const actionA = makeMove('A');\n  const actionB = makeMove('B');\n  const actionC = gameEvent('endTurn');\n\n  state = reducer(state, actionA);\n  expect(state.deltalog).toEqual([\n    {\n      action: actionA,\n      _stateID: 0,\n      phase: null,\n      turn: 1,\n    },\n  ]);\n  state = reducer(state, actionB);\n  expect(state.deltalog).toEqual([\n    {\n      action: actionB,\n      _stateID: 1,\n      phase: null,\n      turn: 1,\n    },\n  ]);\n  state = reducer(state, actionC);\n  expect(state.deltalog).toEqual([\n    {\n      action: actionC,\n      _stateID: 2,\n      phase: null,\n      turn: 1,\n    },\n  ]);\n});\n\ndescribe('Events API', () => {\n  const fn = ({ events }) => (events ? {} : { error: true });\n\n  const game: Game = {\n    setup: () => ({}),\n    phases: { A: {} },\n    turn: {\n      onBegin: fn,\n      onEnd: fn,\n      onMove: fn,\n    },\n  };\n\n  const reducer = CreateGameReducer({ game });\n  let state = InitializeGame({ game });\n\n  test('is attached at the beginning', () => {\n    expect(state.G).not.toEqual({ error: true });\n  });\n\n  test('is attached at the end of turns', () => {\n    state = reducer(state, gameEvent('endTurn'));\n    expect(state.G).not.toEqual({ error: true });\n  });\n\n  test('is attached at the end of phases', () => {\n    state = reducer(state, gameEvent('endPhase'));\n    expect(state.G).not.toEqual({ error: true });\n  });\n});\n\ndescribe('Plugin Invalid Action API', () => {\n  const pluginName = 'validator';\n  const message = 'G.value must divide by 5';\n  const game: Game<{ value: number }> = {\n    setup: () => ({ value: 5 }),\n    plugins: [\n      {\n        name: pluginName,\n        isInvalid: ({ G }) => {\n          if (G.value % 5 !== 0) return message;\n          return false;\n        },\n      },\n    ],\n    moves: {\n      setValue: ({ G }, arg: number) => {\n        G.value = arg;\n      },\n    },\n    phases: {\n      unenterable: {\n        onBegin: () => ({ value: 13 }),\n      },\n      enterable: {\n        onBegin: () => ({ value: 25 }),\n      },\n    },\n  };\n\n  let state: State;\n  beforeEach(() => {\n    state = InitializeGame({ game });\n  });\n\n  describe('multiplayer client', () => {\n    const reducer = CreateGameReducer({ game });\n\n    test('move is cancelled if plugin declares it invalid', () => {\n      state = reducer(state, makeMove('setValue', [6], '0'));\n      expect(state.G).toMatchObject({ value: 5 });\n      expect(state['transients'].error).toEqual({\n        type: 'action/plugin_invalid',\n        payload: { plugin: pluginName, message },\n      });\n    });\n\n    test('move is processed if no plugin declares it invalid', () => {\n      state = reducer(state, makeMove('setValue', [15], '0'));\n      expect(state.G).toMatchObject({ value: 15 });\n      expect(state['transients']).toBeUndefined();\n    });\n\n    test('event is cancelled if plugin declares it invalid', () => {\n      state = reducer(state, gameEvent('setPhase', 'unenterable', '0'));\n      expect(state.G).toMatchObject({ value: 5 });\n      expect(state.ctx.phase).toBe(null);\n      expect(state['transients'].error).toEqual({\n        type: 'action/plugin_invalid',\n        payload: { plugin: pluginName, message },\n      });\n    });\n\n    test('event is processed if no plugin declares it invalid', () => {\n      state = reducer(state, gameEvent('setPhase', 'enterable', '0'));\n      expect(state.G).toMatchObject({ value: 25 });\n      expect(state.ctx.phase).toBe('enterable');\n      expect(state['transients']).toBeUndefined();\n    });\n  });\n\n  describe('local client', () => {\n    const reducer = CreateGameReducer({ game, isClient: true });\n\n    test('move is cancelled if plugin declares it invalid', () => {\n      state = reducer(state, makeMove('setValue', [6], '0'));\n      expect(state.G).toMatchObject({ value: 5 });\n      expect(state['transients'].error).toEqual({\n        type: 'action/plugin_invalid',\n        payload: { plugin: pluginName, message },\n      });\n    });\n\n    test('move is processed if no plugin declares it invalid', () => {\n      state = reducer(state, makeMove('setValue', [15], '0'));\n      expect(state.G).toMatchObject({ value: 15 });\n      expect(state['transients']).toBeUndefined();\n    });\n  });\n});\n\ndescribe('Random inside setup()', () => {\n  const game1: Game = {\n    seed: 'seed1',\n    setup: (ctx) => ({ n: ctx.random.D6() }),\n  };\n\n  const game2: Game = {\n    seed: 'seed2',\n    setup: (ctx) => ({ n: ctx.random.D6() }),\n  };\n\n  const game3: Game = {\n    seed: 'seed2',\n    setup: (ctx) => ({ n: ctx.random.D6() }),\n  };\n\n  test('setting seed', () => {\n    const state1 = InitializeGame({ game: game1 });\n    const state2 = InitializeGame({ game: game2 });\n    const state3 = InitializeGame({ game: game3 });\n\n    expect(state1.G.n).not.toBe(state2.G.n);\n    expect(state2.G.n).toBe(state3.G.n);\n  });\n});\n\ndescribe('redact', () => {\n  const game: Game = {\n    setup: () => ({\n      isASecret: false,\n    }),\n    moves: {\n      A: {\n        move: ({ G }) => G,\n        redact: ({ G }) => G.isASecret,\n      },\n      B: ({ G }) => {\n        return { ...G, isASecret: true };\n      },\n    },\n  };\n\n  const reducer = CreateGameReducer({ game });\n\n  let state = InitializeGame({ game });\n\n  test('move A is not secret and is not redact', () => {\n    state = reducer(state, makeMove('A', ['not redact'], '0'));\n    expect(state.G).toMatchObject({\n      isASecret: false,\n    });\n    const [lastLogEntry] = state.deltalog.slice(-1);\n    expect(lastLogEntry).toMatchObject({\n      action: {\n        payload: {\n          type: 'A',\n          args: ['not redact'],\n        },\n      },\n      redact: false,\n    });\n  });\n\n  test('move A is secret and is redact', () => {\n    state = reducer(state, makeMove('B', ['not redact'], '0'));\n    state = reducer(state, makeMove('A', ['redact'], '0'));\n    expect(state.G).toMatchObject({\n      isASecret: true,\n    });\n    const [lastLogEntry] = state.deltalog.slice(-1);\n    expect(lastLogEntry).toMatchObject({\n      action: {\n        payload: {\n          type: 'A',\n          args: ['redact'],\n        },\n      },\n      redact: true,\n    });\n  });\n});\n\ndescribe('undo / redo', () => {\n  const game: Game = {\n    seed: 0,\n    moves: {\n      move: ({ G }, arg: string) => ({ ...G, [arg]: true }),\n      roll: ({ G, random }) => {\n        G.roll = random.D6();\n      },\n    },\n    turn: {\n      stages: {\n        special: {},\n      },\n    },\n  };\n\n  beforeEach(() => {\n    jest.clearAllMocks();\n  });\n\n  const reducer = CreateGameReducer({ game });\n\n  const initialState = InitializeGame({ game });\n\n  // TODO: Check if this test is still actually required after removal of APIs from ctx\n  test('plugin APIs are not included in undo state', () => {\n    let state = reducer(initialState, makeMove('move', 'A', '0'));\n    state = reducer(state, makeMove('move', 'B', '0'));\n    expect(state.G).toMatchObject({ A: true, B: true });\n    expect(state._undo[1].ctx).not.toHaveProperty('events');\n    expect(state._undo[1].ctx).not.toHaveProperty('random');\n  });\n\n  test('undo restores previous state after move', () => {\n    const initial = reducer(initialState, makeMove('move', 'A', '0'));\n    let newState = reducer(initial, makeMove('roll', null, '0'));\n    newState = reducer(newState, undo());\n    expect(newState.G).toEqual(initial.G);\n    expect(newState.ctx).toEqual(initial.ctx);\n    expect(newState.plugins).toEqual(initial.plugins);\n  });\n\n  test('undo restores previous state after event', () => {\n    const initial = reducer(\n      initialState,\n      gameEvent('setStage', 'special', '0')\n    );\n    let newState = reducer(initial, gameEvent('endStage', undefined, '0'));\n    expect(error).not.toBeCalled();\n    // Make sure we actually modified the stage.\n    expect(newState.ctx.activePlayers).not.toEqual(initial.ctx.activePlayers);\n    newState = reducer(newState, undo());\n    expect(error).not.toBeCalled();\n    expect(newState.G).toEqual(initial.G);\n    expect(newState.ctx).toEqual(initial.ctx);\n    expect(newState.plugins).toEqual(initial.plugins);\n  });\n\n  test('redo restores undone state', () => {\n    let state = initialState;\n    // Make two moves.\n    const state1 = (state = reducer(state, makeMove('move', 'A', '0')));\n    const state2 = (state = reducer(state, makeMove('roll', null, '0')));\n    // Undo both of them.\n    state = reducer(state, undo());\n    state = reducer(state, undo());\n    // Redo one of them.\n    state = reducer(state, redo());\n    expect(state.G).toEqual(state1.G);\n    expect(state.ctx).toEqual(state1.ctx);\n    expect(state.plugins).toEqual(state1.plugins);\n    // Redo a second time.\n    state = reducer(state, redo());\n    expect(state.G).toEqual(state2.G);\n    expect(state.ctx).toEqual(state2.ctx);\n    expect(state.plugins).toEqual(state2.plugins);\n  });\n\n  test('can undo redone state', () => {\n    let state = reducer(initialState, makeMove('move', 'A', '0'));\n    state = reducer(state, undo());\n    state = reducer(state, redo());\n    state = reducer(state, undo());\n    expect(state.G).toMatchObject(initialState.G);\n    expect(state.ctx).toMatchObject(initialState.ctx);\n    expect(state.plugins).toMatchObject(initialState.plugins);\n  });\n\n  test('undo has no effect if nothing to undo', () => {\n    let state = reducer(initialState, undo());\n    state = reducer(state, undo());\n    state = reducer(state, undo());\n    expect(state.G).toMatchObject(initialState.G);\n    expect(state.ctx).toMatchObject(initialState.ctx);\n    expect(state.plugins).toMatchObject(initialState.plugins);\n  });\n\n  test('redo works after multiple undos', () => {\n    let state = reducer(initialState, makeMove('move', 'A', '0'));\n    state = reducer(state, undo());\n    state = reducer(state, undo());\n    state = reducer(state, undo());\n    state = reducer(state, redo());\n    state = reducer(state, makeMove('move', 'C', '0'));\n    expect(state.G).toMatchObject({ A: true, C: true });\n\n    state = reducer(state, undo());\n    expect(state.G).toMatchObject({ A: true });\n\n    state = reducer(state, redo());\n    expect(state.G).toMatchObject({ A: true, C: true });\n  });\n\n  test('redo only resets deltalog if nothing to redo', () => {\n    const state = reducer(initialState, makeMove('move', 'A', '0'));\n    expect(reducer(state, redo())).toMatchObject({\n      ...state,\n      deltalog: [],\n      transients: {\n        error: {\n          type: 'action/action_invalid',\n        },\n      },\n    });\n  });\n});\n\ntest('disable undo / redo', () => {\n  const game: Game = {\n    seed: 0,\n    disableUndo: true,\n    moves: {\n      move: ({ G }, arg: string) => ({ ...G, [arg]: true }),\n    },\n  };\n\n  const reducer = CreateGameReducer({ game });\n\n  let state = InitializeGame({ game });\n\n  state = reducer(state, makeMove('move', 'A', '0'));\n  expect(state.G).toMatchObject({ A: true });\n  expect(state._undo).toEqual([]);\n  expect(state._redo).toEqual([]);\n\n  state = reducer(state, makeMove('move', 'B', '0'));\n  expect(state.G).toMatchObject({ A: true, B: true });\n  expect(state._undo).toEqual([]);\n  expect(state._redo).toEqual([]);\n\n  state = reducer(state, undo());\n  expect(state.G).toMatchObject({ A: true, B: true });\n  expect(state._undo).toEqual([]);\n  expect(state._redo).toEqual([]);\n\n  state = reducer(state, undo());\n  expect(state.G).toMatchObject({ A: true, B: true });\n  expect(state._undo).toEqual([]);\n  expect(state._redo).toEqual([]);\n\n  state = reducer(state, redo());\n  expect(state.G).toMatchObject({ A: true, B: true });\n  expect(state._undo).toEqual([]);\n  expect(state._redo).toEqual([]);\n});\n\ndescribe('undo stack', () => {\n  const game: Game = {\n    moves: {\n      basic: () => {},\n      endTurn: ({ events }) => {\n        events.endTurn();\n      },\n    },\n  };\n\n  const reducer = CreateGameReducer({ game });\n  let state = InitializeGame({ game });\n\n  test('contains initial state at start of game', () => {\n    expect(state._undo).toHaveLength(1);\n    expect(state._undo[0].ctx).toEqual(state.ctx);\n    expect(state._undo[0].plugins).toEqual(state.plugins);\n  });\n\n  test('grows when a move is made', () => {\n    state = reducer(state, makeMove('basic', null, '0'));\n    expect(state._undo).toHaveLength(2);\n    expect(state._undo[1].moveType).toBe('basic');\n    expect(state._undo[1].ctx).toEqual(state.ctx);\n    expect(state._undo[1].plugins).toEqual(state.plugins);\n  });\n\n  test('shrinks when a move is undone', () => {\n    state = reducer(state, undo());\n    expect(state._undo).toHaveLength(1);\n    expect(state._undo[0].ctx).toEqual(state.ctx);\n    expect(state._undo[0].plugins).toEqual(state.plugins);\n  });\n\n  test('grows when a move is redone', () => {\n    state = reducer(state, redo());\n    expect(state._undo).toHaveLength(2);\n    expect(state._undo[1].moveType).toBe('basic');\n    expect(state._undo[1].ctx).toEqual(state.ctx);\n    expect(state._undo[1].plugins).toEqual(state.plugins);\n  });\n\n  test('is reset when a turn ends', () => {\n    state = reducer(state, makeMove('endTurn'));\n    expect(state._undo).toHaveLength(1);\n    expect(state._undo[0].ctx).toEqual(state.ctx);\n    expect(state._undo[0].plugins).toEqual(state.plugins);\n    expect(state._undo[0].moveType).toBe('endTurn');\n  });\n\n  test('can’t undo at the start of a turn', () => {\n    const newState = reducer(state, undo());\n    expect(newState).toMatchObject({\n      ...state,\n      deltalog: [],\n      transients: {\n        error: {\n          type: 'action/action_invalid',\n        },\n      },\n    });\n  });\n\n  test('can’t undo another player’s move', () => {\n    state = reducer(state, makeMove('basic', null, '1'));\n    const newState = reducer(state, undo('0'));\n    expect(newState).toMatchObject({\n      ...state,\n      deltalog: [],\n      transients: {\n        error: {\n          type: 'action/action_invalid',\n        },\n      },\n    });\n  });\n});\n\ndescribe('redo stack', () => {\n  const game: Game = {\n    moves: {\n      basic: () => {},\n      endTurn: ({ events }) => {\n        events.endTurn();\n      },\n    },\n  };\n\n  const reducer = CreateGameReducer({ game });\n  let state = InitializeGame({ game });\n\n  test('is empty at start of game', () => {\n    expect(state._redo).toHaveLength(0);\n  });\n\n  test('grows when a move is undone', () => {\n    state = reducer(state, makeMove('basic', null, '0'));\n    state = reducer(state, undo());\n    expect(state._redo).toHaveLength(1);\n    expect(state._redo[0].moveType).toBe('basic');\n  });\n\n  test('shrinks when a move is redone', () => {\n    state = reducer(state, redo());\n    expect(state._redo).toHaveLength(0);\n  });\n\n  test('is reset when a move is made', () => {\n    state = reducer(state, makeMove('basic', null, '0'));\n    state = reducer(state, undo());\n    state = reducer(state, undo());\n    expect(state._redo).toHaveLength(2);\n    state = reducer(state, makeMove('basic', null, '0'));\n    expect(state._redo).toHaveLength(0);\n  });\n\n  test('is reset when a turn ends', () => {\n    state = reducer(state, makeMove('basic', null, '0'));\n    state = reducer(state, undo());\n    expect(state._redo).toHaveLength(1);\n    state = reducer(state, makeMove('endTurn'));\n    expect(state._redo).toHaveLength(0);\n  });\n\n  test('can’t redo another player’s undo', () => {\n    state = reducer(state, makeMove('basic', null, '1'));\n    state = reducer(state, undo('1'));\n    expect(state._redo).toHaveLength(1);\n    const newState = reducer(state, redo('0'));\n    expect(state._redo).toHaveLength(1);\n    expect(newState).toMatchObject({\n      ...state,\n      deltalog: [],\n      transients: {\n        error: {\n          type: 'action/action_invalid',\n        },\n      },\n    });\n  });\n});\n\ndescribe('undo / redo with stages', () => {\n  const game: Game = {\n    setup: () => ({ A: false, B: false, C: false }),\n    turn: {\n      activePlayers: { currentPlayer: 'start' },\n      stages: {\n        start: {\n          moves: {\n            moveA: {\n              move: ({ G, events }, moveAisReversible) => {\n                events.setStage('A');\n                return { ...G, moveAisReversible, A: true };\n              },\n              undoable: ({ G }) => G.moveAisReversible > 0,\n            },\n          },\n        },\n        A: {\n          moves: {\n            moveB: {\n              move: ({ G, events }) => {\n                events.setStage('B');\n                return { ...G, B: true };\n              },\n              undoable: false,\n            },\n          },\n        },\n        B: {\n          moves: {\n            moveC: {\n              move: ({ G, events }) => {\n                events.setStage('C');\n                return { ...G, C: true };\n              },\n              undoable: true,\n            },\n          },\n        },\n        C: {\n          moves: {},\n        },\n      },\n    },\n  };\n\n  const reducer = CreateGameReducer({ game });\n\n  let state = InitializeGame({ game });\n\n  test('moveA sets state & moves player to stage A (undoable)', () => {\n    state = reducer(state, makeMove('moveA', true, '0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: true,\n      A: true,\n      B: false,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('A');\n  });\n\n  test('undo undoes last move (moveA)', () => {\n    state = reducer(state, undo('0'));\n    expect(state.G).toMatchObject({\n      A: false,\n      B: false,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('start');\n  });\n\n  test('redo redoes moveA', () => {\n    state = reducer(state, redo('0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: true,\n      A: true,\n      B: false,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('A');\n  });\n\n  test('undo undoes last move after redo (moveA)', () => {\n    state = reducer(state, undo('0'));\n    expect(state.G).toMatchObject({\n      A: false,\n      B: false,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('start');\n  });\n\n  test('moveA sets state & moves player to stage A (not undoable)', () => {\n    state = reducer(state, makeMove('moveA', false, '0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: false,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('A');\n  });\n\n  test('moveB sets state & moves player to stage B', () => {\n    state = reducer(state, makeMove('moveB', [], '0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('B');\n  });\n\n  test('undo doesn’t undo last move if not undoable (moveB)', () => {\n    state = reducer(state, undo('0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('B');\n  });\n\n  test('moveC sets state & moves player to stage C', () => {\n    state = reducer(state, makeMove('moveC', [], '0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: true,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('C');\n  });\n\n  test('undo undoes last move (moveC)', () => {\n    state = reducer(state, undo('0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('B');\n  });\n\n  test('redo redoes moveC', () => {\n    state = reducer(state, redo('0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: true,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('C');\n  });\n\n  test('undo undoes last move after redo (moveC)', () => {\n    state = reducer(state, undo('0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('B');\n  });\n\n  test('undo doesn’t undo last move if not undoable after undo/redo', () => {\n    state = reducer(state, undo('0'));\n    expect(state.G).toMatchObject({\n      moveAisReversible: false,\n      A: true,\n      B: true,\n      C: false,\n    });\n    expect(state.ctx.activePlayers['0']).toBe('B');\n  });\n});\n\ndescribe('TransientHandlingMiddleware', () => {\n  const middleware = applyMiddleware(TransientHandlingMiddleware);\n  let store = null;\n\n  beforeEach(() => {\n    store = createStore(reducer, initialState, middleware);\n  });\n\n  test('regular dispatch result has no transients', () => {\n    const result = store.dispatch(makeMove('A'));\n    expect(result).toEqual(\n      expect.not.objectContaining({ transients: expect.anything() })\n    );\n    expect(result).toEqual(\n      expect.not.objectContaining({ stripTransientsResult: expect.anything() })\n    );\n  });\n\n  test('failing dispatch result contains transients', () => {\n    const result = store.dispatch(makeMove('Invalid'));\n    expect(result).toMatchObject({\n      transients: {\n        error: {\n          type: 'action/invalid_move',\n        },\n      },\n    });\n  });\n});\n"
  },
  {
    "path": "src/core/reducer.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport * as Actions from './action-types';\nimport * as plugins from '../plugins/main';\nimport { ProcessGameConfig } from './game';\nimport { error } from './logger';\nimport { INVALID_MOVE } from './constants';\nimport type { Dispatch } from 'redux';\nimport type {\n  ActionShape,\n  Ctx,\n  ErrorType,\n  Game,\n  LogEntry,\n  LongFormMove,\n  Move,\n  State,\n  Store,\n  TransientMetadata,\n  TransientState,\n  Undo,\n} from '../types';\nimport { stripTransients } from './action-creators';\nimport { ActionErrorType, UpdateErrorType } from './errors';\nimport { applyPatch } from 'rfc6902';\n\n/**\n * Check if the payload for the passed action contains a playerID.\n */\nconst actionHasPlayerID = (\n  action:\n    | ActionShape.MakeMove\n    | ActionShape.GameEvent\n    | ActionShape.Undo\n    | ActionShape.Redo\n) => action.payload.playerID !== null && action.payload.playerID !== undefined;\n\n/**\n * Returns true if a move can be undone.\n */\nconst CanUndoMove = (G: any, ctx: Ctx, move: Move): boolean => {\n  function HasUndoable(move: Move): move is LongFormMove {\n    return (move as LongFormMove).undoable !== undefined;\n  }\n\n  function IsFunction(\n    undoable: boolean | ((...args: any[]) => any)\n  ): undoable is (...args: any[]) => any {\n    return undoable instanceof Function;\n  }\n\n  if (!HasUndoable(move)) {\n    return true;\n  }\n\n  if (IsFunction(move.undoable)) {\n    return move.undoable({ G, ctx });\n  }\n\n  return move.undoable;\n};\n\n/**\n * Update the undo and redo stacks for a move or event.\n */\nfunction updateUndoRedoState(\n  state: State,\n  opts: {\n    game: Game;\n    action: ActionShape.GameEvent | ActionShape.MakeMove;\n  }\n): State {\n  if (opts.game.disableUndo) return state;\n\n  const undoEntry: Undo = {\n    G: state.G,\n    ctx: state.ctx,\n    plugins: state.plugins,\n    playerID: opts.action.payload.playerID || state.ctx.currentPlayer,\n  };\n\n  if (opts.action.type === 'MAKE_MOVE') {\n    undoEntry.moveType = opts.action.payload.type;\n  }\n\n  return {\n    ...state,\n    _undo: [...state._undo, undoEntry],\n    // Always reset redo stack when making a move or event\n    _redo: [],\n  };\n}\n\n/**\n * Process state, adding the initial deltalog for this action.\n */\nfunction initializeDeltalog(\n  state: State,\n  action: ActionShape.MakeMove | ActionShape.Undo | ActionShape.Redo,\n  move?: Move\n): TransientState {\n  // Create a log entry for this action.\n  const logEntry: LogEntry = {\n    action,\n    _stateID: state._stateID,\n    turn: state.ctx.turn,\n    phase: state.ctx.phase,\n  };\n\n  const pluginLogMetadata = state.plugins.log.data.metadata;\n  if (pluginLogMetadata !== undefined) {\n    logEntry.metadata = pluginLogMetadata;\n  }\n\n  if (typeof move === 'object' && move.redact === true) {\n    logEntry.redact = true;\n  } else if (typeof move === 'object' && move.redact instanceof Function) {\n    logEntry.redact = move.redact({ G: state.G, ctx: state.ctx });\n  }\n\n  return {\n    ...state,\n    deltalog: [logEntry],\n  };\n}\n\n/**\n * Update plugin state after move/event & check if plugins consider the action to be valid.\n * @param state Current version of state in the reducer.\n * @param oldState State to revert to in case of error.\n * @param pluginOpts Plugin configuration options.\n * @returns Tuple of the new state updated after flushing plugins and the old\n * state augmented with an error if a plugin declared the action invalid.\n */\nfunction flushAndValidatePlugins(\n  state: State,\n  oldState: State,\n  pluginOpts: { game: Game; isClient?: boolean }\n): [State, TransientState?] {\n  const [newState, isInvalid] = plugins.FlushAndValidate(state, pluginOpts);\n  if (!isInvalid) return [newState];\n  return [\n    newState,\n    WithError(oldState, ActionErrorType.PluginActionInvalid, isInvalid),\n  ];\n}\n\n/**\n * ExtractTransientsFromState\n *\n * Split out transients from the a TransientState\n */\nfunction ExtractTransients(\n  transientState: TransientState | null\n): [State | null, TransientMetadata | undefined] {\n  if (!transientState) {\n    // We preserve null for the state for legacy callers, but the transient\n    // field should be undefined if not present to be consistent with the\n    // code path below.\n    return [null, undefined];\n  }\n  const { transients, ...state } = transientState;\n  return [state as State, transients as TransientMetadata];\n}\n\n/**\n * WithError\n *\n * Augment a State instance with transient error information.\n */\nfunction WithError<PT extends any = any>(\n  state: State,\n  errorType: ErrorType,\n  payload?: PT\n): TransientState {\n  const error = {\n    type: errorType,\n    payload,\n  };\n  return {\n    ...state,\n    transients: {\n      error,\n    },\n  };\n}\n\n/**\n * Middleware for processing TransientState associated with the reducer\n * returned by CreateGameReducer.\n * This should pretty much be used everywhere you want realistic state\n * transitions and error handling.\n */\nexport const TransientHandlingMiddleware =\n  (store: Store) =>\n  (next: Dispatch<ActionShape.Any>) =>\n  (action: ActionShape.Any) => {\n    const result = next(action);\n    switch (action.type) {\n      case Actions.STRIP_TRANSIENTS: {\n        return result;\n      }\n      default: {\n        const [, transients] = ExtractTransients(store.getState());\n        if (typeof transients !== 'undefined') {\n          store.dispatch(stripTransients());\n          // Dev Note: If parent middleware needs to correlate the spawned\n          // StripTransients action to the triggering action, instrument here.\n          //\n          // This is a bit tricky; for more details, see:\n          //   https://github.com/boardgameio/boardgame.io/pull/940#discussion_r636200648\n          return {\n            ...result,\n            transients,\n          };\n        }\n        return result;\n      }\n    }\n  };\n\n/**\n * CreateGameReducer\n *\n * Creates the main game state reducer.\n */\nexport function CreateGameReducer({\n  game,\n  isClient,\n}: {\n  game: Game;\n  isClient?: boolean;\n}) {\n  game = ProcessGameConfig(game);\n\n  /**\n   * GameReducer\n   *\n   * Redux reducer that maintains the overall game state.\n   * @param {object} state - The state before the action.\n   * @param {object} action - A Redux action.\n   */\n  return (\n    stateWithTransients: TransientState | null = null,\n    action: ActionShape.Any\n  ): TransientState => {\n    let [state /*, transients */] = ExtractTransients(stateWithTransients);\n    switch (action.type) {\n      case Actions.STRIP_TRANSIENTS: {\n        // This action indicates that transient metadata in the state has been\n        // consumed and should now be stripped from the state..\n        return state;\n      }\n\n      case Actions.GAME_EVENT: {\n        state = { ...state, deltalog: [] };\n\n        // Process game events only on the server.\n        // These events like `endTurn` typically\n        // contain code that may rely on secret state\n        // and cannot be computed on the client.\n        if (isClient) {\n          return state;\n        }\n\n        // Disallow events once the game is over.\n        if (state.ctx.gameover !== undefined) {\n          error(`cannot call event after game end`);\n          return WithError(state, ActionErrorType.GameOver);\n        }\n\n        // Ignore the event if the player isn't active.\n        if (\n          actionHasPlayerID(action) &&\n          !game.flow.isPlayerActive(state.G, state.ctx, action.payload.playerID)\n        ) {\n          error(`disallowed event: ${action.payload.type}`);\n          return WithError(state, ActionErrorType.InactivePlayer);\n        }\n\n        // Execute plugins.\n        state = plugins.Enhance(state, {\n          game,\n          isClient: false,\n          playerID: action.payload.playerID,\n        });\n\n        // Process event.\n        let newState = game.flow.processEvent(state, action);\n\n        // Execute plugins.\n        let stateWithError: TransientState | undefined;\n        [newState, stateWithError] = flushAndValidatePlugins(newState, state, {\n          game,\n          isClient: false,\n        });\n        if (stateWithError) return stateWithError;\n\n        // Update undo / redo state.\n        newState = updateUndoRedoState(newState, { game, action });\n\n        return { ...newState, _stateID: state._stateID + 1 };\n      }\n\n      case Actions.MAKE_MOVE: {\n        const oldState = (state = { ...state, deltalog: [] });\n\n        // Check whether the move is allowed at this time.\n        const move: Move = game.flow.getMove(\n          state.ctx,\n          action.payload.type,\n          action.payload.playerID || state.ctx.currentPlayer\n        );\n        if (move === null) {\n          error(`disallowed move: ${action.payload.type}`);\n          return WithError(state, ActionErrorType.UnavailableMove);\n        }\n\n        // Don't run move on client if move says so.\n        if (isClient && (move as LongFormMove).client === false) {\n          return state;\n        }\n\n        // Disallow moves once the game is over.\n        if (state.ctx.gameover !== undefined) {\n          error(`cannot make move after game end`);\n          return WithError(state, ActionErrorType.GameOver);\n        }\n\n        // Ignore the move if the player isn't active.\n        if (\n          actionHasPlayerID(action) &&\n          !game.flow.isPlayerActive(state.G, state.ctx, action.payload.playerID)\n        ) {\n          error(`disallowed move: ${action.payload.type}`);\n          return WithError(state, ActionErrorType.InactivePlayer);\n        }\n\n        // Execute plugins.\n        state = plugins.Enhance(state, {\n          game,\n          isClient,\n          playerID: action.payload.playerID,\n        });\n\n        // Process the move.\n        const G = game.processMove(state, action.payload);\n\n        // The game declared the move as invalid.\n        if (G === INVALID_MOVE) {\n          error(\n            `invalid move: ${action.payload.type} args: ${action.payload.args}`\n          );\n          // TODO(#723): Marshal a nice error payload with the processed move.\n          return WithError(state, ActionErrorType.InvalidMove);\n        }\n\n        const newState = { ...state, G };\n\n        // Some plugin indicated that it is not suitable to be\n        // materialized on the client (and must wait for the server\n        // response instead).\n        if (isClient && plugins.NoClient(newState, { game })) {\n          return state;\n        }\n\n        state = newState;\n\n        // If we're on the client, just process the move\n        // and no triggers in multiplayer mode.\n        // These will be processed on the server, which\n        // will send back a state update.\n        if (isClient) {\n          let stateWithError: TransientState | undefined;\n          [state, stateWithError] = flushAndValidatePlugins(state, oldState, {\n            game,\n            isClient: true,\n          });\n          if (stateWithError) return stateWithError;\n          return {\n            ...state,\n            _stateID: state._stateID + 1,\n          };\n        }\n\n        // On the server, construct the deltalog.\n        state = initializeDeltalog(state, action, move);\n\n        // Allow the flow reducer to process any triggers that happen after moves.\n        state = game.flow.processMove(state, action.payload);\n        let stateWithError: TransientState | undefined;\n        [state, stateWithError] = flushAndValidatePlugins(state, oldState, {\n          game,\n        });\n        if (stateWithError) return stateWithError;\n\n        // Update undo / redo state.\n        state = updateUndoRedoState(state, { game, action });\n\n        return {\n          ...state,\n          _stateID: state._stateID + 1,\n        };\n      }\n\n      case Actions.RESET:\n      case Actions.UPDATE:\n      case Actions.SYNC: {\n        return action.state;\n      }\n\n      case Actions.UNDO: {\n        state = { ...state, deltalog: [] };\n\n        if (game.disableUndo) {\n          error('Undo is not enabled');\n          return WithError(state, ActionErrorType.ActionDisabled);\n        }\n\n        const { G, ctx, _undo, _redo, _stateID } = state;\n\n        if (_undo.length < 2) {\n          error(`No moves to undo`);\n          return WithError(state, ActionErrorType.ActionInvalid);\n        }\n\n        const last = _undo[_undo.length - 1];\n        const restore = _undo[_undo.length - 2];\n\n        // Only allow players to undo their own moves.\n        if (\n          actionHasPlayerID(action) &&\n          action.payload.playerID !== last.playerID\n        ) {\n          error(`Cannot undo other players' moves`);\n          return WithError(state, ActionErrorType.ActionInvalid);\n        }\n\n        // If undoing a move, check it is undoable.\n        if (last.moveType) {\n          const lastMove: Move = game.flow.getMove(\n            restore.ctx,\n            last.moveType,\n            last.playerID\n          );\n          if (!CanUndoMove(G, ctx, lastMove)) {\n            error(`Move cannot be undone`);\n            return WithError(state, ActionErrorType.ActionInvalid);\n          }\n        }\n\n        state = initializeDeltalog(state, action);\n\n        return {\n          ...state,\n          G: restore.G,\n          ctx: restore.ctx,\n          plugins: restore.plugins,\n          _stateID: _stateID + 1,\n          _undo: _undo.slice(0, -1),\n          _redo: [last, ..._redo],\n        };\n      }\n\n      case Actions.REDO: {\n        state = { ...state, deltalog: [] };\n\n        if (game.disableUndo) {\n          error('Redo is not enabled');\n          return WithError(state, ActionErrorType.ActionDisabled);\n        }\n\n        const { _undo, _redo, _stateID } = state;\n\n        if (_redo.length === 0) {\n          error(`No moves to redo`);\n          return WithError(state, ActionErrorType.ActionInvalid);\n        }\n\n        const first = _redo[0];\n\n        // Only allow players to redo their own undos.\n        if (\n          actionHasPlayerID(action) &&\n          action.payload.playerID !== first.playerID\n        ) {\n          error(`Cannot redo other players' moves`);\n          return WithError(state, ActionErrorType.ActionInvalid);\n        }\n\n        state = initializeDeltalog(state, action);\n\n        return {\n          ...state,\n          G: first.G,\n          ctx: first.ctx,\n          plugins: first.plugins,\n          _stateID: _stateID + 1,\n          _undo: [..._undo, first],\n          _redo: _redo.slice(1),\n        };\n      }\n\n      case Actions.PLUGIN: {\n        // TODO(#723): Expose error semantics to plugin processing.\n        return plugins.ProcessAction(state, action, { game });\n      }\n\n      case Actions.PATCH: {\n        const oldState = state;\n        const newState = JSON.parse(JSON.stringify(oldState));\n        const patchError = applyPatch(newState, action.patch);\n        const hasError = patchError.some((entry) => entry !== null);\n        if (hasError) {\n          error(`Patch ${JSON.stringify(action.patch)} apply failed`);\n          return WithError(oldState, UpdateErrorType.PatchFailed, patchError);\n        } else {\n          return newState;\n        }\n      }\n      default: {\n        return state;\n      }\n    }\n  };\n}\n"
  },
  {
    "path": "src/core/turn-order.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Flow } from './flow';\nimport { Client } from '../client/client';\nimport {\n  UpdateTurnOrderState,\n  Stage,\n  TurnOrder,\n  ActivePlayers,\n} from './turn-order';\nimport { makeMove, gameEvent } from './action-creators';\nimport { CreateGameReducer } from './reducer';\nimport { InitializeGame } from './initialize';\nimport { error } from '../core/logger';\nimport type { Game, State } from '../types';\n\njest.mock('../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\n// Let the Typescript compiler know about our custom matcher.\ndeclare global {\n  namespace jest {\n    interface Matchers<R> {\n      toHaveUndefinedProperties(): R;\n    }\n  }\n}\n\ndescribe('turn orders', () => {\n  // Defines a matcher for testing that ctx has no undefined properties.\n  // Identifies which property is undefined.\n  expect.extend({\n    toHaveUndefinedProperties(ctx) {\n      const undefinedEntry = Object.entries(ctx).find((entry) => {\n        const [, value] = entry;\n        return value === undefined;\n      });\n      if (undefinedEntry === undefined) {\n        return {\n          message: () => `expected some properties of ctx to be undefined`,\n          pass: false,\n        };\n      } else {\n        const [k] = undefinedEntry;\n        return {\n          message: () => `expected ctx.${k} to be defined`,\n          pass: true,\n        };\n      }\n    },\n  });\n\n  test('DEFAULT', () => {\n    const flow = Flow({\n      phases: { A: { start: true, next: 'B' }, B: {} },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('0');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.phase).toBe('A');\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.phase).toBe('B');\n  });\n\n  test('CONTINUE', () => {\n    const flow = Flow({\n      turn: { order: TurnOrder.CONTINUE },\n      phases: { A: { start: true, next: 'B' }, B: {} },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('0');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.phase).toBe('A');\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.phase).toBe('B');\n  });\n\n  test('RESET', () => {\n    const flow = Flow({\n      turn: { order: TurnOrder.RESET },\n      phases: { A: { start: true, next: 'B' }, B: {} },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('0');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.phase).toBe('A');\n    state = flow.processEvent(state, gameEvent('endPhase'));\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.phase).toBe('B');\n  });\n\n  test('ONCE', () => {\n    const flow = Flow({\n      turn: { order: TurnOrder.ONCE },\n      phases: { A: { start: true, next: 'B' }, B: {} },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.phase).toBe('B');\n  });\n\n  test('ALL', () => {\n    const flow = Flow({\n      turn: { activePlayers: ActivePlayers.ALL },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(state.ctx.activePlayers).toEqual({\n      '0': Stage.NULL,\n      '1': Stage.NULL,\n    });\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.activePlayers).toEqual({\n      '0': Stage.NULL,\n      '1': Stage.NULL,\n    });\n  });\n\n  test('ALL_ONCE', () => {\n    const flow = Flow({\n      phases: {\n        A: { start: true, turn: { activePlayers: ActivePlayers.ALL_ONCE } },\n      },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '1']);\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '1']);\n\n    state = flow.processMove(state, makeMove('', null, '0').payload);\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['1']);\n\n    state = flow.processMove(state, makeMove('', null, '1').payload);\n\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.activePlayers).toBeNull();\n\n    state = flow.processMove(state, makeMove('', null, '1').payload);\n  });\n\n  test('OTHERS', () => {\n    const flow = Flow({\n      turn: { activePlayers: ActivePlayers.OTHERS },\n    });\n\n    let state = { ctx: flow.ctx(3) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['1', '2']);\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '2']);\n  });\n\n  test('OTHERS_ONCE', () => {\n    const flow = Flow({\n      turn: { activePlayers: ActivePlayers.OTHERS_ONCE },\n      phases: { A: { start: true } },\n    });\n\n    let state = { ctx: flow.ctx(3) } as State;\n    state = flow.init(state);\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['1', '2']);\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '2']);\n\n    state = flow.processMove(state, makeMove('', null, '0').payload);\n\n    expect(state.ctx.phase).toBe('A');\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['2']);\n\n    state = flow.processMove(state, makeMove('', null, '2').payload);\n\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx.activePlayers).toBeNull();\n\n    state = flow.processMove(state, makeMove('', null, '1').payload);\n  });\n\n  test('CUSTOM', () => {\n    const flow = Flow({\n      turn: { order: TurnOrder.CUSTOM(['1', '0']) },\n    });\n\n    let state = { ctx: flow.ctx(2) } as State;\n    state = flow.init(state);\n\n    expect(state.ctx.currentPlayer).toBe('1');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('0');\n  });\n\n  test('CUSTOM_FROM', () => {\n    const flow = Flow({\n      turn: { order: TurnOrder.CUSTOM_FROM('order') },\n    });\n\n    let state = { G: { order: ['2', '1', '0'] }, ctx: flow.ctx(3) } as State;\n    state = flow.init(state);\n\n    expect(state.ctx.currentPlayer).toBe('2');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('1');\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('0');\n  });\n\n  test('manual', () => {\n    const flow = Flow({\n      phases: {\n        A: {\n          start: true,\n          turn: {\n            order: {\n              first: () => 9,\n              next: () => 3,\n            },\n          },\n        },\n      },\n    });\n\n    let state = { ctx: flow.ctx(10) } as State;\n    state = flow.init(state);\n    expect(state.ctx.currentPlayer).toBe('9');\n    expect(state.ctx).not.toHaveUndefinedProperties();\n\n    state = flow.processEvent(state, gameEvent('endTurn'));\n    expect(state.ctx.currentPlayer).toBe('3');\n  });\n});\n\ntest('override', () => {\n  const even = {\n    first: () => 0,\n    next: ({ ctx }) => (+ctx.currentPlayer + 2) % ctx.numPlayers,\n  };\n\n  const odd = {\n    first: () => 1,\n    next: ({ ctx }) => (+ctx.currentPlayer + 2) % ctx.numPlayers,\n  };\n\n  const flow = Flow({\n    turn: { order: even },\n    phases: { A: { start: true, next: 'B' }, B: { turn: { order: odd } } },\n  });\n\n  let state = { ctx: flow.ctx(10) } as State;\n  state = flow.init(state);\n\n  expect(state.ctx.currentPlayer).toBe('0');\n  state = flow.processEvent(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('2');\n  state = flow.processEvent(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('4');\n\n  state = flow.processEvent(state, gameEvent('endPhase'));\n\n  expect(state.ctx.currentPlayer).toBe('1');\n  state = flow.processEvent(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('3');\n  state = flow.processEvent(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('5');\n});\n\ntest('playOrder', () => {\n  const game: Game = {};\n  const reducer = CreateGameReducer({ game });\n\n  let state = InitializeGame({ game, numPlayers: 3 });\n\n  state.ctx = {\n    ...state.ctx,\n    currentPlayer: '2',\n    playOrder: ['2', '0', '1'],\n  };\n\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('0');\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('1');\n  state = reducer(state, gameEvent('endTurn'));\n  expect(state.ctx.currentPlayer).toBe('2');\n});\n\ndescribe('setActivePlayers', () => {\n  const flow = Flow({});\n  const state = { ctx: flow.ctx(2) } as State;\n\n  test('basic', () => {\n    const newState = flow.processEvent(\n      state,\n      gameEvent('setActivePlayers', [{ value: { '1': Stage.NULL } }])\n    );\n    expect(newState.ctx.activePlayers).toMatchObject({ '1': Stage.NULL });\n  });\n\n  test('short form', () => {\n    const newState = flow.processEvent(\n      state,\n      gameEvent('setActivePlayers', [['1', '2']])\n    );\n    expect(newState.ctx.activePlayers).toMatchObject({\n      '1': Stage.NULL,\n      '2': Stage.NULL,\n    });\n  });\n\n  test('undefined stage leaves player inactive', () => {\n    const newState = flow.processEvent(\n      state,\n      gameEvent('setActivePlayers', [\n        {\n          value: {\n            '1': {\n              minMoves: 2,\n              maxMoves: 2,\n            },\n          },\n        },\n      ])\n    );\n    expect(newState.ctx.activePlayers).toBeNull();\n  });\n\n  test('all', () => {\n    const newState = flow.processEvent(\n      state,\n      gameEvent('setActivePlayers', [{ all: Stage.NULL }])\n    );\n    expect(newState.ctx.activePlayers).toMatchObject({\n      '0': Stage.NULL,\n      '1': Stage.NULL,\n    });\n  });\n\n  test('once', () => {\n    const game: Game = {\n      moves: {\n        B: ({ G, events }) => {\n          events.setActivePlayers({\n            value: { '0': Stage.NULL, '1': Stage.NULL },\n            minMoves: 1,\n            maxMoves: 1,\n          });\n          return G;\n        },\n        A: ({ G }) => G,\n      },\n    };\n\n    const reducer = CreateGameReducer({ game });\n\n    let state = InitializeGame({ game });\n    state = reducer(state, makeMove('B', null, '0'));\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '1']);\n    state = reducer(state, makeMove('A', null, '0'));\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['1']);\n    state = reducer(state, makeMove('A', null, '1'));\n    expect(state.ctx.activePlayers).toBeNull();\n  });\n\n  test('others', () => {\n    const game: Game = {\n      moves: {\n        B: ({ G, events }) => {\n          events.setActivePlayers({\n            minMoves: 1,\n            maxMoves: 1,\n            others: Stage.NULL,\n          });\n          return G;\n        },\n        A: ({ G }) => G,\n      },\n    };\n\n    const reducer = CreateGameReducer({ game });\n\n    let state = InitializeGame({ game, numPlayers: 3 });\n\n    // on move B, control switches from player 0 to players 1 and 2\n    state = reducer(state, makeMove('B', null, '0'));\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['1', '2']);\n\n    // player 1 makes move\n    state = reducer(state, makeMove('A', null, '1'));\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['2']);\n\n    // player 2 makes move\n    state = reducer(state, makeMove('A', null, '2'));\n    expect(state.ctx.activePlayers).toBeNull();\n  });\n\n  test('set stages to Stage.NULL', () => {\n    const game: Game = {\n      moves: {\n        A: ({ G }) => G,\n        B: ({ G, events }) => {\n          events.setActivePlayers({\n            minMoves: 1,\n            maxMoves: 1,\n            currentPlayer: 'start',\n          });\n          return G;\n        },\n      },\n      turn: {\n        activePlayers: {\n          currentPlayer: {\n            stage: 'start',\n          },\n          others: Stage.NULL,\n        },\n        stages: {\n          start: {\n            moves: {\n              S: ({ G, events }) => {\n                events.setStage(Stage.NULL);\n                return G;\n              },\n            },\n          },\n        },\n      },\n    };\n    const reducer = CreateGameReducer({ game });\n    let state = InitializeGame({ game, numPlayers: 3 });\n\n    expect(state.ctx.currentPlayer).toBe('0');\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '1', '2']);\n    expect(state.ctx.activePlayers['0']).toEqual('start');\n    expect(state.ctx.activePlayers['1']).toEqual(Stage.NULL);\n    expect(state.ctx.activePlayers['2']).toEqual(Stage.NULL);\n\n    state = reducer(state, makeMove('S', null, '0'));\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0', '1', '2']);\n    expect(state.ctx.activePlayers['0']).toEqual(Stage.NULL);\n\n    state = reducer(state, makeMove('B', null, '0'));\n    expect(Object.keys(state.ctx.activePlayers)).toEqual(['0']);\n    expect(state.ctx.activePlayers['0']).toEqual('start');\n  });\n\n  describe('reset behavior', () => {\n    test('start of turn', () => {\n      const game: Game = {\n        moves: {\n          A: () => {},\n        },\n\n        turn: {\n          activePlayers: { currentPlayer: 'stage', minMoves: 1, maxMoves: 1 },\n        },\n      };\n\n      const reducer = CreateGameReducer({ game });\n      let state = InitializeGame({ game });\n\n      expect(state.ctx).toMatchObject({\n        activePlayers: { '0': 'stage' },\n        _prevActivePlayers: [],\n      });\n\n      state = reducer(state, makeMove('A', null, '0'));\n\n      expect(state.ctx).toMatchObject({\n        activePlayers: null,\n        _prevActivePlayers: [],\n      });\n    });\n\n    describe('revert', () => {\n      test('resets to previous', () => {\n        const game: Game = {\n          moves: {\n            A: ({ events }) => {\n              events.setActivePlayers({\n                currentPlayer: 'stage2',\n                minMoves: 1,\n                maxMoves: 1,\n                revert: true,\n              });\n            },\n            B: () => {},\n          },\n\n          turn: {\n            activePlayers: { currentPlayer: 'stage1' },\n          },\n        };\n\n        const reducer = CreateGameReducer({ game });\n        let state = InitializeGame({ game });\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage1' },\n          _prevActivePlayers: [],\n        });\n\n        state = reducer(state, makeMove('A', null, '0'));\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage2' },\n          _prevActivePlayers: [\n            {\n              activePlayers: { '0': 'stage1' },\n              _activePlayersMinMoves: null,\n              _activePlayersMaxMoves: null,\n              _activePlayersNumMoves: { '0': 1 },\n            },\n          ],\n        });\n\n        state = reducer(state, makeMove('B', null, '0'));\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage1' },\n          _prevActivePlayers: [],\n        });\n      });\n\n      test('restores move limits and counts', () => {\n        const game: Game = {\n          moves: {\n            A: ({ events }) => {\n              events.setActivePlayers({\n                currentPlayer: 'stage2',\n                minMoves: 1,\n                maxMoves: 1,\n                revert: true,\n              });\n            },\n            B: () => {},\n          },\n\n          turn: {\n            activePlayers: {\n              currentPlayer: 'stage1',\n              minMoves: 2,\n              maxMoves: 3,\n            },\n          },\n        };\n\n        const reducer = CreateGameReducer({ game });\n        let state = InitializeGame({ game });\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage1' },\n          _prevActivePlayers: [],\n          _activePlayersMinMoves: { '0': 2 },\n          _activePlayersMaxMoves: { '0': 3 },\n          _activePlayersNumMoves: {\n            '0': 0,\n          },\n        });\n\n        state = reducer(state, makeMove('B', null, '0'));\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage1' },\n          _prevActivePlayers: [],\n          _activePlayersMinMoves: { '0': 2 },\n          _activePlayersMaxMoves: { '0': 3 },\n          _activePlayersNumMoves: {\n            '0': 1,\n          },\n        });\n\n        state = reducer(state, makeMove('A', null, '0'));\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage2' },\n          _prevActivePlayers: [\n            {\n              activePlayers: { '0': 'stage1' },\n              _activePlayersNumMoves: { '0': 2 },\n              _activePlayersMinMoves: { '0': 2 },\n              _activePlayersMaxMoves: { '0': 3 },\n            },\n          ],\n          _activePlayersMinMoves: { '0': 1 },\n          _activePlayersMaxMoves: { '0': 1 },\n          _activePlayersNumMoves: {\n            '0': 0,\n          },\n        });\n\n        state = reducer(state, makeMove('B', null, '0'));\n\n        expect(state.ctx).toMatchObject({\n          activePlayers: { '0': 'stage1' },\n          _prevActivePlayers: [],\n          _activePlayersMinMoves: { '0': 2 },\n          _activePlayersMaxMoves: { '0': 3 },\n          _activePlayersNumMoves: {\n            '0': 2,\n          },\n        });\n      });\n    });\n\n    test('set to next', () => {\n      const game: Game = {\n        moves: {\n          A: () => {},\n        },\n\n        turn: {\n          activePlayers: {\n            currentPlayer: 'stage1',\n            minMoves: 1,\n            maxMoves: 1,\n            next: {\n              currentPlayer: 'stage2',\n              minMoves: 1,\n              maxMoves: 1,\n              next: {\n                currentPlayer: 'stage3',\n              },\n            },\n          },\n        },\n      };\n\n      const reducer = CreateGameReducer({ game });\n      let state = InitializeGame({ game });\n\n      expect(state.ctx).toMatchObject({\n        activePlayers: { '0': 'stage1' },\n        _prevActivePlayers: [],\n        _nextActivePlayers: {\n          currentPlayer: 'stage2',\n          minMoves: 1,\n          maxMoves: 1,\n          next: {\n            currentPlayer: 'stage3',\n          },\n        },\n      });\n\n      state = reducer(state, makeMove('A', null, '0'));\n\n      expect(state.ctx).toMatchObject({\n        activePlayers: { '0': 'stage2' },\n        _prevActivePlayers: [],\n        _nextActivePlayers: {\n          currentPlayer: 'stage3',\n        },\n      });\n\n      state = reducer(state, makeMove('A', null, '0'));\n\n      expect(state.ctx).toMatchObject({\n        activePlayers: { '0': 'stage3' },\n        _prevActivePlayers: [],\n        _nextActivePlayers: null,\n      });\n    });\n  });\n\n  describe('move limits', () => {\n    test('shorthand syntax', () => {\n      const game: Game = {\n        turn: {\n          activePlayers: {\n            all: 'play',\n            minMoves: 1,\n            maxMoves: 3,\n          },\n          stages: {\n            play: { moves: { A: () => {} } },\n          },\n        },\n      };\n\n      const reducer = CreateGameReducer({ game });\n      let state = InitializeGame({ game, numPlayers: 3 });\n\n      expect(state.ctx._activePlayersMinMoves).toEqual({\n        '0': 1,\n        '1': 1,\n        '2': 1,\n      });\n\n      expect(state.ctx._activePlayersMaxMoves).toEqual({\n        '0': 3,\n        '1': 3,\n        '2': 3,\n      });\n\n      expect(state.ctx._activePlayersNumMoves).toEqual({\n        '0': 0,\n        '1': 0,\n        '2': 0,\n      });\n\n      state = reducer(state, makeMove('A', null, '0'));\n      state = reducer(state, makeMove('A', null, '1'));\n      state = reducer(state, makeMove('A', null, '1'));\n      state = reducer(state, makeMove('A', null, '2'));\n\n      expect(state.ctx._activePlayersNumMoves).toEqual({\n        '0': 1,\n        '1': 2,\n        '2': 1,\n      });\n\n      state = reducer(state, makeMove('A', null, '1'));\n\n      expect(state.ctx.activePlayers).toEqual({\n        '0': 'play',\n        '2': 'play',\n      });\n    });\n\n    test('long-form syntax', () => {\n      const game: Game = {\n        turn: {\n          activePlayers: {\n            currentPlayer: { stage: 'play', minMoves: 1, maxMoves: 2 },\n            others: { stage: 'play', maxMoves: 1 },\n          },\n          stages: {\n            play: { moves: { A: () => {} } },\n          },\n        },\n      };\n\n      const reducer = CreateGameReducer({ game });\n      let state = InitializeGame({ game, numPlayers: 3 });\n\n      expect(state.ctx._activePlayersMinMoves).toStrictEqual({ '0': 1 });\n\n      expect(state.ctx._activePlayersMaxMoves).toEqual({\n        '0': 2,\n        '1': 1,\n        '2': 1,\n      });\n\n      expect(state.ctx._activePlayersNumMoves).toEqual({\n        '0': 0,\n        '1': 0,\n        '2': 0,\n      });\n\n      state = reducer(state, makeMove('A', null, '0'));\n      state = reducer(state, makeMove('A', null, '1'));\n      state = reducer(state, makeMove('A', null, '2'));\n\n      expect(state.ctx._activePlayersNumMoves).toEqual({\n        '0': 1,\n        '1': 1,\n        '2': 1,\n      });\n\n      expect(state.ctx.activePlayers).toEqual({ '0': 'play' });\n\n      state = reducer(state, makeMove('A', null, '0'));\n\n      expect(state.ctx.activePlayers).toBeNull();\n    });\n\n    test('player-specific limit overrides move limit args', () => {\n      const game: Game = {\n        turn: {\n          activePlayers: {\n            all: { stage: 'play', minMoves: 2, maxMoves: 2 },\n            minMoves: 1,\n            maxMoves: 1,\n          },\n        },\n      };\n\n      const state = InitializeGame({ game, numPlayers: 2 });\n\n      expect(state.ctx._activePlayersMinMoves).toEqual({\n        '0': 2,\n        '1': 2,\n      });\n\n      expect(state.ctx._activePlayersMaxMoves).toEqual({\n        '0': 2,\n        '1': 2,\n      });\n    });\n\n    test('value syntax', () => {\n      const game: Game = {\n        turn: {\n          activePlayers: {\n            value: {\n              '0': { stage: 'play', maxMoves: 1 },\n              '1': { stage: 'play', minMoves: 1, maxMoves: 2 },\n              '2': { stage: 'play', minMoves: 2, maxMoves: 3 },\n            },\n          },\n          stages: {\n            play: { moves: { A: () => {} } },\n          },\n        },\n      };\n\n      const reducer = CreateGameReducer({ game });\n      let state = InitializeGame({ game, numPlayers: 3 });\n\n      expect(state.ctx._activePlayersMinMoves).toStrictEqual({\n        '1': 1,\n        '2': 2,\n      });\n\n      expect(state.ctx._activePlayersMaxMoves).toEqual({\n        '0': 1,\n        '1': 2,\n        '2': 3,\n      });\n\n      state = reducer(state, makeMove('A', null, '0'));\n      state = reducer(state, makeMove('A', null, '1'));\n      state = reducer(state, makeMove('A', null, '2'));\n\n      expect(state.ctx.activePlayers).toEqual({ '1': 'play', '2': 'play' });\n\n      state = reducer(state, makeMove('A', null, '1'));\n      state = reducer(state, makeMove('A', null, '2'));\n\n      expect(state.ctx.activePlayers).toEqual({ '2': 'play' });\n\n      state = reducer(state, makeMove('A', null, '2'));\n      expect(state.ctx.activePlayers).toBeNull();\n    });\n\n    test('move counts reset on turn end', () => {\n      const game: Game = {\n        turn: {\n          activePlayers: {\n            all: 'play',\n          },\n          stages: {\n            play: { moves: { A: () => {} } },\n          },\n        },\n      };\n\n      const reducer = CreateGameReducer({ game });\n      let state = InitializeGame({ game, numPlayers: 3 });\n\n      state = reducer(state, makeMove('A', null, '0'));\n      state = reducer(state, makeMove('A', null, '1'));\n\n      expect(state.ctx._activePlayersNumMoves).toEqual({\n        '0': 1,\n        '1': 1,\n        '2': 0,\n      });\n\n      state = reducer(state, gameEvent('endTurn'));\n\n      expect(state.ctx._activePlayersNumMoves).toEqual({\n        '0': 0,\n        '1': 0,\n        '2': 0,\n      });\n    });\n  });\n\n  describe('militia', () => {\n    let state;\n    let reducer;\n    beforeAll(() => {\n      const game: Game = {\n        moves: {\n          militia: ({ events }) => {\n            events.setActivePlayers({\n              others: 'discard',\n              minMoves: 1,\n              maxMoves: 1,\n              revert: true,\n            });\n          },\n        },\n\n        turn: {\n          stages: {\n            discard: {\n              moves: {\n                discard: ({ G }) => G,\n              },\n            },\n          },\n        },\n      };\n\n      reducer = CreateGameReducer({ game });\n      state = InitializeGame({ game, numPlayers: 3 });\n    });\n\n    beforeEach(() => {\n      (error as jest.Mock).mockClear();\n    });\n\n    test('sanity', () => {\n      expect(state.ctx.activePlayers).toEqual(null);\n    });\n\n    test('player 1 cannot play the militia card', () => {\n      state = reducer(state, makeMove('militia', undefined, '1'));\n      expect(error).toHaveBeenCalledWith('disallowed move: militia');\n    });\n\n    test('player 2 cannot play the militia card', () => {\n      state = reducer(state, makeMove('militia', undefined, '2'));\n      expect(error).toHaveBeenCalledWith('disallowed move: militia');\n    });\n\n    test('player 0 cannot discard', () => {\n      state = reducer(state, makeMove('discard', undefined, '0'));\n      expect(error).toHaveBeenCalledWith('disallowed move: discard');\n    });\n\n    test('player 1 cannot discard', () => {\n      state = reducer(state, makeMove('discard', undefined, '1'));\n      expect(error).toHaveBeenCalledWith('disallowed move: discard');\n    });\n\n    test('player 2 cannot discard', () => {\n      state = reducer(state, makeMove('discard', undefined, '2'));\n      expect(error).toHaveBeenCalledWith('disallowed move: discard');\n    });\n\n    test('player 0 plays militia', () => {\n      state = reducer(state, makeMove('militia', undefined, '0'));\n      expect(state.ctx.activePlayers).toEqual({\n        '1': 'discard',\n        '2': 'discard',\n      });\n    });\n\n    test('player 0 cannot play militia again', () => {\n      state = reducer(state, makeMove('militia', undefined, '0'));\n      expect(error).toHaveBeenCalledWith('disallowed move: militia');\n    });\n\n    test('player 0 still cannot discard', () => {\n      state = reducer(state, makeMove('discard', undefined, '0'));\n      expect(error).toHaveBeenCalledWith('disallowed move: discard');\n    });\n\n    test('everyone else discards', () => {\n      state = reducer(state, makeMove('discard', undefined, '1'));\n      expect(state.ctx.activePlayers).toEqual({ '2': 'discard' });\n      state = reducer(state, makeMove('discard', undefined, '2'));\n    });\n\n    test('activePlayers is restored to previous state', () => {\n      expect(state.ctx.activePlayers).toEqual(null);\n    });\n  });\n});\n\ndescribe('UpdateTurnOrderState', () => {\n  const G = {};\n  const ctx = {\n    currentPlayer: '0',\n    playOrder: ['0', '1', '2'],\n    playOrderPos: 0,\n  };\n  const turn = { order: TurnOrder.DEFAULT };\n\n  test('without next player', () => {\n    const { ctx: t } = UpdateTurnOrderState(\n      { G, ctx } as State,\n      ctx.currentPlayer,\n      turn\n    );\n    expect(t).toMatchObject({ currentPlayer: '1' });\n  });\n\n  test('with next player', () => {\n    const { ctx: t } = UpdateTurnOrderState(\n      { G, ctx } as State,\n      ctx.currentPlayer,\n      turn,\n      {\n        next: '2',\n      }\n    );\n    expect(t).toMatchObject({ currentPlayer: '2' });\n  });\n\n  test('errors if turn.order.next doesn’t return a number', () => {\n    UpdateTurnOrderState({ G, ctx } as State, ctx.currentPlayer, {\n      order: {\n        first: () => 0,\n        next: () => '2' as unknown as number,\n      },\n    });\n    expect(error).toHaveBeenCalledWith(\n      `invalid value returned by turn.order.next — expected number or undefined got string “2”.`\n    );\n  });\n});\n\ndescribe('Random API is available', () => {\n  let first;\n  let next;\n\n  const turn = {\n    order: {\n      first: ({ random }) => {\n        if (random !== undefined) {\n          first = true;\n        }\n        return 0;\n      },\n\n      next: ({ random }) => {\n        if (random !== undefined) {\n          next = true;\n        }\n        return 0;\n      },\n    },\n  };\n\n  const game: Game = { turn };\n\n  beforeEach(() => {\n    first = next = false;\n  });\n\n  test('init', () => {\n    Client({ game });\n    expect(first).toBe(true);\n  });\n\n  test('end turn', () => {\n    const client = Client({ game });\n    expect(next).toBe(false);\n    client.events.endTurn();\n    expect(next).toBe(true);\n  });\n});\n"
  },
  {
    "path": "src/core/turn-order.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport * as logging from './logger';\nimport * as plugin from '../plugins/main';\nimport type {\n  Ctx,\n  StageArg,\n  ActivePlayersArg,\n  PlayerID,\n  State,\n  TurnConfig,\n  FnContext,\n} from '../types';\nimport { supportDeprecatedMoveLimit } from './backwards-compatibility';\n\nexport function SetActivePlayers(ctx: Ctx, arg: ActivePlayersArg): Ctx {\n  let activePlayers: typeof ctx.activePlayers = {};\n  let _prevActivePlayers: typeof ctx._prevActivePlayers = [];\n  let _nextActivePlayers: ActivePlayersArg | null = null;\n  let _activePlayersMinMoves = {};\n  let _activePlayersMaxMoves = {};\n\n  if (Array.isArray(arg)) {\n    // support a simple array of player IDs as active players\n    const value = {};\n    arg.forEach((v) => (value[v] = Stage.NULL));\n    activePlayers = value;\n  } else {\n    // process active players argument object\n\n    // stages previously did not enforce minMoves, this behaviour is kept intentionally\n    supportDeprecatedMoveLimit(arg);\n\n    if (arg.next) {\n      _nextActivePlayers = arg.next;\n    }\n\n    if (arg.revert) {\n      _prevActivePlayers = [\n        ...ctx._prevActivePlayers,\n        {\n          activePlayers: ctx.activePlayers,\n          _activePlayersMinMoves: ctx._activePlayersMinMoves,\n          _activePlayersMaxMoves: ctx._activePlayersMaxMoves,\n          _activePlayersNumMoves: ctx._activePlayersNumMoves,\n        },\n      ];\n    }\n\n    if (arg.currentPlayer !== undefined) {\n      ApplyActivePlayerArgument(\n        activePlayers,\n        _activePlayersMinMoves,\n        _activePlayersMaxMoves,\n        ctx.currentPlayer,\n        arg.currentPlayer\n      );\n    }\n\n    if (arg.others !== undefined) {\n      for (let i = 0; i < ctx.playOrder.length; i++) {\n        const id = ctx.playOrder[i];\n        if (id !== ctx.currentPlayer) {\n          ApplyActivePlayerArgument(\n            activePlayers,\n            _activePlayersMinMoves,\n            _activePlayersMaxMoves,\n            id,\n            arg.others\n          );\n        }\n      }\n    }\n\n    if (arg.all !== undefined) {\n      for (let i = 0; i < ctx.playOrder.length; i++) {\n        const id = ctx.playOrder[i];\n        ApplyActivePlayerArgument(\n          activePlayers,\n          _activePlayersMinMoves,\n          _activePlayersMaxMoves,\n          id,\n          arg.all\n        );\n      }\n    }\n\n    if (arg.value) {\n      for (const id in arg.value) {\n        ApplyActivePlayerArgument(\n          activePlayers,\n          _activePlayersMinMoves,\n          _activePlayersMaxMoves,\n          id,\n          arg.value[id]\n        );\n      }\n    }\n\n    if (arg.minMoves) {\n      for (const id in activePlayers) {\n        if (_activePlayersMinMoves[id] === undefined) {\n          _activePlayersMinMoves[id] = arg.minMoves;\n        }\n      }\n    }\n\n    if (arg.maxMoves) {\n      for (const id in activePlayers) {\n        if (_activePlayersMaxMoves[id] === undefined) {\n          _activePlayersMaxMoves[id] = arg.maxMoves;\n        }\n      }\n    }\n  }\n\n  if (Object.keys(activePlayers).length === 0) {\n    activePlayers = null;\n  }\n\n  if (Object.keys(_activePlayersMinMoves).length === 0) {\n    _activePlayersMinMoves = null;\n  }\n\n  if (Object.keys(_activePlayersMaxMoves).length === 0) {\n    _activePlayersMaxMoves = null;\n  }\n\n  const _activePlayersNumMoves = {};\n  for (const id in activePlayers) {\n    _activePlayersNumMoves[id] = 0;\n  }\n\n  return {\n    ...ctx,\n    activePlayers,\n    _activePlayersMinMoves,\n    _activePlayersMaxMoves,\n    _activePlayersNumMoves,\n    _prevActivePlayers,\n    _nextActivePlayers,\n  };\n}\n\n/**\n * Update activePlayers, setting it to previous, next or null values\n * when it becomes empty.\n * @param ctx\n */\nexport function UpdateActivePlayersOnceEmpty(ctx: Ctx) {\n  let {\n    activePlayers,\n    _activePlayersMinMoves,\n    _activePlayersMaxMoves,\n    _activePlayersNumMoves,\n    _prevActivePlayers,\n    _nextActivePlayers,\n  } = ctx;\n\n  if (activePlayers && Object.keys(activePlayers).length === 0) {\n    if (_nextActivePlayers) {\n      ctx = SetActivePlayers(ctx, _nextActivePlayers);\n      ({\n        activePlayers,\n        _activePlayersMinMoves,\n        _activePlayersMaxMoves,\n        _activePlayersNumMoves,\n        _prevActivePlayers,\n      } = ctx);\n    } else if (_prevActivePlayers.length > 0) {\n      const lastIndex = _prevActivePlayers.length - 1;\n      ({\n        activePlayers,\n        _activePlayersMinMoves,\n        _activePlayersMaxMoves,\n        _activePlayersNumMoves,\n      } = _prevActivePlayers[lastIndex]);\n      _prevActivePlayers = _prevActivePlayers.slice(0, lastIndex);\n    } else {\n      activePlayers = null;\n      _activePlayersMinMoves = null;\n      _activePlayersMaxMoves = null;\n    }\n  }\n\n  return {\n    ...ctx,\n    activePlayers,\n    _activePlayersMinMoves,\n    _activePlayersMaxMoves,\n    _activePlayersNumMoves,\n    _prevActivePlayers,\n  };\n}\n\n/**\n * Apply an active player argument to the given player ID\n * @param {Object} activePlayers\n * @param {Object} _activePlayersMinMoves\n * @param {Object} _activePlayersMaxMoves\n * @param {String} playerID The player to apply the parameter to\n * @param {(String|Object)} arg An active player argument\n */\nfunction ApplyActivePlayerArgument(\n  activePlayers: Ctx['activePlayers'],\n  _activePlayersMinMoves: Ctx['_activePlayersMinMoves'],\n  _activePlayersMaxMoves: Ctx['_activePlayersMaxMoves'],\n  playerID: PlayerID,\n  arg: StageArg\n) {\n  if (typeof arg !== 'object' || arg === Stage.NULL) {\n    arg = { stage: arg as string | null };\n  }\n\n  if (arg.stage !== undefined) {\n    // stages previously did not enforce minMoves, this behaviour is kept intentionally\n    supportDeprecatedMoveLimit(arg);\n\n    activePlayers[playerID] = arg.stage;\n    if (arg.minMoves) _activePlayersMinMoves[playerID] = arg.minMoves;\n    if (arg.maxMoves) _activePlayersMaxMoves[playerID] = arg.maxMoves;\n  }\n}\n\n/**\n * Converts a playOrderPos index into its value in playOrder.\n * @param {Array} playOrder - An array of player ID's.\n * @param {number} playOrderPos - An index into the above.\n */\nfunction getCurrentPlayer(\n  playOrder: Ctx['playOrder'],\n  playOrderPos: Ctx['playOrderPos']\n) {\n  // convert to string in case playOrder is set to number[]\n  return playOrder[playOrderPos] + '';\n}\n\n/**\n * Called at the start of a turn to initialize turn order state.\n *\n * TODO: This is called inside StartTurn, which is called from\n * both UpdateTurn and StartPhase (so it's called at the beginning\n * of a new phase as well as between turns). We should probably\n * split it into two.\n */\nexport function InitTurnOrderState(state: State, turn: TurnConfig) {\n  let { G, ctx } = state;\n  const { numPlayers } = ctx;\n  const pluginAPIs = plugin.GetAPIs(state);\n  const context = { ...pluginAPIs, G, ctx };\n  const order = turn.order;\n\n  let playOrder = [...Array.from({ length: numPlayers })].map((_, i) => i + '');\n  if (order.playOrder !== undefined) {\n    playOrder = order.playOrder(context);\n  }\n\n  const playOrderPos = order.first(context);\n  const posType = typeof playOrderPos;\n  if (posType !== 'number') {\n    logging.error(\n      `invalid value returned by turn.order.first — expected number got ${posType} “${playOrderPos}”.`\n    );\n  }\n  const currentPlayer = getCurrentPlayer(playOrder, playOrderPos);\n\n  ctx = { ...ctx, currentPlayer, playOrderPos, playOrder };\n  ctx = SetActivePlayers(ctx, turn.activePlayers || {});\n\n  return ctx;\n}\n\n/**\n * Called at the end of each turn to update the turn order state.\n * @param {object} G - The game object G.\n * @param {object} ctx - The game object ctx.\n * @param {object} turn - A turn object for this phase.\n * @param {string} endTurnArg - An optional argument to endTurn that\n                                may specify the next player.\n */\nexport function UpdateTurnOrderState(\n  state: State,\n  currentPlayer: PlayerID,\n  turn: TurnConfig,\n  endTurnArg?: true | { remove?: any; next?: string }\n) {\n  const order = turn.order;\n\n  let { G, ctx } = state;\n  let playOrderPos = ctx.playOrderPos;\n  let endPhase = false;\n\n  if (endTurnArg && endTurnArg !== true) {\n    if (typeof endTurnArg !== 'object') {\n      logging.error(`invalid argument to endTurn: ${endTurnArg}`);\n    }\n\n    Object.keys(endTurnArg).forEach((arg) => {\n      switch (arg) {\n        case 'remove':\n          currentPlayer = getCurrentPlayer(ctx.playOrder, playOrderPos);\n          break;\n        case 'next':\n          playOrderPos = ctx.playOrder.indexOf(endTurnArg.next);\n          currentPlayer = endTurnArg.next;\n          break;\n        default:\n          logging.error(`invalid argument to endTurn: ${arg}`);\n      }\n    });\n  } else {\n    const pluginAPIs = plugin.GetAPIs(state);\n    const context = { ...pluginAPIs, G, ctx };\n    const t = order.next(context);\n    const type = typeof t;\n    if (t !== undefined && type !== 'number') {\n      logging.error(\n        `invalid value returned by turn.order.next — expected number or undefined got ${type} “${t}”.`\n      );\n    }\n\n    if (t === undefined) {\n      endPhase = true;\n    } else {\n      playOrderPos = t;\n      currentPlayer = getCurrentPlayer(ctx.playOrder, playOrderPos);\n    }\n  }\n\n  ctx = {\n    ...ctx,\n    playOrderPos,\n    currentPlayer,\n  };\n\n  return { endPhase, ctx };\n}\n\n/**\n * Set of different turn orders possible in a phase.\n * These are meant to be passed to the `turn` setting\n * in the flow objects.\n *\n * Each object defines the first player when the phase / game\n * begins, and also a function `next` to determine who the\n * next player is when the turn ends.\n *\n * The phase ends if next() returns undefined.\n */\nexport const TurnOrder = {\n  /**\n   * DEFAULT\n   *\n   * The default round-robin turn order.\n   */\n  DEFAULT: {\n    first: ({ ctx }: FnContext) =>\n      ctx.turn === 0\n        ? ctx.playOrderPos\n        : (ctx.playOrderPos + 1) % ctx.playOrder.length,\n    next: ({ ctx }: FnContext) => (ctx.playOrderPos + 1) % ctx.playOrder.length,\n  },\n\n  /**\n   * RESET\n   *\n   * Similar to DEFAULT, but starts from 0 each time.\n   */\n  RESET: {\n    first: () => 0,\n    next: ({ ctx }: FnContext) => (ctx.playOrderPos + 1) % ctx.playOrder.length,\n  },\n\n  /**\n   * CONTINUE\n   *\n   * Similar to DEFAULT, but starts with the player who ended the last phase.\n   */\n  CONTINUE: {\n    first: ({ ctx }: FnContext) => ctx.playOrderPos,\n    next: ({ ctx }: FnContext) => (ctx.playOrderPos + 1) % ctx.playOrder.length,\n  },\n\n  /**\n   * ONCE\n   *\n   * Another round-robin turn order, but goes around just once.\n   * The phase ends after all players have played.\n   */\n  ONCE: {\n    first: () => 0,\n    next: ({ ctx }: FnContext) => {\n      if (ctx.playOrderPos < ctx.playOrder.length - 1) {\n        return ctx.playOrderPos + 1;\n      }\n    },\n  },\n\n  /**\n   * CUSTOM\n   *\n   * Identical to DEFAULT, but also sets playOrder at the\n   * beginning of the phase.\n   *\n   * @param {Array} playOrder - The play order.\n   */\n  CUSTOM: (playOrder: string[]) => ({\n    playOrder: () => playOrder,\n    first: () => 0,\n    next: ({ ctx }: FnContext) => (ctx.playOrderPos + 1) % ctx.playOrder.length,\n  }),\n\n  /**\n   * CUSTOM_FROM\n   *\n   * Identical to DEFAULT, but also sets playOrder at the\n   * beginning of the phase to a value specified by a field\n   * in G.\n   *\n   * @param {string} playOrderField - Field in G.\n   */\n  CUSTOM_FROM: (playOrderField: string) => ({\n    playOrder: ({ G }: FnContext) => G[playOrderField],\n    first: () => 0,\n    next: ({ ctx }: FnContext) => (ctx.playOrderPos + 1) % ctx.playOrder.length,\n  }),\n};\n\nexport const Stage = {\n  NULL: null,\n};\n\nexport const ActivePlayers = {\n  /**\n   * ALL\n   *\n   * The turn stays with one player, but any player can play (in any order)\n   * until the phase ends.\n   */\n  ALL: { all: Stage.NULL },\n\n  /**\n   * ALL_ONCE\n   *\n   * The turn stays with one player, but any player can play (once, and in any order).\n   * This is typically used in a phase where you want to elicit a response\n   * from every player in the game.\n   */\n  ALL_ONCE: { all: Stage.NULL, minMoves: 1, maxMoves: 1 },\n\n  /**\n   * OTHERS\n   *\n   * The turn stays with one player, and every *other* player can play (in any order)\n   * until the phase ends.\n   */\n  OTHERS: { others: Stage.NULL },\n\n  /**\n   * OTHERS_ONCE\n   *\n   * The turn stays with one player, and every *other* player can play (once, and in any order).\n   * This is typically used in a phase where you want to elicit a response\n   * from every *other* player in the game.\n   */\n  OTHERS_ONCE: { others: Stage.NULL, minMoves: 1, maxMoves: 1 },\n};\n"
  },
  {
    "path": "src/lobby/client.test.ts",
    "content": "// Tell ESLint about additional assertion methods.\n/*\neslint jest/expect-expect: [\n  \"warn\",\n  { \"assertFunctionNames\": [\"expect\", \"throwsWith*\", \"testBasicBody\"] }\n]\n*/\n\nimport { LobbyClient } from './client';\n\nconst throwsWithoutBody = (fn: (...args: any) => Promise<any>) => async () => {\n  await expect(fn('tic-tac-toe')).rejects.toThrow(\n    `Expected body, got “undefined”.`\n  );\n};\n\nconst testStringValidation =\n  (fn: (arg: any) => Promise<any>, label: string) => async () => {\n    await expect(fn(undefined)).rejects.toThrow(\n      `Expected ${label} string, got \"undefined\".`\n    );\n    await expect(fn(2)).rejects.toThrow(`Expected ${label} string, got \"2\".`);\n    await expect(fn('')).rejects.toThrow(`Expected ${label} string, got \"\".`);\n  };\n\nconst throwsWithInvalidGameName = (fn: (...args: any) => Promise<any>) =>\n  testStringValidation(fn, 'game name');\n\nconst throwsWithInvalidMatchID = (fn: (...args: any) => Promise<any>) =>\n  testStringValidation((matchID: string) => fn('chess', matchID), 'match ID');\n\nconst testBasicBody = (fn: (...args: any) => Promise<any>) => async () => {\n  await expect(\n    fn('chess', '1', { playerID: undefined, credentials: 'pwd' })\n  ).rejects.toThrow(\n    'Expected body.playerID to be of type string, got “undefined”.'\n  );\n\n  await expect(\n    fn('chess', '2', { playerID: '0', credentials: 0 as unknown as string })\n  ).rejects.toThrow('Expected body.credentials to be of type string, got “0”.');\n};\n\ndescribe('LobbyClient', () => {\n  let client = new LobbyClient();\n\n  beforeEach(async () => {\n    (global as any).fetch = jest.fn(async () => ({\n      ok: true,\n      status: 200,\n      json: async () => {},\n    }));\n  });\n\n  describe('construction', () => {\n    test('basic', async () => {\n      await client.listGames();\n      expect(fetch).toBeCalledWith(`/games`, undefined);\n    });\n\n    test('with server address', async () => {\n      const client = new LobbyClient({ server: 'http://api.io' });\n      await client.listGames();\n      expect(fetch).toBeCalledWith(`http://api.io/games`, undefined);\n    });\n\n    test('with server address with trailing slash', async () => {\n      const client = new LobbyClient({ server: 'http://api.io/' });\n      await client.listGames();\n      expect(fetch).toBeCalledWith(`http://api.io/games`, undefined);\n    });\n  });\n\n  describe('status errors', () => {\n    beforeEach(async () => {\n      client = new LobbyClient();\n    });\n\n    test('404 throws an error', async () => {\n      (global as any).fetch = jest.fn(async () => ({\n        ok: false,\n        status: 404,\n        json: async () => {},\n      }));\n\n      await expect(client.listGames()).rejects.toThrow('HTTP status 404');\n    });\n\n    test('404 throws an error with json details', async () => {\n      (global as any).fetch = jest.fn(async () => ({\n        ok: false,\n        status: 404,\n        clone: () => ({\n          json: async () => ({ moreInformation: 'some helpful details' }),\n        }),\n      }));\n\n      await expect(client.listGames()).rejects.toThrow(\n        expect.objectContaining({\n          message: 'HTTP status 404',\n          details: {\n            moreInformation: 'some helpful details',\n          },\n        })\n      );\n    });\n\n    test('404 throws an error with text details', async () => {\n      (global as any).fetch = jest.fn(async () => ({\n        ok: false,\n        status: 404,\n        json: async () => {\n          throw new Error('impossible to parse json');\n        },\n        text: async () =>\n          '<moreInformation>some helpful details</moreInformation>',\n      }));\n\n      await expect(client.listGames()).rejects.toThrow(\n        expect.objectContaining({\n          message: 'HTTP status 404',\n          details: '<moreInformation>some helpful details</moreInformation>',\n        })\n      );\n    });\n\n    test('404 throws an error without details', async () => {\n      (global as any).fetch = jest.fn(async () => ({\n        ok: false,\n        status: 404,\n        json: async () => {\n          throw new Error('impossible to parse json');\n        },\n        text: async () => {\n          throw new Error('something went wrong in the connection');\n        },\n      }));\n\n      await expect(client.listGames()).rejects.toThrow(\n        expect.objectContaining({\n          message: 'HTTP status 404',\n          details: 'something went wrong in the connection',\n        })\n      );\n    });\n  });\n\n  describe('listGames', () => {\n    test('calls `/games`', async () => {\n      await client.listGames();\n      expect(fetch).toBeCalledWith('/games', undefined);\n    });\n\n    test('init can be customized', async () => {\n      await client.listGames({ headers: { Authorization: 'pwd' } });\n      expect(fetch).toBeCalledWith('/games', {\n        headers: { Authorization: 'pwd' },\n      });\n    });\n  });\n\n  describe('listMatches', () => {\n    test('calls `/games/:name`', async () => {\n      await client.listMatches('tic-tac-toe');\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe`, undefined);\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.listMatches));\n\n    describe('builds filter queries', () => {\n      test('kitchen sink', async () => {\n        await client.listMatches('chess', {\n          isGameover: false,\n          updatedBefore: 3000,\n          updatedAfter: 1000,\n        });\n        expect(fetch).toBeCalledWith(\n          '/games/chess?isGameover=false&updatedBefore=3000&updatedAfter=1000',\n          undefined\n        );\n      });\n\n      test('isGameover', async () => {\n        await client.listMatches('chess', { isGameover: undefined });\n        expect(fetch).toBeCalledWith('/games/chess', undefined);\n        await client.listMatches('chess', { isGameover: false });\n        expect(fetch).toBeCalledWith(\n          '/games/chess?isGameover=false',\n          undefined\n        );\n        await client.listMatches('chess', { isGameover: true });\n        expect(fetch).toBeCalledWith('/games/chess?isGameover=true', undefined);\n      });\n\n      test('updatedBefore', async () => {\n        const updatedBefore = 1989;\n        await client.listMatches('chess', { updatedBefore });\n        expect(fetch).toBeCalledWith(\n          '/games/chess?updatedBefore=1989',\n          undefined\n        );\n      });\n\n      test('updatedAfter', async () => {\n        const updatedAfter = 1970;\n        await client.listMatches('chess', { updatedAfter });\n        expect(fetch).toBeCalledWith(\n          '/games/chess?updatedAfter=1970',\n          undefined\n        );\n      });\n    });\n  });\n\n  describe('getMatch', () => {\n    test('calls `/games/:name/:id`', async () => {\n      await client.getMatch('tic-tac-toe', 'xyz');\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe/xyz`, undefined);\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.getMatch));\n    test('validates matchID', throwsWithInvalidMatchID(client.getMatch));\n  });\n\n  describe('createMatch', () => {\n    test('calls `/games/:name/create`', async () => {\n      await client.createMatch('tic-tac-toe', { numPlayers: 2 });\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe/create`, {\n        method: 'post',\n        body: '{\"numPlayers\":2}',\n        headers: { 'Content-Type': 'application/json' },\n      });\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.createMatch));\n\n    test('throws without body', throwsWithoutBody(client.createMatch));\n\n    test('validates body', async () => {\n      await expect(\n        client.createMatch('tic-tac-toe', {\n          numPlayers: '12' as unknown as number,\n        })\n      ).rejects.toThrow(\n        'Expected body.numPlayers to be of type number, got “12”.'\n      );\n    });\n\n    test('init can be customized', async () => {\n      await client.createMatch(\n        'chess',\n        { numPlayers: 2 },\n        { headers: { Authorization: 'pwd' } }\n      );\n      expect(fetch).toBeCalledWith(`/games/chess/create`, {\n        method: 'post',\n        body: '{\"numPlayers\":2}',\n        headers: {\n          'Content-Type': 'application/json',\n          Authorization: 'pwd',\n        },\n      });\n    });\n  });\n\n  describe('joinMatch', () => {\n    test('calls `/games/:name/:id/join`', async () => {\n      await client.joinMatch('tic-tac-toe', 'xyz', {\n        playerID: '0',\n        playerName: 'Alice',\n      });\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe/xyz/join`, {\n        method: 'post',\n        body: '{\"playerID\":\"0\",\"playerName\":\"Alice\"}',\n        headers: { 'Content-Type': 'application/json' },\n      });\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.joinMatch));\n    test('validates matchID', throwsWithInvalidMatchID(client.joinMatch));\n\n    test(\n      'throws without body',\n      throwsWithoutBody(() => client.joinMatch('chess', 'id', undefined))\n    );\n\n    test('validates body', async () => {\n      await expect(\n        client.joinMatch('tic-tac-toe', 'xyz', {\n          playerID: 0 as unknown as string,\n          playerName: 'Bob',\n        })\n      ).rejects.toThrow(\n        'Expected body.playerID to be of type string|undefined, got “0”.'\n      );\n\n      await expect(\n        client.joinMatch('tic-tac-toe', 'xyz', {\n          playerID: '0',\n          playerName: undefined,\n        })\n      ).rejects.toThrow(\n        'Expected body.playerName to be of type string, got “undefined”.'\n      );\n\n      // Allows requests that don’t specify `playerID`.\n      await expect(\n        client.joinMatch('tic-tac-toe', 'xyz', { playerName: 'Bob' })\n      ).resolves.not.toThrow();\n    });\n  });\n\n  describe('leaveMatch', () => {\n    test('calls `/games/:name/:id/leave`', async () => {\n      await client.leaveMatch('tic-tac-toe', 'xyz', {\n        playerID: '0',\n        credentials: 'pwd',\n      });\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe/xyz/leave`, {\n        method: 'post',\n        body: '{\"playerID\":\"0\",\"credentials\":\"pwd\"}',\n        headers: { 'Content-Type': 'application/json' },\n      });\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.leaveMatch));\n    test('validates matchID', throwsWithInvalidMatchID(client.leaveMatch));\n\n    test(\n      'throws without body',\n      throwsWithoutBody(() => client.leaveMatch('chess', 'id', undefined))\n    );\n\n    test('validates body', testBasicBody(client.leaveMatch));\n  });\n\n  describe('updatePlayer', () => {\n    test('calls `/games/:name/:id/update`', async () => {\n      await client.updatePlayer('tic-tac-toe', 'xyz', {\n        playerID: '0',\n        credentials: 'pwd',\n        newName: 'Al',\n      });\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe/xyz/update`, {\n        method: 'post',\n        body: '{\"playerID\":\"0\",\"credentials\":\"pwd\",\"newName\":\"Al\"}',\n        headers: { 'Content-Type': 'application/json' },\n      });\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.updatePlayer));\n    test('validates matchID', throwsWithInvalidMatchID(client.updatePlayer));\n\n    test(\n      'throws without body',\n      throwsWithoutBody(() => client.updatePlayer('chess', 'id', undefined))\n    );\n\n    test('validates body', testBasicBody(client.updatePlayer));\n  });\n\n  describe('playAgain', () => {\n    test('calls `/games/:name/:id/playAgain`', async () => {\n      await client.playAgain('tic-tac-toe', 'xyz', {\n        playerID: '0',\n        credentials: 'pwd',\n      });\n      expect(fetch).toBeCalledWith(`/games/tic-tac-toe/xyz/playAgain`, {\n        method: 'post',\n        body: '{\"playerID\":\"0\",\"credentials\":\"pwd\"}',\n        headers: { 'Content-Type': 'application/json' },\n      });\n    });\n\n    test('validates gameName', throwsWithInvalidGameName(client.playAgain));\n    test('validates matchID', throwsWithInvalidMatchID(client.playAgain));\n\n    test(\n      'throws without body',\n      throwsWithoutBody(() => client.playAgain('chess', 'id', undefined))\n    );\n\n    test('validates body', testBasicBody(client.playAgain));\n  });\n});\n"
  },
  {
    "path": "src/lobby/client.ts",
    "content": "import type { LobbyAPI } from '../types';\n\nconst assertString = (str: unknown, label: string) => {\n  if (!str || typeof str !== 'string') {\n    throw new Error(`Expected ${label} string, got \"${str}\".`);\n  }\n};\nconst assertGameName = (name?: string) => assertString(name, 'game name');\nconst assertMatchID = (id?: string) => assertString(id, 'match ID');\n\ntype JSType =\n  | 'string'\n  | 'number'\n  | 'bigint'\n  | 'object'\n  | 'boolean'\n  | 'symbol'\n  | 'function'\n  | 'undefined';\n\nconst validateBody = (\n  body: { [key: string]: any } | undefined,\n  schema: { [key: string]: JSType | JSType[] }\n) => {\n  if (!body) throw new Error(`Expected body, got “${body}”.`);\n  for (const key in schema) {\n    const propSchema = schema[key];\n    const types = Array.isArray(propSchema) ? propSchema : [propSchema];\n    const received = body[key];\n    if (!types.includes(typeof received)) {\n      const union = types.join('|');\n      throw new TypeError(\n        `Expected body.${key} to be of type ${union}, got “${received}”.`\n      );\n    }\n  }\n};\n\nexport class LobbyClientError extends Error {\n  readonly details: any;\n\n  constructor(message: string, details: any) {\n    super(message);\n    this.details = details;\n  }\n}\n\n/**\n * Create a boardgame.io Lobby API client.\n * @param server The API’s base URL, e.g. `http://localhost:8000`.\n */\nexport class LobbyClient {\n  private server: string;\n\n  constructor({ server = '' }: { server?: string } = {}) {\n    // strip trailing slash if passed\n    this.server = server.replace(/\\/$/, '');\n  }\n\n  private async request(route: string, init?: RequestInit) {\n    const response = await fetch(this.server + route, init);\n\n    if (!response.ok) {\n      let details: any;\n\n      try {\n        details = await response.clone().json();\n      } catch {\n        try {\n          details = await response.text();\n        } catch (error) {\n          details = error.message;\n        }\n      }\n\n      throw new LobbyClientError(`HTTP status ${response.status}`, details);\n    }\n\n    return response.json();\n  }\n\n  private async post(route: string, opts: { body?: any; init?: RequestInit }) {\n    let init: RequestInit = {\n      method: 'post',\n      body: JSON.stringify(opts.body),\n      headers: { 'Content-Type': 'application/json' },\n    };\n    if (opts.init)\n      init = {\n        ...init,\n        ...opts.init,\n        headers: { ...init.headers, ...opts.init.headers },\n      };\n    return this.request(route, init);\n  }\n\n  /**\n   * Get a list of the game names available on this server.\n   * @param  init Optional RequestInit interface to override defaults.\n   * @return Array of game names.\n   *\n   * @example\n   * lobbyClient.listGames()\n   *   .then(console.log); // => ['chess', 'tic-tac-toe']\n   */\n  async listGames(init?: RequestInit): Promise<string[]> {\n    return this.request('/games', init);\n  }\n\n  /**\n   * Get a list of the matches for a specific game type on the server.\n   * @param  gameName The game to list for, e.g. 'tic-tac-toe'.\n   * @param  where    Options to filter matches by update time or gameover state\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return Array of match metadata objects.\n   *\n   * @example\n   * lobbyClient.listMatches('tic-tac-toe', where: { isGameover: false })\n   *   .then(data => console.log(data.matches));\n   * // => [\n   * //   {\n   * //     matchID: 'xyz',\n   * //     gameName: 'tic-tac-toe',\n   * //     players: [{ id: 0, name: 'Alice' }, { id: 1 }]\n   * //   },\n   * //   ...\n   * // ]\n   */\n  async listMatches(\n    gameName: string,\n    where?: {\n      /**\n       * If true, only games that have ended will be returned.\n       * If false, only games that have not yet ended will be returned.\n       * Leave undefined to receive both finished and unfinished games.\n       */\n      isGameover?: boolean;\n      /**\n       * List matches last updated before a specific time.\n       * Value should be a timestamp in milliseconds after January 1, 1970.\n       */\n      updatedBefore?: number;\n      /**\n       * List matches last updated after a specific time.\n       * Value should be a timestamp in milliseconds after January 1, 1970.\n       */\n      updatedAfter?: number;\n    },\n    init?: RequestInit\n  ): Promise<LobbyAPI.MatchList> {\n    assertGameName(gameName);\n    let query = '';\n    if (where) {\n      const queries = [];\n      const { isGameover, updatedBefore, updatedAfter } = where;\n      if (isGameover !== undefined) queries.push(`isGameover=${isGameover}`);\n      if (updatedBefore) queries.push(`updatedBefore=${updatedBefore}`);\n      if (updatedAfter) queries.push(`updatedAfter=${updatedAfter}`);\n      if (queries.length > 0) query = '?' + queries.join('&');\n    }\n    return this.request(`/games/${gameName}${query}`, init);\n  }\n\n  /**\n   * Get metadata for a specific match.\n   * @param  gameName The match’s game type, e.g. 'tic-tac-toe'.\n   * @param  matchID  Match ID for the match to fetch.\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return A match metadata object.\n   *\n   * @example\n   * lobbyClient.getMatch('tic-tac-toe', 'xyz').then(console.log);\n   * // => {\n   * //   matchID: 'xyz',\n   * //   gameName: 'tic-tac-toe',\n   * //   players: [{ id: 0, name: 'Alice' }, { id: 1 }]\n   * // }\n   */\n  async getMatch(\n    gameName: string,\n    matchID: string,\n    init?: RequestInit\n  ): Promise<LobbyAPI.Match> {\n    assertGameName(gameName);\n    assertMatchID(matchID);\n    return this.request(`/games/${gameName}/${matchID}`, init);\n  }\n\n  /**\n   * Create a new match for a specific game type.\n   * @param  gameName The game to create a match for, e.g. 'tic-tac-toe'.\n   * @param  body     Options required to configure match creation.\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return An object containing the created `matchID`.\n   *\n   * @example\n   * lobbyClient.createMatch('tic-tac-toe', { numPlayers: 2 })\n   *   .then(console.log);\n   * // => { matchID: 'xyz' }\n   */\n  async createMatch(\n    gameName: string,\n    body: {\n      numPlayers: number;\n      setupData?: any;\n      unlisted?: boolean;\n      [key: string]: any;\n    },\n    init?: RequestInit\n  ): Promise<LobbyAPI.CreatedMatch> {\n    assertGameName(gameName);\n    validateBody(body, { numPlayers: 'number' });\n    return this.post(`/games/${gameName}/create`, { body, init });\n  }\n\n  /**\n   * Join a match using its matchID.\n   * @param  gameName The match’s game type, e.g. 'tic-tac-toe'.\n   * @param  matchID  Match ID for the match to join.\n   * @param  body     Options required to join match.\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return Object containing `playerCredentials` for the player who joined.\n   *\n   * @example\n   * lobbyClient.joinMatch('tic-tac-toe', 'xyz', {\n   *   playerID: '1',\n   *   playerName: 'Bob',\n   * }).then(console.log);\n   * // => { playerID: '1', playerCredentials: 'random-string' }\n   */\n  async joinMatch(\n    gameName: string,\n    matchID: string,\n    body: {\n      playerID?: string;\n      playerName: string;\n      data?: any;\n      [key: string]: any;\n    },\n    init?: RequestInit\n  ): Promise<LobbyAPI.JoinedMatch> {\n    assertGameName(gameName);\n    assertMatchID(matchID);\n    validateBody(body, {\n      playerID: ['string', 'undefined'],\n      playerName: 'string',\n    });\n    return this.post(`/games/${gameName}/${matchID}/join`, { body, init });\n  }\n\n  /**\n   * Leave a previously joined match.\n   * @param  gameName The match’s game type, e.g. 'tic-tac-toe'.\n   * @param  matchID  Match ID for the match to leave.\n   * @param  body     Options required to leave match.\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return Promise resolves if successful.\n   *\n   * @example\n   * lobbyClient.leaveMatch('tic-tac-toe', 'xyz', {\n   *   playerID: '1',\n   *   credentials: 'credentials-returned-when-joining',\n   * })\n   *   .then(() => console.log('Left match.'))\n   *   .catch(error => console.error('Error leaving match', error));\n   */\n  async leaveMatch(\n    gameName: string,\n    matchID: string,\n    body: {\n      playerID: string;\n      credentials: string;\n      [key: string]: any;\n    },\n    init?: RequestInit\n  ): Promise<void> {\n    assertGameName(gameName);\n    assertMatchID(matchID);\n    validateBody(body, { playerID: 'string', credentials: 'string' });\n    await this.post(`/games/${gameName}/${matchID}/leave`, { body, init });\n  }\n\n  /**\n   * Update a player’s name or custom metadata.\n   * @param  gameName The match’s game type, e.g. 'tic-tac-toe'.\n   * @param  matchID  Match ID for the match to update.\n   * @param  body     Options required to update player.\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return Promise resolves if successful.\n   *\n   * @example\n   * lobbyClient.updatePlayer('tic-tac-toe', 'xyz', {\n   *   playerID: '0',\n   *   credentials: 'credentials-returned-when-joining',\n   *   newName: 'Al',\n   * })\n   *   .then(() => console.log('Updated player data.'))\n   *   .catch(error => console.error('Error updating data', error));\n   */\n  async updatePlayer(\n    gameName: string,\n    matchID: string,\n    body: {\n      playerID: string;\n      credentials: string;\n      newName?: string;\n      data?: any;\n      [key: string]: any;\n    },\n    init?: RequestInit\n  ): Promise<void> {\n    assertGameName(gameName);\n    assertMatchID(matchID);\n    validateBody(body, { playerID: 'string', credentials: 'string' });\n    await this.post(`/games/${gameName}/${matchID}/update`, { body, init });\n  }\n\n  /**\n   * Create a new match based on the configuration of the current match.\n   * @param  gameName The match’s game type, e.g. 'tic-tac-toe'.\n   * @param  matchID  Match ID for the match to play again.\n   * @param  body     Options required to configure match.\n   * @param  init     Optional RequestInit interface to override defaults.\n   * @return Object containing `nextMatchID`.\n   *\n   * @example\n   * lobbyClient.playAgain('tic-tac-toe', 'xyz', {\n   *   playerID: '0',\n   *   credentials: 'credentials-returned-when-joining',\n   * })\n   *   .then(({ nextMatchID }) => {\n   *     return lobbyClient.joinMatch('tic-tac-toe', nextMatchID, {\n   *       playerID: '0',\n   *       playerName: 'Al',\n   *     })\n   *   })\n   *   .then({ playerCredentials } => {\n   *     console.log(playerCredentials);\n   *   })\n   *   .catch(console.error);\n   */\n  async playAgain(\n    gameName: string,\n    matchID: string,\n    body: {\n      playerID: string;\n      credentials: string;\n      unlisted?: boolean;\n      [key: string]: any;\n    },\n    init?: RequestInit\n  ): Promise<LobbyAPI.NextMatch> {\n    assertGameName(gameName);\n    assertMatchID(matchID);\n    validateBody(body, { playerID: 'string', credentials: 'string' });\n    return this.post(`/games/${gameName}/${matchID}/playAgain`, { body, init });\n  }\n}\n"
  },
  {
    "path": "src/lobby/connection.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { LobbyConnection } from './connection';\nimport type { LobbyAPI } from '../types';\n\ndescribe('lobby', () => {\n  let lobby: ReturnType<typeof LobbyConnection>;\n  let match1: LobbyAPI.Match, match2: LobbyAPI.Match;\n  let jsonResult = [];\n  let nextStatus = 200;\n\n  beforeEach(async () => {\n    match1 = {\n      gameName: 'game1',\n      matchID: 'matchID_1',\n      players: [{ id: 0 }],\n      createdAt: 1,\n      updatedAt: 4,\n    };\n    match2 = {\n      gameName: 'game2',\n      matchID: 'matchID_2',\n      players: [{ id: 1 }],\n      createdAt: 2,\n      updatedAt: 3,\n    };\n    // result of connection requests\n    jsonResult = [\n      () => ['game1', 'game2'],\n      () => {\n        return { matches: [match1] };\n      },\n      () => {\n        return { matches: [match2] };\n      },\n    ];\n    const nextResult = jsonResult.shift.bind(jsonResult);\n    nextStatus = 200;\n    (global as any).fetch = jest.fn(async () => ({\n      ok: nextStatus === 200,\n      status: nextStatus,\n      json: nextResult(),\n    }));\n  });\n\n  describe('handling all games', () => {\n    beforeEach(async () => {\n      lobby = LobbyConnection({\n        server: 'localhost',\n        gameComponents: [\n          {\n            board: () => null,\n            game: { name: 'game1', minPlayers: 2, maxPlayers: 4 },\n          },\n          {\n            board: () => null,\n            game: { name: 'game2' },\n          },\n        ],\n        playerName: 'Bob',\n      });\n      await lobby.refresh();\n    });\n\n    describe('get list of matches', () => {\n      test('when the server requests succeed', async () => {\n        expect(fetch).toHaveBeenCalledTimes(3);\n        expect(lobby.matches).toEqual([match1, match2]);\n      });\n      test('when the server request fails', async () => {\n        nextStatus = 404;\n        await expect(lobby.refresh()).rejects.toThrow();\n        expect(lobby.matches).toEqual([]);\n      });\n    });\n\n    describe('join a match', () => {\n      beforeEach(async () => {\n        // result of request 'join'\n        jsonResult.push(() => {\n          return { playerCredentials: 'SECRET' };\n        });\n      });\n      test('when the match exists', async () => {\n        await lobby.join('game1', 'matchID_1', '0');\n        expect(fetch).toHaveBeenCalledTimes(4);\n        expect(lobby.matches[0].players[0]).toEqual({\n          id: 0,\n          name: 'Bob',\n        });\n        expect(lobby.playerCredentials).toEqual('SECRET');\n      });\n      test('when the match does not exist', async () => {\n        await expect(lobby.join('game1', 'matchID_3', '0')).rejects.toThrow();\n        expect(lobby.matches).toEqual([match1, match2]);\n      });\n      test('when the seat is not available', async () => {\n        match1.players[0].name = 'Bob';\n        await expect(lobby.join('game1', 'matchID_3', '0')).rejects.toThrow();\n      });\n      test('when the server request fails', async () => {\n        nextStatus = 404;\n        await expect(lobby.join('game1', 'matchID_1', '0')).rejects.toThrow();\n      });\n      test('when the player has already joined another match', async () => {\n        match2.players[0].name = 'Bob';\n        await expect(lobby.join('game1', 'matchID_1', '0')).rejects.toThrow();\n      });\n    });\n\n    describe('leave a match', () => {\n      beforeEach(async () => {\n        // result of request 'join'\n        jsonResult.push(() => {\n          return { playerCredentials: 'SECRET' };\n        });\n        await lobby.join('game1', 'matchID_1', '0');\n        // result of request 'leave'\n        jsonResult.push(() => {\n          return {};\n        });\n      });\n      test('when the match exists', async () => {\n        await lobby.leave('game1', 'matchID_1');\n        expect(fetch).toHaveBeenCalledTimes(5);\n        expect(lobby.matches).toEqual([match1, match2]);\n      });\n      test('when the match does not exist', async () => {\n        await expect(lobby.leave('game1', 'matchID_3')).rejects.toThrow();\n        expect(fetch).toHaveBeenCalledTimes(4);\n        expect(lobby.matches).toEqual([match1, match2]);\n      });\n      test('when the player is not in the match', async () => {\n        await lobby.leave('game1', 'matchID_1');\n        expect(fetch).toHaveBeenCalledTimes(5);\n        await expect(lobby.leave('game1', 'matchID_1')).rejects.toThrow();\n      });\n      test('when the server request fails', async () => {\n        nextStatus = 404;\n        await expect(lobby.leave('game1', 'matchID_1')).rejects.toThrow();\n      });\n    });\n\n    describe('disconnect', () => {\n      beforeEach(async () => {});\n      test('when the player leaves the lobby', async () => {\n        await lobby.disconnect();\n        expect(lobby.matches).toEqual([]);\n      });\n      test('when the player had joined a match', async () => {\n        // result of request 'join'\n        jsonResult.push(() => {\n          return { playerCredentials: 'SECRET' };\n        });\n        await lobby.join('game1', 'matchID_1', '0');\n        // result of request 'leave'\n        jsonResult.push(() => {\n          return {};\n        });\n        await lobby.disconnect();\n        expect(lobby.matches).toEqual([]);\n      });\n    });\n\n    describe('create a match', () => {\n      test('when the server request succeeds', async () => {\n        jsonResult.push(() => ({ matchID: 'abc' }));\n        await lobby.create('game1', 2);\n        expect(fetch).toHaveBeenCalledTimes(4);\n      });\n      test('when the number of players is off boundaries', async () => {\n        await expect(lobby.create('game1', 1)).rejects.toThrow();\n      });\n      test('when the number of players has no boundaries', async () => {\n        jsonResult.push(() => ({ matchID: 'def' }));\n        await expect(lobby.create('game2', 1)).resolves.toBeUndefined();\n      });\n      test('when the game is unknown', async () => {\n        await expect(lobby.create('game3', 2)).rejects.toThrow();\n      });\n      test('when the server request fails', async () => {\n        nextStatus = 404;\n        await expect(lobby.create('game1', 2)).rejects.toThrow();\n      });\n    });\n  });\n\n  describe('handling some games', () => {\n    beforeEach(async () => {\n      lobby = LobbyConnection({\n        server: 'localhost',\n        gameComponents: [{ board: () => null, game: { name: 'game1' } }],\n      });\n      await lobby.refresh();\n    });\n    test('get list of matches for supported games', async () => {\n      expect(fetch).toHaveBeenCalledTimes(2);\n      expect(lobby.matches).toEqual([match1]);\n    });\n  });\n});\n"
  },
  {
    "path": "src/lobby/connection.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { ComponentType } from 'react';\nimport { LobbyClient } from './client';\nimport type { Game, LobbyAPI } from '../types';\n\nexport interface GameComponent {\n  game: Game;\n  board: ComponentType<any>;\n}\n\ninterface LobbyConnectionOpts {\n  server: string;\n  playerName?: string;\n  playerCredentials?: string;\n  gameComponents: GameComponent[];\n}\n\nclass _LobbyConnectionImpl {\n  client: LobbyClient;\n  gameComponents: GameComponent[];\n  playerName: string;\n  playerCredentials?: string;\n  matches: LobbyAPI.MatchList['matches'];\n\n  constructor({\n    server,\n    gameComponents,\n    playerName,\n    playerCredentials,\n  }: LobbyConnectionOpts) {\n    this.client = new LobbyClient({ server });\n    this.gameComponents = gameComponents;\n    this.playerName = playerName || 'Visitor';\n    this.playerCredentials = playerCredentials;\n    this.matches = [];\n  }\n\n  async refresh() {\n    try {\n      this.matches = [];\n      const games = await this.client.listGames();\n      for (const game of games) {\n        if (!this._getGameComponents(game)) continue;\n        const { matches } = await this.client.listMatches(game);\n        this.matches.push(...matches);\n      }\n    } catch (error) {\n      throw new Error('failed to retrieve list of matches (' + error + ')');\n    }\n  }\n\n  _getMatchInstance(matchID: string) {\n    for (const inst of this.matches) {\n      if (inst['matchID'] === matchID) return inst;\n    }\n  }\n\n  _getGameComponents(gameName: string) {\n    for (const comp of this.gameComponents) {\n      if (comp.game.name === gameName) return comp;\n    }\n  }\n\n  _findPlayer(playerName: string) {\n    for (const inst of this.matches) {\n      if (inst.players.some((player) => player.name === playerName))\n        return inst;\n    }\n  }\n\n  async join(gameName: string, matchID: string, playerID: string) {\n    try {\n      let inst = this._findPlayer(this.playerName);\n      if (inst) {\n        throw new Error('player has already joined ' + inst.matchID);\n      }\n      inst = this._getMatchInstance(matchID);\n      if (!inst) {\n        throw new Error('game instance ' + matchID + ' not found');\n      }\n      const json = await this.client.joinMatch(gameName, matchID, {\n        playerID,\n        playerName: this.playerName,\n      });\n      inst.players[Number.parseInt(playerID)].name = this.playerName;\n      this.playerCredentials = json.playerCredentials;\n    } catch (error) {\n      throw new Error('failed to join match ' + matchID + ' (' + error + ')');\n    }\n  }\n\n  async leave(gameName: string, matchID: string) {\n    try {\n      const inst = this._getMatchInstance(matchID);\n      if (!inst) throw new Error('match instance not found');\n      for (const player of inst.players) {\n        if (player.name === this.playerName) {\n          await this.client.leaveMatch(gameName, matchID, {\n            playerID: player.id.toString(),\n            credentials: this.playerCredentials,\n          });\n          delete player.name;\n          delete this.playerCredentials;\n          return;\n        }\n      }\n      throw new Error('player not found in match');\n    } catch (error) {\n      throw new Error('failed to leave match ' + matchID + ' (' + error + ')');\n    }\n  }\n\n  async disconnect() {\n    const inst = this._findPlayer(this.playerName);\n    if (inst) {\n      await this.leave(inst.gameName, inst.matchID);\n    }\n    this.matches = [];\n    this.playerName = 'Visitor';\n  }\n\n  async create(gameName: string, numPlayers: number) {\n    try {\n      const comp = this._getGameComponents(gameName);\n      if (!comp) throw new Error('game not found');\n      if (\n        numPlayers < comp.game.minPlayers ||\n        numPlayers > comp.game.maxPlayers\n      )\n        throw new Error('invalid number of players ' + numPlayers);\n      await this.client.createMatch(gameName, { numPlayers });\n    } catch (error) {\n      throw new Error(\n        'failed to create match for ' + gameName + ' (' + error + ')'\n      );\n    }\n  }\n}\n\n/**\n * LobbyConnection\n *\n * Lobby model.\n *\n * @param {string}   server - '<host>:<port>' of the server.\n * @param {Array}    gameComponents - A map of Board and Game objects for the supported games.\n * @param {string}   playerName - The name of the player.\n * @param {string}   playerCredentials - The credentials currently used by the player, if any.\n *\n * Returns:\n *   A JS object that synchronizes the list of running game instances with the server and provides an API to create/join/start instances.\n */\nexport function LobbyConnection(opts: LobbyConnectionOpts) {\n  return new _LobbyConnectionImpl(opts);\n}\n"
  },
  {
    "path": "src/lobby/create-match-form.tsx",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport type { Game } from '../types';\nimport type { GameComponent } from './connection';\n\ntype CreateMatchProps = {\n  games: GameComponent[];\n  createMatch: (gameName: string, numPlayers: number) => Promise<void>;\n};\n\ntype CreateMatchState = {\n  selectedGame: number;\n  numPlayers: number;\n};\n\nclass LobbyCreateMatchForm extends React.Component<\n  CreateMatchProps,\n  CreateMatchState\n> {\n  state = {\n    selectedGame: 0,\n    numPlayers: 2,\n  };\n\n  constructor(props: CreateMatchProps) {\n    super(props);\n    /* fix min and max number of players */\n    for (const game of props.games) {\n      const matchDetails = game.game;\n      if (!matchDetails.minPlayers) {\n        matchDetails.minPlayers = 1;\n      }\n      if (!matchDetails.maxPlayers) {\n        matchDetails.maxPlayers = 4;\n      }\n      console.assert(matchDetails.maxPlayers >= matchDetails.minPlayers);\n    }\n    this.state = {\n      selectedGame: 0,\n      numPlayers: props.games[0].game.minPlayers,\n    };\n  }\n\n  _createGameNameOption = (game: GameComponent, idx: number) => {\n    return (\n      <option key={'name-option-' + idx} value={idx}>\n        {game.game.name}\n      </option>\n    );\n  };\n\n  _createNumPlayersOption = (idx: number) => {\n    return (\n      <option key={'num-option-' + idx} value={idx}>\n        {idx}\n      </option>\n    );\n  };\n\n  _createNumPlayersRange = (game: Game) => {\n    return Array.from({ length: game.maxPlayers + 1 })\n      .map((_, i) => i)\n      .slice(game.minPlayers);\n  };\n\n  render() {\n    return (\n      <div>\n        <select\n          value={this.state.selectedGame}\n          onChange={(evt) => this.onChangeSelectedGame(evt)}\n        >\n          {this.props.games.map((game, index) =>\n            this._createGameNameOption(game, index)\n          )}\n        </select>\n        <span>Players:</span>\n        <select\n          value={this.state.numPlayers}\n          onChange={this.onChangeNumPlayers}\n        >\n          {this._createNumPlayersRange(\n            this.props.games[this.state.selectedGame].game\n          ).map((number) => this._createNumPlayersOption(number))}\n        </select>\n        <span className=\"buttons\">\n          <button onClick={this.onClickCreate}>Create</button>\n        </span>\n      </div>\n    );\n  }\n\n  onChangeNumPlayers = (event: React.ChangeEvent<HTMLSelectElement>) => {\n    this.setState({\n      numPlayers: Number.parseInt(event.target.value),\n    });\n  };\n\n  onChangeSelectedGame = (event: React.ChangeEvent<HTMLSelectElement>) => {\n    const idx = Number.parseInt(event.target.value);\n    this.setState({\n      selectedGame: idx,\n      numPlayers: this.props.games[idx].game.minPlayers,\n    });\n  };\n\n  onClickCreate = () => {\n    this.props.createMatch(\n      this.props.games[this.state.selectedGame].game.name,\n      this.state.numPlayers\n    );\n  };\n}\n\nexport default LobbyCreateMatchForm;\n"
  },
  {
    "path": "src/lobby/login-form.tsx",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\n\ntype LoginFormProps = {\n  playerName?: string;\n  onEnter: (playerName: string) => void;\n};\n\ntype LoginFormState = {\n  playerName?: string;\n  nameErrorMsg: string;\n};\n\nclass LobbyLoginForm extends React.Component<LoginFormProps, LoginFormState> {\n  static defaultProps = {\n    playerName: '',\n  };\n\n  state = {\n    playerName: this.props.playerName,\n    nameErrorMsg: '',\n  };\n\n  render() {\n    return (\n      <div>\n        <p className=\"phase-title\">Choose a player name:</p>\n        <input\n          type=\"text\"\n          value={this.state.playerName}\n          onChange={this.onChangePlayerName}\n          onKeyPress={this.onKeyPress}\n        />\n        <span className=\"buttons\">\n          <button className=\"buttons\" onClick={this.onClickEnter}>\n            Enter\n          </button>\n        </span>\n        <br />\n        <span className=\"error-msg\">\n          {this.state.nameErrorMsg}\n          <br />\n        </span>\n      </div>\n    );\n  }\n\n  onClickEnter = () => {\n    if (this.state.playerName === '') return;\n    this.props.onEnter(this.state.playerName);\n  };\n\n  onKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {\n    if (event.key === 'Enter') {\n      this.onClickEnter();\n    }\n  };\n\n  onChangePlayerName = (event: React.ChangeEvent<HTMLInputElement>) => {\n    const name = event.target.value.trim();\n    this.setState({\n      playerName: name,\n      nameErrorMsg: name.length > 0 ? '' : 'empty player name',\n    });\n  };\n}\n\nexport default LobbyLoginForm;\n"
  },
  {
    "path": "src/lobby/match-instance.tsx",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport type { LobbyAPI } from '../types';\n\nexport type MatchOpts = {\n  numPlayers: number;\n  matchID: string;\n  playerID?: string;\n};\n\ntype Match = {\n  gameName: string;\n  matchID: string;\n  players: LobbyAPI.Match['players'];\n};\n\ntype MatchInstanceProps = {\n  match: Match;\n  playerName: string;\n  onClickJoin: (gameName: string, matchID: string, playerID: string) => void;\n  onClickLeave: (gameName: string, matchID: string) => void;\n  onClickPlay: (gameName: string, matchOpts: MatchOpts) => void;\n};\n\nclass LobbyMatchInstance extends React.Component<MatchInstanceProps> {\n  _createSeat = (player: { name?: string }) => {\n    return player.name || '[free]';\n  };\n\n  _createButtonJoin = (inst: Match, seatId: number) => (\n    <button\n      key={'button-join-' + inst.matchID}\n      onClick={() =>\n        this.props.onClickJoin(inst.gameName, inst.matchID, '' + seatId)\n      }\n    >\n      Join\n    </button>\n  );\n\n  _createButtonLeave = (inst: Match) => (\n    <button\n      key={'button-leave-' + inst.matchID}\n      onClick={() => this.props.onClickLeave(inst.gameName, inst.matchID)}\n    >\n      Leave\n    </button>\n  );\n\n  _createButtonPlay = (inst: Match, seatId: number) => (\n    <button\n      key={'button-play-' + inst.matchID}\n      onClick={() =>\n        this.props.onClickPlay(inst.gameName, {\n          matchID: inst.matchID,\n          playerID: '' + seatId,\n          numPlayers: inst.players.length,\n        })\n      }\n    >\n      Play\n    </button>\n  );\n\n  _createButtonSpectate = (inst: Match) => (\n    <button\n      key={'button-spectate-' + inst.matchID}\n      onClick={() =>\n        this.props.onClickPlay(inst.gameName, {\n          matchID: inst.matchID,\n          numPlayers: inst.players.length,\n        })\n      }\n    >\n      Spectate\n    </button>\n  );\n\n  _createInstanceButtons = (inst: Match) => {\n    const playerSeat = inst.players.find(\n      (player) => player.name === this.props.playerName\n    );\n    const freeSeat = inst.players.find((player) => !player.name);\n    if (playerSeat && freeSeat) {\n      // already seated: waiting for match to start\n      return this._createButtonLeave(inst);\n    }\n    if (freeSeat) {\n      // at least 1 seat is available\n      return this._createButtonJoin(inst, freeSeat.id);\n    }\n    // match is full\n    if (playerSeat) {\n      return (\n        <div>\n          {[\n            this._createButtonPlay(inst, playerSeat.id),\n            this._createButtonLeave(inst),\n          ]}\n        </div>\n      );\n    }\n    // allow spectating\n    return this._createButtonSpectate(inst);\n  };\n\n  render() {\n    const match = this.props.match;\n    let status = 'OPEN';\n    if (!match.players.some((player) => !player.name)) {\n      status = 'RUNNING';\n    }\n    return (\n      <tr key={'line-' + match.matchID}>\n        <td key={'cell-name-' + match.matchID}>{match.gameName}</td>\n        <td key={'cell-status-' + match.matchID}>{status}</td>\n        <td key={'cell-seats-' + match.matchID}>\n          {match.players.map((player) => this._createSeat(player)).join(', ')}\n        </td>\n        <td key={'cell-buttons-' + match.matchID}>\n          {this._createInstanceButtons(match)}\n        </td>\n      </tr>\n    );\n  }\n}\n\nexport default LobbyMatchInstance;\n"
  },
  {
    "path": "src/lobby/react.ssr.test.tsx",
    "content": "/**\n * @jest-environment node\n */\n\nimport React from 'react';\nimport Lobby from './react';\nimport ReactDOMServer from 'react-dom/server';\n\n/* mock server requests */\nglobal.fetch = jest\n  .fn()\n  .mockReturnValue({ ok: true, status: 200, json: () => [] });\n\ndescribe('lobby', () => {\n  test('is rendered', () => {\n    const components: any[] = [{ board: 'Board', game: { name: 'GameName' } }];\n    const ssrRender = ReactDOMServer.renderToString(\n      <Lobby gameServer=\"localhost\" gameComponents={components} />\n    );\n    expect(ssrRender).toContain('lobby-view');\n  });\n});\n"
  },
  {
    "path": "src/lobby/react.test.tsx",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport Cookies from 'react-cookies';\nimport Lobby from './react';\nimport Enzyme from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\n\n/* mock server requests */\nglobal.fetch = jest\n  .fn()\n  .mockReturnValue({ ok: true, status: 200, json: () => [] });\n\n/* mock 'Client' component */\nfunction NullComponent() {\n  return '<noscript />';\n}\n\nEnzyme.configure({ adapter: new Adapter() });\n\ndescribe('lobby', () => {\n  let lobby;\n  const spy = jest.fn();\n  let setIntervalSpy;\n  let clearIntervalSpy;\n  let components: any[];\n\n  beforeEach(async () => {\n    setIntervalSpy = jest.spyOn(global, 'setInterval');\n    clearIntervalSpy = jest.spyOn(global, 'clearInterval');\n    components = [\n      {\n        board: 'Board1',\n        game: { name: 'GameName1', minPlayers: 3, maxPlayers: 5 },\n      },\n      { board: 'Board2', game: { name: 'GameName2' } },\n      {\n        board: 'Board3',\n        game: { name: 'GameName3', maxPlayers: 1 },\n      },\n    ];\n  });\n\n  afterEach(() => {\n    spy.mockReset();\n    setIntervalSpy.mockRestore();\n    clearIntervalSpy.mockRestore();\n  });\n\n  describe('specify servers', () => {\n    test('gameServer', () => {\n      const spy = jest.fn();\n      const lobby: any = Enzyme.mount(\n        <Lobby\n          gameComponents={components}\n          clientFactory={spy.mockReturnValue(NullComponent)}\n          gameServer=\"localhost:9000\"\n        />\n      );\n      lobby.instance()._startMatch('GameName1', { numPlayers: 2 });\n      expect(spy).toBeCalledWith(\n        expect.objectContaining({\n          multiplayer: expect.anything(),\n        })\n      );\n    });\n  });\n\n  describe('login/logout', () => {\n    beforeEach(async () => {\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n    });\n\n    test('changing prop debug', () => {\n      expect(() => {\n        lobby.setProps({\n          debug: !lobby.props().debug,\n        });\n      }).not.toThrow();\n    });\n\n    describe('login succeeds', () => {\n      beforeEach(async () => {\n        lobby\n          .find('LobbyLoginForm')\n          .find('input')\n          .props()\n          .onChange({ target: { value: 'Mark' } });\n      });\n      test('by clicking', () => {\n        lobby.find('LobbyLoginForm').find('button').simulate('click');\n        expect(lobby.instance().state.playerName).toBe('Mark');\n      });\n      test('by pressing enter', () => {\n        lobby\n          .find('LobbyLoginForm')\n          .find('input')\n          .props()\n          .onKeyPress({ key: 'Enter' });\n        expect(lobby.instance().state.playerName).toBe('Mark');\n      });\n    });\n\n    describe('login fails', () => {\n      test('if no name entered', () => {\n        lobby\n          .find('LobbyLoginForm')\n          .find('input')\n          .props()\n          .onChange({ target: { value: '' } });\n        lobby.find('LobbyLoginForm').find('button').simulate('click');\n        expect(lobby.find('LobbyLoginForm').find('.error-msg').text()).not.toBe(\n          ''\n        );\n      });\n      test('invalid key press', () => {\n        const input = lobby.find('LobbyLoginForm').find('input');\n        const currentValue = input.instance().value;\n        input.props().onKeyPress({ key: 'Wololo' });\n        expect(input.instance().value).toBe(currentValue);\n      });\n    });\n\n    describe('exiting lobby', () => {\n      beforeEach(async () => {\n        lobby.instance().connection.matches = [\n          {\n            matchID: 'matchID1',\n            players: {\n              '0': { id: 0, name: 'Bob' },\n              '1': { id: 1 },\n            },\n            gameName: 'GameName1',\n          },\n        ];\n        lobby.instance().forceUpdate();\n        lobby.update();\n      });\n      test('disconnect from server', async () => {\n        lobby.instance().connection.disconnect = spy;\n        lobby.find('#lobby-exit').find('button').simulate('click');\n        expect(spy).toHaveBeenCalledWith();\n      });\n    });\n  });\n\n  describe('refresh during game', () => {\n    beforeEach(async () => {\n      // initial state = phase 'play'\n      Cookies.save(\n        'lobbyState',\n        {\n          phase: 'play',\n          playerName: 'Bob',\n        },\n        { path: '/' }\n      );\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n    });\n    afterEach(() => {\n      Cookies.remove('lobbyState', { path: '/' });\n    });\n    test('reset phase to list', async () => {\n      expect(lobby.instance().state.phase).toBe('list');\n    });\n  });\n\n  describe('refresh interval triggering', () => {\n    test('refresh does not start on initial component mount', () => {\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n\n      expect(setIntervalSpy).not.toHaveBeenCalled();\n    });\n\n    test('refresh starts when transitioning from ENTER lobby to LIST lobby', () => {\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n\n      lobby\n        .find('LobbyLoginForm')\n        .find('input')\n        .props()\n        .onKeyPress({ key: 'Enter' });\n\n      expect(setIntervalSpy).toHaveBeenCalledTimes(1);\n      expect(setIntervalSpy).toHaveBeenCalledWith(expect.any(Function), 2000);\n    });\n\n    test('refresh starts when component mounts and cookie state sends us to LIST', () => {\n      Cookies.save(\n        'lobbyState',\n        {\n          phase: 'list',\n          playerName: 'Bob',\n        },\n        { path: '/' }\n      );\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n\n      expect(setIntervalSpy).toHaveBeenCalledTimes(1);\n      expect(setIntervalSpy).toHaveBeenCalledWith(expect.any(Function), 2000);\n    });\n\n    test('refresh stops when transitioning from LIST to PLAY', () => {\n      Cookies.save(\n        'lobbyState',\n        {\n          phase: 'list',\n          playerName: 'Bob',\n        },\n        { path: '/' }\n      );\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n\n      lobby.instance()._startMatch('GameName1', { numPlayers: 2 });\n\n      expect(clearIntervalSpy).toHaveBeenCalledWith(\n        lobby.instance()._currentInterval\n      );\n    });\n  });\n\n  describe('refresh interval tracking', () => {\n    beforeEach(() => {\n      lobby = Enzyme.mount(<Lobby gameComponents={components} />);\n      lobby\n        .find('LobbyLoginForm')\n        .find('input')\n        .props()\n        .onKeyPress({ key: 'Enter' });\n    });\n\n    afterEach(() => lobby.unmount());\n\n    test('lobby stores an interval ID', () => {\n      const { _currentInterval } = lobby.instance();\n      expect(_currentInterval).toEqual(expect.any(Number));\n    });\n\n    test('updating interval prop, updates internal interval ID', () => {\n      const { _currentInterval } = lobby.instance();\n      lobby.setProps({ refreshInterval: 10000 });\n      expect(lobby.instance()._currentInterval).not.toEqual(_currentInterval);\n    });\n\n    test('updating other props does not update interval ID', () => {\n      const { _currentInterval } = lobby.instance();\n      lobby.setProps({ debug: true });\n      expect(lobby.instance()._currentInterval).toEqual(_currentInterval);\n    });\n  });\n\n  describe('matches list', () => {\n    const spyClient = jest.fn();\n    beforeEach(async () => {\n      // initial state = logged-in as 'Bob'\n      Cookies.save(\n        'lobbyState',\n        {\n          phase: 'list',\n          playerName: 'Bob',\n        },\n        { path: '/' }\n      );\n      lobby = Enzyme.mount(\n        <Lobby\n          gameComponents={components}\n          // stub for Client factory\n          clientFactory={spyClient.mockReturnValue(NullComponent)}\n        />\n      );\n    });\n\n    afterEach(() => {\n      spyClient.mockReset();\n      Cookies.remove('lobbyState', { path: '/' });\n    });\n\n    describe('creating a match', () => {\n      beforeEach(async () => {\n        lobby.instance().connection.matches = [\n          {\n            matchID: 'matchID1',\n            players: { '0': { id: 0 } },\n            gameName: 'GameName1',\n          },\n        ];\n        lobby.instance().forceUpdate();\n        lobby.update();\n      });\n\n      test('match with default number of players', () => {\n        lobby.instance().connection.create = spy;\n        lobby.find('LobbyCreateMatchForm').find('button').simulate('click');\n        expect(spy).toHaveBeenCalledWith('GameName1', 3);\n      });\n      test('match with 2 players', () => {\n        lobby.instance().connection.create = spy;\n        lobby\n          .find('LobbyCreateMatchForm')\n          .find('select')\n          .first()\n          .props()\n          .onChange({ target: { value: '1' } });\n        lobby\n          .find('LobbyCreateMatchForm')\n          .find('select')\n          .at(1)\n          .props()\n          .onChange({ target: { value: '2' } });\n        lobby.find('LobbyCreateMatchForm').find('button').simulate('click');\n        expect(spy).toHaveBeenCalledWith('GameName2', 2);\n      });\n      test('when server request fails', async () => {\n        lobby.instance().connection.create = spy.mockImplementation(() => {\n          throw new Error('fail');\n        });\n        await lobby\n          .find('LobbyCreateMatchForm')\n          .find('button')\n          .simulate('click');\n        expect(lobby.find('#instances').find('.error-msg').text()).not.toBe('');\n      });\n      test('when game has no boundaries on the number of players', async () => {\n        // select 2nd game\n        lobby\n          .find('LobbyCreateMatchForm')\n          .find('select')\n          .first()\n          .props()\n          .onChange({ target: { value: '1' } });\n        expect(\n          lobby.find('LobbyCreateMatchForm').find('select').at(1).text()\n        ).toBe('1234');\n      });\n      test('when game has boundaries on the number of players', async () => {\n        expect(\n          lobby.find('LobbyCreateMatchForm').find('select').at(1).text()\n        ).toBe('345');\n      });\n    });\n\n    describe('joining a match', () => {\n      beforeEach(async () => {\n        lobby.instance().connection.matches = [\n          {\n            matchID: 'matchID1',\n            players: { '0': { id: 0 } },\n            gameName: 'GameName1',\n          },\n          {\n            matchID: 'matchID2',\n            players: { '0': { id: 0, name: 'Bob' } },\n            gameName: 'GameName1',\n          },\n        ];\n        lobby.instance().forceUpdate();\n        lobby.update();\n      });\n      test('when match is empty', () => {\n        // join 1st match\n        lobby.instance().connection.join = spy;\n        lobby\n          .find('LobbyMatchInstance')\n          .first()\n          .find('button')\n          .simulate('click');\n        expect(spy).toHaveBeenCalledWith('GameName1', 'matchID1', '0');\n      });\n      test('when match is full', () => {\n        // try 2nd match\n        expect(lobby.find('LobbyMatchInstance').at(1).text()).toContain(\n          'RUNNING'\n        );\n      });\n      test('when server request fails', async () => {\n        lobby.instance().connection.join = spy.mockImplementation(() => {\n          throw new Error('fail');\n        });\n        // join 1st match\n        await lobby\n          .find('LobbyMatchInstance')\n          .first()\n          .find('button')\n          .simulate('click');\n        expect(lobby.find('#instances').find('.error-msg').text()).not.toBe('');\n      });\n    });\n\n    describe('leaving a match', () => {\n      beforeEach(async () => {\n        lobby.instance().connection.matches = [\n          {\n            matchID: 'matchID1',\n            players: {\n              '0': { id: 0, name: 'Bob' },\n              '1': { id: 1 },\n            },\n            gameName: 'GameName1',\n          },\n        ];\n        lobby.instance().forceUpdate();\n        lobby.update();\n      });\n      test('shall leave a match', () => {\n        // leave match\n        lobby.instance().connection.leave = spy;\n        lobby.find('LobbyMatchInstance').find('button').simulate('click');\n        expect(spy).toHaveBeenCalledWith('GameName1', 'matchID1');\n      });\n      test('when server request fails', async () => {\n        lobby.instance().connection.leave = spy.mockImplementation(() => {\n          throw new Error('fail');\n        });\n        await lobby.find('LobbyMatchInstance').find('button').simulate('click');\n        expect(lobby.find('#instances').find('.error-msg').text()).not.toBe('');\n      });\n    });\n\n    describe('starting a game', () => {\n      beforeEach(async () => {\n        lobby.instance().connection.matches = [\n          {\n            matchID: 'matchID1',\n            players: {\n              '0': { id: 0, name: 'Bob', credentials: 'SECRET1' },\n              '1': { id: 1, name: 'Charly', credentials: 'SECRET2' },\n            },\n            gameName: 'GameName1',\n          },\n          {\n            matchID: 'matchID2',\n            players: { '0': { id: 0, name: 'Alice' } },\n            gameName: 'GameName2',\n          },\n          {\n            matchID: 'matchID3',\n            players: { '0': { id: 0, name: 'Bob' } },\n            gameName: 'GameName3',\n          },\n          {\n            matchID: 'matchID4',\n            players: { '0': { id: 0, name: 'Zoe' } },\n            gameName: 'GameNameUnknown',\n          },\n        ];\n        lobby.instance().forceUpdate();\n        lobby.update();\n      });\n\n      test('if player has joined the game', () => {\n        lobby.instance().connection.playerCredentials = 'SECRET1';\n        lobby\n          .find('LobbyMatchInstance')\n          .first()\n          .find('button')\n\n          .first()\n          .simulate('click');\n        expect(lobby.instance().state.runningMatch).toEqual({\n          app: NullComponent,\n          matchID: 'matchID1',\n          playerID: '0',\n          credentials: 'SECRET1',\n        });\n        expect(spyClient).toHaveBeenCalledWith({\n          game: components[0].game,\n          board: components[0].board,\n          multiplayer: expect.anything(),\n          debug: false,\n        });\n      });\n\n      test('if player is spectator', () => {\n        lobby.find('LobbyMatchInstance').at(1).find('button').simulate('click');\n        expect(lobby.instance().state.runningMatch).toEqual({\n          app: NullComponent,\n          credentials: undefined,\n          matchID: 'matchID2',\n          playerID: '0',\n        });\n      });\n\n      test('if game is not supported', () => {\n        lobby.find('LobbyMatchInstance').at(3).find('button').simulate('click');\n        expect(spy).not.toHaveBeenCalled();\n        expect(lobby.find('#instances').find('.error-msg').text()).not.toBe('');\n      });\n\n      test('if game is monoplayer', () => {\n        lobby\n          .find('LobbyMatchInstance')\n          .at(2)\n          .find('button')\n\n          .first()\n          .simulate('click');\n        expect(spy).not.toHaveBeenCalledWith(expect.anything(), {\n          matchID: 'matchID3',\n        });\n      });\n    });\n\n    describe('exiting during game', () => {\n      beforeEach(async () => {\n        lobby.instance().connection.matches = [\n          {\n            matchID: 'matchID1',\n            players: {\n              '0': { id: 0, name: 'Bob', credentials: 'SECRET1' },\n              '1': { id: 1, name: 'Charly', credentials: 'SECRET2' },\n            },\n            gameName: 'GameName1',\n          },\n        ];\n        lobby.instance().forceUpdate();\n        lobby.update();\n      });\n      test('reset game', () => {\n        lobby.instance().connection.playerCredentials = 'SECRET1';\n        // start game\n        lobby\n          .find('LobbyMatchInstance')\n          .first()\n          .find('button')\n          .first()\n          .simulate('click');\n        // exit game\n        lobby.find('#match-exit').find('button').simulate('click');\n        expect(lobby.instance().state.runningMatch).toEqual(null);\n        expect(lobby.instance().state.phase).toEqual('list');\n      });\n    });\n\n    describe('custom renderer', () => {\n      test('should render custom lobby ui', () => {\n        const lobby = Enzyme.mount(\n          <Lobby gameComponents={[]} renderer={() => <div>Foo</div>} />\n        );\n\n        expect(lobby.html()).toEqual('<div>Foo</div>');\n      });\n\n      test('should render custom lobby with games list', () => {\n        const components: any[] = [\n          { game: { name: 'GameName1' } },\n          { game: { name: 'GameName2' } },\n        ];\n        const CustomLobbyUI = ({ gameComponents }: any) => (\n          <div>\n            {gameComponents\n              .map((gameComponent) => gameComponent.game.name)\n              .join(',')}\n          </div>\n        );\n\n        const lobby = Enzyme.mount(\n          <Lobby\n            gameComponents={components}\n            renderer={({ gameComponents }) => (\n              <CustomLobbyUI gameComponents={gameComponents} />\n            )}\n          />\n        );\n\n        expect(lobby.html()).toEqual('<div>GameName1,GameName2</div>');\n      });\n\n      test('should change lobby phase when click on custom enter button', () => {\n        const CustomLobbyUI = ({ onEnterLobby }: any) => (\n          <button onClick={() => onEnterLobby('Alex')}>Enter</button>\n        );\n\n        const lobby: any = Enzyme.mount(\n          <Lobby\n            gameComponents={[]}\n            renderer={({ handleEnterLobby }) => (\n              <CustomLobbyUI onEnterLobby={handleEnterLobby} />\n            )}\n          />\n        );\n        lobby.find('button').simulate('click');\n\n        expect(lobby.instance().state.phase).toEqual('list');\n        expect(lobby.instance().state.playerName).toEqual('Alex');\n      });\n    });\n  });\n});\n"
  },
  {
    "path": "src/lobby/react.tsx",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors.\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport React from 'react';\nimport Cookies from 'react-cookies';\nimport PropTypes from 'prop-types';\nimport type { DebugOpt } from '../client/client';\nimport { Client } from '../client/react';\nimport { MCTSBot } from '../ai/mcts-bot';\nimport { Local } from '../client/transport/local';\nimport { SocketIO } from '../client/transport/socketio';\nimport type { GameComponent } from './connection';\nimport { LobbyConnection } from './connection';\nimport LobbyLoginForm from './login-form';\nimport type { MatchOpts } from './match-instance';\nimport LobbyMatchInstance from './match-instance';\nimport LobbyCreateMatchForm from './create-match-form';\nimport type { LobbyAPI } from '../types';\n\nenum LobbyPhases {\n  ENTER = 'enter',\n  PLAY = 'play',\n  LIST = 'list',\n}\n\ntype RunningMatch = {\n  app: ReturnType<typeof Client>;\n  matchID: string;\n  playerID: string;\n  credentials?: string;\n};\n\ntype LobbyProps = {\n  gameComponents: GameComponent[];\n  lobbyServer?: string;\n  gameServer?: string;\n  debug?: DebugOpt | boolean;\n  clientFactory?: typeof Client;\n  refreshInterval?: number;\n  renderer?: (args: {\n    errorMsg: string;\n    gameComponents: GameComponent[];\n    matches: LobbyAPI.MatchList['matches'];\n    phase: LobbyPhases;\n    playerName: string;\n    runningMatch?: RunningMatch;\n    handleEnterLobby: (playerName: string) => void;\n    handleExitLobby: () => Promise<void>;\n    handleCreateMatch: (gameName: string, numPlayers: number) => Promise<void>;\n    handleJoinMatch: (\n      gameName: string,\n      matchID: string,\n      playerID: string\n    ) => Promise<void>;\n    handleLeaveMatch: (gameName: string, matchID: string) => Promise<void>;\n    handleExitMatch: () => void;\n    handleRefreshMatches: () => Promise<void>;\n    handleStartMatch: (gameName: string, matchOpts: MatchOpts) => void;\n  }) => JSX.Element;\n};\n\ntype LobbyState = {\n  phase: LobbyPhases;\n  playerName: string;\n  runningMatch?: RunningMatch;\n  errorMsg: string;\n  credentialStore?: { [playerName: string]: string };\n};\n\n/**\n * Lobby\n *\n * React lobby component.\n *\n * @param {Array}  gameComponents - An array of Board and Game objects for the supported games.\n * @param {string} lobbyServer - Address of the lobby server (for example 'localhost:8000').\n *                               If not set, defaults to the server that served the page.\n * @param {string} gameServer - Address of the game server (for example 'localhost:8001').\n *                              If not set, defaults to the server that served the page.\n * @param {function} clientFactory - Function that is used to create the game clients.\n * @param {number} refreshInterval - Interval between server updates (default: 2000ms).\n * @param {bool}   debug - Enable debug information (default: false).\n *\n * Returns:\n *   A React component that provides a UI to create, list, join, leave, play or\n *   spectate matches (game instances).\n */\nclass Lobby extends React.Component<LobbyProps, LobbyState> {\n  static propTypes = {\n    gameComponents: PropTypes.array.isRequired,\n    lobbyServer: PropTypes.string,\n    gameServer: PropTypes.string,\n    debug: PropTypes.bool,\n    clientFactory: PropTypes.func,\n    refreshInterval: PropTypes.number,\n  };\n\n  static defaultProps = {\n    debug: false,\n    clientFactory: Client,\n    refreshInterval: 2000,\n  };\n\n  state = {\n    phase: LobbyPhases.ENTER,\n    playerName: 'Visitor',\n    runningMatch: null,\n    errorMsg: '',\n    credentialStore: {},\n  };\n\n  private connection?: ReturnType<typeof LobbyConnection>;\n  private _currentInterval?: NodeJS.Timeout;\n\n  constructor(props: LobbyProps) {\n    super(props);\n    this._createConnection(this.props);\n  }\n\n  componentDidMount() {\n    const cookie = Cookies.load('lobbyState') || {};\n    if (cookie.phase && cookie.phase === LobbyPhases.PLAY) {\n      cookie.phase = LobbyPhases.LIST;\n    }\n    if (cookie.phase && cookie.phase !== LobbyPhases.ENTER) {\n      this._startRefreshInterval();\n    }\n    this.setState({\n      phase: cookie.phase || LobbyPhases.ENTER,\n      playerName: cookie.playerName || 'Visitor',\n      credentialStore: cookie.credentialStore || {},\n    });\n  }\n\n  componentDidUpdate(prevProps: LobbyProps, prevState: LobbyState) {\n    const name = this.state.playerName;\n    const creds = this.state.credentialStore[name];\n    if (\n      prevState.phase !== this.state.phase ||\n      prevState.credentialStore[name] !== creds ||\n      prevState.playerName !== name\n    ) {\n      this._createConnection(this.props);\n      this._updateConnection();\n      const cookie = {\n        phase: this.state.phase,\n        playerName: name,\n        credentialStore: this.state.credentialStore,\n      };\n      Cookies.save('lobbyState', cookie, { path: '/' });\n    }\n    if (prevProps.refreshInterval !== this.props.refreshInterval) {\n      this._startRefreshInterval();\n    }\n  }\n\n  componentWillUnmount() {\n    this._clearRefreshInterval();\n  }\n\n  _startRefreshInterval() {\n    this._clearRefreshInterval();\n    this._currentInterval = setInterval(\n      this._updateConnection,\n      this.props.refreshInterval\n    );\n  }\n\n  _clearRefreshInterval() {\n    clearInterval(this._currentInterval);\n  }\n\n  _createConnection = (props: LobbyProps) => {\n    const name = this.state.playerName;\n    this.connection = LobbyConnection({\n      server: props.lobbyServer,\n      gameComponents: props.gameComponents,\n      playerName: name,\n      playerCredentials: this.state.credentialStore[name],\n    });\n  };\n\n  _updateCredentials = (playerName: string, credentials: string) => {\n    this.setState((prevState) => {\n      // clone store or componentDidUpdate will not be triggered\n      const store = Object.assign({}, prevState.credentialStore);\n      store[playerName] = credentials;\n      return { credentialStore: store };\n    });\n  };\n\n  _updateConnection = async () => {\n    await this.connection.refresh();\n    this.forceUpdate();\n  };\n\n  _enterLobby = (playerName: string) => {\n    this._startRefreshInterval();\n    this.setState({ playerName, phase: LobbyPhases.LIST });\n  };\n\n  _exitLobby = async () => {\n    this._clearRefreshInterval();\n    await this.connection.disconnect();\n    this.setState({ phase: LobbyPhases.ENTER, errorMsg: '' });\n  };\n\n  _createMatch = async (gameName: string, numPlayers: number) => {\n    try {\n      await this.connection.create(gameName, numPlayers);\n      await this.connection.refresh();\n      // rerender\n      this.setState({});\n    } catch (error) {\n      this.setState({ errorMsg: error.message });\n    }\n  };\n\n  _joinMatch = async (gameName: string, matchID: string, playerID: string) => {\n    try {\n      await this.connection.join(gameName, matchID, playerID);\n      await this.connection.refresh();\n      this._updateCredentials(\n        this.connection.playerName,\n        this.connection.playerCredentials\n      );\n    } catch (error) {\n      this.setState({ errorMsg: error.message });\n    }\n  };\n\n  _leaveMatch = async (gameName: string, matchID: string) => {\n    try {\n      await this.connection.leave(gameName, matchID);\n      await this.connection.refresh();\n      this._updateCredentials(\n        this.connection.playerName,\n        this.connection.playerCredentials\n      );\n    } catch (error) {\n      this.setState({ errorMsg: error.message });\n    }\n  };\n\n  _startMatch = (gameName: string, matchOpts: MatchOpts) => {\n    const gameCode = this.connection._getGameComponents(gameName);\n    if (!gameCode) {\n      this.setState({\n        errorMsg: 'game ' + gameName + ' not supported',\n      });\n      return;\n    }\n\n    let multiplayer = undefined;\n    if (matchOpts.numPlayers > 1) {\n      multiplayer = this.props.gameServer\n        ? SocketIO({ server: this.props.gameServer })\n        : SocketIO();\n    }\n\n    if (matchOpts.numPlayers == 1) {\n      const maxPlayers = gameCode.game.maxPlayers;\n      const bots = {};\n      for (let i = 1; i < maxPlayers; i++) {\n        bots[i + ''] = MCTSBot;\n      }\n      multiplayer = Local({ bots });\n    }\n\n    const app = this.props.clientFactory({\n      game: gameCode.game,\n      board: gameCode.board,\n      debug: this.props.debug,\n      multiplayer,\n    });\n\n    const match = {\n      app: app,\n      matchID: matchOpts.matchID,\n      playerID: matchOpts.numPlayers > 1 ? matchOpts.playerID : '0',\n      credentials: this.connection.playerCredentials,\n    };\n\n    this._clearRefreshInterval();\n    this.setState({ phase: LobbyPhases.PLAY, runningMatch: match });\n  };\n\n  _exitMatch = () => {\n    this._startRefreshInterval();\n    this.setState({ phase: LobbyPhases.LIST, runningMatch: null });\n  };\n\n  _getPhaseVisibility = (phase: LobbyPhases) => {\n    return this.state.phase !== phase ? 'hidden' : 'phase';\n  };\n\n  renderMatches = (\n    matches: LobbyAPI.MatchList['matches'],\n    playerName: string\n  ) => {\n    return matches.map((match) => {\n      const { matchID, gameName, players } = match;\n      return (\n        <LobbyMatchInstance\n          key={'instance-' + matchID}\n          match={{ matchID, gameName, players: Object.values(players) }}\n          playerName={playerName}\n          onClickJoin={this._joinMatch}\n          onClickLeave={this._leaveMatch}\n          onClickPlay={this._startMatch}\n        />\n      );\n    });\n  };\n\n  render() {\n    const { gameComponents, renderer } = this.props;\n    const { errorMsg, playerName, phase, runningMatch } = this.state;\n\n    if (renderer) {\n      return renderer({\n        errorMsg,\n        gameComponents,\n        matches: this.connection.matches,\n        phase,\n        playerName,\n        runningMatch,\n        handleEnterLobby: this._enterLobby,\n        handleExitLobby: this._exitLobby,\n        handleCreateMatch: this._createMatch,\n        handleJoinMatch: this._joinMatch,\n        handleLeaveMatch: this._leaveMatch,\n        handleExitMatch: this._exitMatch,\n        handleRefreshMatches: this._updateConnection,\n        handleStartMatch: this._startMatch,\n      });\n    }\n\n    return (\n      <div id=\"lobby-view\" style={{ padding: 50 }}>\n        <div className={this._getPhaseVisibility(LobbyPhases.ENTER)}>\n          <LobbyLoginForm\n            key={playerName}\n            playerName={playerName}\n            onEnter={this._enterLobby}\n          />\n        </div>\n\n        <div className={this._getPhaseVisibility(LobbyPhases.LIST)}>\n          <p>Welcome, {playerName}</p>\n\n          <div className=\"phase-title\" id=\"match-creation\">\n            <span>Create a match:</span>\n            <LobbyCreateMatchForm\n              games={gameComponents}\n              createMatch={this._createMatch}\n            />\n          </div>\n          <p className=\"phase-title\">Join a match:</p>\n          <div id=\"instances\">\n            <table>\n              <tbody>\n                {this.renderMatches(this.connection.matches, playerName)}\n              </tbody>\n            </table>\n            <span className=\"error-msg\">\n              {errorMsg}\n              <br />\n            </span>\n          </div>\n          <p className=\"phase-title\">\n            Matches that become empty are automatically deleted.\n          </p>\n        </div>\n\n        <div className={this._getPhaseVisibility(LobbyPhases.PLAY)}>\n          {runningMatch && (\n            <runningMatch.app\n              matchID={runningMatch.matchID}\n              playerID={runningMatch.playerID}\n              credentials={runningMatch.credentials}\n            />\n          )}\n          <div className=\"buttons\" id=\"match-exit\">\n            <button onClick={this._exitMatch}>Exit match</button>\n          </div>\n        </div>\n\n        <div className=\"buttons\" id=\"lobby-exit\">\n          <button onClick={this._exitLobby}>Exit lobby</button>\n        </div>\n      </div>\n    );\n  }\n}\n\nexport default Lobby;\n"
  },
  {
    "path": "src/master/filter-player-view.test.ts",
    "content": "import { getFilterPlayerView, redactLog } from './filter-player-view';\nimport * as ActionCreators from '../core/action-creators';\nimport { Master } from './master';\nimport { InMemory } from '../server/db/inmemory';\nimport { PlayerView } from '../core/player-view';\nimport { INVALID_MOVE } from '../core/constants';\nimport type { Game, SyncInfo } from '../types';\n\nfunction TransportAPI(send = jest.fn(), sendAll = jest.fn()) {\n  return { send, sendAll };\n}\n\nfunction validateNotTransientState(state: any) {\n  expect(state).toEqual(\n    expect.not.objectContaining({ transients: expect.anything() })\n  );\n}\n\ndescribe('playerView - update', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n  const game: Game = {\n    playerView: ({ G, playerID }) => {\n      return { ...G, player: playerID };\n    },\n  };\n  const master = new Master(game, new InMemory(), TransportAPI(send, sendAll));\n\n  beforeAll(async () => {\n    await master.onSync('matchID', '0', undefined, 2);\n  });\n\n  beforeEach(() => {\n    jest.clearAllMocks();\n  });\n\n  test('sync', async () => {\n    await master.onSync('matchID', '0', undefined, 2);\n    const payload = send.mock.calls[0][0];\n    const filterPlayerView = getFilterPlayerView(game);\n    expect(\n      (filterPlayerView('0', payload).args[1] as SyncInfo).state\n    ).toMatchObject({\n      G: { player: '0' },\n    });\n  });\n\n  test('update', async () => {\n    const action = ActionCreators.gameEvent('endTurn');\n    await master.onSync('matchID', '0', undefined, 2);\n    await master.onUpdate(action, 0, 'matchID', '0');\n    const payload = sendAll.mock.calls[sendAll.mock.calls.length - 1][0];\n    const filterPlayerView = getFilterPlayerView(game);\n\n    const transportData0 = filterPlayerView('0', payload);\n    const G_player0 = (transportData0.args[1] as any).G;\n    const transportData1 = filterPlayerView('1', payload);\n    const G_player1 = (transportData1.args[1] as any).G;\n\n    expect(G_player0.player).toBe('0');\n    expect(G_player1.player).toBe('1');\n  });\n});\n\ndescribe('playerView - patch', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n  const db = new InMemory();\n  const game: Game = {\n    seed: 0,\n    deltaState: true,\n    setup: () => {\n      return {\n        players: {\n          '0': {\n            cards: ['card3'],\n          },\n          '1': {\n            cards: [],\n          },\n        },\n        cards: ['card0', 'card1', 'card2'],\n        discardedCards: [],\n      };\n    },\n    playerView: PlayerView.STRIP_SECRETS,\n    turn: {\n      activePlayers: { currentPlayer: { stage: 'A' } },\n      stages: {\n        A: {\n          moves: {\n            Invalid: () => {\n              return INVALID_MOVE;\n            },\n            A: {\n              client: false,\n              move: ({ G, playerID }) => {\n                const card = G.players[playerID].cards.shift();\n                G.discardedCards.push(card);\n              },\n            },\n            B: {\n              client: false,\n              ignoreStaleStateID: true,\n              move: ({ G, playerID }) => {\n                const card = G.cards.pop();\n                G.players[playerID].cards.push(card);\n              },\n            },\n          },\n        },\n      },\n    },\n  };\n  const master = new Master(game, db, TransportAPI(send, sendAll));\n  const move = ActionCreators.makeMove('A', null, '0');\n\n  beforeAll(async () => {\n    master.subscribe(({ state }) => {\n      validateNotTransientState(state);\n    });\n    await master.onSync('matchID', '0', undefined, 2);\n  });\n\n  beforeEach(() => {\n    jest.clearAllMocks();\n  });\n\n  test('patch', async () => {\n    await master.onUpdate(move, 0, 'matchID', '0');\n    expect(sendAll).toBeCalled();\n\n    const payload = sendAll.mock.calls[sendAll.mock.calls.length - 1][0];\n    expect(payload.type).toBe('patch');\n\n    const filterPlayerView = getFilterPlayerView(game);\n    const value = filterPlayerView('0', payload);\n    expect(value.type).toBe('patch');\n    expect(value.args[0]).toBe('matchID');\n    expect(value.args[1]).toBe(0);\n    expect(value.args[2]).toBe(1);\n    expect(value.args[3]).toMatchObject([\n      { op: 'remove', path: '/G/players/0/cards/0' },\n      { op: 'add', path: '/G/discardedCards/-', value: 'card3' },\n      { op: 'replace', path: '/ctx/numMoves', value: 1 },\n      { op: 'replace', path: '/_stateID', value: 1 },\n    ]);\n  });\n});\n\ndescribe('redactLog', () => {\n  test('no-op with undefined log', () => {\n    const result = redactLog(undefined, '0');\n    expect(result).toBeUndefined();\n  });\n\n  test('no redactedMoves', () => {\n    const logEvents = [\n      {\n        _stateID: 0,\n        turn: 0,\n        phase: '',\n        action: ActionCreators.gameEvent('endTurn'),\n      },\n    ];\n    const result = redactLog(logEvents, '0');\n    expect(result).toMatchObject(logEvents);\n  });\n\n  test('redacted move is only shown with args to the player that made the move', () => {\n    const logEvents = [\n      {\n        _stateID: 0,\n        turn: 0,\n        phase: '',\n        action: ActionCreators.makeMove('clickCell', [1, 2, 3], '0'),\n        redact: true,\n      },\n    ];\n\n    // player that made the move\n    let result = redactLog(logEvents, '0');\n    expect(result).toMatchObject(logEvents);\n\n    // other player\n    result = redactLog(logEvents, '1');\n    expect(result).toMatchObject([\n      {\n        _stateID: 0,\n        turn: 0,\n        phase: '',\n        action: {\n          type: 'MAKE_MOVE',\n          payload: {\n            credentials: undefined,\n            playerID: '0',\n            type: 'clickCell',\n          },\n        },\n      },\n    ]);\n  });\n\n  test('not redacted move is shown to all', () => {\n    const logEvents = [\n      {\n        _stateID: 0,\n        turn: 0,\n        phase: '',\n        action: ActionCreators.makeMove('unclickCell', [1, 2, 3], '0'),\n      },\n    ];\n\n    // player that made the move\n    let result = redactLog(logEvents, '0');\n    expect(result).toMatchObject(logEvents);\n    // other player\n    result = redactLog(logEvents, '1');\n    expect(result).toMatchObject(logEvents);\n  });\n\n  test('can explicitly set showing args to true', () => {\n    const logEvents = [\n      {\n        _stateID: 0,\n        turn: 0,\n        phase: '',\n        action: ActionCreators.makeMove('unclickCell', [1, 2, 3], '0'),\n      },\n    ];\n\n    // player that made the move\n    let result = redactLog(logEvents, '0');\n    expect(result).toMatchObject(logEvents);\n    // other player\n    result = redactLog(logEvents, '1');\n    expect(result).toMatchObject(logEvents);\n  });\n\n  test('events are not redacted', () => {\n    const logEvents = [\n      {\n        _stateID: 0,\n        turn: 0,\n        phase: '',\n        action: ActionCreators.gameEvent('endTurn'),\n      },\n    ];\n\n    // player that made the move\n    let result = redactLog(logEvents, '0');\n    expect(result).toMatchObject(logEvents);\n    // other player\n    result = redactLog(logEvents, '1');\n    expect(result).toMatchObject(logEvents);\n  });\n\n  test('make sure filter player view redacts the log', async () => {\n    const game: Game = {\n      moves: {\n        A: ({ G }) => G,\n        B: {\n          move: ({ G }) => G,\n          redact: true,\n        },\n      },\n    };\n\n    const send = jest.fn();\n    const master = new Master(game, new InMemory(), TransportAPI(send));\n    const filterPlayerView = getFilterPlayerView(game);\n\n    const actionA = ActionCreators.makeMove('A', ['not redacted'], '0');\n    const actionB = ActionCreators.makeMove('B', ['redacted'], '0');\n\n    // test: ping-pong two moves, then sync and check the log\n    await master.onSync('matchID', '0', undefined, 2);\n    await master.onUpdate(actionA, 0, 'matchID', '0');\n    await master.onUpdate(actionB, 1, 'matchID', '0');\n    await master.onSync('matchID', '1', undefined, 2);\n\n    const payload = send.mock.calls[send.mock.calls.length - 1][0];\n    expect(\n      (filterPlayerView('1', payload).args[1] as SyncInfo).log\n    ).toMatchObject([\n      {\n        action: {\n          type: 'MAKE_MOVE',\n          payload: {\n            type: 'A',\n            args: ['not redacted'],\n            playerID: '0',\n          },\n        },\n        _stateID: 0,\n      },\n      {\n        action: {\n          type: 'MAKE_MOVE',\n          payload: {\n            type: 'B',\n            args: null,\n            playerID: '0',\n          },\n        },\n        _stateID: 1,\n      },\n    ]);\n  });\n});\n\ntest('make move args to be secret depends on G via conditional redact', async () => {\n  const game: Game = {\n    setup: () => ({\n      isASecret: false,\n    }),\n    moves: {\n      A: {\n        move: ({ G }) => G,\n        redact: ({ G }) => G.isASecret,\n      },\n      B: ({ G }) => {\n        return { ...G, isASecret: true };\n      },\n    },\n  };\n\n  const send = jest.fn();\n  const master = new Master(game, new InMemory(), TransportAPI(send));\n  const filterPlayerView = getFilterPlayerView(game);\n\n  const actionA0 = ActionCreators.makeMove('A', ['not redacted'], '0');\n  const actionB = ActionCreators.makeMove('B', ['not redacted'], '0');\n  const actionA1 = ActionCreators.makeMove('A', ['redacted'], '0');\n\n  // test: ping-pong two moves, then sync and check the log\n  await master.onSync('matchID', '0', undefined, 2);\n  await master.onUpdate(actionA0, 0, 'matchID', '0');\n  await master.onUpdate(actionB, 1, 'matchID', '0');\n  await master.onUpdate(actionA1, 2, 'matchID', '0');\n  await master.onSync('matchID', '1', undefined, 2);\n\n  const payload = send.mock.calls[send.mock.calls.length - 1][0];\n  expect(\n    (filterPlayerView('1', payload).args[1] as SyncInfo).log\n  ).toMatchObject([\n    {\n      action: {\n        type: 'MAKE_MOVE',\n        payload: {\n          type: 'A',\n          args: ['not redacted'],\n          playerID: '0',\n        },\n      },\n      _stateID: 0,\n    },\n    {\n      action: {\n        type: 'MAKE_MOVE',\n        payload: {\n          type: 'B',\n          args: ['not redacted'],\n          playerID: '0',\n        },\n      },\n      _stateID: 1,\n    },\n    {\n      action: {\n        type: 'MAKE_MOVE',\n        payload: {\n          type: 'A',\n          args: null,\n          playerID: '0',\n        },\n      },\n      _stateID: 2,\n    },\n  ]);\n});\n"
  },
  {
    "path": "src/master/filter-player-view.ts",
    "content": "import { PlayerView } from '../plugins/main';\nimport { createPatch } from 'rfc6902';\nimport type { Game, State, LogEntry, PlayerID } from '../types';\nimport type { TransportData, IntermediateTransportData } from './master';\n\nconst applyPlayerView = (\n  game: Game,\n  playerID: string | null,\n  state: State\n): State => ({\n  ...state,\n  G: game.playerView({ G: state.G, ctx: state.ctx, playerID }),\n  plugins: PlayerView(state, { playerID, game }),\n  deltalog: undefined,\n  _undo: [],\n  _redo: [],\n});\n\n/** Gets a function that filters the TransportData for a given player and game. */\nexport const getFilterPlayerView =\n  (game: Game) =>\n  (\n    playerID: string | null,\n    payload: IntermediateTransportData\n  ): TransportData => {\n    switch (payload.type) {\n      case 'patch': {\n        const [matchID, stateID, prevState, state] = payload.args;\n        const log = redactLog(state.deltalog, playerID);\n        const filteredState = applyPlayerView(game, playerID, state);\n        const newStateID = state._stateID;\n        const prevFilteredState = applyPlayerView(game, playerID, prevState);\n        const patch = createPatch(prevFilteredState, filteredState);\n        return {\n          type: 'patch',\n          args: [matchID, stateID, newStateID, patch, log],\n        };\n      }\n      case 'update': {\n        const [matchID, state] = payload.args;\n        const log = redactLog(state.deltalog, playerID);\n        const filteredState = applyPlayerView(game, playerID, state);\n        return {\n          type: 'update',\n          args: [matchID, filteredState, log],\n        };\n      }\n      case 'sync': {\n        const [matchID, syncInfo] = payload.args;\n        const filteredState = applyPlayerView(game, playerID, syncInfo.state);\n        const log = redactLog(syncInfo.log, playerID);\n        const newSyncInfo = {\n          ...syncInfo,\n          state: filteredState,\n          log,\n        };\n        return {\n          type: 'sync',\n          args: [matchID, newSyncInfo],\n        };\n      }\n      default: {\n        return payload;\n      }\n    }\n  };\n\n/**\n * Redact the log.\n *\n * @param {Array} log - The game log (or deltalog).\n * @param {String} playerID - The playerID that this log is\n *                            to be sent to.\n */\nexport function redactLog(log: LogEntry[], playerID: PlayerID | null) {\n  if (log === undefined) {\n    return log;\n  }\n\n  return log.map((logEvent) => {\n    // filter for all other players and spectators.\n    if (playerID !== null && +playerID === +logEvent.action.payload.playerID) {\n      return logEvent;\n    }\n\n    if (logEvent.redact !== true) {\n      return logEvent;\n    }\n\n    const payload = {\n      ...logEvent.action.payload,\n      args: null,\n    };\n    const filteredEvent = {\n      ...logEvent,\n      action: { ...logEvent.action, payload },\n    };\n\n    const { redact, ...remaining } = filteredEvent;\n    return remaining;\n  });\n}\n"
  },
  {
    "path": "src/master/master.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport * as ActionCreators from '../core/action-creators';\nimport { InitializeGame } from '../core/initialize';\nimport { InMemory } from '../server/db/inmemory';\nimport { Master } from './master';\nimport { error } from '../core/logger';\nimport type { Game, Server, State, LogEntry } from '../types';\nimport { Auth } from '../server/auth';\nimport * as StorageAPI from '../server/db/base';\nimport * as dateMock from 'jest-date-mock';\nimport { PlayerView } from '../core/player-view';\nimport { INVALID_MOVE } from '../core/constants';\n\njest.mock('../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\nbeforeEach(() => {\n  dateMock.clear();\n});\n\nclass InMemoryAsync extends StorageAPI.Async {\n  db: InMemory;\n\n  constructor() {\n    super();\n    this.db = new InMemory();\n  }\n\n  async connect() {\n    await this.sleep();\n  }\n\n  private sleep(): Promise<void> {\n    const interval = Math.round(Math.random() * 50 + 50);\n    return new Promise((resolve) => void setTimeout(resolve, interval));\n  }\n\n  async createMatch(id: string, opts: StorageAPI.CreateMatchOpts) {\n    await this.sleep();\n    this.db.createMatch(id, opts);\n  }\n\n  async setMetadata(matchID: string, metadata: Server.MatchData) {\n    await this.sleep();\n    this.db.setMetadata(matchID, metadata);\n  }\n\n  async setState(matchID: string, state: State, deltalog?: LogEntry[]) {\n    await this.sleep();\n    this.db.setState(matchID, state, deltalog);\n  }\n\n  async fetch<O extends StorageAPI.FetchOpts>(\n    matchID: string,\n    opts: O\n  ): Promise<StorageAPI.FetchResult<O>> {\n    await this.sleep();\n    return this.db.fetch(matchID, opts);\n  }\n\n  async wipe(matchID: string) {\n    await this.sleep();\n    this.db.wipe(matchID);\n  }\n\n  async listMatches(opts?: StorageAPI.ListMatchesOpts): Promise<string[]> {\n    await this.sleep();\n    return this.db.listMatches(opts);\n  }\n}\n\nconst game: Game = { seed: 0 };\n\nfunction TransportAPI(send = jest.fn(), sendAll = jest.fn()) {\n  return { send, sendAll };\n}\n\nfunction validateNotTransientState(state: any) {\n  expect(state).toEqual(\n    expect.not.objectContaining({ transients: expect.anything() })\n  );\n}\n\ndescribe('sync', () => {\n  const send = jest.fn();\n  const db = new InMemory();\n  const master = new Master(game, db, TransportAPI(send));\n\n  beforeEach(() => {\n    jest.clearAllMocks();\n  });\n\n  test('causes server to respond', async () => {\n    await master.onSync('matchID', '0', undefined, 2);\n    expect(send).toHaveBeenCalledWith(\n      expect.objectContaining({\n        type: 'sync',\n      })\n    );\n  });\n\n  test('sync a second time does not create a game', async () => {\n    const fetchResult = db.fetch('matchID', { metadata: true });\n    await master.onSync('matchID', '0', undefined, 2);\n    expect(db.fetch('matchID', { metadata: true })).toMatchObject(fetchResult);\n  });\n\n  test('should not have metadata', async () => {\n    db.setState('oldGameID', {} as State);\n    await master.onSync('oldGameID', '0');\n    // [0][0] = first call, first argument\n    expect(send.mock.calls[0][0].args[1].filteredMetadata).toBeUndefined();\n  });\n\n  test('should have metadata', async () => {\n    const db = new InMemory();\n    const metadata = {\n      gameName: 'tic-tac-toe',\n      setupData: {},\n      players: {\n        '0': {\n          id: 0,\n          credentials: 'qS2m4Ujb_',\n          name: 'Alice',\n        },\n        '1': {\n          id: 1,\n          credentials: 'nIQtXFybDD',\n          name: 'Bob',\n        },\n      },\n      createdAt: 0,\n      updatedAt: 0,\n    };\n    db.createMatch('matchID', { metadata, initialState: {} as State });\n    const masterWithMetadata = new Master(game, db, TransportAPI(send));\n    await masterWithMetadata.onSync('matchID', '0', undefined, 2);\n\n    const expectedMetadata = [\n      { id: 0, name: 'Alice' },\n      { id: 1, name: 'Bob' },\n    ];\n    expect(send.mock.calls[0][0].args[1].filteredMetadata).toMatchObject(\n      expectedMetadata\n    );\n  });\n\n  test('should not create match for games that require setupData', async () => {\n    const game: Game = {\n      validateSetupData: () => 'requires setupData',\n    };\n    const db = new InMemory();\n    const master = new Master(game, db, TransportAPI(send));\n\n    const matchID = 'matchID';\n    const res = await master.onSync(matchID, '0', undefined, 2);\n\n    expect(res).toEqual({ error: 'game requires setupData' });\n    expect(send).not.toHaveBeenCalled();\n    expect(db.fetch(matchID, { state: true })).toEqual({ state: undefined });\n  });\n});\n\ndescribe('update', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n  const game: Game = {\n    moves: {\n      A: ({ G }) => G,\n    },\n  };\n  let db;\n  let master;\n  const action = ActionCreators.gameEvent('endTurn');\n\n  beforeEach(async () => {\n    db = new InMemory();\n    master = new Master(game, db, TransportAPI(send, sendAll));\n    await master.onSync('matchID', '0', undefined, 2);\n    jest.clearAllMocks();\n  });\n\n  test('basic', async () => {\n    await master.onUpdate(action, 0, 'matchID', '0');\n    expect(sendAll).toBeCalled();\n    const value = sendAll.mock.calls[0][0];\n    expect(value.type).toBe('update');\n    expect(value.args[0]).toBe('matchID');\n    expect(value.args[1]).toMatchObject({\n      G: {},\n      _stateID: 1,\n      ctx: {\n        currentPlayer: '1',\n        numPlayers: 2,\n        phase: null,\n        playOrder: ['0', '1'],\n        playOrderPos: 1,\n        turn: 2,\n      },\n    });\n  });\n\n  test('missing action', async () => {\n    const { error } = await master.onUpdate(null, 0, 'matchID', '0');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toBe('missing action or action payload');\n  });\n\n  test('missing action payload', async () => {\n    const { error } = await master.onUpdate({}, 0, 'matchID', '0');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toBe('missing action or action payload');\n  });\n\n  test('invalid matchID', async () => {\n    await master.onUpdate(action, 0, 'default:unknown', '1');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `game not found, matchID=[default:unknown]`\n    );\n  });\n\n  test('invalid stateID', async () => {\n    await master.onUpdate(action, 100, 'matchID', '0');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `invalid stateID, was=[100], expected=[0] - playerID=[0] - action[endTurn]`\n    );\n  });\n\n  test('invalid playerID', async () => {\n    await master.onUpdate(action, 0, 'matchID', '100');\n    await master.onUpdate(ActionCreators.makeMove('move'), 1, 'matchID', '100');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `player not active - playerID=[100] - action[move]`\n    );\n  });\n\n  test('invalid move', async () => {\n    await master.onUpdate(ActionCreators.makeMove('move'), 0, 'matchID', '0');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `move not processed - canPlayerMakeMove=false - playerID=[0] - action[move]`\n    );\n  });\n\n  test('valid matchID / stateID / playerID', async () => {\n    await master.onUpdate(action, 0, 'matchID', '0');\n    expect(sendAll).toHaveBeenCalled();\n  });\n\n  test('allow execution of moves with ignoreStaleStateID truthy', async () => {\n    const game: Game = {\n      setup: () => {\n        const G = {\n          players: {\n            '0': {\n              cards: ['card3'],\n            },\n            '1': {\n              cards: [],\n            },\n          },\n          cards: ['card0', 'card1', 'card2'],\n          discardedCards: [],\n        };\n        return G;\n      },\n      playerView: PlayerView.STRIP_SECRETS,\n      turn: {\n        activePlayers: { currentPlayer: { stage: 'A' } },\n        stages: {\n          A: {\n            moves: {\n              A: ({ G, playerID }) => {\n                const card = G.players[playerID].cards.shift();\n                G.discardedCards.push(card);\n              },\n              B: {\n                move: ({ G, playerID }) => {\n                  const card = G.cards.pop();\n                  G.players[playerID].cards.push(card);\n                },\n                ignoreStaleStateID: true,\n              },\n            },\n          },\n        },\n      },\n    };\n\n    const send = jest.fn();\n    const master = new Master(\n      game,\n      new InMemory(),\n      TransportAPI(send, sendAll)\n    );\n\n    const setActivePlayers = ActionCreators.gameEvent(\n      'setActivePlayers',\n      [{ all: 'A' }],\n      '0'\n    );\n    const actionA = ActionCreators.makeMove('A', null, '0');\n    const actionB = ActionCreators.makeMove('B', null, '1');\n    const actionC = ActionCreators.makeMove('B', null, '0');\n\n    // test: simultaneous moves\n    await master.onSync('matchID', '0', undefined, 2);\n    await master.onUpdate(actionA, 0, 'matchID', '0');\n    await master.onUpdate(setActivePlayers, 1, 'matchID', '0');\n    await Promise.all([\n      master.onUpdate(actionB, 2, 'matchID', '1'),\n      master.onUpdate(actionC, 2, 'matchID', '0'),\n    ]);\n    await Promise.all([\n      master.onSync('matchID', '0', undefined, 2),\n      master.onSync('matchID', '1', undefined, 2),\n    ]);\n\n    const G = sendAll.mock.calls[sendAll.mock.calls.length - 1][0].args[1].G;\n\n    expect(G).toMatchObject({\n      players: {\n        '0': {\n          cards: ['card1'],\n        },\n      },\n      cards: ['card0'],\n      discardedCards: ['card3'],\n    });\n  });\n\n  describe('undo / redo', () => {\n    test('player 0 can undo', async () => {\n      const move = ActionCreators.makeMove('A', null, '0');\n      await master.onUpdate(move, 0, 'matchID', '0');\n      expect(error).not.toHaveBeenCalled();\n      await master.onUpdate(ActionCreators.undo(), 1, 'matchID', '0');\n      expect(error).not.toHaveBeenCalled();\n\n      // Negative case: All moves already undone.\n      await master.onUpdate(ActionCreators.undo(), 2, 'matchID', '0');\n      expect(error).toHaveBeenCalledWith(`No moves to undo`);\n    });\n\n    test('player 1 can’t undo', async () => {\n      await master.onUpdate(ActionCreators.undo(), 2, 'matchID', '1');\n      expect(error).toHaveBeenCalledWith(\n        `playerID=[1] cannot undo / redo right now`\n      );\n    });\n\n    test('player can’t undo with multiple active players', async () => {\n      const setActivePlayers = ActionCreators.gameEvent(\n        'setActivePlayers',\n        [{ all: 'A' }],\n        '0'\n      );\n      await master.onUpdate(setActivePlayers, 0, 'matchID', '0');\n      await master.onUpdate(ActionCreators.undo('0'), 1, 'matchID', '0');\n      expect(error).toHaveBeenCalledWith(\n        `playerID=[0] cannot undo / redo right now`\n      );\n    });\n\n    test('player can undo if they are the only active player', async () => {\n      const move = ActionCreators.makeMove('A', null, '0');\n      await master.onUpdate(move, 0, 'matchID', '0');\n      expect(error).not.toHaveBeenCalled();\n      const endStage = ActionCreators.gameEvent('endStage', undefined, '0');\n      await master.onUpdate(endStage, 1, 'matchID', '0');\n      expect(error).not.toBeCalled();\n      await master.onUpdate(ActionCreators.undo(), 2, 'matchID', '0');\n      expect(error).not.toBeCalled();\n\n      // Clean-up active players.\n      const endStage2 = ActionCreators.gameEvent('endStage', undefined, '1');\n      await master.onUpdate(endStage2, 3, 'matchID', '1');\n    });\n  });\n\n  test('game over', async () => {\n    let event = ActionCreators.gameEvent('endGame');\n    await master.onUpdate(event, 0, 'matchID', '0');\n    event = ActionCreators.gameEvent('endTurn');\n    await master.onUpdate(event, 1, 'matchID', '0');\n    expect(error).toHaveBeenCalledWith(\n      `game over - matchID=[matchID] - playerID=[0] - action[endTurn]`\n    );\n  });\n\n  test('writes gameover to metadata', async () => {\n    const id = 'gameWithMetadata';\n    const db = new InMemory();\n    const dbMetadata = {\n      gameName: 'tic-tac-toe',\n      setupData: {},\n      players: { '0': { id: 0 }, '1': { id: 1 } },\n      createdAt: 0,\n      updatedAt: 0,\n    };\n    db.setMetadata(id, dbMetadata);\n    const masterWithMetadata = new Master(game, db, TransportAPI(send));\n    await masterWithMetadata.onSync(id, '0', undefined, 2);\n\n    const gameOverArg = 'gameOverArg';\n    const event = ActionCreators.gameEvent('endGame', gameOverArg);\n    await masterWithMetadata.onUpdate(event, 0, id, '0');\n    const { metadata } = db.fetch(id, { metadata: true });\n    expect(metadata.gameover).toEqual(gameOverArg);\n  });\n\n  test('writes gameover to metadata with null gameover', async () => {\n    const id = 'gameWithMetadataNullGameover';\n    const db = new InMemory();\n    const dbMetadata = {\n      gameName: 'tic-tac-toe',\n      gameover: null,\n      setupData: {},\n      players: { '0': { id: 0 }, '1': { id: 1 } },\n      createdAt: 0,\n      updatedAt: 0,\n    };\n    const masterWithMetadata = new Master(game, db, TransportAPI(send));\n    await masterWithMetadata.onSync(id, '0', undefined, 2);\n    db.setMetadata(id, dbMetadata);\n\n    const gameOverArg = 'gameOverArg';\n    const event = ActionCreators.gameEvent('endGame', gameOverArg);\n    await masterWithMetadata.onUpdate(event, 0, id, '0');\n    const { metadata } = db.fetch(id, { metadata: true });\n    expect(metadata.gameover).toEqual(gameOverArg);\n  });\n\n  test('writes gameover to metadata with async storage API', async () => {\n    const id = 'gameWithMetadata';\n    const db = new InMemoryAsync();\n    const dbMetadata = {\n      gameName: 'tic-tac-toe',\n      setupData: {},\n      players: { '0': { id: 0 }, '1': { id: 1 } },\n      createdAt: 0,\n      updatedAt: 0,\n    };\n    await db.setMetadata(id, dbMetadata);\n    const masterWithMetadata = new Master(game, db, TransportAPI(send));\n    await masterWithMetadata.onSync(id, '0', undefined, 2);\n\n    const gameOverArg = 'gameOverArg';\n    const event = ActionCreators.gameEvent('endGame', gameOverArg);\n    await masterWithMetadata.onUpdate(event, 0, id, '0');\n    const { metadata } = await db.fetch(id, { metadata: true });\n    expect(metadata.gameover).toEqual(gameOverArg);\n  });\n\n  test('writes updatedAt to metadata with async storage API', async () => {\n    const id = 'gameWithMetadata';\n    const db = new InMemoryAsync();\n    const dbMetadata = {\n      gameName: 'tic-tac-toe',\n      setupData: {},\n      players: { '0': { id: 0 }, '1': { id: 1 } },\n      createdAt: 0,\n      updatedAt: 0,\n    };\n    await db.setMetadata(id, dbMetadata);\n    const masterWithMetadata = new Master(game, db, TransportAPI(send));\n    await masterWithMetadata.onSync(id, '0', undefined, 2);\n\n    const updatedAt = new Date(2020, 3, 4, 5, 6, 7);\n    dateMock.advanceTo(updatedAt);\n    const event = ActionCreators.gameEvent('endTurn', null, '0');\n    await masterWithMetadata.onUpdate(event, 0, id, '0');\n    const { metadata } = await db.fetch(id, { metadata: true });\n    expect(metadata.updatedAt).toEqual(updatedAt.getTime());\n  });\n\n  test('processes update if there is no metadata', async () => {\n    const id = 'gameWithoutMetadata';\n    const db = new InMemory();\n    const masterWithoutMetadata = new Master(game, db, TransportAPI(send));\n    // Store state manually to bypass automatic metadata initialization on sync.\n    let state = InitializeGame({ game });\n    expect(state.ctx.turn).toBe(1);\n    db.setState(id, state);\n    // Dispatch update to end the turn.\n    const event = ActionCreators.gameEvent('endTurn', null, '0');\n    await masterWithoutMetadata.onUpdate(event, 0, id, '0');\n    // Confirm the turn ended.\n    let metadata: undefined | Server.MatchData;\n    ({ state, metadata } = db.fetch(id, { state: true, metadata: true }));\n    expect(state.ctx.turn).toBe(2);\n    expect(metadata).toBeUndefined();\n  });\n\n  test('processes update if there is no metadata with async DB', async () => {\n    const id = 'gameWithoutMetadata';\n    const db = new InMemoryAsync();\n    const masterWithoutMetadata = new Master(game, db, TransportAPI(send));\n    // Store state manually to bypass automatic metadata initialization on sync.\n    let state = InitializeGame({ game });\n    expect(state.ctx.turn).toBe(1);\n    await db.setState(id, state);\n    // Dispatch update to end the turn.\n    const event = ActionCreators.gameEvent('endTurn', null, '0');\n    await masterWithoutMetadata.onUpdate(event, 0, id, '0');\n    // Confirm the turn ended.\n    let metadata: undefined | Server.MatchData;\n    ({ state, metadata } = await db.fetch(id, { state: true, metadata: true }));\n    expect(state.ctx.turn).toBe(2);\n    expect(metadata).toBeUndefined();\n  });\n});\n\ndescribe('patch', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n  const db = new InMemory();\n  const master = new Master(\n    {\n      seed: 0,\n      deltaState: true,\n      setup: () => {\n        return {\n          players: {\n            '0': {\n              cards: ['card3'],\n            },\n            '1': {\n              cards: [],\n            },\n          },\n          cards: ['card0', 'card1', 'card2'],\n          discardedCards: [],\n        };\n      },\n      playerView: PlayerView.STRIP_SECRETS,\n      turn: {\n        activePlayers: { currentPlayer: { stage: 'A' } },\n        stages: {\n          A: {\n            moves: {\n              Invalid: () => {\n                return INVALID_MOVE;\n              },\n              A: {\n                client: false,\n                move: ({ G, playerID }) => {\n                  const card = G.players[playerID].cards.shift();\n                  G.discardedCards.push(card);\n                },\n              },\n              B: {\n                client: false,\n                ignoreStaleStateID: true,\n                move: ({ G, playerID }) => {\n                  const card = G.cards.pop();\n                  G.players[playerID].cards.push(card);\n                },\n              },\n            },\n          },\n        },\n      },\n    },\n    db,\n    TransportAPI(send, sendAll)\n  );\n  const move = ActionCreators.makeMove('A', null, '0');\n  const action = ActionCreators.gameEvent('endTurn');\n\n  beforeAll(async () => {\n    master.subscribe(({ state }) => {\n      validateNotTransientState(state);\n    });\n    await master.onSync('matchID', '0', undefined, 2);\n  });\n\n  beforeEach(() => {\n    jest.clearAllMocks();\n  });\n\n  test('basic', async () => {\n    await master.onUpdate(move, 0, 'matchID', '0');\n    expect(sendAll).toBeCalled();\n\n    const value = sendAll.mock.calls[0][0];\n    expect(value.type).toBe('patch');\n    expect(value.args[0]).toBe('matchID');\n    expect(value.args[1]).toBe(0);\n    // prevState -- had a card\n    expect(value.args[2].G.players[0].cards).toEqual(['card3']);\n    // state -- doesnt have a card anymore\n    expect(value.args[3].G.players[0].cards).toEqual([]);\n  });\n\n  test('invalid matchID', async () => {\n    await master.onUpdate(action, 1, 'default:unknown', '1');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `game not found, matchID=[default:unknown]`\n    );\n  });\n\n  test('invalid stateID', async () => {\n    await master.onUpdate(action, 100, 'matchID', '0');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `invalid stateID, was=[100], expected=[1] - playerID=[0] - action[endTurn]`\n    );\n  });\n\n  test('invalid playerID', async () => {\n    await master.onUpdate(action, 1, 'matchID', '102');\n    await master.onUpdate(ActionCreators.makeMove('move'), 1, 'matchID', '102');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `player not active - playerID=[102] - action[move]`\n    );\n  });\n\n  test('disallowed move', async () => {\n    await master.onUpdate(ActionCreators.makeMove('move'), 1, 'matchID', '0');\n    expect(sendAll).not.toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith(\n      `move not processed - canPlayerMakeMove=false - playerID=[0] - action[move]`\n    );\n  });\n\n  test('invalid move', async () => {\n    await master.onUpdate(\n      ActionCreators.makeMove('Invalid', null, '0'),\n      1,\n      'matchID',\n      '0'\n    );\n    expect(sendAll).toHaveBeenCalled();\n    expect(error).toHaveBeenCalledWith('invalid move: Invalid args: null');\n  });\n\n  test('valid matchID / stateID / playerID', async () => {\n    await master.onUpdate(action, 1, 'matchID', '0');\n    expect(sendAll).toHaveBeenCalled();\n  });\n\n  describe('undo / redo', () => {\n    test('player 0 can undo', async () => {\n      await master.onUpdate(ActionCreators.undo(), 2, 'matchID', '1');\n      // The master allows this, but the reducer does not.\n      expect(error).toHaveBeenCalledWith(`No moves to undo`);\n    });\n\n    test('player 1 can’t undo', async () => {\n      await master.onUpdate(ActionCreators.undo(), 2, 'matchID', '0');\n      expect(error).toHaveBeenCalledWith(\n        `playerID=[0] cannot undo / redo right now`\n      );\n    });\n\n    test('player can’t undo with multiple active players', async () => {\n      const setActivePlayers = ActionCreators.gameEvent(\n        'setActivePlayers',\n        [{ all: 'A' }],\n        '0'\n      );\n      await master.onUpdate(setActivePlayers, 2, 'matchID', '0');\n      await master.onUpdate(ActionCreators.undo('0'), 3, 'matchID', '0');\n      expect(error).toHaveBeenCalledWith(\n        `playerID=[0] cannot undo / redo right now`\n      );\n    });\n\n    test('player can undo if they are the only active player', async () => {\n      const endStage = ActionCreators.gameEvent('endStage', undefined, '1');\n      await master.onUpdate(endStage, 2, 'matchID', '1');\n      await master.onUpdate(ActionCreators.undo('0'), 3, 'matchID', '1');\n      // The master allows this, but the reducer does not.\n      expect(error).toHaveBeenCalledWith(`Cannot undo other players' moves`);\n\n      // Clean-up active players.\n      const endStage2 = ActionCreators.gameEvent('endStage', undefined, '1');\n      await master.onUpdate(endStage2, 4, 'matchID', '1');\n    });\n  });\n\n  test('game over', async () => {\n    let event = ActionCreators.gameEvent('endGame');\n    await master.onUpdate(event, 3, 'matchID', '1');\n    event = ActionCreators.gameEvent('endTurn');\n    await master.onUpdate(event, 3, 'matchID', '1');\n    expect(error).toHaveBeenCalledWith(\n      `game over - matchID=[matchID] - playerID=[1] - action[endTurn]`\n    );\n  });\n});\n\ndescribe('connectionChange', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n\n  const db = new InMemory();\n  const master = new Master(game, db, TransportAPI(send, sendAll));\n\n  const metadata = {\n    gameName: 'tic-tac-toe',\n    setupData: {},\n    players: {\n      '0': {\n        id: 0,\n        credentials: 'qS2m4Ujb_',\n        name: 'Alice',\n      },\n      '1': {\n        id: 1,\n        credentials: 'nIQtXFybDD',\n        name: 'Bob',\n        isConnected: true,\n      },\n    },\n    createdAt: 0,\n    updatedAt: 0,\n  };\n  db.createMatch('matchID', { metadata, initialState: {} as State });\n\n  beforeEach(() => {\n    master.subscribe(({ state }) => {\n      validateNotTransientState(state);\n    });\n    jest.clearAllMocks();\n  });\n\n  test('changes players metadata', async () => {\n    await master.onConnectionChange('matchID', '0', undefined, true);\n\n    const expectedPlayerData = { id: 0, name: 'Alice', isConnected: true };\n    const {\n      metadata: { players },\n    } = db.fetch('matchID', { metadata: true });\n    expect(players['0']).toMatchObject(expectedPlayerData);\n  });\n\n  test('sends metadata to all', async () => {\n    await master.onConnectionChange('matchID', '1', undefined, false);\n    const expectedMetadata = [\n      { id: 0, name: 'Alice', isConnected: true },\n      { id: 1, name: 'Bob', isConnected: false },\n    ];\n    const sentMessage = sendAll.mock.calls[0][0];\n    expect(sentMessage.type).toEqual('matchData');\n    expect(sentMessage.args[1]).toMatchObject(expectedMetadata);\n  });\n\n  test('invalid matchID', async () => {\n    const result = await master.onConnectionChange(\n      'invalidMatchID',\n      '0',\n      undefined,\n      true\n    );\n    expect(error).toHaveBeenCalledWith(\n      'metadata not found for matchID=[invalidMatchID]'\n    );\n    expect(result && result.error).toEqual('metadata not found');\n  });\n\n  test('invalid playerID', async () => {\n    const result = await master.onConnectionChange(\n      'matchID',\n      '3',\n      undefined,\n      true\n    );\n    expect(error).toHaveBeenCalledWith(\n      'Player not in the match, matchID=[matchID] playerID=[3]'\n    );\n    expect(result && result.error).toEqual('player not in the match');\n  });\n\n  test('processes connection change with an async db', async () => {\n    const asyncDb = new InMemoryAsync();\n    const masterWithAsyncDb = new Master(\n      game,\n      asyncDb,\n      TransportAPI(send, sendAll)\n    );\n    await asyncDb.createMatch('matchID', {\n      metadata,\n      initialState: {} as State,\n    });\n\n    await masterWithAsyncDb.onConnectionChange('matchID', '0', undefined, true);\n\n    expect(sendAll).toHaveBeenCalled();\n  });\n});\n\ndescribe('subscribe', () => {\n  const callback = jest.fn();\n\n  let master;\n  beforeAll(() => {\n    master = new Master({}, new InMemory(), TransportAPI(jest.fn(), jest.fn()));\n    master.subscribe(callback);\n  });\n\n  test('sync', async () => {\n    master.onSync('matchID', '0');\n    expect(callback).toBeCalledWith({\n      matchID: 'matchID',\n      state: expect.objectContaining({ _stateID: 0 }),\n    });\n  });\n\n  test('update', async () => {\n    const action = ActionCreators.gameEvent('endTurn');\n    master.onUpdate(action, 0, 'matchID', '0');\n    expect(callback).toBeCalledWith({\n      matchID: 'matchID',\n      action,\n      state: expect.objectContaining({ _stateID: 1 }),\n    });\n  });\n});\n\ndescribe('authentication', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n  const game = { seed: 0 };\n  const matchID = 'matchID';\n  let storage = new InMemoryAsync();\n\n  const resetTestEnvironment = async () => {\n    send.mockReset();\n    sendAll.mockReset();\n    storage = new InMemoryAsync();\n    const master = new Master(game, storage, TransportAPI());\n    await master.onSync(matchID, '0', undefined, 2);\n  };\n\n  describe('onUpdate', () => {\n    const action = ActionCreators.gameEvent('endTurn');\n\n    beforeEach(resetTestEnvironment);\n\n    test('auth failure', async () => {\n      const authenticateCredentials = () => false;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onUpdate(action, 0, matchID, '0');\n      expect(ret && ret.error).toBe('unauthorized action');\n      expect(sendAll).not.toHaveBeenCalled();\n    });\n\n    test('auth success', async () => {\n      const authenticateCredentials = () => true;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onUpdate(action, 0, matchID, '0');\n      expect(ret).toBeUndefined();\n      expect(sendAll).toHaveBeenCalled();\n    });\n\n    test('default', async () => {\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth()\n      );\n      const ret = await master.onUpdate(action, 0, matchID, '0');\n      expect(ret).toBeUndefined();\n      expect(sendAll).toHaveBeenCalled();\n    });\n  });\n\n  describe('onSync', () => {\n    beforeEach(resetTestEnvironment);\n\n    test('auth failure', async () => {\n      const authenticateCredentials = () => false;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onSync(matchID, '0');\n      expect(ret && ret.error).toBe('unauthorized');\n      expect(send).not.toHaveBeenCalled();\n    });\n\n    test('auth success', async () => {\n      const authenticateCredentials = () => true;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onSync(matchID, '0');\n      expect(ret).toBeUndefined();\n      expect(send).toHaveBeenCalled();\n    });\n\n    test('spectators don’t need to authenticate', async () => {\n      const authenticateCredentials = () => false;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onSync(matchID, null);\n      expect(ret).toBeUndefined();\n      expect(send).toHaveBeenCalled();\n    });\n  });\n\n  describe('onConnectionChange', () => {\n    beforeEach(resetTestEnvironment);\n\n    test('auth failure', async () => {\n      const authenticateCredentials = () => false;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onConnectionChange(matchID, '0', null, true);\n      expect(ret && ret.error).toBe('unauthorized');\n      expect(sendAll).not.toHaveBeenCalled();\n    });\n\n    test('auth success', async () => {\n      const authenticateCredentials = () => true;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onConnectionChange(matchID, '0', null, true);\n      expect(ret).toBeUndefined();\n      expect(sendAll).toHaveBeenCalled();\n    });\n\n    test('spectators are ignored', async () => {\n      const authenticateCredentials = jest.fn();\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onConnectionChange(matchID, null, null, true);\n      expect(ret).toBeUndefined();\n      expect(authenticateCredentials).not.toHaveBeenCalled();\n      expect(sendAll).not.toHaveBeenCalled();\n    });\n  });\n\n  describe('onChatMessage', () => {\n    const chatMessage = {\n      id: 'uuid',\n      payload: { message: 'foo' },\n      sender: '0',\n    };\n\n    beforeEach(resetTestEnvironment);\n\n    test('auth success', async () => {\n      const authenticateCredentials = () => true;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onChatMessage(matchID, chatMessage, undefined);\n      expect(ret).toBeUndefined();\n      expect(sendAll).toHaveBeenCalled();\n    });\n\n    test('auth failure', async () => {\n      const authenticateCredentials = () => false;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onChatMessage(matchID, chatMessage, undefined);\n      expect(ret && ret.error).toBe('unauthorized');\n      expect(sendAll).not.toHaveBeenCalled();\n    });\n\n    test('invalid packet', async () => {\n      const authenticateCredentials = () => true;\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth({ authenticateCredentials })\n      );\n      const ret = await master.onChatMessage(matchID, undefined, undefined);\n      expect(ret && ret.error).toBe('unauthorized');\n      expect(sendAll).not.toHaveBeenCalled();\n    });\n\n    test('default', async () => {\n      const master = new Master(\n        game,\n        storage,\n        TransportAPI(send, sendAll),\n        new Auth()\n      );\n      const ret = await master.onChatMessage(matchID, chatMessage, undefined);\n      expect(ret).toBeUndefined();\n      expect(sendAll).toHaveBeenCalled();\n    });\n  });\n});\n\ndescribe('chat', () => {\n  const send = jest.fn();\n  const sendAll = jest.fn();\n  const db = new InMemory();\n  const master = new Master(game, db, TransportAPI(send, sendAll));\n\n  beforeEach(() => {\n    jest.clearAllMocks();\n  });\n\n  test('Sends chat messages to all', async () => {\n    master.onChatMessage(\n      'matchID',\n      { id: 'uuid', sender: '0', payload: { message: 'foo' } },\n      undefined\n    );\n    expect(sendAll.mock.calls[0][0]).toEqual({\n      type: 'chat',\n      args: [\n        'matchID',\n        { id: 'uuid', sender: '0', payload: { message: 'foo' } },\n      ],\n    });\n  });\n});\n"
  },
  {
    "path": "src/master/master.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport {\n  CreateGameReducer,\n  TransientHandlingMiddleware,\n} from '../core/reducer';\nimport { ProcessGameConfig, IsLongFormMove } from '../core/game';\nimport { UNDO, REDO, MAKE_MOVE } from '../core/action-types';\nimport { createStore, applyMiddleware } from 'redux';\nimport * as logging from '../core/logger';\nimport type {\n  SyncInfo,\n  FilteredMetadata,\n  Game,\n  Server,\n  State,\n  ActionShape,\n  CredentialedActionShape,\n  LogEntry,\n  PlayerID,\n  ChatMessage,\n} from '../types';\nimport { createMatch } from '../server/util';\nimport type { Auth } from '../server/auth';\nimport * as StorageAPI from '../server/db/base';\nimport type { Operation } from 'rfc6902';\n\n/**\n * Filter match data to get a player metadata object with credentials stripped.\n */\nconst filterMatchData = (matchData: Server.MatchData): FilteredMetadata =>\n  Object.values(matchData.players).map((player) => {\n    const { credentials, ...filteredData } = player;\n    return filteredData;\n  });\n\n/**\n * Remove player credentials from action payload\n */\nconst stripCredentialsFromAction = (action: CredentialedActionShape.Any) => {\n  const { credentials, ...payload } = action.payload;\n  return { ...action, payload };\n};\n\ntype CallbackFn = (arg: {\n  state: State;\n  matchID: string;\n  action?: ActionShape.Any | CredentialedActionShape.Any;\n}) => void;\n\n/**\n * Data types that are shared across `TransportData` and `IntermediateTransportData`.\n */\ntype CommonTransportData =\n  | {\n      type: 'sync';\n      args: [string, SyncInfo];\n    }\n  | {\n      type: 'matchData';\n      args: [string, FilteredMetadata];\n    }\n  | {\n      type: 'chat';\n      args: [string, ChatMessage];\n    };\n\n/**\n * Final shape of data sent by the transport API\n * to be received by clients/client transports.\n */\nexport type TransportData =\n  | {\n      type: 'update';\n      args: [string, State, LogEntry[]];\n    }\n  | {\n      type: 'patch';\n      args: [string, number, number, Operation[], LogEntry[]];\n    }\n  | CommonTransportData;\n\n/**\n * Data type sent by a master to its transport API. The transport then transforms\n * this into `TransportData` for each individual player it forwards it to.\n */\nexport type IntermediateTransportData =\n  | {\n      type: 'update';\n      args: [string, State];\n    }\n  | {\n      type: 'patch';\n      args: [string, number, State, State];\n    }\n  | CommonTransportData;\n\n/** API used by a master to emit data to any connected clients/client transports. */\nexport interface TransportAPI {\n  send: (\n    playerData: { playerID: PlayerID } & IntermediateTransportData\n  ) => void;\n  sendAll: (payload: IntermediateTransportData) => void;\n}\n\n/**\n * Master\n *\n * Class that runs the game and maintains the authoritative state.\n * It uses the transportAPI to communicate with clients and the\n * storageAPI to communicate with the database.\n */\nexport class Master {\n  game: ReturnType<typeof ProcessGameConfig>;\n  storageAPI: StorageAPI.Sync | StorageAPI.Async;\n  transportAPI: TransportAPI;\n  subscribeCallback: CallbackFn;\n  auth?: Auth;\n\n  constructor(\n    game: Game,\n    storageAPI: StorageAPI.Sync | StorageAPI.Async,\n    transportAPI: TransportAPI,\n    auth?: Auth\n  ) {\n    this.game = ProcessGameConfig(game);\n    this.storageAPI = storageAPI;\n    this.transportAPI = transportAPI;\n    this.subscribeCallback = () => {};\n    this.auth = auth;\n  }\n\n  subscribe(fn: CallbackFn) {\n    this.subscribeCallback = fn;\n  }\n\n  /**\n   * Called on each move / event made by the client.\n   * Computes the new value of the game state and returns it\n   * along with a deltalog.\n   */\n  async onUpdate(\n    credAction: CredentialedActionShape.Any,\n    stateID: number,\n    matchID: string,\n    playerID: string\n  ): Promise<void | { error: string }> {\n    if (!credAction || !credAction.payload) {\n      return { error: 'missing action or action payload' };\n    }\n\n    let metadata: Server.MatchData | undefined;\n    if (StorageAPI.isSynchronous(this.storageAPI)) {\n      ({ metadata } = this.storageAPI.fetch(matchID, { metadata: true }));\n    } else {\n      ({ metadata } = await this.storageAPI.fetch(matchID, { metadata: true }));\n    }\n\n    if (this.auth) {\n      const isAuthentic = await this.auth.authenticateCredentials({\n        playerID,\n        credentials: credAction.payload.credentials,\n        metadata,\n      });\n      if (!isAuthentic) {\n        return { error: 'unauthorized action' };\n      }\n    }\n\n    const action = stripCredentialsFromAction(credAction);\n    const key = matchID;\n\n    let state: State;\n    if (StorageAPI.isSynchronous(this.storageAPI)) {\n      ({ state } = this.storageAPI.fetch(key, { state: true }));\n    } else {\n      ({ state } = await this.storageAPI.fetch(key, { state: true }));\n    }\n\n    if (state === undefined) {\n      logging.error(`game not found, matchID=[${key}]`);\n      return { error: 'game not found' };\n    }\n\n    if (state.ctx.gameover !== undefined) {\n      logging.error(\n        `game over - matchID=[${key}] - playerID=[${playerID}]` +\n          ` - action[${action.payload.type}]`\n      );\n      return;\n    }\n\n    const reducer = CreateGameReducer({\n      game: this.game,\n    });\n    const middleware = applyMiddleware(TransientHandlingMiddleware);\n    const store = createStore(reducer, state, middleware);\n\n    // Only allow UNDO / REDO if there is exactly one player\n    // that can make moves right now and the person doing the\n    // action is that player.\n    if (action.type == UNDO || action.type == REDO) {\n      const hasActivePlayers = state.ctx.activePlayers !== null;\n      const isCurrentPlayer = state.ctx.currentPlayer === playerID;\n\n      if (\n        // If activePlayers is empty, non-current players can’t undo.\n        (!hasActivePlayers && !isCurrentPlayer) ||\n        // If player is not active or multiple players are active, can’t undo.\n        (hasActivePlayers &&\n          (state.ctx.activePlayers[playerID] === undefined ||\n            Object.keys(state.ctx.activePlayers).length > 1))\n      ) {\n        logging.error(`playerID=[${playerID}] cannot undo / redo right now`);\n        return;\n      }\n    }\n\n    // Check whether the player is active.\n    if (!this.game.flow.isPlayerActive(state.G, state.ctx, playerID)) {\n      logging.error(\n        `player not active - playerID=[${playerID}]` +\n          ` - action[${action.payload.type}]`\n      );\n      return;\n    }\n\n    // Get move for further checks\n    const move =\n      action.type == MAKE_MOVE\n        ? this.game.flow.getMove(state.ctx, action.payload.type, playerID)\n        : null;\n\n    // Check whether the player is allowed to make the move.\n    if (action.type == MAKE_MOVE && !move) {\n      logging.error(\n        `move not processed - canPlayerMakeMove=false - playerID=[${playerID}]` +\n          ` - action[${action.payload.type}]`\n      );\n      return;\n    }\n\n    // Check if action's stateID is different than store's stateID\n    // and if move does not have ignoreStaleStateID truthy.\n    if (\n      state._stateID !== stateID &&\n      !(move && IsLongFormMove(move) && move.ignoreStaleStateID)\n    ) {\n      logging.error(\n        `invalid stateID, was=[${stateID}], expected=[${state._stateID}]` +\n          ` - playerID=[${playerID}] - action[${action.payload.type}]`\n      );\n      return;\n    }\n\n    const prevState = store.getState();\n\n    // Update server's version of the store.\n    store.dispatch(action);\n    state = store.getState();\n\n    this.subscribeCallback({\n      state,\n      action,\n      matchID,\n    });\n\n    if (this.game.deltaState) {\n      this.transportAPI.sendAll({\n        type: 'patch',\n        args: [matchID, stateID, prevState, state],\n      });\n    } else {\n      this.transportAPI.sendAll({\n        type: 'update',\n        args: [matchID, state],\n      });\n    }\n\n    const { deltalog, ...stateWithoutDeltalog } = state;\n\n    let newMetadata: Server.MatchData | undefined;\n    if (\n      metadata &&\n      (metadata.gameover === undefined || metadata.gameover === null)\n    ) {\n      newMetadata = {\n        ...metadata,\n        updatedAt: Date.now(),\n      };\n      if (state.ctx.gameover !== undefined) {\n        newMetadata.gameover = state.ctx.gameover;\n      }\n    }\n\n    if (StorageAPI.isSynchronous(this.storageAPI)) {\n      this.storageAPI.setState(key, stateWithoutDeltalog, deltalog);\n      if (newMetadata) this.storageAPI.setMetadata(key, newMetadata);\n    } else {\n      const writes = [\n        this.storageAPI.setState(key, stateWithoutDeltalog, deltalog),\n      ];\n      if (newMetadata) {\n        writes.push(this.storageAPI.setMetadata(key, newMetadata));\n      }\n      await Promise.all(writes);\n    }\n  }\n\n  /**\n   * Called when the client connects / reconnects.\n   * Returns the latest game state and the entire log.\n   */\n  async onSync(\n    matchID: string,\n    playerID: string | null | undefined,\n    credentials?: string,\n    numPlayers = 2\n  ): Promise<void | { error: string }> {\n    const key = matchID;\n\n    const fetchOpts = {\n      state: true,\n      metadata: true,\n      log: true,\n      initialState: true,\n    } as const;\n\n    const fetchResult = StorageAPI.isSynchronous(this.storageAPI)\n      ? this.storageAPI.fetch(key, fetchOpts)\n      : await this.storageAPI.fetch(key, fetchOpts);\n\n    let { state, initialState, log, metadata } = fetchResult;\n\n    if (this.auth && playerID !== undefined && playerID !== null) {\n      const isAuthentic = await this.auth.authenticateCredentials({\n        playerID,\n        credentials,\n        metadata,\n      });\n      if (!isAuthentic) {\n        return { error: 'unauthorized' };\n      }\n    }\n\n    // If the game doesn't exist, then create one on demand.\n    // TODO: Move this out of the sync call.\n    if (state === undefined) {\n      const match = createMatch({\n        game: this.game,\n        unlisted: true,\n        numPlayers,\n        setupData: undefined,\n      });\n\n      if ('setupDataError' in match) {\n        return { error: 'game requires setupData' };\n      }\n\n      initialState = state = match.initialState;\n      metadata = match.metadata;\n\n      this.subscribeCallback({ state, matchID });\n\n      if (StorageAPI.isSynchronous(this.storageAPI)) {\n        this.storageAPI.createMatch(key, { initialState, metadata });\n      } else {\n        await this.storageAPI.createMatch(key, { initialState, metadata });\n      }\n    }\n\n    const filteredMetadata = metadata ? filterMatchData(metadata) : undefined;\n\n    const syncInfo: SyncInfo = {\n      state,\n      log,\n      filteredMetadata,\n      initialState,\n    };\n\n    this.transportAPI.send({\n      playerID,\n      type: 'sync',\n      args: [matchID, syncInfo],\n    });\n\n    return;\n  }\n\n  /**\n   * Called when a client connects or disconnects.\n   * Updates and sends out metadata to reflect the player’s connection status.\n   */\n  async onConnectionChange(\n    matchID: string,\n    playerID: string | null | undefined,\n    credentials: string | undefined,\n    connected: boolean\n  ): Promise<void | { error: string }> {\n    const key = matchID;\n\n    // Ignore changes for clients without a playerID, e.g. spectators.\n    if (playerID === undefined || playerID === null) {\n      return;\n    }\n\n    let metadata: Server.MatchData | undefined;\n\n    if (StorageAPI.isSynchronous(this.storageAPI)) {\n      ({ metadata } = this.storageAPI.fetch(key, { metadata: true }));\n    } else {\n      ({ metadata } = await this.storageAPI.fetch(key, { metadata: true }));\n    }\n\n    if (metadata === undefined) {\n      logging.error(`metadata not found for matchID=[${key}]`);\n      return { error: 'metadata not found' };\n    }\n\n    if (metadata.players[playerID] === undefined) {\n      logging.error(\n        `Player not in the match, matchID=[${key}] playerID=[${playerID}]`\n      );\n      return { error: 'player not in the match' };\n    }\n\n    if (this.auth) {\n      const isAuthentic = await this.auth.authenticateCredentials({\n        playerID,\n        credentials,\n        metadata,\n      });\n      if (!isAuthentic) {\n        return { error: 'unauthorized' };\n      }\n    }\n\n    metadata.players[playerID].isConnected = connected;\n\n    const filteredMetadata = filterMatchData(metadata);\n\n    this.transportAPI.sendAll({\n      type: 'matchData',\n      args: [matchID, filteredMetadata],\n    });\n\n    if (StorageAPI.isSynchronous(this.storageAPI)) {\n      this.storageAPI.setMetadata(key, metadata);\n    } else {\n      await this.storageAPI.setMetadata(key, metadata);\n    }\n  }\n\n  async onChatMessage(\n    matchID: string,\n    chatMessage: ChatMessage,\n    credentials: string | undefined\n  ): Promise<void | { error: string }> {\n    const key = matchID;\n\n    if (this.auth) {\n      const { metadata } = await (this.storageAPI as StorageAPI.Async).fetch(\n        key,\n        {\n          metadata: true,\n        }\n      );\n      if (!(chatMessage && typeof chatMessage.sender === 'string')) {\n        return { error: 'unauthorized' };\n      }\n      const isAuthentic = await this.auth.authenticateCredentials({\n        playerID: chatMessage.sender,\n        credentials,\n        metadata,\n      });\n      if (!isAuthentic) {\n        return { error: 'unauthorized' };\n      }\n    }\n\n    this.transportAPI.sendAll({\n      type: 'chat',\n      args: [matchID, chatMessage],\n    });\n  }\n}\n"
  },
  {
    "path": "src/plugins/events/events.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Events } from './events';\nimport { Client } from '../../client/client';\nimport { error } from '../../core/logger';\nimport type { Game, Ctx } from '../../types';\n\njest.mock('../../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\nafterEach(jest.clearAllMocks);\n\ntest('constructor', () => {\n  const flow = {} as Game['flow'];\n  const playerID = '0';\n  const e = new Events(flow, { phase: '', turn: 0 } as Ctx, playerID);\n  expect(e.flow).toBe(flow);\n  expect(e.playerID).toBe(playerID);\n  expect(e.dispatch).toEqual([]);\n  expect(e.initialTurn).toEqual(0);\n  expect(e.currentPhase).toEqual('');\n  expect(e.currentTurn).toEqual(0);\n});\n\ntest('dispatch', () => {\n  const flow = { eventNames: ['A', 'B'] } as Game['flow'];\n  const e = new Events(flow, { phase: '', turn: 0 } as Ctx);\n  const events = e.api();\n\n  expect(e.dispatch).toEqual([]);\n  (events as unknown as { A(): void }).A();\n  (events as unknown as { B(): void }).B();\n  expect(e.dispatch).toEqual([\n    {\n      type: 'A',\n      args: [],\n      phase: '',\n      turn: 0,\n      calledFrom: undefined,\n      error: expect.any(Error),\n    },\n    {\n      type: 'B',\n      args: [],\n      phase: '',\n      turn: 0,\n      calledFrom: undefined,\n      error: expect.any(Error),\n    },\n  ]);\n});\n\ntest('update ctx', () => {\n  const game: Game = {\n    moves: {\n      A: ({ G, events }) => {\n        events.endTurn();\n        return G;\n      },\n    },\n  };\n  const client = Client({ game });\n  expect(client.getState().ctx.turn).toBe(1);\n  client.moves.A();\n  expect(client.getState().ctx.turn).toBe(2);\n});\n\ntest('no duplicate endTurn', () => {\n  const game: Game = {\n    turn: {\n      onEnd: ({ events }) => {\n        events.endTurn();\n      },\n    },\n  };\n  const client = Client({ game });\n  expect(client.getState().ctx.turn).toBe(1);\n  client.events.endTurn();\n  expect(client.getState().ctx.turn).toBe(1);\n  expect(error).toHaveBeenCalled();\n});\n\ntest('no duplicate endPhase', () => {\n  const game: Game = {\n    phases: {\n      A: {\n        start: true,\n        onEnd: ({ events }) => {\n          events.setPhase('C');\n        },\n      },\n      B: {},\n      C: {},\n    },\n  };\n  const client = Client({ game });\n  expect(client.getState().ctx.phase).toBe('A');\n  client.events.setPhase('B');\n  expect(client.getState().ctx.phase).toBe('A');\n  expect(error).toHaveBeenCalled();\n});\n"
  },
  {
    "path": "src/plugins/events/events.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { State, Ctx, PlayerID, Game, ActivePlayersArg } from '../../types';\nimport { automaticGameEvent } from '../../core/action-creators';\nimport { GameMethod } from '../../core/game-methods';\n\nenum Errors {\n  CalledOutsideHook = 'Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\\n' +\n    'This error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.',\n\n  EndTurnInOnEnd = '`endTurn` is disallowed in `onEnd` hooks — the turn is already ending.',\n\n  MaxTurnEndings = 'Maximum number of turn endings exceeded for this update.\\n' +\n    'This likely means game code is triggering an infinite loop.',\n\n  PhaseEventInOnEnd = '`setPhase` & `endPhase` are disallowed in a phase’s `onEnd` hook — the phase is already ending.\\n' +\n    'If you’re trying to dynamically choose the next phase when a phase ends, use the phase’s `next` trigger.',\n\n  StageEventInOnEnd = '`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.',\n\n  StageEventInPhaseBegin = '`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase’s `onBegin` hook.\\n' +\n    'Use `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.',\n\n  StageEventInTurnBegin = '`setStage` & `endStage` are disallowed in `turn.onBegin`.\\n' +\n    'Use `setActivePlayers` or declare stages with `turn.activePlayers` instead.',\n}\n\nexport interface EventsAPI {\n  endGame(gameover?: any): void;\n  endPhase(): void;\n  endStage(): void;\n  endTurn(arg?: { next: PlayerID }): void;\n  pass(arg?: { remove: true }): void;\n  setActivePlayers(arg: ActivePlayersArg): void;\n  setPhase(newPhase: string): void;\n  setStage(newStage: string): void;\n}\n\nexport interface PrivateEventsAPI {\n  _private: {\n    isUsed(): boolean;\n    updateTurnContext(ctx: Ctx, methodType: GameMethod | undefined): void;\n    unsetCurrentMethod(): void;\n    update(state: State): State;\n  };\n}\n\n/**\n * Events\n */\nexport class Events {\n  flow: Game['flow'];\n  playerID: PlayerID | undefined;\n  dispatch: Array<{\n    type: string;\n    args: any[];\n    phase: string;\n    turn: number;\n    calledFrom: GameMethod | undefined;\n    error: Error;\n  }>;\n  maxEndedTurnsPerAction: number;\n  initialTurn: number;\n  currentPhase: string;\n  currentTurn: number;\n  currentMethod?: GameMethod;\n\n  constructor(flow: Game['flow'], ctx: Ctx, playerID?: PlayerID) {\n    this.flow = flow;\n    this.playerID = playerID;\n    this.dispatch = [];\n    this.initialTurn = ctx.turn;\n    this.updateTurnContext(ctx, undefined);\n    // This is an arbitrarily large upper threshold, which could be made\n    // configurable via a game option if the need arises.\n    this.maxEndedTurnsPerAction = ctx.numPlayers * 100;\n  }\n\n  api() {\n    const events = {\n      _private: this,\n    } as unknown as EventsAPI & PrivateEventsAPI;\n    for (const type of this.flow.eventNames) {\n      events[type] = (...args: any[]) => {\n        this.dispatch.push({\n          type,\n          args,\n          phase: this.currentPhase,\n          turn: this.currentTurn,\n          calledFrom: this.currentMethod,\n          // Used to capture a stack trace in case it is needed later.\n          error: new Error('Events Plugin Error'),\n        });\n      };\n    }\n\n    return events;\n  }\n\n  isUsed() {\n    return this.dispatch.length > 0;\n  }\n\n  updateTurnContext(ctx: Ctx, methodType: GameMethod | undefined) {\n    this.currentPhase = ctx.phase;\n    this.currentTurn = ctx.turn;\n    this.currentMethod = methodType;\n  }\n\n  unsetCurrentMethod() {\n    this.currentMethod = undefined;\n  }\n\n  /**\n   * Updates ctx with the triggered events.\n   * @param {object} state - The state object { G, ctx }.\n   */\n  update(state: State): State {\n    const initialState = state;\n    const stateWithError = ({ stack }: Error, message: Errors) => ({\n      ...initialState,\n      plugins: {\n        ...initialState.plugins,\n        events: {\n          ...initialState.plugins.events,\n          data: { error: message + '\\n' + stack },\n        },\n      },\n    });\n\n    EventQueue: for (let i = 0; i < this.dispatch.length; i++) {\n      const event = this.dispatch[i];\n      const turnHasEnded = event.turn !== state.ctx.turn;\n\n      // This protects against potential infinite loops if specific events are called on hooks.\n      // The moment we exceed the defined threshold, we just bail out of all phases.\n      const endedTurns = this.currentTurn - this.initialTurn;\n      if (endedTurns >= this.maxEndedTurnsPerAction) {\n        return stateWithError(event.error, Errors.MaxTurnEndings);\n      }\n\n      if (event.calledFrom === undefined) {\n        return stateWithError(event.error, Errors.CalledOutsideHook);\n      }\n\n      // Stop processing events once the game has finished.\n      if (state.ctx.gameover) break EventQueue;\n\n      switch (event.type) {\n        case 'endStage':\n        case 'setStage':\n        case 'setActivePlayers': {\n          switch (event.calledFrom) {\n            // Disallow all stage events in onEnd and phase.onBegin hooks.\n            case GameMethod.TURN_ON_END:\n            case GameMethod.PHASE_ON_END:\n              return stateWithError(event.error, Errors.StageEventInOnEnd);\n            case GameMethod.PHASE_ON_BEGIN:\n              return stateWithError(event.error, Errors.StageEventInPhaseBegin);\n            // Disallow setStage & endStage in turn.onBegin hooks.\n            case GameMethod.TURN_ON_BEGIN:\n              if (event.type === 'setActivePlayers') break;\n              return stateWithError(event.error, Errors.StageEventInTurnBegin);\n          }\n\n          // If the turn already ended, don't try to process stage events.\n          if (turnHasEnded) continue EventQueue;\n          break;\n        }\n\n        case 'endTurn': {\n          if (\n            event.calledFrom === GameMethod.TURN_ON_END ||\n            event.calledFrom === GameMethod.PHASE_ON_END\n          ) {\n            return stateWithError(event.error, Errors.EndTurnInOnEnd);\n          }\n\n          // If the turn already ended some other way,\n          // don't try to end the turn again.\n          if (turnHasEnded) continue EventQueue;\n          break;\n        }\n\n        case 'endPhase':\n        case 'setPhase': {\n          if (event.calledFrom === GameMethod.PHASE_ON_END) {\n            return stateWithError(event.error, Errors.PhaseEventInOnEnd);\n          }\n\n          // If the phase already ended some other way,\n          // don't try to end the phase again.\n          if (event.phase !== state.ctx.phase) continue EventQueue;\n          break;\n        }\n      }\n\n      const action = automaticGameEvent(event.type, event.args, this.playerID);\n      state = this.flow.processEvent(state, action);\n    }\n    return state;\n  }\n}\n"
  },
  {
    "path": "src/plugins/main.test.ts",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client } from '../client/client';\nimport { Local } from '../client/transport/local';\nimport type { Game, Plugin } from '../types';\nimport { GameMethod } from '../../packages/core';\n\ndescribe('basic', () => {\n  let client: ReturnType<typeof Client>;\n\n  beforeAll(() => {\n    interface TestPluginAPI {\n      get(): number;\n      increment(): number;\n    }\n\n    const TestPlugin = (init: {\n      n: number;\n    }): Plugin<TestPluginAPI, { n: number }> => ({\n      name: 'test',\n\n      setup: () => init,\n\n      api: ({ data }) => {\n        const state = { value: data.n };\n        const increment = () => state.value++;\n        const get = () => state.value;\n        return { increment, get };\n      },\n\n      flush: ({ api }) => ({ n: api.get() }),\n\n      fnWrap: (fn) => (context) => {\n        const G = fn(context);\n        return { ...G, wrap: true };\n      },\n    });\n\n    const game: Game<\n      { beginA: number; endA: number; onMove: number; onTurnEnd: number },\n      { test: TestPluginAPI }\n    > = {\n      moves: {\n        A: ({ G, test }) => {\n          G.beginA = test.get();\n          test.increment();\n          G.endA = test.get();\n        },\n      },\n\n      endIf: ({ test }) => {\n        if (test === undefined) {\n          throw new Error('API is not defined');\n        }\n      },\n\n      turn: {\n        onMove: ({ G, test }) => {\n          G.onMove = test.get();\n          test.increment();\n        },\n\n        onEnd: ({ G, test }) => {\n          G.onTurnEnd = test.get();\n          test.increment();\n        },\n      },\n\n      plugins: [TestPlugin({ n: 10 })],\n    };\n\n    client = Client({ game });\n  });\n\n  test('setup', () => {\n    expect(client.getState().plugins.test.data).toEqual({\n      n: 10,\n    });\n  });\n\n  test('make move', () => {\n    client.moves.A();\n    expect(client.getState().G).toEqual({\n      beginA: 10,\n      endA: 11,\n      onMove: 11,\n      wrap: true,\n    });\n    expect(client.getState().plugins.test.data).toEqual({ n: 12 });\n  });\n\n  test('make another move', () => {\n    client.moves.A();\n    expect(client.getState().G).toEqual({\n      beginA: 12,\n      endA: 13,\n      onMove: 13,\n      wrap: true,\n    });\n    expect(client.getState().plugins.test.data).toEqual({ n: 14 });\n  });\n\n  test('event', () => {\n    client.events.endTurn();\n    expect(client.getState().G).toMatchObject({ onTurnEnd: 14 });\n    expect(client.getState().plugins.test.data).toEqual({ n: 15 });\n  });\n\n  test('does not make it into undo state', () => {\n    client.moves.A();\n    client.undo();\n    expect(Object.keys(client.getState()._undo[0].ctx)).not.toContain('test');\n  });\n});\n\ndescribe('default values', () => {\n  const pluginData = { value: true };\n\n  const plugin = {\n    name: 'test',\n    flush: () => pluginData,\n  };\n\n  const anotherPlugin = {\n    name: 'test2',\n    noClient: () => false,\n  };\n\n  const game: Game = {\n    moves: { A: () => {} },\n    plugins: [plugin, anotherPlugin],\n  };\n\n  test('are used if no setup is present', () => {\n    const client = Client({ game, playerID: '0', multiplayer: Local() });\n    client.start();\n    client.moves.A();\n    expect(client.getState().plugins.test.data).toEqual(pluginData);\n  });\n});\n\ndescribe('isInvalid method', () => {\n  // Silence expected error logging and restore when finished.\n  const stderr = console.error;\n  beforeAll(() => (console.error = () => {}));\n  afterAll(() => (console.error = stderr));\n\n  test('basic plugin', () => {\n    const goodG = { good: 'nice' };\n    const game: Game = {\n      plugins: [\n        {\n          name: 'test',\n          isInvalid: ({ G }) => 'bad' in G && 'not ok',\n        },\n      ],\n      moves: {\n        good: () => goodG,\n        bad: () => ({ bad: 'not ok' }),\n      },\n    };\n\n    const client = Client({ game, playerID: '0' });\n    client.start();\n    client.moves.good();\n    expect(client.getState().G).toEqual(goodG);\n    client.moves.bad();\n    expect(client.getState().G).toEqual(goodG);\n  });\n\n  test('plugin with API and data', () => {\n    const game: Game<any, any> = {\n      plugins: [\n        {\n          name: 'test',\n          setup: () => ({}),\n          api: ({ data }) => ({\n            set: (key, val) => {\n              data[key] = val;\n            },\n          }),\n          isInvalid: ({ data }) => 'bad' in data && 'not ok',\n        },\n      ],\n      moves: {\n        good: ({ test }) => {\n          test.set('good', 'nice');\n        },\n        bad: ({ test }) => {\n          test.set('bad', 'not ok');\n        },\n      },\n    };\n\n    const client = Client({ game, playerID: '0' });\n    client.start();\n    expect(client.getState().ctx.numMoves).toBe(0);\n    client.moves.good();\n    expect(client.getState().ctx.numMoves).toBe(1);\n    client.moves.bad();\n    expect(client.getState().ctx.numMoves).toBe(1);\n  });\n});\n\ndescribe('actions', () => {\n  let client: ReturnType<typeof Client>;\n\n  beforeAll(() => {\n    const game: Game = {\n      plugins: [\n        {\n          name: 'test',\n\n          setup: () => ({\n            initial: true,\n          }),\n\n          action: (_, payload) => {\n            return payload.args[0];\n          },\n        },\n        {\n          name: 'nosetup',\n          action: () => ({ action: true }),\n        },\n      ],\n    };\n\n    client = Client({ game });\n  });\n\n  test('setup', () => {\n    expect(client.getState().plugins.test.data).toEqual({\n      initial: true,\n    });\n    expect(client.getState().plugins.nosetup).toBeUndefined();\n  });\n\n  test('take action', () => {\n    const payload = { payload: true };\n\n    client.plugins.test(payload);\n    client.plugins.nosetup(payload);\n\n    expect(client.getState().plugins.test.data).toEqual(payload);\n    expect(client.getState().plugins.nosetup.data).toEqual({ action: true });\n  });\n});\n\ndescribe('plugins are accessible in events triggered from moves', () => {\n  type TestPluginAPI = { get: () => boolean };\n  type PluginAPIs = { test: TestPluginAPI };\n  const plugins = [\n    {\n      name: 'test',\n\n      setup: () => ({\n        initial: true,\n      }),\n\n      flush: () => ({ initial: true }),\n\n      api: ({ data }): TestPluginAPI => {\n        return {\n          get: () => data.initial,\n        };\n      },\n    },\n  ];\n\n  test('turn/onBegin', () => {\n    const game: Game<any, PluginAPIs> = {\n      plugins,\n      moves: {\n        stop: ({ events }) => events.endTurn(),\n      },\n      turn: {\n        onBegin: ({ G, random, test }) => {\n          G.onBegin = random.Die(1);\n          G.test = test.get();\n        },\n      },\n    };\n\n    const client = Client({ game });\n    client.moves.stop();\n    expect(client.getState().G).toEqual({\n      onBegin: 1,\n      test: true,\n    });\n  });\n\n  test('turn/onEnd', () => {\n    const game: Game<any, PluginAPIs> = {\n      plugins,\n      moves: {\n        stop: ({ events }) => events.endTurn(),\n      },\n      turn: {\n        onEnd: ({ G, random, test }) => {\n          G.onEnd = random.Die(1);\n          G.test = test.get();\n        },\n      },\n    };\n\n    const client = Client({ game });\n    client.moves.stop();\n    expect(client.getState().G).toEqual({\n      onEnd: 1,\n      test: true,\n    });\n  });\n\n  test('phase/onBegin', () => {\n    const game: Game<any, PluginAPIs> = {\n      plugins,\n      moves: {\n        stop: ({ events }) => events.setPhase('second'),\n      },\n      phases: {\n        first: {\n          start: true,\n        },\n        second: {\n          onBegin: ({ G, random, test }) => {\n            G.onBegin = random.Die(1);\n            G.test = test.get();\n          },\n        },\n      },\n    };\n\n    const client = Client({ game });\n    client.moves.stop();\n    expect(client.getState().G).toEqual({\n      onBegin: 1,\n      test: true,\n    });\n  });\n\n  test('phase/onEnd', () => {\n    const game: Game<any, PluginAPIs> = {\n      plugins,\n      moves: {\n        stop: ({ events }) => events.endPhase(),\n      },\n      phases: {\n        first: {\n          start: true,\n          onEnd: ({ G, random, test }) => {\n            G.onEnd = random.Die(1);\n            G.test = test.get();\n          },\n        },\n      },\n    };\n\n    const client = Client({ game });\n    client.moves.stop();\n    expect(client.getState().G).toEqual({\n      onEnd: 1,\n      test: true,\n    });\n  });\n});\n\ndescribe('plugins can use events in fnWrap', () => {\n  const game: Game = {\n    plugins: [\n      {\n        name: 'test',\n        fnWrap:\n          (fn, type) =>\n          (context, ...args) => {\n            const G = fn(context, ...args);\n            if (G.endTurn && type === GameMethod.MOVE) {\n              context.events.endTurn();\n            }\n            if (G.endGame) {\n              context.events.endGame(G.endGame);\n            }\n            return G;\n          },\n      },\n    ],\n    moves: {\n      endGame: () => ({ endGame: true }),\n      endTurn: () => ({ endTurn: true }),\n    },\n  };\n\n  test('plugin can end turn', () => {\n    const client = Client({ game });\n    client.moves.endTurn();\n    expect(client.getState().ctx.turn).toBe(2);\n    expect(client.getState().ctx.currentPlayer).toBe('1');\n  });\n\n  test('plugin can end game', () => {\n    const client = Client({ game });\n    client.moves.endGame();\n    expect(client.getState().ctx.gameover).toBe(true);\n  });\n});\n"
  },
  {
    "path": "src/plugins/main.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport PluginImmer from './plugin-immer';\nimport PluginRandom from './plugin-random';\nimport PluginEvents from './plugin-events';\nimport PluginLog from './plugin-log';\nimport PluginSerializable from './plugin-serializable';\nimport type {\n  AnyFn,\n  DefaultPluginAPIs,\n  PartialGameState,\n  State,\n  Game,\n  Plugin,\n  ActionShape,\n  PlayerID,\n} from '../types';\nimport { error } from '../core/logger';\nimport type { GameMethod } from '../core/game-methods';\n\ninterface PluginOpts {\n  game: Game;\n  isClient?: boolean;\n}\n\n/**\n * List of plugins that are always added.\n */\nconst CORE_PLUGINS = [PluginImmer, PluginRandom, PluginLog, PluginSerializable];\nconst DEFAULT_PLUGINS = [...CORE_PLUGINS, PluginEvents];\n\n/**\n * Allow plugins to intercept actions and process them.\n */\nexport const ProcessAction = (\n  state: State,\n  action: ActionShape.Plugin,\n  opts: PluginOpts\n): State => {\n  // TODO(#723): Extend error handling to plugins.\n  opts.game.plugins\n    .filter((plugin) => plugin.action !== undefined)\n    .filter((plugin) => plugin.name === action.payload.type)\n    .forEach((plugin) => {\n      const name = plugin.name;\n      const pluginState = state.plugins[name] || { data: {} };\n      const data = plugin.action(pluginState.data, action.payload);\n\n      state = {\n        ...state,\n        plugins: {\n          ...state.plugins,\n          [name]: { ...pluginState, data },\n        },\n      };\n    });\n  return state;\n};\n\n/**\n * The APIs created by various plugins are stored in the plugins\n * section of the state object:\n *\n * {\n *   G: {},\n *   ctx: {},\n *   plugins: {\n *     plugin-a: {\n *       data: {},  // this is generated by the plugin at Setup / Flush.\n *       api: {},   // this is ephemeral and generated by Enhance.\n *     }\n *   }\n * }\n *\n * This function retrieves plugin APIs and returns them as an object\n * for consumption as used by move contexts.\n */\nexport const GetAPIs = ({ plugins }: PartialGameState) =>\n  Object.entries(plugins || {}).reduce((apis, [name, { api }]) => {\n    apis[name] = api;\n    return apis;\n  }, {} as DefaultPluginAPIs);\n\n/**\n * Applies the provided plugins to the given move / flow function.\n *\n * @param methodToWrap - The move function or hook to apply the plugins to.\n * @param methodType - The type of the move or hook being wrapped.\n * @param plugins - The list of plugins.\n */\nexport const FnWrap = (\n  methodToWrap: AnyFn,\n  methodType: GameMethod,\n  plugins: Plugin[]\n) => {\n  return [...CORE_PLUGINS, ...plugins, PluginEvents]\n    .filter((plugin) => plugin.fnWrap !== undefined)\n    .reduce(\n      (method: AnyFn, { fnWrap }: Plugin) => fnWrap(method, methodType),\n      methodToWrap\n    );\n};\n\n/**\n * Allows the plugin to generate its initial state.\n */\nexport const Setup = (\n  state: PartialGameState,\n  opts: PluginOpts\n): PartialGameState => {\n  [...DEFAULT_PLUGINS, ...opts.game.plugins]\n    .filter((plugin) => plugin.setup !== undefined)\n    .forEach((plugin) => {\n      const name = plugin.name;\n      const data = plugin.setup({\n        G: state.G,\n        ctx: state.ctx,\n        game: opts.game,\n      });\n\n      state = {\n        ...state,\n        plugins: {\n          ...state.plugins,\n          [name]: { data },\n        },\n      };\n    });\n  return state;\n};\n\n/**\n * Invokes the plugin before a move or event.\n * The API that the plugin generates is stored inside\n * the `plugins` section of the state (which is subsequently\n * merged into ctx).\n */\nexport const Enhance = <S extends State | PartialGameState>(\n  state: S,\n  opts: PluginOpts & { playerID: PlayerID }\n): S => {\n  [...DEFAULT_PLUGINS, ...opts.game.plugins]\n    .filter((plugin) => plugin.api !== undefined)\n    .forEach((plugin) => {\n      const name = plugin.name;\n      const pluginState = state.plugins[name] || { data: {} };\n\n      const api = plugin.api({\n        G: state.G,\n        ctx: state.ctx,\n        data: pluginState.data,\n        game: opts.game,\n        playerID: opts.playerID,\n      });\n\n      state = {\n        ...state,\n        plugins: {\n          ...state.plugins,\n          [name]: { ...pluginState, api },\n        },\n      };\n    });\n  return state;\n};\n\n/**\n * Allows plugins to update their state after a move / event.\n */\nconst Flush = (state: State, opts: PluginOpts): State => {\n  // We flush the events plugin first, then custom plugins and the core plugins.\n  // This means custom plugins cannot use the events API but will be available in event hooks.\n  // Note that plugins are flushed in reverse, to allow custom plugins calling each other.\n  [...CORE_PLUGINS, ...opts.game.plugins, PluginEvents]\n    .reverse()\n    .forEach((plugin) => {\n      const name = plugin.name;\n      const pluginState = state.plugins[name] || { data: {} };\n\n      if (plugin.flush) {\n        const newData = plugin.flush({\n          G: state.G,\n          ctx: state.ctx,\n          game: opts.game,\n          api: pluginState.api,\n          data: pluginState.data,\n        });\n\n        state = {\n          ...state,\n          plugins: {\n            ...state.plugins,\n            [plugin.name]: { data: newData },\n          },\n        };\n      } else if (plugin.dangerouslyFlushRawState) {\n        state = plugin.dangerouslyFlushRawState({\n          state,\n          game: opts.game,\n          api: pluginState.api,\n          data: pluginState.data,\n        });\n\n        // Remove everything other than data.\n        const data = state.plugins[name].data;\n        state = {\n          ...state,\n          plugins: {\n            ...state.plugins,\n            [plugin.name]: { data },\n          },\n        };\n      }\n    });\n\n  return state;\n};\n\n/**\n * Allows plugins to indicate if they should not be materialized on the client.\n * This will cause the client to discard the state update and wait for the\n * master instead.\n */\nexport const NoClient = (state: State, opts: PluginOpts): boolean => {\n  return [...DEFAULT_PLUGINS, ...opts.game.plugins]\n    .filter((plugin) => plugin.noClient !== undefined)\n    .map((plugin) => {\n      const name = plugin.name;\n      const pluginState = state.plugins[name];\n\n      if (pluginState) {\n        return plugin.noClient({\n          G: state.G,\n          ctx: state.ctx,\n          game: opts.game,\n          api: pluginState.api,\n          data: pluginState.data,\n        });\n      }\n\n      return false;\n    })\n    .includes(true);\n};\n\n/**\n * Allows plugins to indicate if the entire action should be thrown out\n * as invalid. This will cancel the entire state update.\n */\nconst IsInvalid = (\n  state: State,\n  opts: PluginOpts\n): false | { plugin: string; message: string } => {\n  const firstInvalidReturn = [...DEFAULT_PLUGINS, ...opts.game.plugins]\n    .filter((plugin) => plugin.isInvalid !== undefined)\n    .map((plugin) => {\n      const { name } = plugin;\n      const pluginState = state.plugins[name];\n\n      const message = plugin.isInvalid({\n        G: state.G,\n        ctx: state.ctx,\n        game: opts.game,\n        data: pluginState && pluginState.data,\n      });\n\n      return message ? { plugin: name, message } : false;\n    })\n    .find((value) => value);\n  return firstInvalidReturn || false;\n};\n\n/**\n * Update plugin state after move/event & check if plugins consider the update to be valid.\n * @returns Tuple of `[updatedState]` or `[originalState, invalidError]`.\n */\nexport const FlushAndValidate = (state: State, opts: PluginOpts) => {\n  const updatedState = Flush(state, opts);\n  const isInvalid = IsInvalid(updatedState, opts);\n  if (!isInvalid) return [updatedState] as const;\n  const { plugin, message } = isInvalid;\n  error(`${plugin} plugin declared action invalid:\\n${message}`);\n  return [state, isInvalid] as const;\n};\n\n/**\n * Allows plugins to customize their data for specific players.\n * For example, a plugin may want to share no data with the client, or\n * want to keep some player data secret from opponents.\n */\nexport const PlayerView = (\n  { G, ctx, plugins = {} }: State,\n  { game, playerID }: PluginOpts & { playerID: PlayerID }\n) => {\n  [...DEFAULT_PLUGINS, ...game.plugins].forEach(({ name, playerView }) => {\n    if (!playerView) return;\n\n    const { data } = plugins[name] || { data: {} };\n    const newData = playerView({ G, ctx, game, data, playerID });\n\n    plugins = {\n      ...plugins,\n      [name]: { data: newData },\n    };\n  });\n\n  return plugins;\n};\n"
  },
  {
    "path": "src/plugins/plugin-events.ts",
    "content": "/*\n * Copyright 2020 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { Plugin } from '../types';\nimport type { PrivateEventsAPI, EventsAPI } from './events/events';\nimport { Events } from './events/events';\n\nexport type { EventsAPI };\n\nconst EventsPlugin: Plugin<EventsAPI & PrivateEventsAPI> = {\n  name: 'events',\n\n  noClient: ({ api }) => api._private.isUsed(),\n\n  isInvalid: ({ data }) => data.error || false,\n\n  // Update the events plugin’s internal turn context each time a move\n  // or hook is called. This allows events called after turn or phase\n  // endings to dispatch the current turn and phase correctly.\n  fnWrap:\n    (method, methodType) =>\n    (context, ...args) => {\n      const api = context.events as EventsAPI & PrivateEventsAPI;\n      if (api) api._private.updateTurnContext(context.ctx, methodType);\n      const G = method(context, ...args);\n      if (api) api._private.unsetCurrentMethod();\n      return G;\n    },\n\n  dangerouslyFlushRawState: ({ state, api }) => api._private.update(state),\n\n  api: ({ game, ctx, playerID }) => new Events(game.flow, ctx, playerID).api(),\n};\n\nexport default EventsPlugin;\n"
  },
  {
    "path": "src/plugins/plugin-immer.test.ts",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client } from '../client/client';\nimport type { _ClientImpl } from '../client/client';\nimport { INVALID_MOVE } from '../core/constants';\n\n// Surpress invalid move error logging\njest.mock('../core/logger');\n\ndescribe('immer', () => {\n  let client: _ClientImpl;\n\n  beforeAll(() => {\n    client = Client({\n      game: {\n        moves: {\n          A: ({ G }) => {\n            G.moveBody = true;\n          },\n          invalid: ({ G }) => {\n            G.madeInvalidMove = true;\n            return INVALID_MOVE;\n          },\n        },\n\n        phases: {\n          A: {\n            start: true,\n            onBegin: ({ G }) => {\n              G.onPhaseBegin = true;\n            },\n            onEnd: ({ G }) => {\n              G.onPhaseEnd = true;\n            },\n          },\n        },\n\n        turn: {\n          onBegin: ({ G }) => {\n            G.onTurnBegin = true;\n          },\n          onEnd: ({ G }) => {\n            G.onTurnEnd = true;\n          },\n          onMove: ({ G }) => {\n            G.onMove = true;\n          },\n        },\n      },\n    });\n  });\n\n  test('begin', () => {\n    expect(client.getState().G.onPhaseBegin).toBe(true);\n    expect(client.getState().G.onTurnBegin).toBe(true);\n    expect(client.getState().G.onPhaseEnd).not.toBe(true);\n    expect(client.getState().G.onTurnEnd).not.toBe(true);\n  });\n\n  test('end turn', () => {\n    client.events.endTurn();\n    expect(client.getState().G.onTurnEnd).toBe(true);\n  });\n\n  test('end phase', () => {\n    client.events.endPhase();\n    expect(client.getState().G.onPhaseEnd).toBe(true);\n  });\n\n  test('move', () => {\n    client.moves.A();\n    expect(client.getState().G.moveBody).toBe(true);\n    expect(client.getState().G.onMove).toBe(true);\n  });\n\n  test('invalid move', () => {\n    client.moves.invalid();\n    expect(client.getState().G.madeInvalidMove).toBeUndefined();\n  });\n});\n"
  },
  {
    "path": "src/plugins/plugin-immer.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport produce from 'immer';\nimport type { Plugin } from '../types';\nimport { INVALID_MOVE } from '../core/constants';\n\n/**\n * Plugin that allows using Immer to make immutable changes\n * to G by just mutating it.\n */\nconst ImmerPlugin: Plugin = {\n  name: 'plugin-immer',\n\n  fnWrap:\n    (move) =>\n    (context, ...args) => {\n      let isInvalid = false;\n      const newG = produce(context.G, (G) => {\n        const result = move({ ...context, G }, ...args);\n        if (result === INVALID_MOVE) {\n          isInvalid = true;\n          return;\n        }\n        return result;\n      });\n      if (isInvalid) return INVALID_MOVE;\n      return newG;\n    },\n};\n\nexport default ImmerPlugin;\n"
  },
  {
    "path": "src/plugins/plugin-log.test.ts",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Client } from '../client/client';\nimport type { Game } from '../types';\n\ndescribe('log-metadata', () => {\n  test('It sets metadata in a move and then clears the metadata', () => {\n    const game: Game = {\n      moves: {\n        setMetadataMove: ({ log }) => {\n          log.setMetadata({\n            message: 'test',\n          });\n        },\n        doNothing: ({ G }) => G,\n      },\n    };\n    const client = Client({ game });\n    client.moves.setMetadataMove();\n\n    expect(client.getState().plugins.log.data).toEqual({});\n    expect(client.getState().log[0].metadata).toEqual({\n      message: 'test',\n    });\n\n    client.moves.doNothing();\n\n    expect(client.getState().plugins.log.data).toEqual({});\n    expect(client.getState().log[1].metadata).toEqual(undefined);\n  });\n});\n"
  },
  {
    "path": "src/plugins/plugin-log.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { Plugin } from '../types';\n\ninterface LogData {\n  metadata?: any;\n}\n\nexport interface LogAPI {\n  setMetadata(metadata: any): void;\n}\n\n/**\n * Plugin that makes it possible to add metadata to log entries.\n * During a move, you can set metadata using ctx.log.setMetadata and it will be\n * available on the log entry for that move.\n */\nconst LogPlugin: Plugin<LogAPI, LogData> = {\n  name: 'log',\n\n  flush: () => ({}),\n\n  api: ({ data }) => {\n    return {\n      setMetadata: (metadata) => {\n        data.metadata = metadata;\n      },\n    };\n  },\n\n  setup: () => ({}),\n};\n\nexport default LogPlugin;\n"
  },
  {
    "path": "src/plugins/plugin-player.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport PluginPlayer from './plugin-player';\nimport type { PlayerAPI } from './plugin-player';\nimport { Client } from '../client/client';\nimport type { Game } from '../types';\n\ndescribe('default values', () => {\n  test('playerState is not passed', () => {\n    const plugin = PluginPlayer();\n    const game: Game<any, { player: PlayerAPI }> = {\n      plugins: [plugin],\n    };\n    const client = Client({ game });\n    expect(client.getState().plugins[plugin.name].data).toEqual({\n      players: { '0': {}, '1': {} },\n    });\n  });\n\n  test('playerState is passed', () => {\n    const plugin = PluginPlayer({ setup: () => ({ A: 1 }) });\n    const game: Game<any, { player: PlayerAPI }> = {\n      plugins: [plugin],\n    };\n    const client = Client({ game });\n    expect(client.getState().plugins[plugin.name].data).toEqual({\n      players: { '0': { A: 1 }, '1': { A: 1 } },\n    });\n  });\n});\n\ndescribe('2 player game', () => {\n  let client;\n\n  beforeAll(() => {\n    const game: Game<any, { player: PlayerAPI }> = {\n      moves: {\n        A: ({ player }) => {\n          player.set({ field: 'A1' });\n          player.opponent.set({ field: 'A2' });\n        },\n\n        B: ({ G, player }) => {\n          G.playerValue = player.get().field;\n          G.opponentValue = player.opponent.get().field;\n        },\n      },\n\n      plugins: [PluginPlayer()],\n    };\n\n    client = Client({ game });\n  });\n\n  test('player 0 turn', () => {\n    client.moves.A();\n    expect(client.getState().plugins[PluginPlayer().name].data).toEqual({\n      players: {\n        '0': { field: 'A1' },\n        '1': { field: 'A2' },\n      },\n    });\n  });\n\n  test('player 1 turn', () => {\n    client.events.endTurn();\n    client.moves.A();\n    expect(client.getState().plugins[PluginPlayer().name].data).toEqual({\n      players: {\n        '0': { field: 'A2' },\n        '1': { field: 'A1' },\n      },\n    });\n  });\n\n  test('player 1 makes move B', () => {\n    client.moves.B();\n    expect(client.getState().G).toEqual({\n      playerValue: 'A1',\n      opponentValue: 'A2',\n    });\n  });\n});\n\ndescribe('3 player game', () => {\n  let client;\n\n  beforeAll(() => {\n    const game: Game<any, { player: PlayerAPI }> = {\n      moves: {\n        A: ({ player }) => {\n          player.set({ field: 'A' });\n        },\n      },\n\n      plugins: [PluginPlayer()],\n    };\n\n    client = Client({ game, numPlayers: 3 });\n  });\n\n  test('G.opponent is not created', () => {\n    client.moves.A();\n    expect(client.getState().plugins[PluginPlayer().name].data).toEqual({\n      players: {\n        '0': { field: 'A' },\n        '1': {},\n        '2': {},\n      },\n    });\n  });\n});\n\ndescribe('game with phases', () => {\n  let client;\n\n  beforeAll(() => {\n    const game: Game<any, { player: PlayerAPI }> = {\n      plugins: [PluginPlayer({ setup: (id) => ({ id }) })],\n      phases: {\n        phase: {},\n      },\n    };\n\n    client = Client({ game });\n  });\n\n  test('includes playerSetup state', () => {\n    expect(client.getState().plugins[PluginPlayer().name].data).toEqual({\n      players: {\n        0: {\n          id: '0',\n        },\n        1: {\n          id: '1',\n        },\n      },\n    });\n  });\n});\n\ndescribe('with playerView', () => {\n  const plugin = PluginPlayer({\n    setup: (id) => ({ id }),\n    playerView: (players, playerID) => ({\n      [playerID]: players[playerID],\n    }),\n  });\n  const game = {\n    plugins: [plugin],\n  };\n\n  test('spectator doesn’t see player state', () => {\n    const spectator = Client({ game });\n    expect(spectator.getState().plugins[plugin.name].data).toEqual({\n      players: {},\n    });\n  });\n\n  test('player only sees own state', () => {\n    const client = Client({ game, playerID: '0' });\n    expect(client.getState().plugins[plugin.name].data).toEqual({\n      players: { '0': { id: '0' } },\n    });\n  });\n});\n"
  },
  {
    "path": "src/plugins/plugin-player.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { Plugin, PlayerID } from '../types';\n\ninterface PlayerData<PlayerState extends any = any> {\n  players: Record<PlayerID, PlayerState>;\n}\n\nexport interface PlayerAPI<PlayerState extends any = any> {\n  state: Record<PlayerID, PlayerState>;\n  get(): PlayerState;\n  set(value: PlayerState): PlayerState;\n  opponent?: {\n    get(): PlayerState;\n    set(value: PlayerState): PlayerState;\n  };\n}\n\ninterface PluginPlayerOpts<PlayerState extends any = any> {\n  setup?: (playerID: string) => PlayerState;\n  playerView?: (\n    players: Record<PlayerID, PlayerState>,\n    playerID?: string | null\n  ) => any;\n}\n\nexport interface PlayerPlugin<PlayerState extends any = any> {\n  player: PlayerAPI<PlayerState>;\n}\n\n/**\n * Plugin that maintains state for each player in G.players.\n * During a turn, G.player will contain the object for the current player.\n * In two player games, G.opponent will contain the object for the other player.\n *\n * @param {function} initPlayerState - Function of type (playerID) => playerState.\n */\nconst PlayerPlugin = <PlayerState extends any = any>({\n  setup,\n  playerView,\n}: PluginPlayerOpts<PlayerState> = {}): Plugin<\n  PlayerAPI<PlayerState>,\n  PlayerData<PlayerState>\n> => ({\n  name: 'player',\n\n  flush: ({ api }) => {\n    return { players: api.state };\n  },\n\n  api: ({ ctx, data }): PlayerAPI => {\n    const state = data.players;\n\n    const get = () => {\n      return data.players[ctx.currentPlayer];\n    };\n\n    const set = (value) => {\n      return (state[ctx.currentPlayer] = value);\n    };\n\n    const result: PlayerAPI = { state, get, set };\n\n    if (ctx.numPlayers === 2) {\n      const other = ctx.currentPlayer === '0' ? '1' : '0';\n      const get = () => {\n        return data.players[other];\n      };\n      const set = (value) => {\n        return (state[other] = value);\n      };\n      result.opponent = { get, set };\n    }\n\n    return result;\n  },\n\n  setup: ({ ctx }) => {\n    const players: Record<PlayerID, any> = {};\n    for (let i = 0; i < ctx.numPlayers; i++) {\n      let playerState: any = {};\n      if (setup !== undefined) {\n        playerState = setup(i + '');\n      }\n      players[i + ''] = playerState;\n    }\n    return { players };\n  },\n\n  playerView: ({ data, playerID }) =>\n    playerView ? { players: playerView(data.players, playerID) } : data,\n});\n\nexport default PlayerPlugin;\n"
  },
  {
    "path": "src/plugins/plugin-random.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { Plugin } from '../types';\nimport type { RandomAPI, PrivateRandomAPI, RandomState } from './random/random';\nimport { Random } from './random/random';\n\nconst RandomPlugin: Plugin<RandomAPI & PrivateRandomAPI, RandomState> = {\n  name: 'random',\n\n  noClient: ({ api }) => {\n    return api._private.isUsed();\n  },\n\n  flush: ({ api }) => {\n    return api._private.getState();\n  },\n\n  api: ({ data }) => {\n    const random = new Random(data);\n    return random.api();\n  },\n\n  setup: ({ game }) => {\n    let { seed } = game;\n    if (seed === undefined) {\n      seed = Random.seed();\n    }\n    return { seed };\n  },\n\n  playerView: () => undefined,\n};\n\nexport default RandomPlugin;\n"
  },
  {
    "path": "src/plugins/plugin-serializable.test.ts",
    "content": "import { Client } from '../client/client';\nimport type { Game } from '../types';\n\ndescribe('plugin-serializable', () => {\n  let client: ReturnType<typeof Client>;\n\n  beforeAll(() => {\n    const game: Game = {\n      moves: {\n        serializable: () => {\n          return { hello: 'world' };\n        },\n\n        nonSerializable: () => {\n          class Foo {\n            a: number;\n            constructor(a: number) {\n              this.a = a;\n            }\n          }\n          return { hello: new Foo(1) };\n        },\n      },\n    };\n\n    client = Client({ game });\n  });\n\n  test('does not throw for serializable move', () => {\n    expect(() => {\n      client.moves.serializable();\n    }).not.toThrow();\n  });\n\n  test('throws for non-serializable move', () => {\n    expect(() => {\n      client.moves.nonSerializable();\n    }).toThrow();\n  });\n});\n"
  },
  {
    "path": "src/plugins/plugin-serializable.ts",
    "content": "import type { Plugin } from '../types';\nimport isPlainObject from 'lodash.isplainobject';\n\n/**\n * Check if a value can be serialized (e.g. using `JSON.stringify`).\n * Adapted from: https://stackoverflow.com/a/30712764/3829557\n */\nfunction isSerializable(value: any) {\n  // Primitives are OK.\n  if (\n    value === undefined ||\n    value === null ||\n    typeof value === 'boolean' ||\n    typeof value === 'number' ||\n    typeof value === 'string'\n  ) {\n    return true;\n  }\n\n  // A non-primitive value that is neither a POJO or an array cannot be serialized.\n  if (!isPlainObject(value) && !Array.isArray(value)) {\n    return false;\n  }\n\n  // Recurse entries if the value is an object or array.\n  for (const key in value) {\n    if (!isSerializable(value[key])) return false;\n  }\n\n  return true;\n}\n\n/**\n * Plugin that checks whether state is serializable, in order to avoid\n * network serialization bugs.\n */\nconst SerializablePlugin: Plugin = {\n  name: 'plugin-serializable',\n\n  fnWrap:\n    (move) =>\n    (context, ...args) => {\n      const result = move(context, ...args);\n      // Check state in non-production environments.\n      if (process.env.NODE_ENV !== 'production' && !isSerializable(result)) {\n        throw new Error(\n          'Move state is not JSON-serialiazable.\\n' +\n            'See https://boardgame.io/documentation/#/?id=state for more information.'\n        );\n      }\n      return result;\n    },\n};\n\nexport default SerializablePlugin;\n"
  },
  {
    "path": "src/plugins/random/random.alea.ts",
    "content": "// Inlined version of Alea from https://github.com/davidbau/seedrandom.\n// Converted to Typescript October 2020.\n\n/*\n * Copyright 2015 David Bau.\n *\n * Permission is hereby granted, free of charge,\n * to any person obtaining a copy of this software\n * and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge,\n * publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall\n * be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n\nexport interface AleaState {\n  c: number;\n  s0: number;\n  s1: number;\n  s2: number;\n}\n\nclass Alea {\n  c: number;\n  s0: number;\n  s1: number;\n  s2: number;\n\n  constructor(seed: string | number) {\n    const mash = Mash();\n\n    // Apply the seeding algorithm from Baagoe.\n    this.c = 1;\n    this.s0 = mash(' ');\n    this.s1 = mash(' ');\n    this.s2 = mash(' ');\n    this.s0 -= mash(seed);\n    if (this.s0 < 0) {\n      this.s0 += 1;\n    }\n    this.s1 -= mash(seed);\n    if (this.s1 < 0) {\n      this.s1 += 1;\n    }\n    this.s2 -= mash(seed);\n    if (this.s2 < 0) {\n      this.s2 += 1;\n    }\n  }\n\n  next() {\n    const t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32\n    this.s0 = this.s1;\n    this.s1 = this.s2;\n    return (this.s2 = t - (this.c = Math.trunc(t)));\n  }\n}\n\nfunction Mash() {\n  let n = 0xefc8249d;\n\n  const mash = function (data: string | number) {\n    const str = data.toString();\n    for (let i = 0; i < str.length; i++) {\n      n += str.charCodeAt(i);\n      let h = 0.02519603282416938 * n;\n      n = h >>> 0;\n      h -= n;\n      h *= n;\n      n = h >>> 0;\n      h -= n;\n      n += h * 0x100000000; // 2^32\n    }\n    return (n >>> 0) * 2.3283064365386963e-10; // 2^-32\n  };\n\n  return mash;\n}\n\nfunction copy(f: AleaState, t: Partial<AleaState>) {\n  t.c = f.c;\n  t.s0 = f.s0;\n  t.s1 = f.s1;\n  t.s2 = f.s2;\n  return t as AleaState;\n}\n\ntype PRNG = Alea['next'] & { state?: () => AleaState };\n\nexport function alea(seed: string | number, state?: AleaState): PRNG {\n  const xg = new Alea(seed);\n  const prng = xg.next.bind(xg) as PRNG;\n  if (state) copy(state, xg);\n  prng.state = () => copy(xg, {});\n  return prng;\n}\n"
  },
  {
    "path": "src/plugins/random/random.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { Random } from './random';\nimport { makeMove } from '../../core/action-creators';\nimport { CreateGameReducer } from '../../core/reducer';\nimport { InitializeGame } from '../../core/initialize';\nimport { Client } from '../../client/client';\nimport type { Game } from '../../types';\nimport { PlayerView } from '../main';\n\nfunction Init(seed) {\n  return new Random({ seed });\n}\n\ntest('random', () => {\n  const r = Init('hi there');\n  // make sure that subsequent calls are different.\n  expect(r._random()).toBe(0.573445922927931);\n  expect(r._random()).toBe(0.4695413049776107);\n  expect(r._random()).toBe(0.5943194630090147);\n});\n\ntest('predefined dice values', () => {\n  const r = Init(0);\n\n  const rfns = [4, 6, 8, 10, 12, 20].map((v) => {\n    return { fn: r.api()[`D${v}`], highest: v };\n  });\n\n  rfns.forEach((pair) => {\n    const result = pair.fn();\n    expect(result).toBeDefined();\n    expect(result).toBeGreaterThanOrEqual(1);\n    expect(result).toBeLessThanOrEqual(pair.highest);\n    expect(r.state.prngstate).toBeDefined();\n\n    const multiple = pair.fn(5);\n    expect(multiple).toBeDefined();\n    expect(multiple).toHaveLength(5);\n    multiple.forEach((m) => {\n      expect(m).toBeGreaterThanOrEqual(1);\n      expect(m).toBeLessThanOrEqual(pair.highest);\n    });\n  });\n});\n\ntest('Random.Die', () => {\n  const r = Init(0);\n  const api = r.api();\n\n  {\n    const result = api.Die(123);\n    expect(result).toBeDefined();\n    expect(result).toBe(74);\n    expect(r.state.prngstate).toBeDefined();\n  }\n\n  {\n    const result = api.Die();\n    expect(result).toBeDefined();\n    expect(result).toBeLessThanOrEqual(6);\n    expect(r.state.prngstate).toBeDefined();\n  }\n\n  {\n    const multiple = api.Die(6, 3);\n    expect(multiple).toBeDefined();\n    expect(multiple).toHaveLength(3);\n    multiple.forEach((m) => {\n      expect(m).toBeGreaterThanOrEqual(1);\n      expect(m).toBeLessThanOrEqual(6);\n    });\n    expect(r.state.prngstate).toBeDefined();\n  }\n});\n\ntest('Random.Number', () => {\n  const r = Init(0);\n  const result = r.api().Number();\n  expect(result).toBeDefined();\n  expect(result).toBeGreaterThanOrEqual(0);\n  expect(result).toBeLessThanOrEqual(1);\n  expect(r.state.prngstate).toBeDefined();\n});\n\ntest('Random.Shuffle', () => {\n  const r = Init(0);\n  const initialTiles = ['A', 'B', 'C', 'D', 'E'];\n  const tiles = [...initialTiles];\n  const result = r.api().Shuffle(tiles);\n  expect(result).toHaveLength(initialTiles.length);\n  expect(result).toEqual(expect.arrayContaining(initialTiles));\n  expect(result.sort()).toEqual(initialTiles);\n  expect(r.state.prngstate).toBeDefined();\n});\n\ntest('Random API is not executed optimisitically', () => {\n  const game: Game = {\n    seed: 0,\n    moves: {\n      rollDie: ({ G, random }) => ({ ...G, die: random.D6() }),\n    },\n  };\n\n  {\n    const reducer = CreateGameReducer({ game });\n    let state = InitializeGame({ game });\n    expect(state.G.die).not.toBeDefined();\n    state = reducer(state, makeMove('rollDie'));\n    expect(state.G).toMatchObject({ die: 4 });\n  }\n\n  {\n    const reducer = CreateGameReducer({ game, isClient: true });\n    let state = InitializeGame({ game });\n    expect(state.G.die).not.toBeDefined();\n    state = reducer(state, makeMove('rollDie'));\n    expect(state.G.die).not.toBeDefined();\n  }\n});\n\ntest('Random API works when its state is redacted by playerView', () => {\n  const game = {\n    seed: 0,\n    moves: {\n      rollDie: ({ G, random }) => ({ ...G, die: random.D6() }),\n    },\n  };\n\n  const opts = { game, isClient: true };\n  const reducer = CreateGameReducer(opts);\n  let state = InitializeGame({ game });\n  state.plugins = PlayerView(state, { ...opts, playerID: '0' });\n  expect(state.plugins.random.data).not.toBeDefined();\n  expect(state.G.die).not.toBeDefined();\n  state = reducer(state, makeMove('rollDie'));\n  expect(state.G.die).not.toBeDefined();\n});\n\ntest('turn.onBegin has ctx APIs at the beginning of the game', () => {\n  let random = null;\n  let events = null;\n\n  const game: Game = {\n    turn: {\n      onBegin: (context) => {\n        random = context.random;\n        events = context.events;\n      },\n    },\n  };\n\n  InitializeGame({ game });\n  expect(random).not.toBe(null);\n  expect(events).not.toBe(null);\n});\n\ntest('PRNG state is not sent to the client', () => {\n  const client = Client({ game: {} });\n  expect(client.getState().plugins.random.data).toBeUndefined();\n});\n"
  },
  {
    "path": "src/plugins/random/random.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { AleaState } from './random.alea';\nimport { alea } from './random.alea';\n\nexport interface RandomState {\n  seed: string | number;\n  prngstate?: AleaState;\n}\n\nexport interface RandomAPI {\n  D4(): number;\n  D4(diceCount: number): number[];\n  D6(): number;\n  D6(diceCount: number): number[];\n  D10(): number;\n  D10(diceCount: number): number[];\n  D12(): number;\n  D12(diceCount: number): number[];\n  D20(): number;\n  D20(diceCount: number): number[];\n  Die(spotvalue?: number): number;\n  Die(spotvalue: number, diceCount: number): number[];\n  Number(): number;\n  Shuffle<T>(deck: T[]): T[];\n}\n\nexport interface PrivateRandomAPI {\n  _private: {\n    isUsed(): boolean;\n    getState(): RandomState;\n  };\n}\n\n/**\n * Random\n *\n * Calls that require a pseudorandom number generator.\n * Uses a seed from ctx, and also persists the PRNG\n * state in ctx so that moves can stay pure.\n */\nexport class Random {\n  state: RandomState;\n  used: boolean;\n\n  /**\n   * Generates a new seed from the current date / time.\n   */\n  static seed() {\n    return Date.now().toString(36).slice(-10);\n  }\n\n  /**\n   * constructor\n   * @param {object} ctx - The ctx object to initialize from.\n   */\n  constructor(state?: RandomState) {\n    // If we are on the client, the seed is not present.\n    // Just use a temporary seed to execute the move without\n    // crashing it. The move state itself is discarded,\n    // so the actual value doesn't matter.\n    this.state = state || { seed: '0' };\n    this.used = false;\n  }\n\n  isUsed() {\n    return this.used;\n  }\n\n  getState() {\n    return this.state;\n  }\n\n  /**\n   * Generate a random number.\n   */\n  _random() {\n    this.used = true;\n\n    const R = this.state;\n\n    const seed = R.prngstate ? '' : R.seed;\n    const rand = alea(seed, R.prngstate);\n\n    const number = rand();\n\n    this.state = {\n      ...R,\n      prngstate: rand.state(),\n    };\n\n    return number;\n  }\n\n  api(): RandomAPI & PrivateRandomAPI {\n    const random: Random['_random'] = this._random.bind(this);\n\n    const SpotValue = {\n      D4: 4,\n      D6: 6,\n      D8: 8,\n      D10: 10,\n      D12: 12,\n      D20: 20,\n    };\n\n    type DieFn = {\n      (): number;\n      (diceCount: number): number[];\n    };\n\n    // Generate functions for predefined dice values D4 - D20.\n    const predefined = {} as Record<keyof typeof SpotValue, DieFn>;\n    for (const key in SpotValue) {\n      const spotvalue = SpotValue[key];\n      predefined[key] = (diceCount?: number) => {\n        return diceCount === undefined\n          ? Math.floor(random() * spotvalue) + 1\n          : Array.from({ length: diceCount }).map(\n              () => Math.floor(random() * spotvalue) + 1\n            );\n      };\n    }\n\n    function Die(spotValue?: number): number;\n    function Die(spotValue: number, diceCount: number): number[];\n    function Die(spotvalue = 6, diceCount?: number) {\n      return diceCount === undefined\n        ? Math.floor(random() * spotvalue) + 1\n        : Array.from({ length: diceCount }).map(\n            () => Math.floor(random() * spotvalue) + 1\n          );\n    }\n\n    return {\n      /**\n       * Similar to Die below, but with fixed spot values.\n       * Supports passing a diceCount\n       *    if not defined, defaults to 1 and returns the value directly.\n       *    if defined, returns an array containing the random dice values.\n       *\n       * D4: (diceCount) => value\n       * D6: (diceCount) => value\n       * D8: (diceCount) => value\n       * D10: (diceCount) => value\n       * D12: (diceCount) => value\n       * D20: (diceCount) => value\n       */\n      ...predefined,\n\n      /**\n       * Roll a die of specified spot value.\n       *\n       * @param {number} spotvalue - The die dimension (default: 6).\n       * @param {number} diceCount - number of dice to throw.\n       *                             if not defined, defaults to 1 and returns the value directly.\n       *                             if defined, returns an array containing the random dice values.\n       */\n      Die,\n\n      /**\n       * Generate a random number between 0 and 1.\n       */\n      Number: () => {\n        return random();\n      },\n\n      /**\n       * Shuffle an array.\n       *\n       * @param {Array} deck - The array to shuffle. Does not mutate\n       *                       the input, but returns the shuffled array.\n       */\n      Shuffle: <T extends any>(deck: T[]) => {\n        const clone = [...deck];\n        let sourceIndex = deck.length;\n        let destinationIndex = 0;\n        const shuffled = Array.from<T>({ length: sourceIndex });\n\n        while (sourceIndex) {\n          const randomIndex = Math.trunc(sourceIndex * random());\n          shuffled[destinationIndex++] = clone[randomIndex];\n          clone[randomIndex] = clone[--sourceIndex];\n        }\n\n        return shuffled;\n      },\n\n      _private: this,\n    };\n  }\n}\n"
  },
  {
    "path": "src/server/api.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport request from 'supertest';\nimport Koa from 'koa';\nimport Router from '@koa/router';\nimport * as dateMock from 'jest-date-mock';\n\nimport { configureRouter, configureApp } from './api';\nimport { ProcessGameConfig } from '../core/game';\nimport { Auth } from './auth';\nimport * as StorageAPI from './db/base';\nimport { Origins } from './cors';\nimport type { Game, Server } from '../types';\n\njest.setTimeout(2000000000);\n\nbeforeEach(() => {\n  dateMock.clear();\n});\n\ntype StorageMocks = Record<\n  'createMatch' | 'setState' | 'fetch' | 'setMetadata' | 'listMatches' | 'wipe',\n  jest.Mock | ((...args: any[]) => any)\n>;\n\nclass AsyncStorage extends StorageAPI.Async {\n  public mocks: StorageMocks;\n\n  constructor(args: Partial<StorageMocks> = {}) {\n    super();\n    this.mocks = {\n      createMatch: args.createMatch || jest.fn(),\n      setState: args.setState || jest.fn(),\n      fetch: args.fetch || jest.fn(() => ({})),\n      setMetadata: args.setMetadata || jest.fn(),\n      listMatches: args.listMatches || jest.fn(() => []),\n      wipe: args.wipe || jest.fn(),\n    };\n  }\n\n  async connect() {}\n\n  async createMatch(...args) {\n    this.mocks.createMatch(...args);\n  }\n\n  async fetch(...args) {\n    return this.mocks.fetch(...args);\n  }\n\n  async setState(...args) {\n    this.mocks.setState(...args);\n  }\n\n  async setMetadata(...args) {\n    this.mocks.setMetadata(...args);\n  }\n\n  async wipe(...args) {\n    this.mocks.wipe(...args);\n  }\n\n  async listMatches(...args) {\n    return this.mocks.listMatches(...args);\n  }\n}\n\ndescribe('.configureRouter', () => {\n  function addApiToServer({\n    app,\n    origins,\n    ...args\n  }: {\n    app: Server.App;\n    origins?: Parameters<typeof configureApp>[2];\n  } & Omit<Parameters<typeof configureRouter>[0], 'router'>) {\n    const router = new Router<any, Server.AppCtx>();\n    configureRouter({ router, ...args });\n    configureApp(app, router, origins);\n  }\n\n  function createApiServer(\n    args: Omit<Parameters<typeof addApiToServer>[0], 'app'>\n  ) {\n    const app: Server.App = new Koa();\n    addApiToServer({ app, ...args });\n    return app;\n  }\n\n  describe('creating a game', () => {\n    let response;\n    let app: Koa;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n    const updatedAt = new Date(2020, 3, 4, 5, 6, 7);\n\n    beforeEach(async () => {\n      db = new AsyncStorage();\n      games = [\n        {\n          name: 'foo',\n          setup: (_, setupData) =>\n            setupData\n              ? {\n                  colors: setupData.colors,\n                }\n              : {},\n        },\n        {\n          name: 'validate',\n          setup: (_, setupData) =>\n            setupData\n              ? {\n                  numTokens: setupData.tokens,\n                }\n              : {},\n          validateSetupData: (setupData, numPlayers) =>\n            numPlayers == 2 && setupData.tokens !== 2\n              ? 'Two player games must use two tokens'\n              : undefined,\n          minPlayers: 2,\n          maxPlayers: 2,\n        },\n      ];\n    });\n\n    describe('for an unprotected lobby server', () => {\n      beforeEach(async () => {\n        dateMock.advanceTo(updatedAt);\n\n        delete process.env.API_SECRET;\n\n        const uuid = () => 'matchID';\n        app = createApiServer({ db, auth, games, uuid });\n\n        response = await request(app.callback())\n          .post('/games/foo/create')\n          .send({ numPlayers: 3 });\n      });\n\n      test('is successful', () => {\n        expect(response.status).toEqual(200);\n      });\n\n      test('creates game state and metadata', () => {\n        expect(db.mocks.createMatch).toHaveBeenCalledWith(\n          'matchID',\n          expect.objectContaining({\n            initialState: expect.objectContaining({\n              ctx: expect.objectContaining({\n                numPlayers: 3,\n              }),\n            }),\n            metadata: expect.objectContaining({\n              gameName: 'foo',\n              players: expect.objectContaining({\n                '0': expect.objectContaining({}),\n                '1': expect.objectContaining({}),\n              }),\n              unlisted: false,\n              createdAt: updatedAt.getTime(),\n              updatedAt: updatedAt.getTime(),\n            }),\n          })\n        );\n      });\n\n      test('returns match id', () => {\n        expect(response.body.matchID).not.toBeNull();\n      });\n\n      describe('without numPlayers', () => {\n        beforeEach(async () => {\n          response = await request(app.callback()).post('/games/foo/create');\n        });\n\n        test('uses default numPlayers', () => {\n          expect(db.mocks.createMatch).toHaveBeenCalledWith(\n            'matchID',\n            expect.objectContaining({\n              initialState: expect.objectContaining({\n                ctx: expect.objectContaining({\n                  numPlayers: 2,\n                }),\n              }),\n            })\n          );\n        });\n      });\n\n      describe('with invalid numPlayers', () => {\n        test('not enough players fails', async () => {\n          response = await request(app.callback())\n            .post('/games/validate/create')\n            .send({ numPlayers: 1 });\n\n          expect(response.status).toEqual(400);\n        });\n\n        test('too many players fails', async () => {\n          response = await request(app.callback())\n            .post('/games/validate/create')\n            .send({ numPlayers: 3 });\n\n          expect(response.status).toEqual(400);\n        });\n\n        test('invalid type fails', async () => {\n          response = await request(app.callback())\n            .post('/games/validate/create')\n            .send({ numPlayers: 'hello' });\n\n          expect(response.status).toEqual(400);\n        });\n      });\n\n      describe('for an unknown game name', () => {\n        beforeEach(async () => {\n          response = await request(app.callback()).post('/games/bar/create');\n        });\n\n        test('returns 404 error', () => {\n          expect(response.status).toEqual(404);\n        });\n      });\n\n      describe('with setupData', () => {\n        beforeEach(async () => {\n          response = await request(app.callback())\n            .post('/games/foo/create')\n            .send({\n              setupData: {\n                colors: {\n                  '0': 'green',\n                  '1': 'red',\n                },\n              },\n            });\n        });\n\n        test('includes setupData in metadata', () => {\n          expect(db.mocks.createMatch).toHaveBeenCalledWith(\n            'matchID',\n            expect.objectContaining({\n              metadata: expect.objectContaining({\n                setupData: expect.objectContaining({\n                  colors: expect.objectContaining({\n                    '0': 'green',\n                    '1': 'red',\n                  }),\n                }),\n              }),\n            })\n          );\n        });\n\n        test('passes setupData to game setup function', () => {\n          expect(db.mocks.createMatch).toHaveBeenCalledWith(\n            'matchID',\n            expect.objectContaining({\n              initialState: expect.objectContaining({\n                G: expect.objectContaining({\n                  colors: {\n                    '0': 'green',\n                    '1': 'red',\n                  },\n                }),\n              }),\n            })\n          );\n        });\n      });\n\n      describe('with setupData validation', () => {\n        test('creates game if validation passes', async () => {\n          response = await request(app.callback())\n            .post('/games/validate/create')\n            .send({\n              numPlayers: 2,\n              setupData: {\n                tokens: 2,\n              },\n            });\n\n          expect(response.status).toEqual(200);\n        });\n\n        test('returns error if validation fails', async () => {\n          response = await request(app.callback())\n            .post('/games/validate/create')\n            .send({\n              numPlayers: 2,\n              setupData: {\n                tokens: 3,\n              },\n            });\n\n          expect(response.status).toEqual(400);\n        });\n      });\n\n      describe('with unlisted option', () => {\n        beforeEach(async () => {\n          response = await request(app.callback())\n            .post('/games/foo/create')\n            .send({ unlisted: true });\n        });\n\n        test('sets unlisted in metadata', () => {\n          expect(db.mocks.createMatch).toHaveBeenCalledWith(\n            'matchID',\n            expect.objectContaining({\n              metadata: expect.objectContaining({\n                unlisted: true,\n              }),\n            })\n          );\n        });\n      });\n    });\n\n    describe('for a protected lobby', () => {\n      beforeEach(() => {\n        process.env.API_SECRET = 'protected';\n        app = createApiServer({ db, auth, games });\n      });\n\n      describe('without the lobby token', () => {\n        beforeEach(async () => {\n          response = await request(app.callback()).post('/games/foo/create');\n        });\n\n        test('fails', () => {\n          expect(response.status).toEqual(403);\n        });\n      });\n\n      describe('with the lobby token', () => {\n        beforeEach(async () => {\n          response = await request(app.callback())\n            .post('/games/foo/create')\n            .set('API-Secret', 'protected');\n        });\n\n        test('succeeds', () => {\n          expect(response.status).toEqual(200);\n        });\n      });\n    });\n  });\n\n  describe('joining a room', () => {\n    let response;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n    let credentials: string;\n\n    beforeEach(() => {\n      credentials = 'SECRET';\n      games = [ProcessGameConfig({ name: 'foo' })];\n    });\n\n    describe('for an unprotected lobby', () => {\n      beforeEach(() => {\n        delete process.env.API_SECRET;\n      });\n\n      describe('when the game does not exist', () => {\n        beforeEach(async () => {\n          db = new AsyncStorage({\n            fetch: () => ({ metadata: null }),\n          });\n          const app = createApiServer({ db, auth, games });\n\n          response = await request(app.callback())\n            .post('/games/foo/1/join')\n            .send('playerID=0&playerName=alice');\n        });\n\n        test('throws a \"not found\" error', async () => {\n          expect(response.status).toEqual(404);\n        });\n      });\n\n      describe('when the game does exist', () => {\n        beforeEach(async () => {\n          db = new AsyncStorage({\n            fetch: async () => {\n              return {\n                metadata: {\n                  players: {\n                    '0': {},\n                  },\n                },\n              };\n            },\n          });\n        });\n\n        describe('when the playerID is available', () => {\n          beforeEach(async () => {\n            const app = createApiServer({\n              db,\n              auth: new Auth({ generateCredentials: () => credentials }),\n              games,\n              uuid: () => 'matchID',\n            });\n            response = await request(app.callback())\n              .post('/games/foo/1/join')\n              .send({ playerID: 0, playerName: 'alice' });\n          });\n\n          test('is successful', async () => {\n            expect(response.status).toEqual(200);\n          });\n\n          test('returns the player credentials', async () => {\n            expect(response.body.playerCredentials).toEqual(credentials);\n          });\n\n          test('updates the player name', async () => {\n            expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n              '1',\n              expect.objectContaining({\n                players: expect.objectContaining({\n                  '0': expect.objectContaining({\n                    name: 'alice',\n                  }),\n                }),\n              })\n            );\n          });\n\n          describe('when custom data is provided', () => {\n            beforeEach(async () => {\n              const app = createApiServer({ db, auth, games });\n              response = await request(app.callback())\n                .post('/games/foo/1/join')\n                .send({ playerID: 0, playerName: 'alice', data: 99 });\n            });\n\n            test('updates the player data', async () => {\n              expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n                '1',\n                expect.objectContaining({\n                  players: expect.objectContaining({\n                    '0': expect.objectContaining({\n                      data: 99,\n                    }),\n                  }),\n                })\n              );\n            });\n          });\n        });\n\n        describe('when the playerID does not exist', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/join')\n              .send('playerID=1&playerName=alice');\n          });\n\n          test('throws error 404', async () => {\n            expect(response.status).toEqual(404);\n          });\n        });\n\n        describe('when playerID is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({\n              db,\n              auth: new Auth({ generateCredentials: () => credentials }),\n              games,\n              uuid: () => 'matchID',\n            });\n            response = await request(app.callback())\n              .post('/games/foo/1/join')\n              .send('playerName=alice');\n          });\n\n          describe('numPlayers is reached in match', () => {\n            beforeEach(async () => {\n              db = new AsyncStorage({\n                fetch: async () => {\n                  return {\n                    metadata: {\n                      players: {\n                        '0': { name: 'alice' },\n                      },\n                    },\n                  };\n                },\n              });\n              const app = createApiServer({ db, auth, games });\n              response = await request(app.callback())\n                .post('/games/foo/1/join')\n                .send('playerName=bob');\n            });\n\n            test('throws error 409', async () => {\n              expect(response.status).toEqual(409);\n            });\n          });\n\n          test('is successful', async () => {\n            expect(response.status).toEqual(200);\n          });\n\n          test('returns the player credentials', async () => {\n            expect(response.body.playerCredentials).toEqual(credentials);\n          });\n\n          test('returns the playerID', async () => {\n            expect(response.body.playerID).toEqual('0');\n          });\n\n          test('updates the player name', async () => {\n            expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n              '1',\n              expect.objectContaining({\n                players: expect.objectContaining({\n                  '0': expect.objectContaining({\n                    name: 'alice',\n                  }),\n                }),\n              })\n            );\n          });\n        });\n\n        describe('when playerName is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/join')\n              .send('playerID=1');\n          });\n\n          test('throws error 403', async () => {\n            expect(response.status).toEqual(403);\n          });\n        });\n\n        describe('when the playerID is not available', () => {\n          beforeEach(async () => {\n            db = new AsyncStorage({\n              fetch: async () => {\n                return {\n                  metadata: {\n                    players: {\n                      '0': {\n                        credentials,\n                        name: 'bob',\n                      },\n                    },\n                  },\n                };\n              },\n            });\n\n            const app = createApiServer({ db, auth, games });\n\n            response = await request(app.callback())\n              .post('/games/foo/1/join')\n              .send('playerID=0&playerName=alice');\n          });\n          test('throws error 409', async () => {\n            expect(response.status).toEqual(409);\n          });\n        });\n      });\n    });\n  });\n\n  describe('rename with deprecated endpoint', () => {\n    let response;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n    const warnMsg =\n      'This endpoint /rename is deprecated. Please use /update instead.';\n\n    beforeEach(() => {\n      games = [ProcessGameConfig({ name: 'foo' })];\n      console.warn = jest.fn();\n    });\n\n    describe('for an unprotected lobby', () => {\n      beforeEach(() => {\n        delete process.env.API_SECRET;\n      });\n\n      describe('when the game does not exist', () => {\n        test('throws a \"not found\" error', async () => {\n          db = new AsyncStorage({\n            fetch: async () => ({ metadata: null }),\n          });\n          const app = createApiServer({ db, auth, games });\n          response = await request(app.callback())\n            .post('/games/foo/1/rename')\n            .send('playerID=0&playerName=alice&newName=ali');\n          expect(response.status).toEqual(404);\n          expect(console.warn).toBeCalledWith(warnMsg);\n        });\n      });\n\n      describe('when the game does exist', () => {\n        describe('when the playerID does exist', () => {\n          beforeEach(async () => {\n            db = new AsyncStorage({\n              fetch: async () => {\n                return {\n                  metadata: {\n                    players: {\n                      '0': {\n                        name: 'alice',\n                        credentials: 'SECRET1',\n                      },\n                      '1': {\n                        name: 'bob',\n                        credentials: 'SECRET2',\n                      },\n                    },\n                  },\n                };\n              },\n            });\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/rename')\n              .send('playerID=0&credentials=SECRET1&newName=ali');\n          });\n\n          describe('when the playerName is not a string', () => {\n            test('throws newName must be a string', async () => {\n              const app = createApiServer({ db, auth, games });\n              response = await request(app.callback())\n                .post('/games/foo/1/rename')\n                .send({ playerID: 0, credentials: 'SECRET1', newName: 2 });\n              expect(response.text).toEqual(\n                'newName must be a string, got number'\n              );\n              expect(console.warn).toBeCalledWith(warnMsg);\n            });\n          });\n\n          test('is successful', async () => {\n            expect(response.status).toEqual(200);\n            expect(console.warn).toBeCalledWith(warnMsg);\n          });\n\n          test('updates the players', async () => {\n            expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n              '1',\n              expect.objectContaining({\n                players: expect.objectContaining({\n                  '0': expect.objectContaining({\n                    name: 'ali',\n                  }),\n                }),\n              })\n            );\n            expect(console.warn).toBeCalledWith(warnMsg);\n          });\n        });\n\n        describe('when the playerID does not exist', () => {\n          test('throws error 404', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/rename')\n              .send('playerID=2&credentials=SECRET1&newName=joe');\n            expect(response.status).toEqual(404);\n            expect(console.warn).toBeCalledWith(warnMsg);\n          });\n        });\n\n        describe('when the credentials are invalid', () => {\n          test('throws error 404', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/rename')\n              .send('playerID=0&credentials=SECRET2&newName=mike');\n            expect(response.status).toEqual(403);\n            expect(console.warn).toBeCalledWith(warnMsg);\n          });\n        });\n\n        describe('when playerID is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/rename')\n              .send('credentials=foo&newName=bill');\n          });\n\n          test('throws error 403', async () => {\n            expect(response.status).toEqual(403);\n            expect(console.warn).toBeCalledWith(warnMsg);\n          });\n        });\n\n        describe('when newName is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/rename')\n              .send('credentials=foo&playerID=0');\n          });\n\n          test('throws error 403', async () => {\n            expect(response.status).toEqual(403);\n            expect(console.warn).toBeCalledWith(warnMsg);\n          });\n        });\n      });\n    });\n  });\n\n  describe('rename with update endpoint', () => {\n    let response;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n\n    beforeEach(() => {\n      games = [ProcessGameConfig({ name: 'foo' })];\n    });\n\n    describe('for an unprotected lobby', () => {\n      beforeEach(() => {\n        delete process.env.API_SECRET;\n      });\n\n      describe('when the game does not exist', () => {\n        test('throws game not found', async () => {\n          db = new AsyncStorage({\n            fetch: async () => ({ metadata: null }),\n          });\n          const app = createApiServer({ db, auth, games });\n          response = await request(app.callback())\n            .post('/games/foo/1/update')\n            .send('playerID=0&playerName=alice&newName=ali');\n          expect(response.text).toEqual('Match 1 not found');\n        });\n      });\n\n      describe('when the game does exist', () => {\n        describe('when the playerID does exist', () => {\n          beforeEach(async () => {\n            db = new AsyncStorage({\n              fetch: async () => {\n                return {\n                  metadata: {\n                    players: {\n                      '0': {\n                        name: 'alice',\n                        credentials: 'SECRET1',\n                      },\n                      '1': {\n                        name: 'bob',\n                        credentials: 'SECRET2',\n                      },\n                    },\n                  },\n                };\n              },\n            });\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send('playerID=0&credentials=SECRET1&newName=ali');\n          });\n\n          describe('when the playerName is not a string', () => {\n            test('throws newName must be a string', async () => {\n              const app = createApiServer({ db, auth, games });\n              response = await request(app.callback())\n                .post('/games/foo/1/update')\n                .send({ playerID: 0, credentials: 'SECRET1', newName: 2 });\n              expect(response.text).toEqual(\n                'newName must be a string, got number'\n              );\n            });\n          });\n\n          test('is successful', async () => {\n            expect(response.status).toEqual(200);\n          });\n\n          test('updates the players', async () => {\n            expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n              '1',\n              expect.objectContaining({\n                players: expect.objectContaining({\n                  '0': expect.objectContaining({\n                    name: 'ali',\n                  }),\n                }),\n              })\n            );\n          });\n        });\n\n        describe('when the playerID does not exist', () => {\n          test('throws player not found', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send('playerID=2&credentials=SECRET1&newName=joe');\n            expect(response.text).toEqual('Player 2 not found');\n          });\n        });\n\n        describe('when the credentials are invalid', () => {\n          test('throws invalid credentials', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send('playerID=0&credentials=SECRET2&newName=mike');\n            expect(response.text).toEqual('Invalid credentials SECRET2');\n          });\n        });\n\n        describe('when playerID is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send('credentials=foo&newName=bill');\n          });\n          test('throws playerID is required', async () => {\n            expect(response.text).toEqual('playerID is required');\n          });\n        });\n\n        describe('when newName is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send('credentials=foo&playerID=0');\n          });\n\n          test('throws newName is required', async () => {\n            expect(response.text).toEqual('newName or data is required');\n          });\n        });\n      });\n    });\n  });\n\n  describe('updating player metadata', () => {\n    let response;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n\n    beforeEach(() => {\n      games = [ProcessGameConfig({ name: 'foo' })];\n    });\n\n    describe('for an unprotected lobby', () => {\n      beforeEach(() => {\n        delete process.env.API_SECRET;\n      });\n      describe('when the game does not exist', () => {\n        test('throws game not found', async () => {\n          db = new AsyncStorage({\n            fetch: async () => ({ metadata: null }),\n          });\n          const app = createApiServer({ db, auth, games });\n          response = await request(app.callback())\n            .post('/games/foo/1/update')\n            .send({ playerID: 0, data: { subdata: 'text' } });\n          expect(response.text).toEqual('Match 1 not found');\n        });\n      });\n\n      describe('when the game does exist', () => {\n        describe('when the playerID does exist', () => {\n          beforeEach(async () => {\n            db = new AsyncStorage({\n              fetch: async () => {\n                return {\n                  metadata: {\n                    players: {\n                      '0': {\n                        name: 'alice',\n                        credentials: 'SECRET1',\n                      },\n                      '1': {\n                        name: 'bob',\n                        credentials: 'SECRET2',\n                      },\n                    },\n                  },\n                };\n              },\n            });\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send({\n                playerID: 0,\n                credentials: 'SECRET1',\n                data: { subdata: 'text' },\n              });\n          });\n\n          test('is successful', async () => {\n            expect(response.status).toEqual(200);\n          });\n\n          test('updates the players', async () => {\n            expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n              '1',\n              expect.objectContaining({\n                players: expect.objectContaining({\n                  '0': expect.objectContaining({\n                    data: expect.objectContaining({\n                      subdata: 'text',\n                    }),\n                  }),\n                }),\n              })\n            );\n          });\n        });\n\n        describe('when the playerID does not exist', () => {\n          test('throws playerID not found', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send({\n                playerID: 2,\n                credentials: 'SECRET1',\n                data: { subdata: 'text' },\n              });\n            expect(response.text).toEqual('Player 2 not found');\n          });\n        });\n\n        describe('when the credentials are invalid', () => {\n          test('invalid credentials', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send({\n                playerID: 0,\n                credentials: 'SECRET2',\n                data: { subdata: 'text' },\n              });\n            expect(response.text).toEqual('Invalid credentials SECRET2');\n          });\n        });\n\n        describe('when playerID is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send({ credentials: 'foo', data: { subdata: 'text' } });\n          });\n\n          test('throws playerID is required', async () => {\n            expect(response.text).toEqual('playerID is required');\n          });\n        });\n\n        describe('when data is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/update')\n              .send({ playerID: 0, credentials: 'foo' });\n          });\n\n          test('throws data is required', async () => {\n            expect(response.text).toEqual('newName or data is required');\n          });\n        });\n      });\n    });\n  });\n\n  describe('leaving a room', () => {\n    let response;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n\n    beforeEach(() => {\n      games = [ProcessGameConfig({ name: 'foo' })];\n    });\n\n    describe('for an unprotected lobby', () => {\n      beforeEach(() => {\n        delete process.env.API_SECRET;\n      });\n\n      describe('when the game does not exist', () => {\n        test('throws a \"not found\" error', async () => {\n          db = new AsyncStorage({\n            fetch: async () => ({ metadata: null }),\n          });\n          const app = createApiServer({ db, auth, games });\n          response = await request(app.callback())\n            .post('/games/foo/1/leave')\n            .send('playerID=0&playerName=alice');\n          expect(response.status).toEqual(404);\n        });\n      });\n\n      describe('when the game does exist', () => {\n        describe('when the playerID does exist', () => {\n          beforeEach(async () => {\n            db = new AsyncStorage({\n              fetch: async () => {\n                return {\n                  metadata: {\n                    players: {\n                      '0': {\n                        name: 'alice',\n                        credentials: 'SECRET1',\n                      },\n                      '1': {\n                        name: 'bob',\n                        credentials: 'SECRET2',\n                      },\n                    },\n                  },\n                };\n              },\n            });\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/leave')\n              .send('playerID=0&credentials=SECRET1');\n          });\n\n          test('is successful', async () => {\n            expect(response.status).toEqual(200);\n          });\n\n          test('updates the players', async () => {\n            expect(db.mocks.setMetadata).toHaveBeenCalledWith(\n              '1',\n              expect.objectContaining({\n                players: expect.objectContaining({\n                  '0': expect.objectContaining({}),\n                  '1': expect.objectContaining({\n                    name: 'bob',\n                    credentials: 'SECRET2',\n                  }),\n                }),\n              })\n            );\n          });\n\n          describe('when there are not players left', () => {\n            test('removes the game', async () => {\n              db = new AsyncStorage({\n                fetch: async () => {\n                  return {\n                    metadata: {\n                      players: {\n                        '0': {\n                          name: 'alice',\n                          credentials: 'SECRET1',\n                        },\n                        '1': {\n                          credentials: 'SECRET2',\n                        },\n                      },\n                    },\n                  };\n                },\n              });\n              const app = createApiServer({ db, auth, games });\n              response = await request(app.callback())\n                .post('/games/foo/1/leave')\n                .send('playerID=0&credentials=SECRET1');\n              expect(db.mocks.wipe).toHaveBeenCalledWith('1');\n            });\n          });\n        });\n\n        describe('when the playerID does not exist', () => {\n          test('throws error 404', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/leave')\n              .send('playerID=2&credentials=SECRET1');\n            expect(response.status).toEqual(404);\n          });\n        });\n\n        describe('when the credentials are invalid', () => {\n          test('throws error 404', async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/leave')\n              .send('playerID=0&credentials=SECRET2');\n            expect(response.status).toEqual(403);\n          });\n        });\n        describe('when playerID is omitted', () => {\n          beforeEach(async () => {\n            const app = createApiServer({ db, auth, games });\n            response = await request(app.callback())\n              .post('/games/foo/1/leave')\n              .send('credentials=foo');\n          });\n\n          test('throws error 403', async () => {\n            expect(response.status).toEqual(403);\n          });\n        });\n      });\n    });\n  });\n\n  describe('requesting game list', () => {\n    let db: AsyncStorage;\n    const auth = new Auth();\n    beforeEach(() => {\n      delete process.env.API_SECRET;\n      db = new AsyncStorage();\n    });\n\n    describe('when given 2 games', () => {\n      let response;\n      beforeEach(async () => {\n        const games = [ProcessGameConfig({ name: 'foo' }), { name: 'bar' }];\n        const app = createApiServer({ db, auth, games });\n\n        response = await request(app.callback()).get('/games');\n      });\n\n      test('should get 2 games', async () => {\n        expect(JSON.parse(response.text)).toEqual(['foo', 'bar']);\n      });\n    });\n  });\n\n  describe('play again', () => {\n    let response;\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let games: Game[];\n\n    beforeEach(() => {\n      games = [ProcessGameConfig({ name: 'foo' })];\n      delete process.env.API_SECRET;\n      db = new AsyncStorage({\n        fetch: async () => {\n          return {\n            metadata: {\n              setupData: {\n                colors: {\n                  '0': 'green',\n                  '1': 'red',\n                },\n              },\n              players: {\n                '0': {\n                  name: 'alice',\n                  credentials: 'SECRET1',\n                },\n                '1': {\n                  name: 'bob',\n                  credentials: 'SECRET2',\n                },\n                '2': {\n                  name: 'chris',\n                  credentials: 'SECRET3',\n                },\n              },\n            },\n          };\n        },\n      });\n    });\n\n    test('creates new game data', async () => {\n      const uuid = () => 'newGameID';\n      const app = createApiServer({ db, auth, games, uuid });\n\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send({\n          playerID: 0,\n          credentials: 'SECRET1',\n          numPlayers: 4,\n          setupData: {\n            colors: {\n              '3': 'blue',\n            },\n          },\n        });\n      expect(db.mocks.createMatch).toHaveBeenCalledWith(\n        'newGameID',\n        expect.objectContaining({\n          initialState: expect.objectContaining({\n            ctx: expect.objectContaining({\n              numPlayers: 4,\n            }),\n          }),\n          metadata: expect.objectContaining({\n            setupData: expect.objectContaining({\n              colors: expect.objectContaining({\n                '3': 'blue',\n              }),\n            }),\n          }),\n        })\n      );\n      expect(response.body.nextMatchID).toBe('newGameID');\n    });\n\n    test('when game configuration not supplied, uses previous game config', async () => {\n      const uuid = () => 'newGameID';\n      const app = createApiServer({ db, auth, games, uuid });\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send('playerID=0&credentials=SECRET1');\n      expect(db.mocks.createMatch).toHaveBeenCalledWith(\n        'newGameID',\n        expect.objectContaining({\n          initialState: expect.objectContaining({\n            ctx: expect.objectContaining({\n              numPlayers: 3,\n            }),\n          }),\n          metadata: expect.objectContaining({\n            setupData: expect.objectContaining({\n              colors: expect.objectContaining({\n                '0': 'green',\n                '1': 'red',\n              }),\n            }),\n          }),\n        })\n      );\n      expect(response.body.nextMatchID).toBe('newGameID');\n    });\n\n    test('fetches next id', async () => {\n      db = new AsyncStorage({\n        fetch: async () => {\n          return {\n            metadata: {\n              players: {\n                '0': {\n                  name: 'alice',\n                  credentials: 'SECRET1',\n                },\n                '1': {\n                  name: 'bob',\n                  credentials: 'SECRET2',\n                },\n              },\n              nextMatchID: '12345',\n            },\n          };\n        },\n      });\n      const app = createApiServer({ db, auth, games });\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send('playerID=0&credentials=SECRET1');\n      expect(response.body.nextMatchID).toBe('12345');\n    });\n\n    test('when the match does not exist throws a \"not found\" error', async () => {\n      db = new AsyncStorage({\n        fetch: async () => ({ metadata: null }),\n      });\n      const app = createApiServer({ db, auth, games });\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send('playerID=0&playerName=alice');\n      expect(response.status).toEqual(404);\n    });\n\n    test('when the playerID is undefined throws error 403', async () => {\n      const app = createApiServer({ db, auth, games });\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send('credentials=SECRET1');\n      expect(response.status).toEqual(403);\n    });\n\n    test('when the playerID does not exist throws error 404', async () => {\n      const app = createApiServer({ db, auth, games });\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send('playerID=3&credentials=SECRET1');\n      expect(response.status).toEqual(404);\n    });\n\n    test('when the credentials are invalid throws error 404', async () => {\n      const app = createApiServer({ db, auth, games });\n      response = await request(app.callback())\n        .post('/games/foo/1/playAgain')\n        .send('playerID=0&credentials=SECRET2');\n      expect(response.status).toEqual(403);\n    });\n\n    test('when playerID is omitted throws error 403', async () => {\n      const app = createApiServer({ db, auth, games });\n      response = await request(app.callback())\n        .post('/games/foo/1/leave')\n        .send('credentials=foo');\n      expect(response.status).toEqual(403);\n    });\n  });\n\n  describe('requesting room list', () => {\n    let db: AsyncStorage;\n    const auth = new Auth();\n    const dbFetch = jest.fn(async (matchID) => {\n      return {\n        metadata: {\n          players: {\n            '0': {\n              id: 0,\n              credentials: 'SECRET1',\n            },\n            '1': {\n              id: 1,\n              credentials: 'SECRET2',\n            },\n          },\n          unlisted: matchID === 'bar-4',\n          gameover: matchID === 'bar-3' ? { winner: 0 } : undefined,\n        },\n      };\n    });\n    const dblistMatches = jest.fn(async (opts) => {\n      const metadata = {\n        'foo-0': { gameName: 'foo' },\n        'foo-1': { gameName: 'foo' },\n        'bar-2': { gameName: 'bar' },\n        'bar-3': { gameName: 'bar' },\n        'bar-4': { gameName: 'bar' },\n      };\n      const keys = Object.keys(metadata);\n      if (opts && opts.gameName) {\n        return keys.filter((key) => metadata[key].gameName === opts.gameName);\n      }\n      return [...keys];\n    });\n    beforeEach(() => {\n      delete process.env.API_SECRET;\n      db = new AsyncStorage({\n        fetch: dbFetch,\n        listMatches: dblistMatches,\n      });\n    });\n\n    describe('when given 2 matches', () => {\n      let response;\n      let matches;\n      beforeEach(async () => {\n        const games = [ProcessGameConfig({ name: 'foo' }), { name: 'bar' }];\n        const app = createApiServer({ db, auth, games });\n        response = await request(app.callback()).get('/games/bar');\n        matches = JSON.parse(response.text).matches;\n      });\n\n      test('returns matches for the selected game', async () => {\n        expect(matches).toHaveLength(2);\n      });\n\n      test('returns match ids', async () => {\n        expect(matches[0].matchID).toEqual('bar-2');\n        expect(matches[1].matchID).toEqual('bar-3');\n      });\n\n      test('returns player names', async () => {\n        expect(matches[0].players).toEqual([{ id: 0 }, { id: 1 }]);\n        expect(matches[1].players).toEqual([{ id: 0 }, { id: 1 }]);\n      });\n\n      test('returns gameover data for ended match', async () => {\n        expect(matches[0].gameover).toBeUndefined();\n        expect(matches[1].gameover).toEqual({ winner: 0 });\n      });\n    });\n\n    describe('when given filter options', () => {\n      const games = [ProcessGameConfig({ name: 'foo' }), { name: 'bar' }];\n      let app;\n\n      beforeEach(() => {\n        app = createApiServer({ db, auth, games });\n        dblistMatches.mockClear();\n      });\n\n      describe('isGameover query param', () => {\n        test('is undefined if not specified in request', async () => {\n          await request(app.callback()).get('/games/bar');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { isGameover: undefined } })\n          );\n        });\n        test('is true', async () => {\n          await request(app.callback()).get('/games/bar?isGameover=true');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { isGameover: true } })\n          );\n        });\n        test('is false', async () => {\n          await request(app.callback()).get('/games/bar?isGameover=false');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { isGameover: false } })\n          );\n        });\n        test('invalid value is ignored', async () => {\n          await request(app.callback()).get('/games/bar?isGameover=5');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { isGameover: undefined } })\n          );\n        });\n        test('uses first array value', async () => {\n          await request(app.callback()).get(\n            '/games/bar?isGameover=true&isGameover=false'\n          );\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { isGameover: true } })\n          );\n        });\n      });\n\n      describe('updatedBefore query param', () => {\n        test('is undefined if not specified in request', async () => {\n          await request(app.callback()).get('/games/bar');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({\n              where: expect.objectContaining({ updatedBefore: undefined }),\n            })\n          );\n        });\n        test('is specified', async () => {\n          const timestamp = new Date(2020, 3, 4, 5, 6, 7);\n          await request(app.callback()).get(\n            `/games/bar?updatedBefore=${timestamp.getTime()}`\n          );\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({\n              where: expect.objectContaining({\n                updatedBefore: timestamp.getTime(),\n              }),\n            })\n          );\n        });\n        test('invalid value is ignored', async () => {\n          await request(app.callback()).get('/games/bar?updatedBefore=-5');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { updatedBefore: undefined } })\n          );\n        });\n        test('uses first array value', async () => {\n          const t1 = new Date(2020, 3, 4, 5, 6, 7).getTime();\n          const t2 = new Date(2021, 3, 4, 5, 6, 7).getTime();\n          await request(app.callback()).get(\n            `/games/bar?updatedBefore=${t1}&updatedBefore=${t2}`\n          );\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({\n              where: expect.objectContaining({ updatedBefore: t1 }),\n            })\n          );\n        });\n      });\n\n      describe('updatedAfter query param', () => {\n        test('is undefined if not specified in request', async () => {\n          await request(app.callback()).get('/games/bar');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({\n              where: expect.objectContaining({ updatedAfter: undefined }),\n            })\n          );\n        });\n        test('is specified', async () => {\n          const timestamp = new Date(2020, 3, 4, 5, 6, 7);\n          await request(app.callback()).get(\n            `/games/bar?updatedAfter=${timestamp.getTime()}`\n          );\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({\n              where: expect.objectContaining({\n                updatedAfter: timestamp.getTime(),\n              }),\n            })\n          );\n        });\n        test('invalid value is ignored', async () => {\n          await request(app.callback()).get('/games/bar?updatedAfter=-5');\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({ where: { updatedAfter: undefined } })\n          );\n        });\n        test('uses first array value', async () => {\n          const t1 = new Date(2020, 3, 4, 5, 6, 7).getTime();\n          const t2 = new Date(2021, 3, 4, 5, 6, 7).getTime();\n          await request(app.callback()).get(\n            `/games/bar?updatedAfter=${t1}&updatedAfter=${t2}`\n          );\n          expect(dblistMatches).toBeCalledWith(\n            expect.objectContaining({\n              where: expect.objectContaining({ updatedAfter: t1 }),\n            })\n          );\n        });\n      });\n    });\n  });\n\n  describe('requesting room', () => {\n    let db: AsyncStorage;\n    const auth = new Auth();\n    beforeEach(() => {\n      delete process.env.API_SECRET;\n      db = new AsyncStorage({\n        fetch: async () => {\n          return {\n            metadata: {\n              players: {\n                '0': {\n                  id: 0,\n                  credentials: 'SECRET1',\n                },\n                '1': {\n                  id: 1,\n                  credentials: 'SECRET2',\n                },\n              },\n              gameover: { winner: 1 },\n            },\n          };\n        },\n        listMatches: async () => {\n          return ['bar:bar-0', 'foo:foo-0', 'bar:bar-1'];\n        },\n      });\n    });\n\n    describe('when given room ID', () => {\n      let response;\n      let room;\n      beforeEach(async () => {\n        const games = [ProcessGameConfig({ name: 'foo' }), { name: 'bar' }];\n        const app = createApiServer({ db, auth, games });\n        response = await request(app.callback()).get('/games/bar/bar-0');\n        room = JSON.parse(response.text);\n      });\n\n      test('returns game ids', async () => {\n        expect(room.matchID).toEqual('bar-0');\n      });\n\n      test('returns player names', async () => {\n        expect(room.players).toEqual([{ id: 0 }, { id: 1 }]);\n      });\n\n      test('returns gameover data for ended game', async () => {\n        expect(room.gameover).toEqual({ winner: 1 });\n      });\n    });\n\n    describe('when given a non-existent room ID', () => {\n      let response;\n      beforeEach(async () => {\n        db = new AsyncStorage({\n          fetch: async () => ({ metadata: null }),\n        });\n        const games = [ProcessGameConfig({ name: 'foo' })];\n        const app = createApiServer({ db, auth, games });\n        response = await request(app.callback()).get('/games/bar/doesnotexist');\n      });\n\n      test('throws error 404', async () => {\n        expect(response.status).toEqual(404);\n      });\n    });\n  });\n\n  describe('when server app is provided', () => {\n    let db: AsyncStorage;\n    const auth = new Auth();\n    let server;\n    let useChain;\n    let games: Game[];\n\n    beforeEach(async () => {\n      useChain = jest.fn(() => ({ use: useChain }));\n      server = { use: useChain };\n      db = new AsyncStorage();\n      games = [\n        {\n          name: 'foo',\n          setup: () => {},\n        },\n      ];\n    });\n\n    test('call .use method several times', async () => {\n      addApiToServer({ app: server, db, auth, games });\n      expect(server.use.mock.calls.length).toBeGreaterThan(1);\n    });\n\n    test('call .use method several times with uuid', async () => {\n      const uuid = () => 'foo';\n      addApiToServer({ app: server, db, auth, games, uuid });\n      expect(server.use.mock.calls.length).toBeGreaterThan(1);\n    });\n  });\n\n  describe('cors', () => {\n    const auth = new Auth();\n    const games: Game[] = [];\n    const db = new AsyncStorage();\n\n    describe('no allowed origins', () => {\n      const app = createApiServer({ auth, games, db, origins: false });\n\n      test('does not allow CORS', async () => {\n        const res = await request(app.callback())\n          .get('/games')\n          .set('Origin', 'https://www.example.com')\n          .expect('Vary', 'Origin');\n        expect(res.headers).not.toHaveProperty('access-control-allow-origin');\n        expect(res.headers).not.toHaveProperty('Access-Control-Allow-Origin');\n      });\n    });\n\n    describe('single allowed origin', () => {\n      const origin = 'https://www.example.com';\n      const app = createApiServer({ auth, games, db, origins: origin });\n\n      test('disallows non-matching origin', async () => {\n        const res = await request(app.callback())\n          .get('/games')\n          .set('Origin', 'https://www.other.com')\n          .expect('Vary', 'Origin');\n        expect(res.headers).not.toHaveProperty('access-control-allow-origin');\n        expect(res.headers).not.toHaveProperty('Access-Control-Allow-Origin');\n      });\n\n      // eslint-disable-next-line jest/expect-expect\n      test('allows matching origin', async () => {\n        await request(app.callback())\n          .get('/games')\n          .set('Origin', origin)\n          .expect('Vary', 'Origin')\n          .expect('Access-Control-Allow-Origin', origin);\n      });\n    });\n\n    describe('multiple allowed origins', () => {\n      const origins = [Origins.LOCALHOST, 'https://www.example.com'];\n      const app = createApiServer({ auth, games, db, origins });\n\n      test('disallows non-matching origin', async () => {\n        const res = await request(app.callback())\n          .get('/games')\n          .set('Origin', 'https://www.other.com')\n          .expect('Vary', 'Origin');\n        expect(res.headers).not.toHaveProperty('access-control-allow-origin');\n        expect(res.headers).not.toHaveProperty('Access-Control-Allow-Origin');\n      });\n\n      // eslint-disable-next-line jest/expect-expect\n      test('allows matching origin', async () => {\n        const origin = 'http://localhost:5000';\n        await request(app.callback())\n          .get('/games')\n          .set('Origin', origin)\n          .expect('Vary', 'Origin')\n          .expect('Access-Control-Allow-Origin', origin);\n      });\n    });\n  });\n});\n"
  },
  {
    "path": "src/server/api.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { CorsOptions } from 'cors';\nimport type Koa from 'koa';\nimport type Router from '@koa/router';\nimport koaBody from 'koa-body';\nimport { nanoid } from 'nanoid';\nimport cors from '@koa/cors';\nimport { createMatch, getFirstAvailablePlayerID, getNumPlayers } from './util';\nimport type { Auth } from './auth';\nimport type { Server, LobbyAPI, Game, StorageAPI } from '../types';\n\n/**\n * Creates a new match.\n *\n * @param {object} db - The storage API.\n * @param {object} game - The game config object.\n * @param {number} numPlayers - The number of players.\n * @param {object} setupData - User-defined object that's available\n *                             during game setup.\n * @param {object } lobbyConfig - Configuration options for the lobby.\n * @param {boolean} unlisted - Whether the match should be excluded from public listing.\n */\nconst CreateMatch = async ({\n  ctx,\n  db,\n  uuid,\n  ...opts\n}: {\n  db: StorageAPI.Sync | StorageAPI.Async;\n  ctx: Koa.BaseContext;\n  uuid: () => string;\n} & Parameters<typeof createMatch>[0]): Promise<string> => {\n  const matchID = uuid();\n  const match = createMatch(opts);\n\n  if ('setupDataError' in match) {\n    ctx.throw(400, match.setupDataError);\n  } else {\n    await db.createMatch(matchID, match);\n    return matchID;\n  }\n};\n\n/**\n * Create a metadata object without secret credentials to return to the client.\n *\n * @param {string} matchID - The identifier of the match the metadata belongs to.\n * @param {object} metadata - The match metadata object to strip credentials from.\n * @return - A metadata object without player credentials.\n */\nconst createClientMatchData = (\n  matchID: string,\n  metadata: Server.MatchData\n): LobbyAPI.Match => {\n  return {\n    ...metadata,\n    matchID,\n    players: Object.values(metadata.players).map((player) => {\n      // strip away credentials\n      const { credentials, ...strippedInfo } = player;\n      return strippedInfo;\n    }),\n  };\n};\n\n/** Utility extracting `string` from a query if it is `string[]`. */\nconst unwrapQuery = (\n  query: undefined | string | string[]\n): string | undefined => (Array.isArray(query) ? query[0] : query);\n\nexport const configureRouter = ({\n  router,\n  db,\n  auth,\n  games,\n  uuid = () => nanoid(11),\n}: {\n  router: Router<any, Server.AppCtx>;\n  auth: Auth;\n  games: Game[];\n  uuid?: () => string;\n  db: StorageAPI.Sync | StorageAPI.Async;\n}) => {\n  /**\n   * List available games.\n   *\n   * @return - Array of game names as string.\n   */\n  router.get('/games', async (ctx) => {\n    const body: LobbyAPI.GameList = games.map((game) => game.name);\n    ctx.body = body;\n  });\n\n  /**\n   * Create a new match of a given game.\n   *\n   * @param {string} name - The name of the game of the new match.\n   * @param {number} numPlayers - The number of players.\n   * @param {object} setupData - User-defined object that's available\n   *                             during game setup.\n   * @param {boolean} unlisted - Whether the match should be excluded from public listing.\n   * @return - The ID of the created match.\n   */\n  router.post('/games/:name/create', koaBody(), async (ctx) => {\n    // The name of the game (for example: tic-tac-toe).\n    const gameName = ctx.params.name;\n    // User-data to pass to the game setup function.\n    const setupData = ctx.request.body.setupData;\n    // Whether the game should be excluded from public listing.\n    const unlisted = ctx.request.body.unlisted;\n    // The number of players for this game instance.\n    const numPlayers = Number.parseInt(ctx.request.body.numPlayers);\n\n    const game = games.find((g) => g.name === gameName);\n    if (!game) ctx.throw(404, 'Game ' + gameName + ' not found');\n\n    if (\n      ctx.request.body.numPlayers !== undefined &&\n      (Number.isNaN(numPlayers) ||\n        (game.minPlayers && numPlayers < game.minPlayers) ||\n        (game.maxPlayers && numPlayers > game.maxPlayers))\n    ) {\n      ctx.throw(400, 'Invalid numPlayers');\n    }\n\n    const matchID = await CreateMatch({\n      ctx,\n      db,\n      game,\n      numPlayers,\n      setupData,\n      uuid,\n      unlisted,\n    });\n\n    const body: LobbyAPI.CreatedMatch = { matchID };\n    ctx.body = body;\n  });\n\n  /**\n   * List matches for a given game.\n   *\n   * This does not return matches that are marked as unlisted.\n   *\n   * @param {string} name - The name of the game.\n   * @return - Array of match objects.\n   */\n  router.get('/games/:name', async (ctx) => {\n    const gameName = ctx.params.name;\n    const isGameoverString = unwrapQuery(ctx.query.isGameover);\n    const updatedBeforeString = unwrapQuery(ctx.query.updatedBefore);\n    const updatedAfterString = unwrapQuery(ctx.query.updatedAfter);\n\n    let isGameover: boolean | undefined;\n    if (isGameoverString) {\n      if (isGameoverString.toLowerCase() === 'true') {\n        isGameover = true;\n      } else if (isGameoverString.toLowerCase() === 'false') {\n        isGameover = false;\n      }\n    }\n    let updatedBefore: number | undefined;\n    if (updatedBeforeString) {\n      const parsedNumber = Number.parseInt(updatedBeforeString, 10);\n      if (parsedNumber > 0) {\n        updatedBefore = parsedNumber;\n      }\n    }\n    let updatedAfter: number | undefined;\n    if (updatedAfterString) {\n      const parsedNumber = Number.parseInt(updatedAfterString, 10);\n      if (parsedNumber > 0) {\n        updatedAfter = parsedNumber;\n      }\n    }\n    const matchList = await db.listMatches({\n      gameName,\n      where: {\n        isGameover,\n        updatedAfter,\n        updatedBefore,\n      },\n    });\n    const matches = [];\n    for (const matchID of matchList) {\n      const { metadata } = await (db as StorageAPI.Async).fetch(matchID, {\n        metadata: true,\n      });\n      if (!metadata.unlisted) {\n        matches.push(createClientMatchData(matchID, metadata));\n      }\n    }\n    const body: LobbyAPI.MatchList = { matches };\n    ctx.body = body;\n  });\n\n  /**\n   * Get data about a specific match.\n   *\n   * @param {string} name - The name of the game.\n   * @param {string} id - The ID of the match.\n   * @return - A match object.\n   */\n  router.get('/games/:name/:id', async (ctx) => {\n    const matchID = ctx.params.id;\n    const { metadata } = await (db as StorageAPI.Async).fetch(matchID, {\n      metadata: true,\n    });\n    if (!metadata) {\n      ctx.throw(404, 'Match ' + matchID + ' not found');\n    }\n    const body: LobbyAPI.Match = createClientMatchData(matchID, metadata);\n    ctx.body = body;\n  });\n\n  /**\n   * Join a given match.\n   *\n   * @param {string} name - The name of the game.\n   * @param {string} id - The ID of the match.\n   * @param {string} playerID - The ID of the player who joins. If not sent, will be assigned to the first index available.\n   * @param {string} playerName - The name of the player who joins.\n   * @param {object} data - The default data of the player in the match.\n   * @return - Player ID and credentials to use when interacting in the joined match.\n   */\n  router.post('/games/:name/:id/join', koaBody(), async (ctx) => {\n    let playerID = ctx.request.body.playerID;\n    const playerName = ctx.request.body.playerName;\n    const data = ctx.request.body.data;\n    const matchID = ctx.params.id;\n    if (!playerName) {\n      ctx.throw(403, 'playerName is required');\n    }\n\n    const { metadata } = await (db as StorageAPI.Async).fetch(matchID, {\n      metadata: true,\n    });\n    if (!metadata) {\n      ctx.throw(404, 'Match ' + matchID + ' not found');\n    }\n\n    if (typeof playerID === 'undefined' || playerID === null) {\n      playerID = getFirstAvailablePlayerID(metadata.players);\n      if (playerID === undefined) {\n        const numPlayers = getNumPlayers(metadata.players);\n        ctx.throw(\n          409,\n          `Match ${matchID} reached maximum number of players (${numPlayers})`\n        );\n      }\n    }\n\n    if (!metadata.players[playerID]) {\n      ctx.throw(404, 'Player ' + playerID + ' not found');\n    }\n    if (metadata.players[playerID].name) {\n      ctx.throw(409, 'Player ' + playerID + ' not available');\n    }\n\n    if (data) {\n      metadata.players[playerID].data = data;\n    }\n    metadata.players[playerID].name = playerName;\n    const playerCredentials = await auth.generateCredentials(ctx);\n    metadata.players[playerID].credentials = playerCredentials;\n\n    await db.setMetadata(matchID, metadata);\n\n    const body: LobbyAPI.JoinedMatch = { playerID, playerCredentials };\n    ctx.body = body;\n  });\n\n  /**\n   * Leave a given match.\n   *\n   * @param {string} name - The name of the game.\n   * @param {string} id - The ID of the match.\n   * @param {string} playerID - The ID of the player who leaves.\n   * @param {string} credentials - The credentials of the player who leaves.\n   * @return - Nothing.\n   */\n  router.post('/games/:name/:id/leave', koaBody(), async (ctx) => {\n    const matchID = ctx.params.id;\n    const playerID = ctx.request.body.playerID;\n    const credentials = ctx.request.body.credentials;\n    const { metadata } = await (db as StorageAPI.Async).fetch(matchID, {\n      metadata: true,\n    });\n    if (typeof playerID === 'undefined' || playerID === null) {\n      ctx.throw(403, 'playerID is required');\n    }\n\n    if (!metadata) {\n      ctx.throw(404, 'Match ' + matchID + ' not found');\n    }\n    if (!metadata.players[playerID]) {\n      ctx.throw(404, 'Player ' + playerID + ' not found');\n    }\n    const isAuthorized = await auth.authenticateCredentials({\n      playerID,\n      credentials,\n      metadata,\n    });\n    if (!isAuthorized) {\n      ctx.throw(403, 'Invalid credentials ' + credentials);\n    }\n\n    delete metadata.players[playerID].name;\n    delete metadata.players[playerID].credentials;\n    const hasPlayers = Object.values(metadata.players).some(({ name }) => name);\n    await (hasPlayers\n      ? db.setMetadata(matchID, metadata) // Update metadata.\n      : db.wipe(matchID)); // Delete match.\n    ctx.body = {};\n  });\n\n  /**\n   * Start a new match based on another existing match.\n   *\n   * @param {string} name - The name of the game.\n   * @param {string} id - The ID of the match.\n   * @param {string} playerID - The ID of the player creating the match.\n   * @param {string} credentials - The credentials of the player creating the match.\n   * @param {boolean} unlisted - Whether the match should be excluded from public listing.\n   * @return - The ID of the new match.\n   */\n  router.post('/games/:name/:id/playAgain', koaBody(), async (ctx) => {\n    const gameName = ctx.params.name;\n    const matchID = ctx.params.id;\n    const playerID = ctx.request.body.playerID;\n    const credentials = ctx.request.body.credentials;\n    const unlisted = ctx.request.body.unlisted;\n    const { metadata } = await (db as StorageAPI.Async).fetch(matchID, {\n      metadata: true,\n    });\n\n    if (typeof playerID === 'undefined' || playerID === null) {\n      ctx.throw(403, 'playerID is required');\n    }\n\n    if (!metadata) {\n      ctx.throw(404, 'Match ' + matchID + ' not found');\n    }\n    if (!metadata.players[playerID]) {\n      ctx.throw(404, 'Player ' + playerID + ' not found');\n    }\n    const isAuthorized = await auth.authenticateCredentials({\n      playerID,\n      credentials,\n      metadata,\n    });\n    if (!isAuthorized) {\n      ctx.throw(403, 'Invalid credentials ' + credentials);\n    }\n\n    // Check if nextMatch is already set, if so, return that id.\n    if (metadata.nextMatchID) {\n      ctx.body = { nextMatchID: metadata.nextMatchID };\n      return;\n    }\n\n    // User-data to pass to the game setup function.\n    const setupData = ctx.request.body.setupData || metadata.setupData;\n    // The number of players for this game instance.\n    const numPlayers =\n      Number.parseInt(ctx.request.body.numPlayers) ||\n      // eslint-disable-next-line unicorn/explicit-length-check\n      Object.keys(metadata.players).length;\n\n    const game = games.find((g) => g.name === gameName);\n    const nextMatchID = await CreateMatch({\n      ctx,\n      db,\n      game,\n      numPlayers,\n      setupData,\n      uuid,\n      unlisted,\n    });\n    metadata.nextMatchID = nextMatchID;\n\n    await db.setMetadata(matchID, metadata);\n\n    const body: LobbyAPI.NextMatch = { nextMatchID };\n    ctx.body = body;\n  });\n\n  const updatePlayerMetadata = async (ctx: Koa.Context) => {\n    const matchID = ctx.params.id;\n    const playerID = ctx.request.body.playerID;\n    const credentials = ctx.request.body.credentials;\n    const newName = ctx.request.body.newName;\n    const data = ctx.request.body.data;\n    const { metadata } = await (db as StorageAPI.Async).fetch(matchID, {\n      metadata: true,\n    });\n    if (typeof playerID === 'undefined') {\n      ctx.throw(403, 'playerID is required');\n    }\n    if (data === undefined && !newName) {\n      ctx.throw(403, 'newName or data is required');\n    }\n    if (newName && typeof newName !== 'string') {\n      ctx.throw(403, `newName must be a string, got ${typeof newName}`);\n    }\n    if (!metadata) {\n      ctx.throw(404, 'Match ' + matchID + ' not found');\n    }\n    if (!metadata.players[playerID]) {\n      ctx.throw(404, 'Player ' + playerID + ' not found');\n    }\n    const isAuthorized = await auth.authenticateCredentials({\n      playerID,\n      credentials,\n      metadata,\n    });\n    if (!isAuthorized) {\n      ctx.throw(403, 'Invalid credentials ' + credentials);\n    }\n\n    if (newName) {\n      metadata.players[playerID].name = newName;\n    }\n    if (data) {\n      metadata.players[playerID].data = data;\n    }\n    await db.setMetadata(matchID, metadata);\n    ctx.body = {};\n  };\n\n  /**\n   * Change the name of a player in a given match.\n   *\n   * @param {string} name - The name of the game.\n   * @param {string} id - The ID of the match.\n   * @param {string} playerID - The ID of the player.\n   * @param {string} credentials - The credentials of the player.\n   * @param {object} newName - The new name of the player in the match.\n   * @return - Nothing.\n   */\n  router.post('/games/:name/:id/rename', koaBody(), async (ctx) => {\n    console.warn(\n      'This endpoint /rename is deprecated. Please use /update instead.'\n    );\n    await updatePlayerMetadata(ctx);\n  });\n\n  /**\n   * Update the player's data for a given match.\n   *\n   * @param {string} name - The name of the game.\n   * @param {string} id - The ID of the match.\n   * @param {string} playerID - The ID of the player.\n   * @param {string} credentials - The credentials of the player.\n   * @param {object} newName - The new name of the player in the match.\n   * @param {object} data - The new data of the player in the match.\n   * @return - Nothing.\n   */\n  router.post('/games/:name/:id/update', koaBody(), updatePlayerMetadata);\n\n  return router;\n};\n\nexport const configureApp = (\n  app: Server.App,\n  router: Router<any, Server.AppCtx>,\n  origins: CorsOptions['origin']\n): void => {\n  app.use(\n    cors({\n      // Set Access-Control-Allow-Origin header for allowed origins.\n      origin: (ctx) => {\n        const origin = ctx.get('Origin');\n        return isOriginAllowed(origin, origins) ? origin : '';\n      },\n    })\n  );\n\n  // If API_SECRET is set, then require that requests set an\n  // api-secret header that is set to the same value.\n  app.use(async (ctx, next) => {\n    if (\n      !!process.env.API_SECRET &&\n      ctx.request.headers['api-secret'] !== process.env.API_SECRET\n    ) {\n      ctx.throw(403, 'Invalid API secret');\n    }\n\n    await next();\n  });\n\n  app.use(router.routes()).use(router.allowedMethods());\n};\n\n/**\n * Check if a request’s origin header is allowed for CORS.\n * Adapted from `cors` package: https://github.com/expressjs/cors\n * @param origin Request origin to test.\n * @param allowedOrigin Origin(s) that are allowed to connect via CORS.\n * @returns `true` if the origin matched at least one of the allowed origins.\n */\nfunction isOriginAllowed(\n  origin: string,\n  allowedOrigin: CorsOptions['origin']\n): boolean {\n  if (Array.isArray(allowedOrigin)) {\n    for (const entry of allowedOrigin) {\n      if (isOriginAllowed(origin, entry)) {\n        return true;\n      }\n    }\n    return false;\n  } else if (typeof allowedOrigin === 'string') {\n    return origin === allowedOrigin;\n  } else if (allowedOrigin instanceof RegExp) {\n    return allowedOrigin.test(origin);\n  } else {\n    return !!allowedOrigin;\n  }\n}\n"
  },
  {
    "path": "src/server/auth.test.ts",
    "content": "import {\n  extractPlayerMetadata,\n  doesMatchRequireAuthentication,\n  areCredentialsAuthentic,\n  Auth,\n} from './auth';\n\nimport type { Server } from '../types';\n\ndescribe('extractPlayerMetadata', () => {\n  describe('when metadata is not found', () => {\n    test('then playerMetadata is undefined', () => {\n      expect(extractPlayerMetadata(undefined, '0')).toBeUndefined();\n    });\n  });\n\n  describe('when metadata does not contain players field', () => {\n    test('then playerMetadata is undefined', () => {\n      expect(\n        extractPlayerMetadata({} as Server.MatchData, '0')\n      ).toBeUndefined();\n    });\n  });\n\n  describe('when metadata does not contain playerID', () => {\n    test('then playerMetadata is undefined', () => {\n      expect(\n        extractPlayerMetadata(\n          {\n            gameName: '',\n            setupData: {},\n            players: { '1': { id: 1 } },\n            createdAt: 0,\n            updatedAt: 0,\n          },\n          '0'\n        )\n      ).toBeUndefined();\n    });\n  });\n\n  describe('when metadata contains playerID', () => {\n    test('then playerMetadata is returned', () => {\n      const playerMetadata = { id: 0, credentials: 'SECRET' };\n      const result = extractPlayerMetadata(\n        {\n          gameName: '',\n          setupData: {},\n          players: { '0': playerMetadata },\n          createdAt: 0,\n          updatedAt: 0,\n        },\n        '0'\n      );\n      expect(result).toBe(playerMetadata);\n    });\n  });\n});\n\ndescribe('doesMatchRequireAuthentication', () => {\n  describe('when game metadata is not found', () => {\n    test('then authentication is not required', () => {\n      const result = doesMatchRequireAuthentication();\n      expect(result).toBe(false);\n    });\n  });\n\n  describe('when match has no credentials', () => {\n    test('then authentication is not required', () => {\n      const matchData = {\n        gameName: '',\n        setupData: {},\n        players: {\n          '0': { id: 1 },\n        },\n        createdAt: 0,\n        updatedAt: 0,\n      };\n      const result = doesMatchRequireAuthentication(matchData);\n      expect(result).toBe(false);\n    });\n  });\n\n  describe('when match has credentials', () => {\n    test('then authentication is required', () => {\n      const matchData = {\n        gameName: '',\n        setupData: {},\n        players: {\n          '0': {\n            id: 0,\n            credentials: 'SECRET',\n          },\n        },\n        createdAt: 0,\n        updatedAt: 0,\n      };\n      const result = doesMatchRequireAuthentication(matchData);\n      expect(result).toBe(true);\n    });\n  });\n});\n\ndescribe('areCredentialsAuthentic', () => {\n  let action;\n  let playerID;\n  let matchData;\n  let credentials;\n  let playerMetadata;\n\n  beforeEach(() => {\n    playerID = '0';\n\n    action = {\n      payload: { credentials: 'SECRET' },\n    };\n\n    matchData = {\n      players: {\n        '0': { credentials: 'SECRET' },\n      },\n    };\n\n    playerMetadata = matchData.players[playerID];\n    ({ credentials } = action.payload || {});\n  });\n\n  describe('when game has credentials', () => {\n    describe('when action contains no payload', () => {\n      beforeEach(() => {\n        action = {};\n        ({ credentials } = action.payload || {});\n      });\n\n      test('the action is not authentic', async () => {\n        const result = areCredentialsAuthentic(credentials, playerMetadata);\n        expect(result).toBe(false);\n      });\n    });\n\n    describe('when action contains no credentials', () => {\n      beforeEach(() => {\n        action = {\n          payload: { someStuff: 'foo' },\n        };\n        ({ credentials } = action.payload || {});\n      });\n\n      test('then action is not authentic', async () => {\n        const result = areCredentialsAuthentic(credentials, playerMetadata);\n        expect(result).toBe(false);\n      });\n    });\n\n    describe('when action credentials do not match game credentials', () => {\n      beforeEach(() => {\n        action = {\n          payload: { credentials: 'WRONG' },\n        };\n        ({ credentials } = action.payload || {});\n      });\n      test('then action is not authentic', async () => {\n        const result = areCredentialsAuthentic(credentials, playerMetadata);\n        expect(result).toBe(false);\n      });\n    });\n\n    describe('when playerMetadata is not found', () => {\n      test('then action is not authentic', () => {\n        const result = areCredentialsAuthentic(credentials, undefined);\n        expect(result).toBe(false);\n      });\n    });\n\n    describe('when action credentials do match game credentials', () => {\n      test('then action is authentic', async () => {\n        const result = areCredentialsAuthentic(credentials, playerMetadata);\n        expect(result).toBe(true);\n      });\n    });\n  });\n});\n\ndescribe('Auth', () => {\n  const credentials = 'credentials';\n  const playerData = { id: 0, credentials };\n  const metadata = {\n    gameName: '',\n    players: { '0': playerData },\n    createdAt: 0,\n    updatedAt: 0,\n  };\n\n  describe('defaults', () => {\n    const auth = new Auth();\n\n    test('generateCredentials', () => {\n      expect(typeof auth.generateCredentials({})).toBe('string');\n    });\n\n    test('authenticateCredentials', () => {\n      expect(\n        auth.authenticateCredentials({ playerID: '0', metadata, credentials })\n      ).toBe(true);\n    });\n  });\n\n  describe('ignores bad options', () => {\n    const auth = new Auth({\n      generateCredentials: 'foo',\n      authenticateCredentials: 'bar',\n    } as any);\n\n    test('generateCredentials', () => {\n      expect(typeof auth.generateCredentials({})).toBe('string');\n    });\n\n    test('authenticateCredentials', () => {\n      expect(\n        auth.authenticateCredentials({ playerID: '0', metadata, credentials })\n      ).toBe(true);\n    });\n  });\n\n  describe('custom methods', () => {\n    const generateCredentials = jest.fn(() => credentials);\n    const authenticateCredentials = jest.fn(() => true);\n    const auth = new Auth({ generateCredentials, authenticateCredentials });\n\n    test('generateCredentials', () => {\n      const ctx = {};\n      expect(auth.generateCredentials(ctx)).toBe(credentials);\n      expect(generateCredentials).toHaveBeenCalledWith(ctx);\n    });\n\n    test('authenticateCredentials', () => {\n      expect(\n        auth.authenticateCredentials({ playerID: '0', metadata, credentials })\n      ).toBe(true);\n      expect(authenticateCredentials).toHaveBeenCalledWith(\n        credentials,\n        playerData\n      );\n    });\n  });\n\n  describe('async', () => {\n    const generateCredentials = jest.fn(async () => credentials);\n    const authenticateCredentials = jest.fn(async () => true);\n    const auth = new Auth({ generateCredentials, authenticateCredentials });\n\n    test('generateCredentials', async () => {\n      const ctx = {};\n      const promise = auth.generateCredentials(ctx);\n      expect(promise).toBeInstanceOf(Promise);\n      expect(generateCredentials).toHaveBeenCalledWith(ctx);\n      expect(await promise).toBe(credentials);\n    });\n\n    test('authenticateCredentials', async () => {\n      const promise = auth.authenticateCredentials({\n        playerID: '0',\n        metadata,\n        credentials,\n      });\n\n      expect(promise).toBeInstanceOf(Promise);\n      expect(authenticateCredentials).toHaveBeenCalledWith(\n        credentials,\n        playerData\n      );\n      expect(await promise).toBe(true);\n    });\n  });\n});\n"
  },
  {
    "path": "src/server/auth.ts",
    "content": "import { nanoid } from 'nanoid';\nimport type { Server, PlayerID } from '../types';\n\n/**\n * Verifies that a match has metadata and is using credentials.\n */\nexport const doesMatchRequireAuthentication = (\n  matchData?: Server.MatchData\n) => {\n  if (!matchData) return false;\n  const { players } = matchData;\n  const hasCredentials = Object.values(players).some(\n    (player) => !!(player && player.credentials)\n  );\n  return hasCredentials;\n};\n\n/**\n * The default `authenticateCredentials` method.\n * Verifies that the provided credentials match the player’s metadata.\n */\nexport const areCredentialsAuthentic: Server.AuthenticateCredentials = (\n  actionCredentials: string,\n  playerMetadata?: Server.PlayerMetadata\n) => {\n  if (!actionCredentials) return false;\n  if (!playerMetadata) return false;\n  return actionCredentials === playerMetadata.credentials;\n};\n\n/**\n * Extracts a player’s metadata from the match data object.\n */\nexport const extractPlayerMetadata = (\n  matchData: Server.MatchData,\n  playerID: PlayerID\n): Server.PlayerMetadata => {\n  if (matchData && matchData.players) {\n    return matchData.players[playerID];\n  }\n};\n\n/**\n * Class that provides authentication methods to the lobby server & transport.\n */\nexport class Auth {\n  private readonly shouldAuthenticate = doesMatchRequireAuthentication;\n  private readonly authenticate = areCredentialsAuthentic;\n\n  /**\n   * Generate credentials string from the Koa context.\n   */\n  public readonly generateCredentials: Server.GenerateCredentials = () =>\n    nanoid();\n\n  constructor(\n    opts: {\n      authenticateCredentials?: Server.AuthenticateCredentials;\n      generateCredentials?: Server.GenerateCredentials;\n    } = {}\n  ) {\n    if (typeof opts.authenticateCredentials === 'function') {\n      this.authenticate = opts.authenticateCredentials;\n      this.shouldAuthenticate = () => true;\n    }\n    if (typeof opts.generateCredentials === 'function') {\n      this.generateCredentials = opts.generateCredentials;\n    }\n  }\n\n  /**\n   * Resolves to true if the provided credentials are valid for the given\n   * metadata and player IDs, or if the match does not require authentication.\n   */\n  public authenticateCredentials({\n    playerID,\n    credentials,\n    metadata,\n  }: {\n    playerID: string;\n    credentials: string | undefined;\n    metadata: Server.MatchData;\n  }) {\n    const playerMetadata = extractPlayerMetadata(metadata, playerID);\n    return this.shouldAuthenticate(metadata)\n      ? this.authenticate(credentials, playerMetadata)\n      : true;\n  }\n}\n"
  },
  {
    "path": "src/server/cors.test.ts",
    "content": "import { EventEmitter } from 'events';\nimport cors from 'cors';\nimport type { Origins as OriginsTS } from './cors';\nlet { Origins } = require('./cors') as { Origins: typeof OriginsTS };\n\ndescribe('localhost origin', () => {\n  const middleware = cors({ origin: [Origins.LOCALHOST] });\n\n  test('allows localhost', () => {\n    const origin = 'http://localhost:8000/';\n    const req = createMockRequest(origin);\n    const res = new MockResponse();\n    middleware(req, res, () => {});\n    expect(res._headers['access-control-allow-origin']).toBe(origin);\n  });\n\n  test('disallows other origins', () => {\n    const req = createMockRequest('http://example.com/');\n    const res = new MockResponse();\n    middleware(req, res, () => {});\n    expect('access-control-allow-origin' in res._headers).toBe(false);\n  });\n});\n\ndescribe('development-only localhost origin', () => {\n  const reloadOriginsModule = () => {\n    jest.resetModules();\n    ({ Origins } = require('./cors'));\n  };\n\n  const oldNodeEnv = process.env.NODE_ENV;\n\n  afterEach(() => {\n    process.env.NODE_ENV = oldNodeEnv;\n    reloadOriginsModule();\n  });\n\n  const origin = 'http://localhost:8000/';\n\n  describe('development environment', () => {\n    test('allows localhost', () => {\n      const middleware = cors({ origin: [Origins.LOCALHOST_IN_DEVELOPMENT] });\n      const req = createMockRequest(origin);\n      const res = new MockResponse();\n      middleware(req, res, () => {});\n      expect(res._headers['access-control-allow-origin']).toBe(origin);\n    });\n  });\n\n  describe('production environment', () => {\n    beforeEach(() => {\n      process.env.NODE_ENV = 'production';\n      reloadOriginsModule();\n    });\n\n    test('disallows localhost', () => {\n      const middleware = cors({ origin: [Origins.LOCALHOST_IN_DEVELOPMENT] });\n      const req = createMockRequest(origin);\n      const res = new MockResponse();\n      middleware(req, res, () => {});\n      expect('access-control-allow-origin' in res._headers).toBe(false);\n    });\n\n    test('disallows random URL', () => {\n      const middleware = cors({ origin: [Origins.LOCALHOST_IN_DEVELOPMENT] });\n      const req = createMockRequest('http://example.com/');\n      const res = new MockResponse();\n      middleware(req, res, () => {});\n      expect('access-control-allow-origin' in res._headers).toBe(false);\n    });\n\n    test('allows URL when set alongside localhost', () => {\n      const origin = 'http://example.com/';\n      const middleware = cors({\n        origin: [Origins.LOCALHOST_IN_DEVELOPMENT, origin],\n      });\n      const req = createMockRequest(origin);\n      const res = new MockResponse();\n      middleware(req, res, () => {});\n      expect(res._headers['access-control-allow-origin']).toBe(origin);\n    });\n  });\n});\n\n/**\n * Create a fake request object from the given origin.\n */\nfunction createMockRequest(origin: string): cors.CorsRequest {\n  return { headers: { origin } };\n}\n\n/**\n * Class mocking the interface of the request object expected by the\n * CORS middleware package.\n */\nclass MockResponse extends EventEmitter {\n  _headers: Record<string, string>;\n  statusCode: number;\n\n  constructor() {\n    super();\n    this._headers = {};\n    this.statusCode = 200;\n  }\n\n  end() {\n    process.nextTick(\n      function () {\n        this.emit('finish');\n      }.bind(this)\n    );\n  }\n\n  getHeader(name: string) {\n    return this._headers[name.toLowerCase()];\n  }\n\n  setHeader(name: string, value: string) {\n    this._headers[name.toLowerCase()] = value;\n  }\n}\n"
  },
  {
    "path": "src/server/cors.ts",
    "content": "const LOCALHOST = /localhost:\\d+/;\n\nexport const Origins = {\n  LOCALHOST,\n  LOCALHOST_IN_DEVELOPMENT:\n    process.env.NODE_ENV === 'production' ? false : LOCALHOST,\n};\n"
  },
  {
    "path": "src/server/db/base.ts",
    "content": "import type { Object } from 'ts-toolbelt';\nimport type { State, Server, LogEntry } from '../../types';\n\nexport enum Type {\n  SYNC = 0,\n  ASYNC = 1,\n}\n\n/**\n * Type guard that checks if a storage implementation is synchronous.\n */\nexport function isSynchronous(storageAPI: Sync | Async): storageAPI is Sync {\n  return storageAPI.type() === Type.SYNC;\n}\n\n/**\n * Indicates which fields the fetch operation should return.\n */\nexport interface FetchOpts {\n  state?: boolean;\n  log?: boolean;\n  metadata?: boolean;\n  initialState?: boolean;\n}\n\n/**\n * Data that can be retrieved from a database fetch query\n */\nexport interface FetchFields {\n  state: State;\n  log: LogEntry[];\n  metadata: Server.MatchData;\n  initialState: State;\n}\n\n/**\n * The result of the fetch operation.\n */\nexport type FetchResult<O extends FetchOpts> = Object.Pick<\n  FetchFields,\n  Object.SelectKeys<O, true>\n>;\n\n/**\n * Options passed when listing matches.\n */\nexport interface ListMatchesOpts {\n  gameName?: string;\n  where?: {\n    isGameover?: boolean;\n    updatedBefore?: number;\n    updatedAfter?: number;\n  };\n}\n\n/**\n * @deprecated Use ListMatchesOpts instead\n */\nexport interface ListGamesOpts {\n  gameName?: string;\n  where?: {\n    isGameover?: boolean;\n    updatedBefore?: number;\n    updatedAfter?: number;\n  };\n}\n\n/**\n * Options passed when creating a new match.\n */\nexport interface CreateMatchOpts {\n  initialState: State;\n  metadata: Server.MatchData;\n}\n\n/**\n * @deprecated Use CreateMatchOpts instead\n */\nexport interface CreateGameOpts {\n  initialState: State;\n  metadata: Server.MatchData;\n}\n\nexport abstract class Async {\n  /* istanbul ignore next */\n  type() {\n    /* istanbul ignore next */\n    return Type.ASYNC;\n  }\n\n  /**\n   * Connect.\n   */\n  abstract connect();\n\n  /**\n   * Create a new match.\n   *\n   * This might just need to call setState and setMetadata in\n   * most implementations.\n   *\n   * However, it exists as a separate call so that the\n   * implementation can provision things differently when\n   * a match is created.  For example, it might stow away the\n   * initial match state in a separate field for easier retrieval.\n   */\n  /* istanbul ignore next */\n  async createMatch(matchID: string, opts: CreateMatchOpts): Promise<void> {\n    if (this.createGame) {\n      console.warn(\n        'The database connector does not implement a createMatch method.',\n        '\\nUsing the deprecated createGame method instead.'\n      );\n      return this.createGame(matchID, opts);\n    } else {\n      console.error(\n        'The database connector does not implement a createMatch method.'\n      );\n    }\n  }\n\n  /**\n   * Create a new game.\n   *\n   * This might just need to call setState and setMetadata in\n   * most implementations.\n   *\n   * However, it exists as a separate call so that the\n   * implementation can provision things differently when\n   * a game is created.  For example, it might stow away the\n   * initial game state in a separate field for easier retrieval.\n   *\n   * @deprecated Use createMatch instead, if implemented\n   */\n  async createGame?(matchID: string, opts: CreateGameOpts): Promise<void>;\n\n  /**\n   * Update the game state.\n   *\n   * If passed a deltalog array, setState should append its contents to the\n   * existing log for this game.\n   */\n  abstract setState(\n    matchID: string,\n    state: State,\n    deltalog?: LogEntry[]\n  ): Promise<void>;\n\n  /**\n   * Update the game metadata.\n   */\n  abstract setMetadata(\n    matchID: string,\n    metadata: Server.MatchData\n  ): Promise<void>;\n\n  /**\n   * Fetch the game state.\n   */\n  abstract fetch<O extends FetchOpts>(\n    matchID: string,\n    opts: O\n  ): Promise<FetchResult<O>>;\n\n  /**\n   * Remove the game state.\n   */\n  abstract wipe(matchID: string): Promise<void>;\n\n  /**\n   * Return all matches.\n   */\n  /* istanbul ignore next */\n  async listMatches(opts?: ListMatchesOpts): Promise<string[]> {\n    if (this.listGames) {\n      console.warn(\n        'The database connector does not implement a listMatches method.',\n        '\\nUsing the deprecated listGames method instead.'\n      );\n      return this.listGames(opts);\n    } else {\n      console.error(\n        'The database connector does not implement a listMatches method.'\n      );\n    }\n  }\n\n  /**\n   * Return all games.\n   *\n   * @deprecated Use listMatches instead, if implemented\n   */\n  async listGames?(opts?: ListGamesOpts): Promise<string[]>;\n}\n\nexport abstract class Sync {\n  type() {\n    return Type.SYNC;\n  }\n\n  /**\n   * Connect.\n   */\n  connect() {\n    return;\n  }\n\n  /**\n   * Create a new match.\n   *\n   * This might just need to call setState and setMetadata in\n   * most implementations.\n   *\n   * However, it exists as a separate call so that the\n   * implementation can provision things differently when\n   * a match is created.  For example, it might stow away the\n   * initial match state in a separate field for easier retrieval.\n   */\n  /* istanbul ignore next */\n  createMatch(matchID: string, opts: CreateMatchOpts): void {\n    if (this.createGame) {\n      console.warn(\n        'The database connector does not implement a createMatch method.',\n        '\\nUsing the deprecated createGame method instead.'\n      );\n      return this.createGame(matchID, opts);\n    } else {\n      console.error(\n        'The database connector does not implement a createMatch method.'\n      );\n    }\n  }\n\n  /**\n   * Create a new game.\n   *\n   * This might just need to call setState and setMetadata in\n   * most implementations.\n   *\n   * However, it exists as a separate call so that the\n   * implementation can provision things differently when\n   * a game is created.  For example, it might stow away the\n   * initial game state in a separate field for easier retrieval.\n   *\n   * @deprecated Use createMatch instead, if implemented\n   */\n  createGame?(matchID: string, opts: CreateGameOpts): void;\n\n  /**\n   * Update the match state.\n   *\n   * If passed a deltalog array, setState should append its contents to the\n   * existing log for this match.\n   */\n  abstract setState(matchID: string, state: State, deltalog?: LogEntry[]): void;\n\n  /**\n   * Update the match metadata.\n   */\n  abstract setMetadata(matchID: string, metadata: Server.MatchData): void;\n\n  /**\n   * Fetch the match state.\n   */\n  abstract fetch<O extends FetchOpts>(matchID: string, opts: O): FetchResult<O>;\n\n  /**\n   * Remove the match state.\n   */\n  abstract wipe(matchID: string): void;\n\n  /**\n   * Return all matches.\n   */\n  /* istanbul ignore next */\n  listMatches(opts?: ListMatchesOpts): string[] {\n    if (this.listGames) {\n      console.warn(\n        'The database connector does not implement a listMatches method.',\n        '\\nUsing the deprecated listGames method instead.'\n      );\n      return this.listGames(opts);\n    } else {\n      console.error(\n        'The database connector does not implement a listMatches method.'\n      );\n    }\n  }\n\n  /**\n   * Return all games.\n   *\n   * @deprecated Use listMatches instead, if implemented\n   */\n  listGames?(opts?: ListGamesOpts): string[];\n}\n"
  },
  {
    "path": "src/server/db/flatfile.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { FlatFile } from './flatfile';\nimport type { State, Server, LogEntry } from '../../types';\n\ndescribe('FlatFile', () => {\n  let db: FlatFile;\n\n  beforeAll(async () => {\n    db = new FlatFile({ dir: './tmp', logging: false });\n    await db.connect();\n  });\n\n  afterEach(async () => {\n    await db.clear();\n  });\n\n  test('basic', async () => {\n    // Must return undefined when no game exists.\n    const result = await db.fetch('matchID', { state: true });\n    expect(result.state).toEqual(undefined);\n\n    // Create game.\n    const state: unknown = { a: 1 };\n    const metadata: unknown = { metadata: true };\n\n    await db.createMatch('matchID', {\n      initialState: state as State,\n      metadata: metadata as Server.MatchData,\n    });\n\n    // Must return created game.\n    {\n      const result = await db.fetch('matchID', {\n        state: true,\n        metadata: true,\n        initialState: true,\n      });\n      expect(result.state).toEqual({ a: 1 });\n      expect(result.initialState).toEqual(result.state);\n      expect(result.metadata).toEqual({ metadata: true });\n    }\n\n    // Must return all keys\n    const keys = await db.listMatches();\n    expect(keys).toEqual(['matchID']);\n\n    // Must remove match from DB\n    await db.wipe('matchID');\n    expect(\n      await db.fetch('matchID', { metadata: true, state: true, log: true })\n    ).toEqual({});\n\n    // Shall not return error\n    await db.wipe('matchID');\n\n    // Shall create match, then clear DB, then check whether DB is cleared\n    await db.setState('game2', state as State);\n    await db.clear();\n    const keys2 = await db.listMatches();\n    expect(keys2).toHaveLength(0);\n  });\n\n  test('log', async () => {\n    const logEntry1: LogEntry = {\n      _stateID: 0,\n      action: {\n        type: 'MAKE_MOVE',\n        payload: { type: '', playerID: '0', args: [] },\n      },\n      turn: 0,\n      phase: '',\n    };\n\n    const logEntry2: LogEntry = {\n      _stateID: 1,\n      action: {\n        type: 'MAKE_MOVE',\n        payload: { type: '', playerID: '0', args: [] },\n      },\n      turn: 1,\n      phase: '',\n    };\n\n    await db.setState('matchID', null, [logEntry1]);\n    await db.setState('matchID', null, [logEntry2]);\n\n    const result = await db.fetch('matchID', { log: true });\n    expect(result.log).toEqual([logEntry1, logEntry2]);\n  });\n\n  describe('listMatches', () => {\n    beforeEach(async () => {\n      const state: unknown = { a: 1 };\n\n      await db.createMatch('matchID', {\n        initialState: state as State,\n        metadata: {\n          gameName: 'game1',\n          updatedAt: new Date(2020, 3).getTime(),\n        } as Server.MatchData,\n      });\n\n      await db.createMatch('matchID2', {\n        initialState: state as State,\n        metadata: {\n          gameName: 'game1',\n          gameover: 'gameover',\n          updatedAt: new Date(2020, 5).getTime(),\n        } as Server.MatchData,\n      });\n\n      await db.createMatch('matchID3', {\n        initialState: state as State,\n        metadata: {\n          gameName: 'game2',\n          updatedAt: new Date(2020, 4).getTime(),\n        } as Server.MatchData,\n      });\n    });\n\n    test('filter by gameName', async () => {\n      let keys = await db.listMatches();\n      expect(keys).toEqual(\n        expect.arrayContaining(['matchID', 'matchID2', 'matchID3'])\n      );\n\n      keys = await db.listMatches({ gameName: 'game1' });\n      expect(keys).toEqual(expect.arrayContaining(['matchID', 'matchID2']));\n\n      keys = await db.listMatches({ gameName: 'game2' });\n      expect(keys).toEqual(['matchID3']);\n    });\n\n    test('filter by isGameover', async () => {\n      let keys = await db.listMatches({});\n\n      expect(keys).toEqual(\n        expect.arrayContaining(['matchID', 'matchID2', 'matchID3'])\n      );\n\n      keys = await db.listMatches({ where: { isGameover: true } });\n      expect(keys).toEqual(['matchID2']);\n\n      keys = await db.listMatches({ where: { isGameover: false } });\n      expect(keys).toEqual(expect.arrayContaining(['matchID', 'matchID3']));\n    });\n\n    test('filter by updatedBefore', async () => {\n      const timestamp = new Date(2020, 4);\n\n      let keys = await db.listMatches({});\n      expect(keys).toEqual(\n        expect.arrayContaining(['matchID', 'matchID2', 'matchID3'])\n      );\n\n      keys = await db.listMatches({\n        where: { updatedBefore: timestamp.getTime() },\n      });\n      expect(keys).toEqual(expect.arrayContaining(['matchID']));\n    });\n\n    test('filter by updatedAfter', async () => {\n      const timestamp = new Date(2020, 4);\n\n      let keys = await db.listMatches({});\n      expect(keys).toEqual(\n        expect.arrayContaining(['matchID', 'matchID2', 'matchID3'])\n      );\n\n      keys = await db.listMatches({\n        where: { updatedAfter: timestamp.getTime() },\n      });\n      expect(keys).toEqual(['matchID2']);\n    });\n\n    test('filter combined', async () => {\n      const timestamp = new Date(2020, 4);\n      const timestamp2 = new Date(2020, 2, 15);\n      let keys = await db.listMatches({\n        gameName: 'chess',\n        where: { isGameover: true },\n      });\n      expect(keys).toEqual([]);\n\n      keys = await db.listMatches({\n        where: { isGameover: true, updatedBefore: timestamp.getTime() },\n      });\n      expect(keys).toEqual([]);\n\n      keys = await db.listMatches({\n        where: { isGameover: false, updatedBefore: timestamp.getTime() },\n      });\n      expect(keys).toEqual(['matchID']);\n\n      keys = await db.listMatches({\n        where: { isGameover: true, updatedAfter: timestamp.getTime() },\n      });\n      expect(keys).toEqual(['matchID2']);\n\n      keys = await db.listMatches({\n        where: { isGameover: false, updatedAfter: timestamp.getTime() },\n      });\n      expect(keys).toEqual([]);\n\n      keys = await db.listMatches({\n        where: {\n          updatedBefore: timestamp.getTime(),\n          updatedAfter: timestamp2.getTime(),\n        },\n      });\n      expect(keys).toEqual(['matchID']);\n    });\n  });\n});\n"
  },
  {
    "path": "src/server/db/flatfile.ts",
    "content": "import * as StorageAPI from './base';\nimport type { State, Server, LogEntry } from '../../types';\n\n/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\ninterface InitOptions {\n  dir: string;\n  logging?: boolean;\n  ttl?: boolean;\n}\n\n/**\n * FlatFile data storage.\n */\nexport class FlatFile extends StorageAPI.Async {\n  private games: {\n    init: (opts: InitOptions) => Promise<void>;\n    setItem: (id: string, value: any) => Promise<any>;\n    getItem: (id: string) => Promise<State | Server.MatchData | LogEntry[]>;\n    removeItem: (id: string) => Promise<void>;\n    clear: () => void;\n    keys: () => Promise<string[]>;\n  };\n  private dir: string;\n  private logging?: boolean;\n  private ttl?: boolean;\n  private fileQueues: { [key: string]: Promise<any> };\n\n  constructor({ dir, logging, ttl }: InitOptions) {\n    super();\n    this.games = require('node-persist');\n    this.dir = dir;\n    this.logging = logging || false;\n    this.ttl = ttl || false;\n    this.fileQueues = {};\n  }\n\n  private async chainRequest(\n    key: string,\n    request: () => Promise<any>\n  ): Promise<any> {\n    if (!(key in this.fileQueues)) this.fileQueues[key] = Promise.resolve();\n\n    this.fileQueues[key] = this.fileQueues[key].then(request, request);\n    return this.fileQueues[key];\n  }\n\n  private async getItem<T extends any = any>(key: string): Promise<T> {\n    return this.chainRequest(key, () => this.games.getItem(key));\n  }\n\n  private async setItem<T extends any = any>(\n    key: string,\n    value: T\n  ): Promise<any> {\n    return this.chainRequest(key, () => this.games.setItem(key, value));\n  }\n\n  private async removeItem(key: string): Promise<void> {\n    return this.chainRequest(key, () => this.games.removeItem(key));\n  }\n\n  async connect() {\n    await this.games.init({\n      dir: this.dir,\n      logging: this.logging,\n      ttl: this.ttl,\n    });\n    return;\n  }\n\n  /**\n   * Create new match.\n   *\n   * @param matchID\n   * @param opts\n   * @override\n   */\n  async createMatch(\n    matchID: string,\n    opts: StorageAPI.CreateMatchOpts\n  ): Promise<void> {\n    // Store initial state separately for easy retrieval later.\n    const key = InitialStateKey(matchID);\n\n    await this.setItem(key, opts.initialState);\n    await this.setState(matchID, opts.initialState);\n    await this.setMetadata(matchID, opts.metadata);\n  }\n\n  async fetch<O extends StorageAPI.FetchOpts>(\n    matchID: string,\n    opts: O\n  ): Promise<StorageAPI.FetchResult<O>> {\n    const result = {} as StorageAPI.FetchFields;\n\n    if (opts.state) {\n      result.state = (await this.getItem(matchID)) as State;\n    }\n\n    if (opts.metadata) {\n      const key = MetadataKey(matchID);\n      result.metadata = (await this.getItem(key)) as Server.MatchData;\n    }\n\n    if (opts.log) {\n      const key = LogKey(matchID);\n      result.log = (await this.getItem(key)) as LogEntry[];\n    }\n\n    if (opts.initialState) {\n      const key = InitialStateKey(matchID);\n      result.initialState = (await this.getItem(key)) as State;\n    }\n\n    return result as StorageAPI.FetchResult<O>;\n  }\n\n  async clear() {\n    return this.games.clear();\n  }\n\n  async setState(id: string, state: State, deltalog?: LogEntry[]) {\n    if (deltalog && deltalog.length > 0) {\n      const key = LogKey(id);\n      const log: LogEntry[] = ((await this.getItem(key)) as LogEntry[]) || [];\n\n      await this.setItem(key, [...log, ...deltalog]);\n    }\n\n    return await this.setItem(id, state);\n  }\n\n  async setMetadata(id: string, metadata: Server.MatchData): Promise<void> {\n    const key = MetadataKey(id);\n\n    return await this.setItem(key, metadata);\n  }\n\n  async wipe(id: string) {\n    const keys = await this.games.keys();\n    if (!keys.includes(id)) return;\n\n    await this.removeItem(id);\n    await this.removeItem(InitialStateKey(id));\n    await this.removeItem(LogKey(id));\n    await this.removeItem(MetadataKey(id));\n  }\n\n  /**\n   * List matches IDs.\n   *\n   * @param opts\n   * @override\n   */\n  async listMatches(opts?: StorageAPI.ListMatchesOpts): Promise<string[]> {\n    const keys = await this.games.keys();\n    const suffix = ':metadata';\n\n    const arr = await Promise.all(\n      keys.map(async (k) => {\n        if (!k.endsWith(suffix)) {\n          return false;\n        }\n\n        const matchID = k.slice(0, k.length - suffix.length);\n\n        if (!opts) {\n          return matchID;\n        }\n\n        const game = await this.fetch(matchID, {\n          state: true,\n          metadata: true,\n        });\n\n        if (opts.gameName && opts.gameName !== game.metadata.gameName) {\n          return false;\n        }\n\n        if (opts.where !== undefined) {\n          if (typeof opts.where.isGameover !== 'undefined') {\n            const isGameover = typeof game.metadata.gameover !== 'undefined';\n            if (isGameover !== opts.where.isGameover) {\n              return false;\n            }\n          }\n\n          if (\n            typeof opts.where.updatedBefore !== 'undefined' &&\n            game.metadata.updatedAt >= opts.where.updatedBefore\n          ) {\n            return false;\n          }\n\n          if (\n            typeof opts.where.updatedAfter !== 'undefined' &&\n            game.metadata.updatedAt <= opts.where.updatedAfter\n          ) {\n            return false;\n          }\n        }\n\n        return matchID;\n      })\n    );\n\n    return arr.filter((r): r is string => typeof r === 'string');\n  }\n}\n\nfunction InitialStateKey(matchID: string) {\n  return `${matchID}:initial`;\n}\n\nfunction MetadataKey(matchID: string) {\n  return `${matchID}:metadata`;\n}\n\nfunction LogKey(matchID: string) {\n  return `${matchID}:log`;\n}\n"
  },
  {
    "path": "src/server/db/index.test.ts",
    "content": "import { DBFromEnv, FlatFile } from '.';\n\ntest('FLATFILE_DIR', () => {\n  process.env.FLATFILE_DIR = 'test';\n  const db = DBFromEnv();\n  expect(db).toBeInstanceOf(FlatFile);\n  delete process.env.FLATFILE_DIR;\n});\n"
  },
  {
    "path": "src/server/db/index.ts",
    "content": "import { InMemory } from './inmemory';\nimport { FlatFile } from './flatfile';\n\nconst DBFromEnv = () => {\n  return process.env.FLATFILE_DIR\n    ? new FlatFile({\n        dir: process.env.FLATFILE_DIR,\n      })\n    : new InMemory();\n};\n\nexport { InMemory, FlatFile, DBFromEnv };\n"
  },
  {
    "path": "src/server/db/inmemory.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport { InMemory } from './inmemory';\nimport type { State, Server } from '../../types';\n\ndescribe('InMemory', () => {\n  let db: InMemory;\n\n  beforeAll(() => {\n    db = new InMemory();\n    db.connect();\n  });\n\n  // Must return undefined when no game exists.\n  test('must return undefined when no game exists', () => {\n    const { state } = db.fetch('matchID', { state: true });\n    expect(state).toEqual(undefined);\n  });\n\n  test('createMatch', () => {\n    const stateEntry: unknown = { a: 1 };\n\n    // Create match.\n    db.createMatch('matchID', {\n      metadata: {\n        gameName: 'tic-tac-toe',\n        updatedAt: new Date(2020, 1).getTime(),\n      } as Server.MatchData,\n      initialState: stateEntry as State,\n    });\n\n    // Must return created game.\n    const { state } = db.fetch('matchID', { state: true });\n    expect(state).toEqual(stateEntry);\n\n    // Fetch initial state.\n    const { initialState } = db.fetch('matchID', { initialState: true });\n    expect(initialState).toEqual(stateEntry);\n  });\n\n  describe('listMatches', () => {\n    test('filter by gameName', () => {\n      let keys = db.listMatches();\n      expect(keys).toEqual(['matchID']);\n      keys = db.listMatches({ gameName: 'tic-tac-toe' });\n      expect(keys).toEqual(['matchID']);\n      keys = db.listMatches({ gameName: 'chess' });\n      expect(keys).toEqual([]);\n    });\n\n    test('filter by isGameover', () => {\n      const stateEntry: unknown = { a: 1 };\n      db.createMatch('matchID2', {\n        metadata: {\n          gameName: 'tic-tac-toe',\n          gameover: 'gameover',\n          updatedAt: new Date(2020, 3).getTime(),\n        } as Server.MatchData,\n        initialState: stateEntry as State,\n      });\n\n      let keys = db.listMatches({});\n      expect(keys).toEqual(['matchID', 'matchID2']);\n      keys = db.listMatches({ where: { isGameover: true } });\n      expect(keys).toEqual(['matchID2']);\n      keys = db.listMatches({ where: { isGameover: false } });\n      expect(keys).toEqual(['matchID']);\n    });\n\n    test('filter by updatedBefore', () => {\n      const stateEntry: unknown = { a: 1 };\n      db.createMatch('matchID3', {\n        metadata: {\n          gameName: 'tic-tac-toe',\n          updatedAt: new Date(2020, 5).getTime(),\n        } as Server.MatchData,\n        initialState: stateEntry as State,\n      });\n      const timestamp = new Date(2020, 4);\n\n      let keys = db.listMatches({});\n      expect(keys).toEqual(['matchID', 'matchID2', 'matchID3']);\n      keys = db.listMatches({ where: { updatedBefore: timestamp.getTime() } });\n      expect(keys).toEqual(['matchID', 'matchID2']);\n    });\n\n    test('filter by updatedAfter', () => {\n      const timestamp = new Date(2020, 4);\n\n      let keys = db.listMatches({});\n      expect(keys).toEqual(['matchID', 'matchID2', 'matchID3']);\n      keys = db.listMatches({ where: { updatedAfter: timestamp.getTime() } });\n      expect(keys).toEqual(['matchID3']);\n    });\n\n    test('filter combined', () => {\n      const timestamp = new Date(2020, 4);\n      const timestamp2 = new Date(2020, 2, 15);\n      let keys = db.listMatches({\n        gameName: 'chess',\n        where: { isGameover: true },\n      });\n      expect(keys).toEqual([]);\n      keys = db.listMatches({\n        where: { isGameover: true, updatedBefore: timestamp.getTime() },\n      });\n      expect(keys).toEqual(['matchID2']);\n      keys = db.listMatches({\n        where: { isGameover: false, updatedBefore: timestamp.getTime() },\n      });\n      expect(keys).toEqual(['matchID']);\n      keys = db.listMatches({\n        where: { isGameover: true, updatedAfter: timestamp.getTime() },\n      });\n      expect(keys).toEqual([]);\n      keys = db.listMatches({\n        where: { isGameover: false, updatedAfter: timestamp.getTime() },\n      });\n      expect(keys).toEqual(['matchID3']);\n      keys = db.listMatches({\n        where: {\n          updatedBefore: timestamp.getTime(),\n          updatedAfter: timestamp2.getTime(),\n        },\n      });\n      expect(keys).toEqual(['matchID2']);\n    });\n  });\n\n  test('remove', () => {\n    // Must remove game from DB\n    db.wipe('matchID');\n    expect(db.fetch('matchID', { state: true })).toEqual({});\n    // Shall not return error\n    db.wipe('matchID');\n  });\n});\n"
  },
  {
    "path": "src/server/db/inmemory.ts",
    "content": "import type { State, Server, LogEntry } from '../../types';\nimport * as StorageAPI from './base';\n\n/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\n/**\n * InMemory data storage.\n */\nexport class InMemory extends StorageAPI.Sync {\n  protected state: Map<string, State>;\n  protected initial: Map<string, State>;\n  protected metadata: Map<string, Server.MatchData>;\n  protected log: Map<string, LogEntry[]>;\n\n  /**\n   * Creates a new InMemory storage.\n   */\n  constructor() {\n    super();\n    this.state = new Map();\n    this.initial = new Map();\n    this.metadata = new Map();\n    this.log = new Map();\n  }\n\n  /**\n   * Create a new match.\n   *\n   * @override\n   */\n  createMatch(matchID: string, opts: StorageAPI.CreateMatchOpts) {\n    this.initial.set(matchID, opts.initialState);\n    this.setState(matchID, opts.initialState);\n    this.setMetadata(matchID, opts.metadata);\n  }\n\n  /**\n   * Write the match metadata to the in-memory object.\n   */\n  setMetadata(matchID: string, metadata: Server.MatchData) {\n    this.metadata.set(matchID, metadata);\n  }\n\n  /**\n   * Write the match state to the in-memory object.\n   */\n  setState(matchID: string, state: State, deltalog?: LogEntry[]): void {\n    if (deltalog && deltalog.length > 0) {\n      const log = this.log.get(matchID) || [];\n      this.log.set(matchID, [...log, ...deltalog]);\n    }\n    this.state.set(matchID, state);\n  }\n\n  /**\n   * Fetches state for a particular matchID.\n   */\n  fetch<O extends StorageAPI.FetchOpts>(\n    matchID: string,\n    opts: O\n  ): StorageAPI.FetchResult<O> {\n    const result = {} as StorageAPI.FetchFields;\n\n    if (opts.state) {\n      result.state = this.state.get(matchID);\n    }\n\n    if (opts.metadata) {\n      result.metadata = this.metadata.get(matchID);\n    }\n\n    if (opts.log) {\n      result.log = this.log.get(matchID) || [];\n    }\n\n    if (opts.initialState) {\n      result.initialState = this.initial.get(matchID);\n    }\n\n    return result as StorageAPI.FetchResult<O>;\n  }\n\n  /**\n   * Remove the match state from the in-memory object.\n   */\n  wipe(matchID: string) {\n    this.state.delete(matchID);\n    this.metadata.delete(matchID);\n  }\n\n  /**\n   * Return all keys.\n   *\n   * @override\n   */\n  listMatches(opts?: StorageAPI.ListMatchesOpts): string[] {\n    return [...this.metadata.entries()]\n      .filter(([, metadata]) => {\n        if (!opts) {\n          return true;\n        }\n\n        if (\n          opts.gameName !== undefined &&\n          metadata.gameName !== opts.gameName\n        ) {\n          return false;\n        }\n\n        if (opts.where !== undefined) {\n          if (opts.where.isGameover !== undefined) {\n            const isGameover = metadata.gameover !== undefined;\n            if (isGameover !== opts.where.isGameover) {\n              return false;\n            }\n          }\n\n          if (\n            opts.where.updatedBefore !== undefined &&\n            metadata.updatedAt >= opts.where.updatedBefore\n          ) {\n            return false;\n          }\n\n          if (\n            opts.where.updatedAfter !== undefined &&\n            metadata.updatedAt <= opts.where.updatedAfter\n          ) {\n            return false;\n          }\n        }\n\n        return true;\n      })\n      .map(([key]) => key);\n  }\n}\n"
  },
  {
    "path": "src/server/db/localstorage.test.ts",
    "content": "import { nanoid } from 'nanoid';\nimport { LocalStorage } from './localstorage';\nimport type { State, Server } from '../../types';\n\ndescribe('LocaLStorage', () => {\n  let db: LocalStorage;\n\n  beforeAll(() => {\n    db = new LocalStorage(nanoid());\n    db.connect();\n  });\n\n  // Must return undefined when no game exists.\n  test('must return undefined when no game exists', () => {\n    const { state } = db.fetch('gameID', { state: true });\n    expect(state).toEqual(undefined);\n  });\n\n  test('create game', () => {\n    const stateEntry: unknown = { a: 1 };\n\n    // Create game.\n    db.createMatch('gameID', {\n      metadata: {\n        gameName: 'tic-tac-toe',\n      } as Server.MatchData,\n      initialState: stateEntry as State,\n    });\n\n    // Must return created game.\n    const { state } = db.fetch('gameID', { state: true });\n    expect(state).toEqual(stateEntry);\n\n    // Fetch initial state.\n    const { initialState } = db.fetch('gameID', { initialState: true });\n    expect(initialState).toEqual(stateEntry);\n  });\n\n  test('listGames', () => {\n    let keys = db.listMatches({});\n    expect(keys).toEqual(['gameID']);\n    keys = db.listMatches({ gameName: 'tic-tac-toe' });\n    expect(keys).toEqual(['gameID']);\n    keys = db.listMatches({ gameName: 'chess' });\n    expect(keys).toEqual([]);\n  });\n\n  test('remove', () => {\n    // Must remove game from DB\n    db.wipe('gameID');\n    expect(db.fetch('gameID', { state: true })).toEqual({});\n    // Shall not return error\n    db.wipe('gameID');\n  });\n\n  test('must create new empty db if other localstorage key is used', () => {\n    // create another localstorage with anothr key\n    const db2 = new LocalStorage(nanoid());\n    const stateEntry: unknown = { a: 1 };\n\n    // create game in db\n    db.createMatch('gameID', {\n      metadata: {\n        gameName: 'tic-tac-toe',\n      } as Server.MatchData,\n      initialState: stateEntry as State,\n    });\n\n    // game shouldnt be visible in db2\n    const { state } = db2.fetch('gameID', { state: true });\n    expect(state).toEqual(undefined);\n  });\n});\n"
  },
  {
    "path": "src/server/db/localstorage.ts",
    "content": "import { InMemory } from './inmemory';\n\nclass WithLocalStorageMap<Key, Value> extends Map {\n  key: string;\n\n  constructor(key: string) {\n    super();\n    this.key = key;\n    const cache = JSON.parse(localStorage.getItem(this.key)) || [];\n    cache.forEach((entry: [Key, Value]) => this.set(...entry));\n  }\n\n  sync(): void {\n    const entries = [...this.entries()];\n    localStorage.setItem(this.key, JSON.stringify(entries));\n  }\n\n  set(key: Key, value: Value): this {\n    super.set(key, value);\n    this.sync();\n    return this;\n  }\n\n  delete(key: Key): boolean {\n    const result = super.delete(key);\n    this.sync();\n    return result;\n  }\n}\n\n/**\n * locaStorage data storage.\n */\nexport class LocalStorage extends InMemory {\n  constructor(storagePrefix = 'bgio') {\n    super();\n    const StorageMap = (stateKey: string) =>\n      new WithLocalStorageMap(`${storagePrefix}_${stateKey}`);\n    this.state = StorageMap('state');\n    this.initial = StorageMap('initial');\n    this.metadata = StorageMap('metadata');\n    this.log = StorageMap('log');\n  }\n}\n"
  },
  {
    "path": "src/server/index.test.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport request from 'supertest';\n\nimport { Server, createServerRunConfig, getPortFromServer } from '.';\nimport type { KoaServer } from '.';\nimport type { SocketIO } from './transport/socketio';\nimport type { Game, StorageAPI } from '../types';\n\nconst game: Game = { seed: 0 };\n\nconst warn = jest.spyOn(console, 'warn').mockImplementation(() => {});\nbeforeEach(warn.mockReset);\nafterAll(warn.mockRestore);\n\njest.mock('../core/logger', () => ({\n  info: () => {},\n  error: () => {},\n}));\n\njest.mock('koa-socket-2', () => {\n  class MockSocket {\n    on() {}\n  }\n\n  return class {\n    constructor() {\n      (this as any).socket = new MockSocket();\n    }\n    attach(app) {\n      app.io = app._io = this;\n    }\n    of() {\n      return this;\n    }\n    on(type, callback) {\n      callback((this as any).socket);\n    }\n    adapter() {\n      return this;\n    }\n  };\n});\n\ndescribe('new', () => {\n  test('custom db implementation', () => {\n    const game: Game = {};\n    const db = {} as StorageAPI.Sync;\n    const server = Server({ games: [game], db });\n    expect(server.db).toBe(db);\n  });\n\n  test('custom transport implementation', () => {\n    const game: Game = {};\n    const transport = { init: jest.fn() } as unknown as SocketIO;\n    Server({ games: [game], transport });\n    expect(transport.init).toBeCalled();\n  });\n\n  test('custom auth implementation', () => {\n    const game: Game = {};\n    const authenticateCredentials = () => true;\n    const server = Server({ games: [game], authenticateCredentials });\n    expect(server.db).not.toBeNull();\n  });\n\n  test('logs a warning if origins not set', () => {\n    Server({ games: [{}] });\n    expect(warn).toHaveBeenCalledWith(\n      expect.stringContaining('Server `origins` option is not set.')\n    );\n  });\n\n  test('does not log a warning if origins set', () => {\n    Server({ games: [{}], origins: [] });\n    expect(warn).not.toHaveBeenCalled();\n  });\n});\n\ndescribe('run', () => {\n  let server: ReturnType<typeof Server> | null;\n  let runningServer: { appServer: KoaServer; apiServer?: KoaServer } | null;\n\n  beforeEach(() => {\n    server = null;\n    runningServer = null;\n  });\n\n  afterEach(() => {\n    if (server && runningServer) {\n      const { apiServer, appServer } = runningServer;\n      server.kill({ apiServer, appServer });\n    }\n  });\n\n  test('single server running', async () => {\n    server = Server({ games: [game] });\n    runningServer = await server.run(undefined);\n\n    expect(server).not.toBeUndefined();\n    expect(runningServer.appServer).not.toBeUndefined();\n    expect(runningServer.apiServer).toBeUndefined();\n  });\n\n  test('multiple servers running', async () => {\n    server = Server({ games: [game] });\n    runningServer = await server.run({\n      port: 57890,\n      lobbyConfig: { apiPort: 57891 },\n    });\n\n    expect(server).not.toBeUndefined();\n    expect(runningServer.appServer).not.toBeUndefined();\n    expect(runningServer.apiServer).not.toBeUndefined();\n  });\n\n  test('calls app callback', async () => {\n    const callback = jest.fn();\n    server = Server({ games: [game] });\n    runningServer = await server.run({ callback });\n    expect(callback).toHaveBeenCalled();\n  });\n\n  test('calls API callback', async () => {\n    const apiCallback = jest.fn();\n    server = Server({ games: [game] });\n    runningServer = await server.run({\n      lobbyConfig: { apiPort: 9999, apiCallback },\n    });\n    expect(apiCallback).toHaveBeenCalled();\n  });\n\n  test('runs route middleware', async () => {\n    const usedMiddleware = jest.fn(async (_ctx, next) => {\n      await next;\n    });\n    const unusedMiddleware = jest.fn(async (_ctx, next) => {\n      await next;\n    });\n    server = Server({ games: [game] });\n    server.router.use('/games', usedMiddleware);\n    server.router.use('/games/unused', unusedMiddleware);\n    runningServer = await server.run(8888);\n\n    await request(runningServer.appServer).get('/games');\n    expect(usedMiddleware).toHaveBeenCalled();\n    expect(unusedMiddleware).not.toHaveBeenCalled();\n  });\n});\n\ndescribe('kill', () => {\n  test('call close on both servers', async () => {\n    const apiServer = {\n      close: jest.fn(),\n    } as unknown as KoaServer;\n    const appServer = {\n      close: jest.fn(),\n    } as unknown as KoaServer;\n    const server = Server({ games: [game] });\n\n    server.kill({ appServer, apiServer });\n\n    expect(apiServer.close).toBeCalled();\n    expect(appServer.close).toBeCalled();\n  });\n\n  test('do not fail if api server is not defined', async () => {\n    const appServer = {\n      close: jest.fn(),\n    } as unknown as KoaServer;\n    const server = Server({ games: [game] });\n\n    expect(() => server.kill({ appServer })).not.toThrowError();\n    expect(appServer.close).toBeCalled();\n  });\n});\n\ndescribe('createServerRunConfig', () => {\n  // TODO use data-driven-test here after upgrading to Jest 23+.\n  test('should return valid config with different server run arguments', () => {\n    const mockCallback = () => {};\n    const mockApiCallback = () => {};\n\n    expect(createServerRunConfig(8000)).toEqual({\n      port: 8000,\n      callback: undefined,\n    });\n    expect(createServerRunConfig(8000, mockCallback)).toEqual({\n      port: 8000,\n      callback: mockCallback,\n    });\n\n    expect(createServerRunConfig({})).toEqual({\n      port: undefined,\n      callback: undefined,\n    });\n    expect(createServerRunConfig({ port: 1234 })).toEqual({\n      port: 1234,\n      callback: undefined,\n    });\n    expect(\n      createServerRunConfig({ port: 1234, callback: mockCallback })\n    ).toEqual({\n      port: 1234,\n      callback: mockCallback,\n    });\n\n    expect(\n      createServerRunConfig({ port: 1234, lobbyConfig: { apiPort: 5467 } })\n    ).toEqual({\n      port: 1234,\n      callback: undefined,\n      lobbyConfig: { apiPort: 5467 },\n    });\n    expect(\n      createServerRunConfig({\n        port: 1234,\n        callback: mockCallback,\n        lobbyConfig: {\n          apiPort: 5467,\n          apiCallback: mockApiCallback,\n        },\n      })\n    ).toEqual({\n      port: 1234,\n      callback: mockCallback,\n      lobbyConfig: {\n        apiPort: 5467,\n        apiCallback: mockApiCallback,\n      },\n    });\n  });\n});\n\ndescribe('getPortFromServer', () => {\n  test('returns null', () => {\n    expect(\n      getPortFromServer({\n        address: () => null,\n      } as KoaServer)\n    ).toBeNull();\n  });\n\n  test('returns port', () => {\n    expect(\n      getPortFromServer({\n        address: () => '8000',\n      } as KoaServer)\n    ).toBe('8000');\n  });\n\n  test('returns port from address object', () => {\n    expect(\n      getPortFromServer({\n        address: () => ({ port: '8000' }),\n      } as unknown as KoaServer)\n    ).toBe('8000');\n  });\n});\n"
  },
  {
    "path": "src/server/index.ts",
    "content": "/*\n * Copyright 2017 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport Koa from 'koa';\nimport Router from '@koa/router';\nimport type { CorsOptions } from 'cors';\n\nimport { configureRouter, configureApp } from './api';\nimport { DBFromEnv } from './db';\nimport { ProcessGameConfig } from '../core/game';\nimport * as logger from '../core/logger';\nimport { Auth } from './auth';\nimport { SocketIO } from './transport/socketio';\nimport type { Server as ServerTypes, Game, StorageAPI } from '../types';\n\nexport type KoaServer = ReturnType<Koa['listen']>;\n\ninterface ServerConfig {\n  port?: number;\n  callback?: () => void;\n  lobbyConfig?: {\n    apiPort: number;\n    apiCallback?: () => void;\n  };\n}\n\ninterface HttpsOptions {\n  cert: string;\n  key: string;\n}\n\n/**\n * Build config object from server run arguments.\n */\nexport const createServerRunConfig = (\n  portOrConfig: number | ServerConfig,\n  callback?: () => void\n): ServerConfig =>\n  portOrConfig && typeof portOrConfig === 'object'\n    ? {\n        ...portOrConfig,\n        callback: portOrConfig.callback || callback,\n      }\n    : { port: portOrConfig as number, callback };\n\nexport const getPortFromServer = (\n  server: KoaServer\n): string | number | null => {\n  const address = server.address();\n  if (typeof address === 'string') return address;\n  if (address === null) return null;\n  return address.port;\n};\n\ninterface ServerOpts {\n  games: Game[];\n  origins?: CorsOptions['origin'];\n  apiOrigins?: CorsOptions['origin'];\n  db?: StorageAPI.Async | StorageAPI.Sync;\n  transport?: SocketIO;\n  uuid?: () => string;\n  authenticateCredentials?: ServerTypes.AuthenticateCredentials;\n  generateCredentials?: ServerTypes.GenerateCredentials;\n  https?: HttpsOptions;\n}\n\n/**\n * Instantiate a game server.\n *\n * @param games - The games that this server will handle.\n * @param db - The interface with the database.\n * @param transport - The interface with the clients.\n * @param authenticateCredentials - Function to test player credentials.\n * @param origins - Allowed origins to use this server, e.g. `['http://localhost:3000']`.\n * @param apiOrigins - Allowed origins to use the Lobby API, defaults to `origins`.\n * @param generateCredentials - Method for API to generate player credentials.\n * @param https - HTTPS configuration options passed through to the TLS module.\n * @param lobbyConfig - Configuration options for the Lobby API server.\n */\nexport function Server({\n  games,\n  db,\n  transport,\n  https,\n  uuid,\n  origins,\n  apiOrigins = origins,\n  generateCredentials = uuid,\n  authenticateCredentials,\n}: ServerOpts) {\n  const app: ServerTypes.App = new Koa();\n\n  games = games.map((game) => ProcessGameConfig(game));\n\n  if (db === undefined) {\n    db = DBFromEnv();\n  }\n  app.context.db = db;\n\n  const auth = new Auth({ authenticateCredentials, generateCredentials });\n  app.context.auth = auth;\n\n  if (transport === undefined) {\n    transport = new SocketIO({ https });\n  }\n  if (origins === undefined) {\n    console.warn(\n      'Server `origins` option is not set.\\n' +\n        'Since boardgame.io@0.45, CORS is not enabled by default and you must ' +\n        'explicitly set the origins that are allowed to connect to the server.\\n' +\n        'See https://boardgame.io/documentation/#/api/Server'\n    );\n  }\n  transport.init(app, games, origins);\n\n  const router = new Router<any, ServerTypes.AppCtx>();\n\n  return {\n    app,\n    db,\n    auth,\n    router,\n    transport,\n\n    run: async (portOrConfig: number | ServerConfig, callback?: () => void) => {\n      const serverRunConfig = createServerRunConfig(portOrConfig, callback);\n      configureRouter({ router, db, games, uuid, auth });\n\n      // DB\n      await db.connect();\n\n      // Lobby API\n      const lobbyConfig = serverRunConfig.lobbyConfig;\n      let apiServer: KoaServer | undefined;\n      if (!lobbyConfig || !lobbyConfig.apiPort) {\n        configureApp(app, router, apiOrigins);\n      } else {\n        // Run API in a separate Koa app.\n        const api: ServerTypes.App = new Koa();\n        api.context.db = db;\n        api.context.auth = auth;\n        configureApp(api, router, apiOrigins);\n        await new Promise((resolve) => {\n          apiServer = api.listen(lobbyConfig.apiPort, resolve);\n        });\n        if (lobbyConfig.apiCallback) lobbyConfig.apiCallback();\n        logger.info(`API serving on ${getPortFromServer(apiServer)}...`);\n      }\n\n      // Run Game Server (+ API, if necessary).\n      let appServer: KoaServer;\n      await new Promise((resolve) => {\n        appServer = app.listen(serverRunConfig.port, resolve);\n      });\n      if (serverRunConfig.callback) serverRunConfig.callback();\n      logger.info(`App serving on ${getPortFromServer(appServer)}...`);\n\n      return { apiServer, appServer };\n    },\n\n    kill: (servers: { apiServer?: KoaServer; appServer: KoaServer }) => {\n      if (servers.apiServer) {\n        servers.apiServer.close();\n      }\n      servers.appServer.close();\n    },\n  };\n}\n"
  },
  {
    "path": "src/server/transport/pubsub/generic-pub-sub.ts",
    "content": "/** Generic interface for pub-subs.  */\nexport interface GenericPubSub<T> {\n  // Publish an event for a match.\n  publish(channelId: string, payload: T);\n\n  // Subscribes to events related to a single match.\n  subscribe(channelId: string, callback: (payload: T) => void): void;\n\n  // Cleans up subscription for a given channel.\n  unsubscribeAll(channelId: string);\n}\n"
  },
  {
    "path": "src/server/transport/pubsub/in-memory-pub-sub.test.ts",
    "content": "import { InMemoryPubSub } from './in-memory-pub-sub';\n\nconst CHANNEL_FOO = 'foo';\n\ndescribe('in-memory pubsub', () => {\n  it('should receive message from subscription', () => {\n    const pubSub = new InMemoryPubSub<string>();\n    const callback = jest.fn();\n    pubSub.subscribe(CHANNEL_FOO, callback);\n    const payload = 'hello world';\n    pubSub.publish(CHANNEL_FOO, payload);\n    expect(callback).toHaveBeenCalledWith(payload);\n  });\n\n  it('should receive message from two subscriptions', () => {\n    const pubSub = new InMemoryPubSub<string>();\n    const callback1 = jest.fn();\n    const callback2 = jest.fn();\n    pubSub.subscribe(CHANNEL_FOO, callback1);\n    pubSub.subscribe(CHANNEL_FOO, callback2);\n    const payload = 'hello world';\n    pubSub.publish(CHANNEL_FOO, payload);\n    expect(callback1).toHaveBeenCalledWith(payload);\n    expect(callback2).toHaveBeenCalledWith(payload);\n  });\n\n  it('should unsubscribe', () => {\n    const pubSub = new InMemoryPubSub<string>();\n    const callback = jest.fn();\n    pubSub.subscribe(CHANNEL_FOO, callback);\n    pubSub.unsubscribeAll(CHANNEL_FOO);\n    const payload = 'hello world';\n    pubSub.publish(CHANNEL_FOO, payload);\n    expect(callback).not.toHaveBeenCalled();\n  });\n\n  it('should ignore extra unsubscribe', () => {\n    const pubSub = new InMemoryPubSub<string>();\n    const callback = jest.fn();\n    pubSub.subscribe(CHANNEL_FOO, callback);\n    pubSub.unsubscribeAll(CHANNEL_FOO);\n    pubSub.unsubscribeAll(CHANNEL_FOO); // do nothing\n    const payload = 'hello world';\n    pubSub.publish(CHANNEL_FOO, payload);\n    expect(callback).not.toHaveBeenCalled();\n  });\n});\n"
  },
  {
    "path": "src/server/transport/pubsub/in-memory-pub-sub.ts",
    "content": "import type { GenericPubSub } from './generic-pub-sub';\n\nexport class InMemoryPubSub<T> implements GenericPubSub<T> {\n  callbacks: Map<string, ((payload: T) => void)[]> = new Map();\n\n  publish(channelId: string, payload: T) {\n    if (!this.callbacks.has(channelId)) {\n      return;\n    }\n    const allCallbacks = this.callbacks.get(channelId);\n    for (const callback of allCallbacks) {\n      callback(payload);\n    }\n  }\n\n  subscribe(channelId: string, callback: (payload: T) => void): void {\n    if (!this.callbacks.has(channelId)) {\n      this.callbacks.set(channelId, []);\n    }\n    this.callbacks.get(channelId).push(callback);\n  }\n\n  unsubscribeAll(channelId: string) {\n    if (this.callbacks.has(channelId)) {\n      this.callbacks.delete(channelId);\n    }\n  }\n}\n"
  },
  {
    "path": "src/server/transport/socketio-simultaneous.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { SocketOpts } from './socketio';\nimport { SocketIO } from './socketio';\nimport { Auth } from '../auth';\nimport { InMemory } from '../db';\nimport { Async } from '../db/base';\nimport { createMetadata } from '../util';\nimport { ProcessGameConfig } from '../../core/game';\nimport * as ActionCreators from '../../core/action-creators';\nimport { InitializeGame } from '../../core/initialize';\nimport { PlayerView } from '../../core/player-view';\nimport type { Master } from '../../master/master';\nimport type { Game, LogEntry, Server, State, StorageAPI } from '../../types';\n\ntype SyncArgs = Parameters<Master['onSync']>;\ntype UpdateArgs = Parameters<Master['onUpdate']>;\n\ntype SocketIOTestAdapterOpts = SocketOpts & {\n  clientInfo?: Map<any, any>;\n  roomInfo?: Map<any, any>;\n};\n\nclass InMemoryAsync extends Async {\n  db: InMemory;\n  delays: number[];\n\n  constructor() {\n    super();\n    this.db = new InMemory();\n    this.delays = [];\n  }\n\n  async connect() {\n    await this.sleep();\n  }\n\n  private sleep(): Promise<void> {\n    const interval =\n      this.delays.length > 0\n        ? this.delays.shift()\n        : Math.round(Math.random() * 50 + 50);\n    return new Promise((resolve) => void setTimeout(resolve, interval));\n  }\n\n  async createMatch(id: string, opts: StorageAPI.CreateMatchOpts) {\n    await this.sleep();\n    this.db.createMatch(id, opts);\n  }\n\n  async setMetadata(matchID: string, metadata: Server.MatchData) {\n    await this.sleep();\n    this.db.setMetadata(matchID, metadata);\n  }\n\n  async setState(matchID: string, state: State, deltalog?: LogEntry[]) {\n    await this.sleep();\n    this.db.setState(matchID, state, deltalog);\n  }\n\n  async fetch<O extends StorageAPI.FetchOpts>(\n    matchID: string,\n    opts: O\n  ): Promise<StorageAPI.FetchResult<O>> {\n    await this.sleep();\n    return this.db.fetch(matchID, opts);\n  }\n\n  async wipe(matchID: string) {\n    await this.sleep();\n    this.db.wipe(matchID);\n  }\n\n  async listMatches(opts?: StorageAPI.ListMatchesOpts): Promise<string[]> {\n    await this.sleep();\n    return this.db.listMatches(opts);\n  }\n}\n\nclass SocketIOTestAdapter extends SocketIO {\n  constructor({\n    clientInfo = new Map(),\n    roomInfo = new Map(),\n    ...args\n  }: SocketIOTestAdapterOpts = {}) {\n    super(Object.keys(args).length > 0 ? args : undefined);\n    this.clientInfo = clientInfo;\n    this.roomInfo = roomInfo;\n  }\n\n  public get getPerMatchQueue() {\n    return this.perMatchQueue;\n  }\n}\n\njest.mock('koa-socket-2', () => {\n  class MockSocket {\n    id: string;\n    callbacks: Record<string, (...args: any[]) => Promise<void>>;\n    emit: jest.Mock<any, any>;\n    broadcast: { emit: jest.Mock<any, any> };\n\n    constructor({ id }: { id: string }) {\n      this.id = id;\n      this.callbacks = {};\n      this.emit = jest.fn();\n      this.broadcast = { emit: jest.fn() };\n    }\n\n    async receive(type, ...args) {\n      await this.callbacks[type](...args);\n    }\n\n    on(type, callback) {\n      this.callbacks[type] = callback;\n    }\n\n    to() {\n      return {\n        broadcast: this.broadcast,\n        emit: this.emit,\n      };\n    }\n\n    join() {}\n  }\n\n  class MockIO {\n    sockets: Map<string, MockSocket>;\n    socketAdapter: any;\n\n    constructor() {\n      this.sockets = new Map(\n        ['0', '1'].map((id) => [id, new MockSocket({ id })])\n      );\n    }\n\n    adapter(socketAdapter) {\n      this.socketAdapter = socketAdapter;\n    }\n\n    attach(app) {\n      app.io = app._io = this;\n    }\n\n    of() {\n      return this;\n    }\n\n    on(_event, callback) {\n      this.sockets.forEach((socket) => void callback(socket));\n    }\n  }\n\n  return MockIO;\n});\n\ndescribe('simultaneous moves on server game', () => {\n  const game: Game = {\n    name: 'test',\n    setup: () => ({\n      players: {\n        '0': {\n          cards: ['card3'],\n        },\n        '1': {\n          cards: [],\n        },\n      },\n      cards: ['card0', 'card1', 'card2'],\n      discardedCards: [],\n    }),\n    playerView: PlayerView.STRIP_SECRETS,\n    turn: {\n      activePlayers: { currentPlayer: { stage: 'A' } },\n      stages: {\n        A: {\n          moves: {\n            A: {\n              client: false,\n              move: ({ G, playerID }) => {\n                const card = G.players[playerID].cards.shift();\n                G.discardedCards.push(card);\n              },\n            },\n            B: {\n              client: false,\n              ignoreStaleStateID: true,\n              move: ({ G, playerID }) => {\n                const card = G.cards.pop();\n                G.players[playerID].cards.push(card);\n              },\n            },\n          },\n        },\n      },\n    },\n  };\n\n  let app;\n  let transport: SocketIOTestAdapter;\n  let clientInfo;\n  let roomInfo;\n  let io;\n\n  beforeEach(async () => {\n    clientInfo = new Map();\n    roomInfo = new Map();\n  });\n\n  test('two clients playing using sync storage', async () => {\n    const db = new InMemory();\n    const auth = new Auth();\n    app = { context: { db, auth } };\n    transport = new SocketIOTestAdapter({\n      clientInfo,\n      roomInfo,\n    });\n    transport.init(app, [ProcessGameConfig(game)]);\n    io = app.context.io;\n    const socket0 = io.sockets.get('0');\n    const socket1 = io.sockets.get('1');\n\n    const spyGetMatchQueue = jest.spyOn(\n      SocketIOTestAdapter.prototype,\n      'getMatchQueue'\n    );\n    const spyDeleteMatchQueue = jest.spyOn(\n      SocketIOTestAdapter.prototype,\n      'deleteMatchQueue'\n    );\n\n    db.createMatch('matchID', {\n      initialState: InitializeGame({ game, numPlayers: 2 }),\n      metadata: createMetadata({\n        game: game,\n        unlisted: false,\n        numPlayers: 2,\n      }),\n    });\n\n    // Call sync for both players\n    await Promise.all([\n      (async () => {\n        const args0: SyncArgs = ['matchID', '0', undefined, 2];\n        await socket0.receive('sync', ...args0);\n      })(),\n      (async () => {\n        const args1: SyncArgs = ['matchID', '1', undefined, 2];\n        await socket1.receive('sync', ...args1);\n      })(),\n    ]);\n\n    const moveAArgs: UpdateArgs = [\n      ActionCreators.makeMove('A', null, '0'),\n      0,\n      'matchID',\n      '0',\n    ];\n\n    // Call normal move\n    await socket0.receive('update', ...moveAArgs);\n\n    // Assertions for match queue creation\n    expect(spyGetMatchQueue).toHaveBeenCalledWith('matchID');\n\n    const activePlayersArgs: UpdateArgs = [\n      ActionCreators.gameEvent('setActivePlayers', [{ all: 'A' }], '0'),\n      1,\n      'matchID',\n      '0',\n    ];\n\n    // Set all players active\n    await socket0.receive('update', ...activePlayersArgs);\n\n    // Call actions simultaeously\n    await Promise.all([\n      (async () => {\n        const moveBArgs: UpdateArgs = [\n          ActionCreators.makeMove('B', null, '1'),\n          2,\n          'matchID',\n          '1',\n        ];\n        await socket1.receive('update', ...moveBArgs);\n      })(),\n      (async () => {\n        const moveBArgs: UpdateArgs = [\n          ActionCreators.makeMove('B', null, '0'),\n          2,\n          'matchID',\n          '0',\n        ];\n        await socket0.receive('update', ...moveBArgs);\n      })(),\n    ]);\n\n    const fetchResult = db.fetch('matchID', {\n      state: true,\n      metadata: true,\n      log: true,\n    });\n\n    expect(fetchResult.state.G).toMatchObject({\n      players: {\n        '0': {\n          cards: ['card1'],\n        },\n        '1': {\n          cards: ['card2'],\n        },\n      },\n      cards: ['card0'],\n      discardedCards: ['card3'],\n    });\n\n    // Call disconnect for both players\n    await Promise.all([\n      (async () => {\n        await socket0.receive('disconnect');\n      })(),\n      (async () => {\n        await socket1.receive('disconnect');\n      })(),\n    ]);\n\n    expect(spyDeleteMatchQueue).toHaveBeenCalledWith('matchID');\n\n    db.wipe('matchID');\n  });\n\n  test('two clients playing using async storage', async () => {\n    const db = new InMemoryAsync();\n    await db.connect();\n    const auth = new Auth();\n\n    app = { context: { db, auth } };\n    transport = new SocketIOTestAdapter({\n      clientInfo,\n      roomInfo,\n    });\n    transport.init(app, [ProcessGameConfig(game)]);\n    io = app.context.io;\n    const socket0 = io.sockets.get('0');\n    const socket1 = io.sockets.get('1');\n\n    const spyGetMatchQueue = jest.spyOn(\n      SocketIOTestAdapter.prototype,\n      'getMatchQueue'\n    );\n    const spyDeleteMatchQueue = jest.spyOn(\n      SocketIOTestAdapter.prototype,\n      'deleteMatchQueue'\n    );\n\n    await db.createMatch('matchID', {\n      initialState: InitializeGame({ game, numPlayers: 2 }),\n      metadata: createMetadata({\n        game: game,\n        unlisted: false,\n        numPlayers: 2,\n      }),\n    });\n\n    // Call sync for both players\n    await Promise.all([\n      (async () => {\n        await socket0.receive('sync', 'matchID', '0', 2);\n      })(),\n      (async () => {\n        await socket1.receive('sync', 'matchID', '1', 2);\n      })(),\n    ]);\n\n    const moveAArgs: UpdateArgs = [\n      ActionCreators.makeMove('A', null, '0'),\n      0,\n      'matchID',\n      '0',\n    ];\n\n    // Call normal move\n    await socket0.receive('update', ...moveAArgs);\n\n    // Assertions for match queue creation\n    expect(spyGetMatchQueue).toHaveBeenCalledWith('matchID');\n\n    const activePlayersArgs: UpdateArgs = [\n      ActionCreators.gameEvent('setActivePlayers', [{ all: 'A' }], '0'),\n      1,\n      'matchID',\n      '0',\n    ];\n\n    // Set all players active\n    await socket0.receive('update', ...activePlayersArgs);\n\n    // Call actions simultaeously\n    await Promise.all([\n      (async () => {\n        const moveBArgs: UpdateArgs = [\n          ActionCreators.makeMove('B', null, '1'),\n          2,\n          'matchID',\n          '1',\n        ];\n        await socket1.receive('update', ...moveBArgs);\n      })(),\n      (async () => {\n        const moveBArgs: UpdateArgs = [\n          ActionCreators.makeMove('B', null, '0'),\n          2,\n          'matchID',\n          '0',\n        ];\n        await socket0.receive('update', ...moveBArgs);\n      })(),\n    ]);\n\n    const fetchResult = await db.fetch('matchID', {\n      state: true,\n      metadata: true,\n      log: true,\n    });\n\n    expect(fetchResult.state.G).toMatchObject({\n      players: {\n        '0': {\n          cards: ['card1'],\n        },\n        '1': {\n          cards: ['card2'],\n        },\n      },\n      cards: ['card0'],\n      discardedCards: ['card3'],\n    });\n\n    // Call disconnect for both players\n    await Promise.all([\n      (async () => {\n        await socket0.receive('disconnect');\n      })(),\n      (async () => {\n        await socket1.receive('disconnect');\n      })(),\n    ]);\n\n    expect(spyDeleteMatchQueue).toHaveBeenCalledWith('matchID');\n\n    await db.wipe('matchID');\n  });\n});\n\ndescribe('inauthentic clients', () => {\n  const game: Game = {\n    setup: () => ({\n      0: 'foo',\n      1: 'bar',\n    }),\n    playerView: ({ G, playerID }) => ({ [playerID]: G[playerID] }),\n  };\n\n  let app;\n  let db: InMemoryAsync;\n  let transport: SocketIOTestAdapter;\n  let clientInfo: Map<string, Record<string, any>>;\n  let roomInfo: Map<string, Set<string>>;\n  let io;\n  const matchID = 'matchID';\n  const cred0 = 'password-0';\n  const cred1 = 'password-1';\n\n  beforeEach(async () => {\n    clientInfo = new Map();\n    roomInfo = new Map();\n\n    db = new InMemoryAsync();\n    await db.connect();\n\n    app = { context: { db, auth: new Auth() } };\n    transport = new SocketIOTestAdapter({ clientInfo, roomInfo });\n    transport.init(app, [ProcessGameConfig(game)]);\n    io = app.context.io;\n\n    // Create credentialed match.\n    const metadata = createMetadata({ game, unlisted: false, numPlayers: 2 });\n    metadata.players[0].credentials = cred0;\n    metadata.players[1].credentials = cred1;\n    const initialState = InitializeGame({ game, numPlayers: 2 });\n    await db.createMatch(matchID, { initialState, metadata });\n  });\n\n  afterEach(async () => {\n    await db.wipe(matchID);\n  });\n\n  test('inauthentic client is not added to clientInfo', async () => {\n    const inauthenticID = '0';\n    const socket = io.sockets.get(inauthenticID);\n\n    const args: Parameters<Master['onSync']> = ['matchID', '0', undefined];\n    const doneReceiving = socket.receive('sync', ...args);\n    // Is not added before awaiting the game master.\n    expect(clientInfo.get(inauthenticID)).toBeUndefined();\n    await doneReceiving;\n    // Is not added after awaiting the game master.\n    expect(clientInfo.get(inauthenticID)).toBeUndefined();\n  });\n\n  test('connected inauthentic client doesn’t receive authentic client’s sync', async () => {\n    const inauthenticID = '0';\n    const authenticID = '1';\n    const inauthenticSocket = io.sockets.get(inauthenticID);\n    const authenticSocket = io.sockets.get(authenticID);\n\n    // Call sync for both players\n    {\n      const args: Parameters<Master['onSync']> = ['matchID', '0', undefined];\n      await inauthenticSocket.receive('sync', ...args);\n    }\n    {\n      const args: Parameters<Master['onSync']> = ['matchID', '0', cred0];\n      await authenticSocket.receive('sync', ...args);\n    }\n\n    expect(clientInfo.get(inauthenticID)).toBeUndefined();\n\n    expect(clientInfo.get(authenticID)).toEqual({\n      matchID,\n      playerID: '0',\n      credentials: cred0,\n      socket: authenticSocket,\n    });\n\n    expect(inauthenticSocket.emit).not.toHaveBeenCalled();\n\n    expect(authenticSocket.emit).toHaveBeenCalledWith(\n      'sync',\n      matchID,\n      expect.objectContaining({\n        state: expect.objectContaining({\n          G: {\n            0: 'foo',\n          },\n        }),\n      })\n    );\n\n    const syncEmits = authenticSocket.emit.mock.calls.filter(\n      ([type]) => type === 'sync'\n    );\n    expect(syncEmits).toHaveLength(1);\n  });\n\n  test('inauthentic client doesn’t receive authentic client’s sync while still syncing', async () => {\n    const inauthenticID = '0';\n    const authenticID = '1';\n    const inauthenticSocket = io.sockets.get(inauthenticID);\n    const authenticSocket = io.sockets.get(authenticID);\n\n    // Make db#fetch in Master#onSync for first sync resolve after second sync.\n    db.delays = [200, 0];\n\n    // Call sync for both players\n    await Promise.all([\n      (async () => {\n        const args: Parameters<Master['onSync']> = ['matchID', '0', undefined];\n        await inauthenticSocket.receive('sync', ...args);\n      })(),\n      (async () => {\n        const args: Parameters<Master['onSync']> = ['matchID', '0', cred0];\n        await authenticSocket.receive('sync', ...args);\n      })(),\n    ]);\n\n    expect(clientInfo.get(inauthenticID)).toBeUndefined();\n\n    expect(authenticSocket.emit).toHaveBeenCalledWith(\n      'sync',\n      matchID,\n      expect.objectContaining({\n        state: expect.objectContaining({\n          G: {\n            0: 'foo',\n          },\n        }),\n      })\n    );\n\n    const syncEmits = authenticSocket.emit.mock.calls.filter(\n      ([type]) => type === 'sync'\n    );\n    expect(syncEmits).toHaveLength(1);\n  });\n});\n"
  },
  {
    "path": "src/server/transport/socketio.test.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { SocketOpts } from './socketio';\nimport { TransportAPI, SocketIO } from './socketio';\nimport { Auth } from '../auth';\nimport { ProcessGameConfig } from '../../core/game';\nimport type { Master } from '../../master/master';\nimport { error } from '../../core/logger';\nimport { getFilterPlayerView } from '../../master/filter-player-view';\n\njest.mock('../../core/logger', () => ({\n  info: jest.fn(),\n  error: jest.fn(),\n}));\n\ntype SyncArgs = Parameters<Master['onSync']>;\n\ntype SocketIOTestAdapterOpts = SocketOpts & {\n  clientInfo?: Map<any, any>;\n  roomInfo?: Map<any, any>;\n};\n\nclass SocketIOTestAdapter extends SocketIO {\n  constructor({\n    clientInfo = new Map(),\n    roomInfo = new Map(),\n    ...args\n  }: SocketIOTestAdapterOpts = {}) {\n    super(Object.keys(args).length > 0 ? args : undefined);\n    this.clientInfo = clientInfo;\n    this.roomInfo = roomInfo;\n  }\n\n  public getPubSub() {\n    return this.pubSub;\n  }\n}\n\njest.mock('../../master/master', () => {\n  class Master {\n    onUpdate: jest.Mock<any, any>;\n    onSync: jest.Mock<any, any>;\n    onConnectionChange: jest.Mock<any, any>;\n    onChatMessage: jest.Mock<any, any>;\n\n    constructor() {\n      this.onUpdate = jest.fn();\n      this.onSync = jest.fn();\n      this.onConnectionChange = jest.fn();\n      this.onChatMessage = jest.fn();\n    }\n  }\n\n  return { Master };\n});\n\njest.mock('koa-socket-2', () => {\n  class MockSocket {\n    id: string;\n    callbacks: Record<string, (...args: any[]) => any>;\n    emit: jest.Mock<any, any>;\n    broadcast: { emit: jest.Mock<any, any> };\n\n    constructor() {\n      this.id = 'id';\n      this.callbacks = {};\n      this.emit = jest.fn();\n      this.broadcast = { emit: jest.fn() };\n    }\n\n    async receive(type, ...args) {\n      await this.callbacks[type](args[0], args[1], args[2], args[3], args[4]);\n      return;\n    }\n\n    on(type, callback) {\n      this.callbacks[type] = callback;\n    }\n\n    to() {\n      return {\n        broadcast: this.broadcast,\n        emit: this.emit,\n      };\n    }\n\n    join() {}\n  }\n\n  class MockIO {\n    socket: MockSocket;\n    socketAdapter: any;\n\n    constructor() {\n      this.socket = new MockSocket();\n    }\n\n    adapter(socketAdapter) {\n      this.socketAdapter = socketAdapter;\n    }\n\n    attach(app) {\n      app.io = app._io = this;\n    }\n\n    of() {\n      return this;\n    }\n\n    on(type, callback) {\n      callback(this.socket);\n    }\n  }\n\n  return MockIO;\n});\n\ndescribe('basic', () => {\n  const auth = new Auth({ authenticateCredentials: () => true });\n  const app: any = { context: { auth } };\n  const games = [ProcessGameConfig({ seed: 0 })];\n  let clientInfo;\n  let roomInfo;\n\n  beforeEach(() => {\n    clientInfo = new Map();\n    roomInfo = new Map();\n    const transport = new SocketIOTestAdapter({ clientInfo, roomInfo });\n    transport.init(app, games);\n  });\n\n  test('is attached to app', () => {\n    expect(app.context.io).toBeDefined();\n  });\n});\n\ndescribe('socketAdapter', () => {\n  const auth = new Auth({ authenticateCredentials: () => true });\n  const app: any = { context: { auth } };\n  const games = [ProcessGameConfig({ seed: 0 })];\n\n  const socketAdapter = jest.fn();\n\n  beforeEach(() => {\n    const transport = new SocketIOTestAdapter({ socketAdapter });\n    transport.init(app, games);\n  });\n\n  test('socketAdapter is passed', () => {\n    expect(app.io.socketAdapter).toBe(socketAdapter);\n  });\n});\n\ndescribe('TransportAPI', () => {\n  let io;\n  let api;\n  const matchID = 'matchID';\n\n  beforeAll(() => {\n    const auth = new Auth({ authenticateCredentials: () => true });\n    const app: any = { context: { auth } };\n    const games = [ProcessGameConfig({ seed: 0 })];\n    const clientInfo = new Map();\n    const roomInfo = new Map();\n    const transport = new SocketIOTestAdapter({ clientInfo, roomInfo });\n    transport.init(app, games);\n    io = app.context.io;\n    const socket = io.socket;\n    const filterPlayerView = getFilterPlayerView(games[0]);\n    api = TransportAPI(\n      matchID,\n      socket,\n      filterPlayerView,\n      transport.getPubSub()\n    );\n  });\n\n  beforeEach(async () => {\n    io.socket.emit = jest.fn();\n    io.socket.id = '0';\n    const args0: SyncArgs = [matchID, '0', undefined];\n    await io.socket.receive('sync', ...args0);\n    io.socket.id = '1';\n    const args1: SyncArgs = [matchID, '1', undefined];\n    await io.socket.receive('sync', ...args1);\n  });\n\n  test('send', () => {\n    io.socket.id = '0';\n    api.send({ type: 'A', playerID: '0', args: [] });\n    expect(io.socket.emit).toHaveBeenCalledWith('A');\n  });\n\n  test('sendAll - function', () => {\n    api.sendAll({ type: 'A', args: [] });\n    expect(io.socket.emit).toHaveBeenCalledTimes(2);\n    expect(io.socket.emit).toHaveBeenCalledWith('A');\n  });\n});\n\ndescribe('sync / update', () => {\n  const auth = new Auth({ authenticateCredentials: () => true });\n  const app: any = { context: { auth } };\n  const games = [ProcessGameConfig({ seed: 0 })];\n  const transport = new SocketIOTestAdapter();\n  transport.init(app, games);\n  const io = app.context.io;\n\n  test('sync', () => {\n    io.socket.receive('sync', 'matchID', '0');\n    expect(error).not.toBeCalled();\n  });\n\n  test('update', () => {\n    io.socket.receive('update');\n    expect(error).not.toBeCalled();\n  });\n});\n\ndescribe('chat', () => {\n  const app: any = { context: {} };\n  const games = [ProcessGameConfig({ seed: 0 })];\n  const transport = new SocketIOTestAdapter();\n  transport.init(app, games);\n  const io = app.context.io;\n\n  test('chat message', async () => {\n    await io.socket.receive('chat', 'matchID', { message: 'foo' });\n    expect(error).not.toBeCalled();\n  });\n});\n\ndescribe('connect / disconnect', () => {\n  const auth = new Auth({ authenticateCredentials: () => true });\n  const app: any = { context: { auth } };\n  const games = [ProcessGameConfig({ seed: 0 })];\n  let clientInfo;\n  let roomInfo;\n  let io;\n\n  beforeAll(() => {\n    clientInfo = new Map();\n    roomInfo = new Map();\n    const transport = new SocketIOTestAdapter({ clientInfo, roomInfo });\n    transport.init(app, games);\n    io = app.context.io;\n  });\n\n  test('0 and 1 connect', async () => {\n    io.socket.id = '0';\n    const args0: SyncArgs = ['matchID', '0', undefined, 2];\n    await io.socket.receive('sync', ...args0);\n    io.socket.id = '1';\n    const args1: SyncArgs = ['matchID', '1', undefined, 2];\n    await io.socket.receive('sync', ...args1);\n\n    expect(clientInfo.get('0')).toMatchObject({\n      matchID: 'matchID',\n      playerID: '0',\n    });\n    expect(clientInfo.get('1')).toMatchObject({\n      matchID: 'matchID',\n      playerID: '1',\n    });\n  });\n\n  test('0 disconnects', async () => {\n    io.socket.id = '0';\n    await io.socket.receive('disconnect');\n\n    expect(clientInfo.get('0')).toBeUndefined();\n    expect(clientInfo.get('1')).toMatchObject({\n      matchID: 'matchID',\n      playerID: '1',\n    });\n    expect([...roomInfo.get('matchID')]).toEqual(['1']);\n  });\n\n  test('unknown player disconnects', async () => {\n    io.socket.id = 'unknown';\n    await io.socket.receive('disconnect');\n\n    expect(clientInfo.get('0')).toBeUndefined();\n    expect(clientInfo.get('1')).toMatchObject({\n      matchID: 'matchID',\n      playerID: '1',\n    });\n    expect([...roomInfo.get('matchID')]).toEqual(['1']);\n  });\n\n  test('1 disconnects', async () => {\n    io.socket.id = '1';\n    await io.socket.receive('disconnect');\n    expect([...clientInfo.keys()]).toHaveLength(0);\n    expect(roomInfo.get('matchID')).toBeUndefined();\n  });\n});\n"
  },
  {
    "path": "src/server/transport/socketio.ts",
    "content": "/*\n * Copyright 2018 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nimport type { CorsOptions } from 'cors';\nimport IO from 'koa-socket-2';\nimport type IOTypes from 'socket.io';\nimport type { ServerOptions as HttpsOptions } from 'https';\nimport PQueue from 'p-queue';\nimport { Master } from '../../master/master';\nimport type {\n  TransportAPI as MasterTransport,\n  TransportData,\n} from '../../master/master';\nimport { getFilterPlayerView } from '../../master/filter-player-view';\nimport type { Game, Server } from '../../types';\nimport type { GenericPubSub } from './pubsub/generic-pub-sub';\nimport type { IntermediateTransportData } from '../../master/master';\nimport { InMemoryPubSub } from './pubsub/in-memory-pub-sub';\n\nconst PING_TIMEOUT = 20 * 1e3;\nconst PING_INTERVAL = 10 * 1e3;\n\nconst emit = (socket: IOTypes.Socket, { type, args }: TransportData) => {\n  socket.emit(type, ...args);\n};\n\nfunction getPubSubChannelId(matchID: string): string {\n  return `MATCH-${matchID}`;\n}\n\n/**\n * API that's exposed by SocketIO for the Master to send\n * information to the clients.\n */\nexport const TransportAPI = (\n  matchID: string,\n  socket: IOTypes.Socket,\n  filterPlayerView: any,\n  pubSub: GenericPubSub<IntermediateTransportData>\n): MasterTransport => {\n  const send: MasterTransport['send'] = ({ playerID, ...data }) => {\n    emit(socket, filterPlayerView(playerID, data));\n  };\n\n  /**\n   * Send a message to all clients.\n   */\n  const sendAll: MasterTransport['sendAll'] = (payload) => {\n    pubSub.publish(getPubSubChannelId(matchID), payload);\n  };\n\n  return { send, sendAll };\n};\n\nexport interface SocketOpts {\n  https?: HttpsOptions;\n  socketOpts?: IOTypes.ServerOptions;\n  socketAdapter?: any;\n  pubSub?: GenericPubSub<IntermediateTransportData>;\n}\n\ninterface Client {\n  matchID: string;\n  playerID: string;\n  socket: IOTypes.Socket;\n  credentials: string | undefined;\n}\n\n/**\n * Transport interface that uses socket.io\n */\nexport class SocketIO {\n  protected clientInfo: Map<string, Client>;\n  protected roomInfo: Map<string, Set<string>>;\n  protected perMatchQueue: Map<string, PQueue>;\n  private readonly https: HttpsOptions;\n  private readonly socketAdapter: any;\n  private readonly socketOpts: IOTypes.ServerOptions;\n  protected pubSub: GenericPubSub<IntermediateTransportData>;\n\n  constructor({ https, socketAdapter, socketOpts, pubSub }: SocketOpts = {}) {\n    this.clientInfo = new Map();\n    this.roomInfo = new Map();\n    this.perMatchQueue = new Map();\n    this.https = https;\n    this.socketAdapter = socketAdapter;\n    this.socketOpts = socketOpts;\n    this.pubSub = pubSub || new InMemoryPubSub();\n  }\n\n  /**\n   * Unregister client data for a socket.\n   */\n  private removeClient(socketID: string): void {\n    // Get client data for this socket ID.\n    const client = this.clientInfo.get(socketID);\n    if (!client) return;\n    // Remove client from list of connected sockets for this match.\n    const { matchID } = client;\n    const matchClients = this.roomInfo.get(matchID);\n    matchClients.delete(socketID);\n    // If the match is now empty, delete its promise queue & client ID list.\n    if (matchClients.size === 0) {\n      this.unsubscribePubSubChannel(matchID);\n      this.roomInfo.delete(matchID);\n      this.deleteMatchQueue(matchID);\n    }\n    // Remove client data from the client map.\n    this.clientInfo.delete(socketID);\n  }\n\n  /**\n   * Register client data for a socket.\n   */\n  private addClient(client: Client, game: Game): void {\n    const { matchID, socket } = client;\n    // Add client to list of connected sockets for this match.\n    let matchClients = this.roomInfo.get(matchID);\n    if (matchClients === undefined) {\n      this.subscribePubSubChannel(matchID, game);\n      matchClients = new Set<string>();\n      this.roomInfo.set(matchID, matchClients);\n    }\n    matchClients.add(socket.id);\n    // Register data for this socket in the client map.\n    this.clientInfo.set(socket.id, client);\n  }\n\n  private subscribePubSubChannel(matchID: string, game: Game) {\n    const filterPlayerView = getFilterPlayerView(game);\n    const broadcast = (payload: IntermediateTransportData) => {\n      this.roomInfo.get(matchID).forEach((clientID) => {\n        const client = this.clientInfo.get(clientID);\n        const data = filterPlayerView(client.playerID, payload);\n        emit(client.socket, data);\n      });\n    };\n\n    this.pubSub.subscribe(getPubSubChannelId(matchID), broadcast);\n  }\n\n  private unsubscribePubSubChannel(matchID: string) {\n    this.pubSub.unsubscribeAll(getPubSubChannelId(matchID));\n  }\n\n  init(\n    app: Server.App & { _io?: IOTypes.Server },\n    games: Game[],\n    origins: CorsOptions['origin'] = []\n  ) {\n    const io = new IO({\n      ioOptions: {\n        pingTimeout: PING_TIMEOUT,\n        pingInterval: PING_INTERVAL,\n        cors: {\n          origins,\n        },\n        ...this.socketOpts,\n      },\n    });\n\n    app.context.io = io;\n    io.attach(app, !!this.https, this.https);\n\n    if (this.socketAdapter) {\n      io.adapter(this.socketAdapter);\n    }\n\n    for (const game of games) {\n      const nsp = app._io.of(game.name);\n      const filterPlayerView = getFilterPlayerView(game);\n\n      nsp.on('connection', (socket: IOTypes.Socket) => {\n        socket.on('update', async (...args: Parameters<Master['onUpdate']>) => {\n          const [action, stateID, matchID, playerID] = args;\n          const master = new Master(\n            game,\n            app.context.db,\n            TransportAPI(matchID, socket, filterPlayerView, this.pubSub),\n            app.context.auth\n          );\n\n          const matchQueue = this.getMatchQueue(matchID);\n          await matchQueue.add(() =>\n            master.onUpdate(action, stateID, matchID, playerID)\n          );\n        });\n\n        socket.on('sync', async (...args: Parameters<Master['onSync']>) => {\n          const [matchID, playerID, credentials] = args;\n          socket.join(matchID);\n          this.removeClient(socket.id);\n          const requestingClient = { socket, matchID, playerID, credentials };\n          const transport = TransportAPI(\n            matchID,\n            socket,\n            filterPlayerView,\n            this.pubSub\n          );\n          const master = new Master(\n            game,\n            app.context.db,\n            transport,\n            app.context.auth\n          );\n\n          const syncResponse = await master.onSync(...args);\n          if (syncResponse && syncResponse.error === 'unauthorized') {\n            return;\n          }\n          this.addClient(requestingClient, game);\n          await master.onConnectionChange(matchID, playerID, credentials, true);\n        });\n\n        socket.on('disconnect', async () => {\n          const client = this.clientInfo.get(socket.id);\n          this.removeClient(socket.id);\n          if (client) {\n            const { matchID, playerID, credentials } = client;\n            const master = new Master(\n              game,\n              app.context.db,\n              TransportAPI(matchID, socket, filterPlayerView, this.pubSub),\n              app.context.auth\n            );\n            await master.onConnectionChange(\n              matchID,\n              playerID,\n              credentials,\n              false\n            );\n          }\n        });\n\n        socket.on(\n          'chat',\n          async (...args: Parameters<Master['onChatMessage']>) => {\n            const [matchID] = args;\n            const master = new Master(\n              game,\n              app.context.db,\n              TransportAPI(matchID, socket, filterPlayerView, this.pubSub),\n              app.context.auth\n            );\n            master.onChatMessage(...args);\n          }\n        );\n      });\n    }\n  }\n\n  /**\n   * Create a PQueue for a given matchID if none exists and return it.\n   * @param matchID\n   * @returns\n   */\n  getMatchQueue(matchID: string): PQueue {\n    if (!this.perMatchQueue.has(matchID)) {\n      // PQueue should process only one action at a time.\n      this.perMatchQueue.set(matchID, new PQueue({ concurrency: 1 }));\n    }\n    return this.perMatchQueue.get(matchID);\n  }\n\n  /**\n   * Delete a PQueue for a given matchID.\n   * @param matchID\n   */\n  deleteMatchQueue(matchID: string): void {\n    this.perMatchQueue.delete(matchID);\n  }\n}\n"
  },
  {
    "path": "src/server/util.ts",
    "content": "import { InitializeGame } from '../core/initialize';\nimport type { Server, State, Game } from '../types';\n\n/**\n * Creates a new match metadata object.\n */\nexport const createMetadata = ({\n  game,\n  unlisted,\n  setupData,\n  numPlayers,\n}: {\n  game: Game;\n  numPlayers: number;\n  setupData?: any;\n  unlisted?: boolean;\n}): Server.MatchData => {\n  const metadata: Server.MatchData = {\n    gameName: game.name,\n    unlisted: !!unlisted,\n    players: {},\n    createdAt: Date.now(),\n    updatedAt: Date.now(),\n  };\n\n  if (setupData !== undefined) metadata.setupData = setupData;\n\n  for (let playerIndex = 0; playerIndex < numPlayers; playerIndex++) {\n    metadata.players[playerIndex] = { id: playerIndex };\n  }\n\n  return metadata;\n};\n\n/**\n * Creates initial state and metadata for a new match.\n * If the provided `setupData` doesn’t pass the game’s validation,\n * an error object is returned instead.\n */\nexport const createMatch = ({\n  game,\n  numPlayers,\n  setupData,\n  unlisted,\n}: {\n  game: Game;\n  numPlayers: number;\n  setupData: any;\n  unlisted: boolean;\n}):\n  | { metadata: Server.MatchData; initialState: State }\n  | { setupDataError: string } => {\n  if (!numPlayers || typeof numPlayers !== 'number') numPlayers = 2;\n\n  const setupDataError =\n    game.validateSetupData && game.validateSetupData(setupData, numPlayers);\n  if (setupDataError !== undefined) return { setupDataError };\n\n  const metadata = createMetadata({ game, numPlayers, setupData, unlisted });\n  const initialState = InitializeGame({ game, numPlayers, setupData });\n\n  return { metadata, initialState };\n};\n\n/**\n * Given players, returns the count of players.\n */\nexport const getNumPlayers = (players: Server.MatchData['players']): number =>\n  Object.keys(players).length;\n\n/**\n * Given players, tries to find the ID of the first player that can be joined.\n * Returns `undefined` if there’s no available ID.\n */\nexport const getFirstAvailablePlayerID = (\n  players: Server.MatchData['players']\n): string | undefined => {\n  const numPlayers = getNumPlayers(players);\n  // Try to get the first index available\n  for (let i = 0; i < numPlayers; i++) {\n    if (typeof players[i].name === 'undefined' || players[i].name === null) {\n      return String(i);\n    }\n  }\n};\n"
  },
  {
    "path": "src/testing/mock-random.test.ts",
    "content": "import { Client } from '../client/client';\nimport type { Game } from '../types';\nimport { MockRandom } from './mock-random';\n\ntest('it creates a plugin object', () => {\n  const plugin = MockRandom();\n  expect(plugin).toEqual({\n    name: 'random',\n    noClient: expect.any(Function),\n    api: expect.any(Function),\n    setup: expect.any(Function),\n    playerView: expect.any(Function),\n  });\n});\n\ntest('it can override random API methods', () => {\n  const game: Game<{ roll: number }> = {\n    moves: {\n      roll: ({ G, random }) => {\n        G.roll = random.D6();\n      },\n    },\n    plugins: [MockRandom({ D6: () => 1 })],\n  };\n\n  const client = Client({ game });\n  client.moves.roll();\n  expect(client.getState().G.roll).toBe(1);\n});\n\ntest('it can use non-overridden API methods', () => {\n  const game: Game<{ roll: number }> = {\n    moves: {\n      roll: ({ G, random }) => {\n        G.roll = random.D6();\n      },\n    },\n    plugins: [MockRandom({ D10: () => 1 })],\n    seed: 0,\n  };\n\n  const client = Client({ game });\n  client.moves.roll();\n  expect(client.getState().G.roll).toMatchInlineSnapshot(`4`);\n});\n"
  },
  {
    "path": "src/testing/mock-random.ts",
    "content": "import type { RandomAPI } from '../plugins/random/random';\nimport RandomPlugin from '../plugins/plugin-random';\n\n/**\n * Test helper that creates a plugin to override the built-in random API.\n *\n * @param overrides - A map of method names to mock functions.\n *\n * @example\n * const game = {\n *   plugins: [\n *     MockRandom({ D6: () => 1 }),\n *   ],\n * };\n */\nexport const MockRandom = (\n  overrides: Partial<Record<keyof RandomAPI, (...args: any[]) => any>> = {}\n): Omit<typeof RandomPlugin, 'flush'> => {\n  // Don’t include the original flush method, otherwise when the\n  // built-in random plugin flushes, it won’t have access to the\n  // state it needs.\n  const { flush, ...rest } = RandomPlugin;\n  return {\n    ...rest,\n    api: (context) => ({ ...RandomPlugin.api(context), ...overrides }),\n  };\n};\n"
  },
  {
    "path": "src/types.ts",
    "content": "import type { Object } from 'ts-toolbelt';\nimport type Koa from 'koa';\nimport type { Store as ReduxStore } from 'redux';\nimport type * as ActionCreators from './core/action-creators';\nimport type { ActionErrorType, UpdateErrorType } from './core/errors';\nimport type { Flow } from './core/flow';\nimport type { CreateGameReducer } from './core/reducer';\nimport type { INVALID_MOVE } from './core/constants';\nimport type { GameMethod } from './core/game-methods';\nimport type { Auth } from './server/auth';\nimport type * as StorageAPI from './server/db/base';\nimport type { EventsAPI } from './plugins/plugin-events';\nimport type { LogAPI } from './plugins/plugin-log';\nimport type { RandomAPI } from './plugins/random/random';\nimport type { Operation } from 'rfc6902';\nexport type { StorageAPI };\n\nexport type AnyFn = (...args: any[]) => any;\n\n// \"Public\" state to be communicated to clients.\nexport interface State<G extends any = any> {\n  G: G;\n  ctx: Ctx;\n  deltalog?: Array<LogEntry>;\n  plugins: {\n    [pluginName: string]: PluginState;\n  };\n  _undo: Array<Undo<G>>;\n  _redo: Array<Undo<G>>;\n  _stateID: number;\n}\n\nexport type ErrorType = UpdateErrorType | ActionErrorType;\n\nexport interface ActionError {\n  type: ErrorType;\n  // TODO(#723): Figure out if we want to strongly type payloads.\n  payload?: any;\n}\n\nexport interface TransientMetadata {\n  error?: ActionError;\n}\n\n// TODO(#732): Actually define a schema for the action dispatch results.\nexport type ActionResult = any;\n\n// \"Private\" state that may include garbage that should be stripped before\n// being handed back to a client.\nexport interface TransientState<G extends any = any> extends State<G> {\n  transients?: TransientMetadata;\n}\n\nexport type PartialGameState = Pick<State, 'G' | 'ctx' | 'plugins'>;\n\nexport type StageName = string;\nexport type PlayerID = string;\n\nexport type StageArg =\n  | StageName\n  | {\n      stage?: StageName;\n      /** @deprecated Use `minMoves` and `maxMoves` instead. */\n      moveLimit?: number;\n      minMoves?: number;\n      maxMoves?: number;\n    };\n\nexport type ActivePlayersArg =\n  | PlayerID[]\n  | {\n      currentPlayer?: StageArg;\n      others?: StageArg;\n      all?: StageArg;\n      value?: Record<PlayerID, StageArg>;\n      minMoves?: number;\n      maxMoves?: number;\n      /** @deprecated Use `minMoves` and `maxMoves` instead. */\n      moveLimit?: number;\n      revert?: boolean;\n      next?: ActivePlayersArg;\n    };\n\nexport interface ActivePlayers {\n  [playerID: string]: StageName;\n}\n\nexport interface Ctx {\n  numPlayers: number;\n  playOrder: Array<PlayerID>;\n  playOrderPos: number;\n  activePlayers: null | ActivePlayers;\n  currentPlayer: PlayerID;\n  numMoves?: number;\n  gameover?: any;\n  turn: number;\n  phase: string;\n  _activePlayersMinMoves?: Record<PlayerID, number>;\n  _activePlayersMaxMoves?: Record<PlayerID, number>;\n  _activePlayersNumMoves?: Record<PlayerID, number>;\n  _prevActivePlayers?: Array<{\n    activePlayers: null | ActivePlayers;\n    _activePlayersMinMoves?: Record<PlayerID, number>;\n    _activePlayersMaxMoves?: Record<PlayerID, number>;\n    _activePlayersNumMoves?: Record<PlayerID, number>;\n  }>;\n  _nextActivePlayers?: ActivePlayersArg;\n  _random?: {\n    seed: string | number;\n  };\n}\n\nexport interface DefaultPluginAPIs {\n  events: EventsAPI;\n  log: LogAPI;\n  random: RandomAPI;\n}\n\nexport interface PluginState {\n  data: any;\n  api?: any;\n}\n\nexport interface LogEntry {\n  action:\n    | ActionShape.MakeMove\n    | ActionShape.GameEvent\n    | ActionShape.Undo\n    | ActionShape.Redo;\n  _stateID: number;\n  turn: number;\n  phase: string;\n  redact?: boolean;\n  automatic?: boolean;\n  metadata?: any;\n  patch?: Operation[];\n}\n\nexport interface PluginContext<\n  API extends any = any,\n  Data extends any = any,\n  G extends any = any\n> {\n  G: G;\n  ctx: Ctx;\n  game: Game;\n  api: API;\n  data: Data;\n}\n\nexport interface Plugin<\n  API extends any = any,\n  Data extends any = any,\n  G extends any = any\n> {\n  name: string;\n  noClient?: (context: PluginContext<API, Data, G>) => boolean;\n  setup?: (setupCtx: { G: G; ctx: Ctx; game: Game<G> }) => Data;\n  isInvalid?: (\n    context: Omit<PluginContext<API, Data, G>, 'api'>\n  ) => false | string;\n  action?: (data: Data, payload: ActionShape.Plugin['payload']) => Data;\n  api?: (context: {\n    G: G;\n    ctx: Ctx;\n    game: Game<G>;\n    data: Data;\n    playerID?: PlayerID;\n  }) => API;\n  flush?: (context: PluginContext<API, Data, G>) => Data;\n  dangerouslyFlushRawState?: (flushCtx: {\n    state: State<G>;\n    game: Game<G>;\n    api: API;\n    data: Data;\n  }) => State<G>;\n  fnWrap?: (\n    moveOrHook: (context: FnContext<G>, ...args: any[]) => any,\n    methodType: GameMethod\n  ) => (context: FnContext<G>, ...args: any[]) => any;\n  playerView?: (context: {\n    G: G;\n    ctx: Ctx;\n    game: Game<G>;\n    data: Data;\n    playerID?: PlayerID | null;\n  }) => any;\n}\n\nexport type FnContext<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> = PluginAPIs &\n  DefaultPluginAPIs & {\n    G: G;\n    ctx: Ctx;\n  };\n\nexport type MoveFn<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> = (\n  context: FnContext<G, PluginAPIs> & { playerID: PlayerID },\n  ...args: any[]\n) => void | G | typeof INVALID_MOVE;\n\nexport interface LongFormMove<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  move: MoveFn<G, PluginAPIs>;\n  redact?: boolean | ((context: { G: G; ctx: Ctx }) => boolean);\n  noLimit?: boolean;\n  client?: boolean;\n  undoable?: boolean | ((context: { G: G; ctx: Ctx }) => boolean);\n  ignoreStaleStateID?: boolean;\n}\n\nexport type Move<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> = MoveFn<G, PluginAPIs> | LongFormMove<G, PluginAPIs>;\n\nexport interface MoveMap<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  [moveName: string]: Move<G, PluginAPIs>;\n}\n\nexport interface PhaseConfig<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  start?: boolean;\n  next?: ((context: FnContext<G, PluginAPIs>) => string | void) | string;\n  onBegin?: (context: FnContext<G, PluginAPIs>) => void | G;\n  onEnd?: (context: FnContext<G, PluginAPIs>) => void | G;\n  endIf?: (\n    context: FnContext<G, PluginAPIs>\n  ) => boolean | void | { next: string };\n  moves?: MoveMap<G, PluginAPIs>;\n  turn?: TurnConfig<G, PluginAPIs>;\n  wrapped?: {\n    endIf?: (state: State<G>) => boolean | void | { next: string };\n    onBegin?: (state: State<G>) => void | G;\n    onEnd?: (state: State<G>) => void | G;\n    next?: (state: State<G>) => string | void;\n  };\n}\n\nexport interface StageConfig<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  moves?: MoveMap<G, PluginAPIs>;\n  next?: string;\n}\n\nexport interface StageMap<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  [stageName: string]: StageConfig<G, PluginAPIs>;\n}\n\nexport interface TurnOrderConfig<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  first: (context: FnContext<G, PluginAPIs>) => number;\n  next: (context: FnContext<G, PluginAPIs>) => number | undefined;\n  playOrder?: (context: FnContext<G, PluginAPIs>) => PlayerID[];\n}\n\nexport interface TurnConfig<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  activePlayers?: ActivePlayersArg;\n  minMoves?: number;\n  maxMoves?: number;\n  /** @deprecated Use `minMoves` and `maxMoves` instead. */\n  moveLimit?: number;\n  onBegin?: (context: FnContext<G, PluginAPIs>) => void | G;\n  onEnd?: (context: FnContext<G, PluginAPIs>) => void | G;\n  endIf?: (\n    context: FnContext<G, PluginAPIs>\n  ) => boolean | void | { next: PlayerID };\n  onMove?: (\n    context: FnContext<G, PluginAPIs> & { playerID: PlayerID }\n  ) => void | G;\n  stages?: StageMap<G, PluginAPIs>;\n  order?: TurnOrderConfig<G, PluginAPIs>;\n  wrapped?: {\n    endIf?: (state: State<G>) => boolean | void | { next: PlayerID };\n    onBegin?: (state: State<G>) => void | G;\n    onEnd?: (state: State<G>) => void | G;\n    onMove?: (state: State<G> & { playerID: PlayerID }) => void | G;\n  };\n}\n\nexport interface PhaseMap<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>\n> {\n  [phaseName: string]: PhaseConfig<G, PluginAPIs>;\n}\n\nexport type AiEnumerate = Array<\n  | { event: string; args?: any[] }\n  | { move: string; args?: any[] }\n  | ActionShape.MakeMove\n  | ActionShape.GameEvent\n>;\n\nexport interface Game<\n  G extends any = any,\n  PluginAPIs extends Record<string, unknown> = Record<string, unknown>,\n  SetupData extends any = any\n> {\n  name?: string;\n  minPlayers?: number;\n  maxPlayers?: number;\n  deltaState?: boolean;\n  disableUndo?: boolean;\n  seed?: string | number;\n  setup?: (\n    context: PluginAPIs & DefaultPluginAPIs & { ctx: Ctx },\n    setupData?: SetupData\n  ) => G;\n  validateSetupData?: (\n    setupData: SetupData | undefined,\n    numPlayers: number\n  ) => string | undefined;\n  moves?: MoveMap<G, PluginAPIs>;\n  phases?: PhaseMap<G, PluginAPIs>;\n  turn?: TurnConfig<G, PluginAPIs>;\n  events?: {\n    endGame?: boolean;\n    endPhase?: boolean;\n    endTurn?: boolean;\n    setPhase?: boolean;\n    endStage?: boolean;\n    setStage?: boolean;\n    pass?: boolean;\n    setActivePlayers?: boolean;\n  };\n  endIf?: (context: FnContext<G, PluginAPIs>) => any;\n  onEnd?: (context: FnContext<G, PluginAPIs>) => void | G;\n  playerView?: (context: { G: G; ctx: Ctx; playerID: PlayerID | null }) => any;\n  plugins?: Array<Plugin<any, any, G>>;\n  ai?: {\n    enumerate: (G: G, ctx: Ctx, playerID: PlayerID) => AiEnumerate;\n  };\n  processMove?: (\n    state: State<G>,\n    action: ActionPayload.MakeMove\n  ) => State<G> | typeof INVALID_MOVE;\n  flow?: ReturnType<typeof Flow>;\n}\n\nexport type Undo<G extends any = any> = {\n  G: G;\n  ctx: Ctx;\n  plugins: {\n    [pluginName: string]: PluginState;\n  };\n  moveType?: string;\n  playerID?: PlayerID;\n};\n\nexport namespace Server {\n  export type GenerateCredentials = (\n    ctx: Koa.DefaultContext\n  ) => Promise<string> | string;\n\n  export type AuthenticateCredentials = (\n    credentials: string,\n    playerMetadata: PlayerMetadata\n  ) => Promise<boolean> | boolean;\n\n  export type PlayerMetadata = {\n    id: number;\n    name?: string;\n    credentials?: string;\n    data?: any;\n    isConnected?: boolean;\n  };\n\n  export interface MatchData {\n    gameName: string;\n    players: { [id: number]: PlayerMetadata };\n    setupData?: any;\n    gameover?: any;\n    nextMatchID?: string;\n    unlisted?: boolean;\n    createdAt: number;\n    updatedAt: number;\n  }\n\n  export type AppCtx = Koa.DefaultContext & {\n    db: StorageAPI.Async | StorageAPI.Sync;\n    auth: Auth;\n  };\n\n  export type App = Koa<Koa.DefaultState, AppCtx>;\n}\n\nexport namespace LobbyAPI {\n  export type GameList = string[];\n  type PublicPlayerMetadata = Omit<Server.PlayerMetadata, 'credentials'>;\n  export type Match = Omit<Server.MatchData, 'players'> & {\n    matchID: string;\n    players: PublicPlayerMetadata[];\n  };\n  export interface MatchList {\n    matches: Match[];\n  }\n  export interface CreatedMatch {\n    matchID: string;\n  }\n  export interface JoinedMatch {\n    playerID: string;\n    playerCredentials: string;\n  }\n  export interface NextMatch {\n    nextMatchID: string;\n  }\n}\n\nexport type Reducer = ReturnType<typeof CreateGameReducer>;\nexport type Store = ReduxStore<State, ActionShape.Any>;\n\nexport namespace CredentialedActionShape {\n  export type MakeMove = ReturnType<typeof ActionCreators.makeMove>;\n  export type GameEvent = ReturnType<typeof ActionCreators.gameEvent>;\n  export type Plugin = ReturnType<typeof ActionCreators.plugin>;\n  export type AutomaticGameEvent = ReturnType<\n    typeof ActionCreators.automaticGameEvent\n  >;\n  export type Undo = ReturnType<typeof ActionCreators.undo>;\n  export type Redo = ReturnType<typeof ActionCreators.redo>;\n  export type Any =\n    | MakeMove\n    | GameEvent\n    | AutomaticGameEvent\n    | Undo\n    | Redo\n    | Plugin;\n}\n\nexport namespace ActionShape {\n  type StripCredentials<T extends CredentialedActionShape.Any> = Object.P.Omit<\n    T,\n    ['payload', 'credentials']\n  >;\n  export type MakeMove = StripCredentials<CredentialedActionShape.MakeMove>;\n  export type GameEvent = StripCredentials<CredentialedActionShape.GameEvent>;\n  export type Plugin = StripCredentials<CredentialedActionShape.Plugin>;\n  export type AutomaticGameEvent =\n    StripCredentials<CredentialedActionShape.AutomaticGameEvent>;\n  export type Sync = ReturnType<typeof ActionCreators.sync>;\n  export type Update = ReturnType<typeof ActionCreators.update>;\n  export type Patch = ReturnType<typeof ActionCreators.patch>;\n  export type Reset = ReturnType<typeof ActionCreators.reset>;\n  export type Undo = StripCredentials<CredentialedActionShape.Undo>;\n  export type Redo = StripCredentials<CredentialedActionShape.Redo>;\n  // Private type used only for internal error processing.\n  // Included here to preserve type-checking of reducer inputs.\n  export type StripTransients = ReturnType<\n    typeof ActionCreators.stripTransients\n  >;\n  export type Any =\n    | MakeMove\n    | GameEvent\n    | AutomaticGameEvent\n    | Sync\n    | Update\n    | Patch\n    | Reset\n    | Undo\n    | Redo\n    | Plugin\n    | StripTransients;\n}\n\nexport namespace ActionPayload {\n  type GetPayload<T extends ActionShape.Any> = Object.At<T, 'payload'>;\n  export type MakeMove = GetPayload<ActionShape.MakeMove>;\n  export type GameEvent = GetPayload<ActionShape.GameEvent>;\n}\n\nexport type FilteredMetadata = {\n  id: number;\n  name?: string;\n  isConnected?: boolean;\n}[];\n\nexport interface SyncInfo {\n  state: State;\n  filteredMetadata: FilteredMetadata;\n  initialState: State;\n  log: LogEntry[];\n}\n\nexport interface ChatMessage {\n  id: string;\n  sender: PlayerID;\n  payload: any;\n}\n"
  },
  {
    "path": "subpackages.js",
    "content": "/*\n * Copyright 2019 The boardgame.io Authors\n *\n * Use of this source code is governed by a MIT-style\n * license that can be found in the LICENSE file or at\n * https://opensource.org/licenses/MIT.\n */\n\nmodule.exports = [\n  'client',\n  'core',\n  'debug',\n  'react',\n  'react-native',\n  'ai',\n  'plugins',\n  'master',\n  'multiplayer',\n  'internal',\n  'testing',\n];\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"esnext\",\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"declaration\": false,\n    \"strict\": false,\n    \"allowSyntheticDefaultImports\": true,\n    \"esModuleInterop\": true,\n    \"jsx\": \"react\",\n    \"skipLibCheck\": true,\n    \"plugins\": [{ \"transform\": \"ts-transformer-imports\" }]\n  }\n}\n"
  }
]