[
  {
    "path": ".babelrc",
    "content": "{\n  \"presets\": [\"es2015\"],\n  \"plugins\": [\"transform-runtime\"]\n}\n"
  },
  {
    "path": ".eslintignore",
    "content": "node_modules/\nlib/\ncoverage/\ndist/\n"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"env\": {\n    \"es6\": true,\n    \"node\": true,\n    \"browser\": true\n  },\n  \"parserOptions\": {\n    \"sourceType\": \"module\"\n  },\n  \"ecmaFeatures\": {\n    \"arrowFunctions\": true,\n    \"blockBindings\": true,\n    \"destructuring\": true,\n    \"objectLiteralShorthandMethods\": true,\n    \"objectLiteralShorthandProperties\": true,\n    \"templateStrings\": true,\n    \"classes\": true,\n    \"modules\": true\n  },\n  \"rules\": {\n    \"brace-style\": [2, \"1tbs\", { \"allowSingleLine\": true }],\n    \"camelcase\": 2,\n    \"curly\": 2,\n    \"eqeqeq\": [2, \"smart\"],\n    \"guard-for-in\": 2,\n    \"indent\": [2, 2, { \"SwitchCase\": 1 }],\n    \"init-declarations\": [2, \"always\"],\n    \"max-nested-callbacks\": [2, 4],\n    \"no-caller\": 2,\n    \"no-console\": 2,\n    \"no-const-assign\": 2,\n    \"no-else-return\": 2,\n    \"no-empty\": 2,\n    \"no-empty-pattern\": 2,\n    \"no-floating-decimal\": 2,\n    \"no-lonely-if\": 2,\n    \"no-mixed-requires\": 2,\n    \"no-multi-spaces\": 2,\n    \"no-multiple-empty-lines\": [2, {\n      \"max\": 2\n    }],\n    \"no-param-reassign\": 0,\n    \"no-process-exit\": 0,\n    \"no-self-compare\": 2,\n    \"no-sequences\": 2,\n    \"no-shadow\": 0,\n    \"no-undef\": 2,\n    \"no-undefined\": 0,\n    \"no-underscore-dangle\": 0,\n    \"no-unused-vars\": [2, { \"args\": \"none\", \"argsIgnorePattern\": \"^_\" }],\n    \"no-use-before-define\": 0,\n    \"no-useless-concat\": 2,\n    \"no-var\": 2,\n    \"prefer-const\": 2,\n    \"quotes\": [2, \"single\"],\n    \"space-before-function-paren\": [2, {\n      \"anonymous\": \"never\",\n      \"named\": \"never\"\n    }],\n    \"space-in-parens\": [2, \"never\"],\n    \"yoda\": [2, \"never\", { \"exceptRange\": true }]\n  }\n}\n"
  },
  {
    "path": ".gitignore",
    "content": ".idea/\n*.ipr\n*.iml\n*.iws\n\n*.log\n*.bak\n*~\n~*\n.DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.Trashes\nehthumbs.db\nThumbs.db\ndesktop.ini\nnohup.out\n\nnode_modules/\ncoverage/\n"
  },
  {
    "path": ".npmignore",
    "content": ".idea/\n*.ipr\n*.iml\n*.iws\n\n*.log\n*.bak\n*~\n~*\n.DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.Trashes\nehthumbs.db\nThumbs.db\ndesktop.ini\nnohup.out\n\nnode_modules/\ncoverage/\ntest/\nsite/\n\n"
  },
  {
    "path": "README.md",
    "content": "# Voie.js\n\n**Important! Due to [breaking changes](https://github.com/vuejs/vue/issues/2873)\nin Vue 2.0 current versions of Voie (0.x.x) are now deprecated\n(feel free to use it with Vue 1.x.x).\nThe 1.x.x will most probably be a major rewrite, so there's\nno guarantee of backwards compatibility. Sorry.**\n\n**Voie** /vwa/ (fr. \"way\") is a simple router / layout manager for [Vue.js](http://vuejs.org).\nUse it to build SPAs of your dreams.\n\nCurrent status: **active development** — any feedback is appreciated.\n\nSimple example app is available on [GitHub](https://github.com/inca/voie-example)\nand [live on Netlify](http://voie-example.netlify.com/).\n\n[Standalone bundles](dist/) are also available, mostly for using with\njsfiddle, jsbin, codepen, etc. (note, Vue.js is **not** included in bundles).\n\nYou should never use them in real development — use module bundlers instead.\n\n## Core concepts\n\nUnlike official [vue-router](https://github.com/vuejs/vue-router) which\nis organized around URLs, Voie is organized around _states_. Voie-based apps\nare basically [finite-state machines](https://en.wikipedia.org/wiki/Finite-state_machine).\n\nState is simply a _named_ logical \"place\" within your application.\n\nEach state can _optionally_ have:\n\n  * URL pattern\n  * Vue component\n  * enter hook to populate state with data\n  * leave hook to cleanup things\n\nStates are organized into hierarchies: child states will inherit parameters and data\nfrom parent state. Also, if child state has a component, then it will be rendered at the location\nspecified by parent (or nearest ancestor) state denoted by `<v-view>` directive.\n\nConsider this example:\n\n```es6\napp.add('user', {\n  path: '/user/:userId',\n  redirect: 'user.dashboard',   // specify \"default\" sub-state\n  enter: (ctx) => {             // can return a Promise\n    return fetch('/user/' + ctx.params.userId)\n      .then(res => res.json())\n      .then(data = ctx.data.user = data);\n  },\n  component: {\n    template: '<div class=\"user-layout\"><v-view></v-view></div>'\n  }\n});\n\napp.add('user.dashboard', {\n  component: {\n    template: '<h1>Hello, {{ user.name }}!</h1>'\n  }\n});\n```\n\nIn this example visiting `/user/123` would fetch a user with id `123` from a server\nand then render following markup (assuming user has name \"Alice\"):\n\n```html\n<div class=\"user-layout\">\n  <h1>Hello, Alice!</h1>\n</div>\n```\n\n**Note:** [fragment instances](http://vuejs.org/guide/components.html#Fragment_Instance)\nare not supported as components. In other words, make sure all components\ncontain a single top-level element without flow control directives (`v-if`, `v-for`, etc.)\n\n## Installation\n\nExamples assume ES6 and build environment\n([browserify](http://browserify.org/) + [babelify](https://github.com/babel/babelify)\nor [webpack](https://webpack.github.io/) + [babel-loader](https://github.com/babel/babel-loader))\nwhich is a mainstream.\n\n```bash\nnpm i --save voie\n```\n\nYou also need an [es6-shim](https://github.com/paulmillr/es6-shim) to make everything\ngo smooth in not-so-modern browsers.\n\n## Usage\n\n### State manager\n\nVoie app is an instance of `StateManager`. You provide it with `el`, which\nis an \"entry-point\" DOM node where views will be entered.\n\n```es6\nimport { StateManager } from 'voie'\n\nexport default new StateManager({\n  el: '#app'    // entry point, either a selector or HTMLElement\n});\n```\n\nIt is a good idea to expose state manager instance as a singleton module\n(i.e. single instance per application)\nsince you will often want to use it in your Vue methods and stores.\n\n### Define states\n\nNext thing you want to do is to register some states.\nYour app will probably contain plenty of states, so you'll need some structure.\nI prefer \"domain-centric\" directory structure:\n\n```es6\n// states.js\nimport './users';\nimport './groups';\n// ...\n```\n\n```es6\n// users/index.js\nimport app from '../app';\nimport UsersLayout from './layout.vue';\nimport UsersList from './list.vue';\n\napp.add('users', {\n  component: UsersLayout\n  ...\n});\napp.add('users.list', {\n  component: UsersList,\n  ...\n});\napp.add('users.create', { ... });\napp.add('user', { ... });\napp.add('user.view', { ... });\napp.add('user.edit', { ... });\napp.add('user.delete', { ... });\n```\n\n```es6\n// groups/index.js\nimport app from '../app';\n\napp.add('groups', { ... });\n// ...\n```\n\nStructuring apps is a matter of preference, so you are free to choose\nwhatever suits you best.\n\n### Running\n\nFinally, run your state manager like this:\n\n```es6\n// index.js\nimport app from './app';\nimport './states';\n\napp.start();\n```\n\nIt will begin listening for history events and match-and-render current route.\n\n## More usage\n\n### States hierarchy\n\nStates are automatically organized into a tree-like structure. Each state\nwill have a single parent state. \"Root\" states would have a `null` parent\n\nThere are two ways of specifying a parent:\n\n  * using dot character `.` in state name\n    (e.g. `user` -> `user.transaction` -> `user.transaction.details`)\n\n  * explicitly using `parent` configuration parameter:\n\n    ```es6\n    app.add('users', { ... });\n    app.add('user', {\n      parent: 'users'\n    });\n    ```\n\nEach way has its own advantages, so it's usually OK to use both styles in the same app.\nSpecifically, use qualified names to outline context (e.g. \"User's profile page\" would\nbe `user.profile`) or entity-relationship (e.g. \"User's transactions list would\nbe `user.transactions`).\n\nSpecifying `parent` is handy in cases when you want to preserve concise and clean state name\nwhile being able to use a different layout or add some global \"enter\" hook on state subtree.\n\nA typical example would be authentication/authorization:\n\n```es6\napp.add('root', { ... });\n\napp.add('login', {\n  parent: 'root',\n  ...\n});\n\napp.add('authenticated', {\n  parent: 'root',\n  enter: ctx => {\n    if (!UserService.isAuthenticated()) {\n      return { redirect: 'login' };\n    }\n  }\n});\n\napp.add('users', {\n  parent: 'authenticated',\n  ...\n});\n\napp.add('groups', {\n  parent: 'authenticated',\n  ...\n});\n\n```\n\n### Navigating states\n\nUse `stateManager.go` to navigate programmatically:\n\n```es6\nstateManager.go({\n  name: 'user.dashboard',\n  params: {\n    userId: '123'\n  }\n});\n```\n\nIn templates you can use `v-link` directive with the same semantics:\n\n```html\n<a v-link=\"{ name: 'user.dashboard', params: { userId: 123 } }\">\n  Dashboard\n</a>\n```\n\nIn addition to invoking `stateManager.go` it will also update the `href`\nattribute and apply an `active` class if current state \"includes\"\nthe state specified by link.\n\nActive class name can be customised globally:\n\n```es6\nnew StateManager({\n  el: '#el',\n  activeClass: 'highlighted'\n});\n```\n\n### Enter / leave\n\nState can optionally define `enter` and `leave` hooks which are functions\nthat accept _state context_ object.\n\nState context contains:\n\n  * `params` — a hash of `string` parameters matched from URL pattern,\n    specified explicitly via `stateManager.go(...)` and inherited from parent context\n  * `data` — object where you can write data to be exposed to Vue component and\n    inherited states\n  * `state` — `State` object to which this context corresponds\n  * `parent` — parent context of this object\n\nTypical `enter` hook will use `params` to fetch or prepare some data and expose it\nvia `data` object.\n\nBoth `enter` and `leave` can return a `Promise`, which makes hooks asynchronous.\nIn case of `enter` the component will only be entered when promise is resolved.\n\nExample:\n\n```es6\n{\n  enter: (ctx) => UserService.findByEmail(ctx.params.email)\n    .then(user => ctx.data.user = user)\n}\n```\n\n### Before each / after each\n\nAdditionally one can configure global `beforeEach` and `afterEach` hooks\nthat will be applied before `enter` hooks and after `leave` hook on each state\nrespectively.\n\nGlobal hooks are configured on `StateManager`:\n\n```es6\nnew StateManager({\n\n  beforeEach(ctx) {\n    if (ctx.state.name === 'private') {\n      return { redirect: 'not_allowed' };\n    }\n  }\n\n});\n```\n\n### Redirecting\n\nEnter can optionally redirect to another state by\nreturning (or resolving via promise) an object like this:\n`{ redirect: 'state.name' }` or\n`{ redirect: { name: 'state.name', params: {} }`.\n\nWhen `redirect` is returned by `enter` hook the transition will always redirect\nwhenever it enters specified state (even if this state was not a destination).\n\nRedirect can also be specified at state configuration level:\n\n```es6\napp.add('users', {\n  redirect: 'users.list',\n  // or with params\n  redirect: {\n    name: 'users.list',\n    params: { sort: '+name' }\n  },\n  // or even function Transition => Promise(stateName)\n  redirect: (transition) => {\n    transition.params.sort = '+name';\n    return Promise.resolve('users.list');\n  }\n});\n```\n\nWhen `redirect` is specified as state configuration option it will\nonly be effective when moving specifically to this state (in other words,\nno redirect occurs when transitioning through this state to another one).\n\n### State transitions\n\nConsider following components hierarchy:\n\n```\n  A\n/   \\\nB   D\n|   |\nC   E\n```\n\nGoing from C to E implies:\n\n  * leaving state C\n  * leaving state B\n  * entering state D\n  * entering state E\n\nBy \"leaving\" we mean:\n\n  * executing `leave` hook\n  * destroying Vue component, if any\n  * restoring the original state of `<v-view>` element where the component was rendered\n\nBy \"entering\" we mean:\n\n  * preparing new context\n  * executing `enter` hook\n  * rendering Vue component, if any\n  * preserving the original state of `<v-view>` so that it could later be restored\n\n### Parameters\n\nEach state has a specification of parameters it can accept when entered.\nMandatory parameters (e.g. `userId` for state `user`) are classically specified\nin pathname (e.g. `/user/28`).\nOptional parameters (e.g. `page`, `limit` for lists) are usually specified\nin querystring (e.g. `/users?page=5&limit=100`).\n\nHere's how you define both parameter types when registering states:\n\n```es6\napp.add('user', {\n  path: '/user/:userId',   // userId param is mandatory\n  params: {\n    section: null,        // these are optional\n    collapsed: false      // with optional default values\n  }\n});\n```\n\nBoth querystring and pathname parameters are accessible in `ctx.params` object\nwhich is exposed both to `enter` hook and components.\n\nExample:\n\n```\nlocation.href = '/user/123?section=profile&collapsed=true';\napp.context.params\n// { userId: '123', section: 'profile', collapsed: 'true' }\n```\n\n**Note:** Voie doesn't do any type conversion on params, so they are returned as strings.\n\nWhen navigating between states specify parameters in `go` (or `v-link`):\n\n```es6\napp.go({\n  name: 'user',\n  params: {\n    userId: '123',\n    section: 'profile',\n    unknown: 'wut?'     // Important, this will be dropped!\n  }\n});\n```\n\n**Note:** params must be listed explicitly when registering states,\nall other parameters will be dropped. In the example above\nparameter `unknown` is not specified in `path` or `params` of `user` state (or its ancestors),\nso it's not part of `user` state spec and, therefore, will not be accessible in `ctx.params`.\n\n### History\n\nA common need for any web application is to update browser URL upon navigating to\na state with URL mapping, so that when the user presses \"Refresh\" application\nloads the most recent state (not the \"start\" screen).\nDecent SPAs would also have Back/Forward buttons working as expected.\nWe refer to these features as \"history support\".\n\nNow there's two ways of implementing history support in your application:\n\n  * **hash** (uncool, but fairly simple) — state will be maintained using\n    hash portions of URL (e.g. `https://myapp/#user/1/transactions`)\n\n  * **HTML5** (cool, a bit more complex) — state will be maintained using\n    pathname portion of URL (e.g. `https://myapp/user/1/transactions`)\n\nHTML5 history requires server-side setup: server must reply with the same HTML\nwrapper to **all URLs** used by your application.\n\n#### HTML5 server setup example\n\nHere's an example [Express](http://expressjs.com) server:\n\n```es6\nimport express from 'express';\n\nlet app = express();\n\n// Allow using static resources with `/static` prefix\napp.use('/static', express.static('static'));\n\n// Serve application data with `/~` prefix\napp.use('/~', appDataRouter);\n\n// Serve SPA entry-point HTML to all other routes\napp.get('/*', (req, res) => res.sendFile('app.html'))\n```\n\nThis example shows potential gotchas:\nsince `app.html` will be served for all GET requests, in order\nto serve other resources (e.g. static or compiled assets, scripts,\nstylesheets, application data, etc.) you'll need separate prefixes.\nWithout these prefixes it won't be easy to configure your front web server\n([nginx](http://nginx.org/en/) or Apache) for production.\n\n#### History setup\n\nVoie uses awesome [history](https://github.com/rackt/history)\nto provide apps with history support. HTML5 mode is used by default.\n\nHere's how to switch to hash-history (you need to install `history`):\n\n```es6\n// app.js\nimport { StateManager } from 'voie';\nimport { createHashHistory } from 'history';\n\nexport default new StateManager({\n  el: '#app',\n  history: createHashHistory()\n});\n```\n\nSee [history docs](https://github.com/rackt/history/tree/master/docs)\nfor more options.\n\n#### Base URL\n\nIt's a bit easier to setup servers using \"base\" URL for your app, e.g.:\n\n```\napp.get('/app*', (req, res) => res.sendFile('app.html'))\n```\n\nIn this case all you need to do is to add `<base href=\"/app\"/>`\ninside the `<head>` of your HTML wrapper.\n\nOr you can just specify `base` configuration parameter (it's only used\nwhen `history` is not present):\n\n```es6\n// app.js\nimport { StateManager } from 'voie';\n\nexport default new StateManager({\n  el: '#app',\n  base: '/app'\n});\n```\n\n### More docs\n\nVoie is in active development, so more docs are coming soon.\n\n## License (ISC)\n\nCopyright (c) 2015-2016, Boris Okunskiy <boris@okunskiy.name>\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n"
  },
  {
    "path": "dist/voie.js",
    "content": "(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.voie = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/object/assign\"), __esModule: true };\n},{\"core-js/library/fn/object/assign\":14}],2:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/object/create\"), __esModule: true };\n},{\"core-js/library/fn/object/create\":15}],3:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/object/define-property\"), __esModule: true };\n},{\"core-js/library/fn/object/define-property\":16}],4:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/object/get-prototype-of\"), __esModule: true };\n},{\"core-js/library/fn/object/get-prototype-of\":17}],5:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/object/keys\"), __esModule: true };\n},{\"core-js/library/fn/object/keys\":18}],6:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/object/set-prototype-of\"), __esModule: true };\n},{\"core-js/library/fn/object/set-prototype-of\":19}],7:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/promise\"), __esModule: true };\n},{\"core-js/library/fn/promise\":20}],8:[function(require,module,exports){\nmodule.exports = { \"default\": require(\"core-js/library/fn/symbol\"), __esModule: true };\n},{\"core-js/library/fn/symbol\":21}],9:[function(require,module,exports){\n\"use strict\";\n\nexports.default = function (instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n};\n\nexports.__esModule = true;\n},{}],10:[function(require,module,exports){\n\"use strict\";\n\nvar _defineProperty = require(\"babel-runtime/core-js/object/define-property\");\n\nvar _defineProperty2 = _interopRequireDefault(_defineProperty);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = (function () {\n  function defineProperties(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      (0, _defineProperty2.default)(target, descriptor.key, descriptor);\n    }\n  }\n\n  return function (Constructor, protoProps, staticProps) {\n    if (protoProps) defineProperties(Constructor.prototype, protoProps);\n    if (staticProps) defineProperties(Constructor, staticProps);\n    return Constructor;\n  };\n})();\n\nexports.__esModule = true;\n},{\"babel-runtime/core-js/object/define-property\":3}],11:[function(require,module,exports){\n\"use strict\";\n\nvar _Object$create = require(\"babel-runtime/core-js/object/create\")[\"default\"];\n\nvar _Object$setPrototypeOf = require(\"babel-runtime/core-js/object/set-prototype-of\")[\"default\"];\n\nexports[\"default\"] = function (subClass, superClass) {\n  if (typeof superClass !== \"function\" && superClass !== null) {\n    throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n  }\n\n  subClass.prototype = _Object$create(superClass && superClass.prototype, {\n    constructor: {\n      value: subClass,\n      enumerable: false,\n      writable: true,\n      configurable: true\n    }\n  });\n  if (superClass) _Object$setPrototypeOf ? _Object$setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n};\n\nexports.__esModule = true;\n},{\"babel-runtime/core-js/object/create\":2,\"babel-runtime/core-js/object/set-prototype-of\":6}],12:[function(require,module,exports){\n\"use strict\";\n\nvar _typeof2 = require(\"babel-runtime/helpers/typeof\");\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = function (self, call) {\n  if (!self) {\n    throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n  }\n\n  return call && ((typeof call === \"undefined\" ? \"undefined\" : (0, _typeof3.default)(call)) === \"object\" || typeof call === \"function\") ? call : self;\n};\n\nexports.__esModule = true;\n},{\"babel-runtime/helpers/typeof\":13}],13:[function(require,module,exports){\n\"use strict\";\n\nvar _Symbol = require(\"babel-runtime/core-js/symbol\")[\"default\"];\n\nexports[\"default\"] = function (obj) {\n  return obj && obj.constructor === _Symbol ? \"symbol\" : typeof obj;\n};\n\nexports.__esModule = true;\n},{\"babel-runtime/core-js/symbol\":8}],14:[function(require,module,exports){\nrequire('../../modules/es6.object.assign');\nmodule.exports = require('../../modules/$.core').Object.assign;\n},{\"../../modules/$.core\":27,\"../../modules/es6.object.assign\":78}],15:[function(require,module,exports){\nvar $ = require('../../modules/$');\nmodule.exports = function create(P, D){\n  return $.create(P, D);\n};\n},{\"../../modules/$\":52}],16:[function(require,module,exports){\nvar $ = require('../../modules/$');\nmodule.exports = function defineProperty(it, key, desc){\n  return $.setDesc(it, key, desc);\n};\n},{\"../../modules/$\":52}],17:[function(require,module,exports){\nrequire('../../modules/es6.object.get-prototype-of');\nmodule.exports = require('../../modules/$.core').Object.getPrototypeOf;\n},{\"../../modules/$.core\":27,\"../../modules/es6.object.get-prototype-of\":79}],18:[function(require,module,exports){\nrequire('../../modules/es6.object.keys');\nmodule.exports = require('../../modules/$.core').Object.keys;\n},{\"../../modules/$.core\":27,\"../../modules/es6.object.keys\":80}],19:[function(require,module,exports){\nrequire('../../modules/es6.object.set-prototype-of');\nmodule.exports = require('../../modules/$.core').Object.setPrototypeOf;\n},{\"../../modules/$.core\":27,\"../../modules/es6.object.set-prototype-of\":81}],20:[function(require,module,exports){\nrequire('../modules/es6.object.to-string');\nrequire('../modules/es6.string.iterator');\nrequire('../modules/web.dom.iterable');\nrequire('../modules/es6.promise');\nmodule.exports = require('../modules/$.core').Promise;\n},{\"../modules/$.core\":27,\"../modules/es6.object.to-string\":82,\"../modules/es6.promise\":83,\"../modules/es6.string.iterator\":84,\"../modules/web.dom.iterable\":86}],21:[function(require,module,exports){\nrequire('../../modules/es6.symbol');\nrequire('../../modules/es6.object.to-string');\nmodule.exports = require('../../modules/$.core').Symbol;\n},{\"../../modules/$.core\":27,\"../../modules/es6.object.to-string\":82,\"../../modules/es6.symbol\":85}],22:[function(require,module,exports){\nmodule.exports = function(it){\n  if(typeof it != 'function')throw TypeError(it + ' is not a function!');\n  return it;\n};\n},{}],23:[function(require,module,exports){\nmodule.exports = function(){ /* empty */ };\n},{}],24:[function(require,module,exports){\nvar isObject = require('./$.is-object');\nmodule.exports = function(it){\n  if(!isObject(it))throw TypeError(it + ' is not an object!');\n  return it;\n};\n},{\"./$.is-object\":45}],25:[function(require,module,exports){\n// getting tag from 19.1.3.6 Object.prototype.toString()\nvar cof = require('./$.cof')\n  , TAG = require('./$.wks')('toStringTag')\n  // ES3 wrong here\n  , ARG = cof(function(){ return arguments; }()) == 'Arguments';\n\nmodule.exports = function(it){\n  var O, T, B;\n  return it === undefined ? 'Undefined' : it === null ? 'Null'\n    // @@toStringTag case\n    : typeof (T = (O = Object(it))[TAG]) == 'string' ? T\n    // builtinTag case\n    : ARG ? cof(O)\n    // ES3 arguments fallback\n    : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;\n};\n},{\"./$.cof\":26,\"./$.wks\":75}],26:[function(require,module,exports){\nvar toString = {}.toString;\n\nmodule.exports = function(it){\n  return toString.call(it).slice(8, -1);\n};\n},{}],27:[function(require,module,exports){\nvar core = module.exports = {version: '1.2.6'};\nif(typeof __e == 'number')__e = core; // eslint-disable-line no-undef\n},{}],28:[function(require,module,exports){\n// optional / simple context binding\nvar aFunction = require('./$.a-function');\nmodule.exports = function(fn, that, length){\n  aFunction(fn);\n  if(that === undefined)return fn;\n  switch(length){\n    case 1: return function(a){\n      return fn.call(that, a);\n    };\n    case 2: return function(a, b){\n      return fn.call(that, a, b);\n    };\n    case 3: return function(a, b, c){\n      return fn.call(that, a, b, c);\n    };\n  }\n  return function(/* ...args */){\n    return fn.apply(that, arguments);\n  };\n};\n},{\"./$.a-function\":22}],29:[function(require,module,exports){\n// 7.2.1 RequireObjectCoercible(argument)\nmodule.exports = function(it){\n  if(it == undefined)throw TypeError(\"Can't call method on  \" + it);\n  return it;\n};\n},{}],30:[function(require,module,exports){\n// Thank's IE8 for his funny defineProperty\nmodule.exports = !require('./$.fails')(function(){\n  return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;\n});\n},{\"./$.fails\":34}],31:[function(require,module,exports){\nvar isObject = require('./$.is-object')\n  , document = require('./$.global').document\n  // in old IE typeof document.createElement is 'object'\n  , is = isObject(document) && isObject(document.createElement);\nmodule.exports = function(it){\n  return is ? document.createElement(it) : {};\n};\n},{\"./$.global\":37,\"./$.is-object\":45}],32:[function(require,module,exports){\n// all enumerable object keys, includes symbols\nvar $ = require('./$');\nmodule.exports = function(it){\n  var keys       = $.getKeys(it)\n    , getSymbols = $.getSymbols;\n  if(getSymbols){\n    var symbols = getSymbols(it)\n      , isEnum  = $.isEnum\n      , i       = 0\n      , key;\n    while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))keys.push(key);\n  }\n  return keys;\n};\n},{\"./$\":52}],33:[function(require,module,exports){\nvar global    = require('./$.global')\n  , core      = require('./$.core')\n  , ctx       = require('./$.ctx')\n  , PROTOTYPE = 'prototype';\n\nvar $export = function(type, name, source){\n  var IS_FORCED = type & $export.F\n    , IS_GLOBAL = type & $export.G\n    , IS_STATIC = type & $export.S\n    , IS_PROTO  = type & $export.P\n    , IS_BIND   = type & $export.B\n    , IS_WRAP   = type & $export.W\n    , exports   = IS_GLOBAL ? core : core[name] || (core[name] = {})\n    , target    = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]\n    , key, own, out;\n  if(IS_GLOBAL)source = name;\n  for(key in source){\n    // contains in native\n    own = !IS_FORCED && target && key in target;\n    if(own && key in exports)continue;\n    // export native or passed\n    out = own ? target[key] : source[key];\n    // prevent global pollution for namespaces\n    exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]\n    // bind timers to global for call from export context\n    : IS_BIND && own ? ctx(out, global)\n    // wrap global constructors for prevent change them in library\n    : IS_WRAP && target[key] == out ? (function(C){\n      var F = function(param){\n        return this instanceof C ? new C(param) : C(param);\n      };\n      F[PROTOTYPE] = C[PROTOTYPE];\n      return F;\n    // make static versions for prototype methods\n    })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;\n    if(IS_PROTO)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out;\n  }\n};\n// type bitmap\n$export.F = 1;  // forced\n$export.G = 2;  // global\n$export.S = 4;  // static\n$export.P = 8;  // proto\n$export.B = 16; // bind\n$export.W = 32; // wrap\nmodule.exports = $export;\n},{\"./$.core\":27,\"./$.ctx\":28,\"./$.global\":37}],34:[function(require,module,exports){\nmodule.exports = function(exec){\n  try {\n    return !!exec();\n  } catch(e){\n    return true;\n  }\n};\n},{}],35:[function(require,module,exports){\nvar ctx         = require('./$.ctx')\n  , call        = require('./$.iter-call')\n  , isArrayIter = require('./$.is-array-iter')\n  , anObject    = require('./$.an-object')\n  , toLength    = require('./$.to-length')\n  , getIterFn   = require('./core.get-iterator-method');\nmodule.exports = function(iterable, entries, fn, that){\n  var iterFn = getIterFn(iterable)\n    , f      = ctx(fn, that, entries ? 2 : 1)\n    , index  = 0\n    , length, step, iterator;\n  if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');\n  // fast case for arrays with default iterator\n  if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){\n    entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);\n  } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){\n    call(iterator, f, step.value, entries);\n  }\n};\n},{\"./$.an-object\":24,\"./$.ctx\":28,\"./$.is-array-iter\":43,\"./$.iter-call\":46,\"./$.to-length\":72,\"./core.get-iterator-method\":76}],36:[function(require,module,exports){\n// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window\nvar toIObject = require('./$.to-iobject')\n  , getNames  = require('./$').getNames\n  , toString  = {}.toString;\n\nvar windowNames = typeof window == 'object' && Object.getOwnPropertyNames\n  ? Object.getOwnPropertyNames(window) : [];\n\nvar getWindowNames = function(it){\n  try {\n    return getNames(it);\n  } catch(e){\n    return windowNames.slice();\n  }\n};\n\nmodule.exports.get = function getOwnPropertyNames(it){\n  if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it);\n  return getNames(toIObject(it));\n};\n},{\"./$\":52,\"./$.to-iobject\":71}],37:[function(require,module,exports){\n// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nvar global = module.exports = typeof window != 'undefined' && window.Math == Math\n  ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();\nif(typeof __g == 'number')__g = global; // eslint-disable-line no-undef\n},{}],38:[function(require,module,exports){\nvar hasOwnProperty = {}.hasOwnProperty;\nmodule.exports = function(it, key){\n  return hasOwnProperty.call(it, key);\n};\n},{}],39:[function(require,module,exports){\nvar $          = require('./$')\n  , createDesc = require('./$.property-desc');\nmodule.exports = require('./$.descriptors') ? function(object, key, value){\n  return $.setDesc(object, key, createDesc(1, value));\n} : function(object, key, value){\n  object[key] = value;\n  return object;\n};\n},{\"./$\":52,\"./$.descriptors\":30,\"./$.property-desc\":58}],40:[function(require,module,exports){\nmodule.exports = require('./$.global').document && document.documentElement;\n},{\"./$.global\":37}],41:[function(require,module,exports){\n// fast apply, http://jsperf.lnkit.com/fast-apply/5\nmodule.exports = function(fn, args, that){\n  var un = that === undefined;\n  switch(args.length){\n    case 0: return un ? fn()\n                      : fn.call(that);\n    case 1: return un ? fn(args[0])\n                      : fn.call(that, args[0]);\n    case 2: return un ? fn(args[0], args[1])\n                      : fn.call(that, args[0], args[1]);\n    case 3: return un ? fn(args[0], args[1], args[2])\n                      : fn.call(that, args[0], args[1], args[2]);\n    case 4: return un ? fn(args[0], args[1], args[2], args[3])\n                      : fn.call(that, args[0], args[1], args[2], args[3]);\n  } return              fn.apply(that, args);\n};\n},{}],42:[function(require,module,exports){\n// fallback for non-array-like ES3 and non-enumerable old V8 strings\nvar cof = require('./$.cof');\nmodule.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){\n  return cof(it) == 'String' ? it.split('') : Object(it);\n};\n},{\"./$.cof\":26}],43:[function(require,module,exports){\n// check on default Array iterator\nvar Iterators  = require('./$.iterators')\n  , ITERATOR   = require('./$.wks')('iterator')\n  , ArrayProto = Array.prototype;\n\nmodule.exports = function(it){\n  return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);\n};\n},{\"./$.iterators\":51,\"./$.wks\":75}],44:[function(require,module,exports){\n// 7.2.2 IsArray(argument)\nvar cof = require('./$.cof');\nmodule.exports = Array.isArray || function(arg){\n  return cof(arg) == 'Array';\n};\n},{\"./$.cof\":26}],45:[function(require,module,exports){\nmodule.exports = function(it){\n  return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n},{}],46:[function(require,module,exports){\n// call something on iterator step with safe closing on error\nvar anObject = require('./$.an-object');\nmodule.exports = function(iterator, fn, value, entries){\n  try {\n    return entries ? fn(anObject(value)[0], value[1]) : fn(value);\n  // 7.4.6 IteratorClose(iterator, completion)\n  } catch(e){\n    var ret = iterator['return'];\n    if(ret !== undefined)anObject(ret.call(iterator));\n    throw e;\n  }\n};\n},{\"./$.an-object\":24}],47:[function(require,module,exports){\n'use strict';\nvar $              = require('./$')\n  , descriptor     = require('./$.property-desc')\n  , setToStringTag = require('./$.set-to-string-tag')\n  , IteratorPrototype = {};\n\n// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()\nrequire('./$.hide')(IteratorPrototype, require('./$.wks')('iterator'), function(){ return this; });\n\nmodule.exports = function(Constructor, NAME, next){\n  Constructor.prototype = $.create(IteratorPrototype, {next: descriptor(1, next)});\n  setToStringTag(Constructor, NAME + ' Iterator');\n};\n},{\"./$\":52,\"./$.hide\":39,\"./$.property-desc\":58,\"./$.set-to-string-tag\":64,\"./$.wks\":75}],48:[function(require,module,exports){\n'use strict';\nvar LIBRARY        = require('./$.library')\n  , $export        = require('./$.export')\n  , redefine       = require('./$.redefine')\n  , hide           = require('./$.hide')\n  , has            = require('./$.has')\n  , Iterators      = require('./$.iterators')\n  , $iterCreate    = require('./$.iter-create')\n  , setToStringTag = require('./$.set-to-string-tag')\n  , getProto       = require('./$').getProto\n  , ITERATOR       = require('./$.wks')('iterator')\n  , BUGGY          = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`\n  , FF_ITERATOR    = '@@iterator'\n  , KEYS           = 'keys'\n  , VALUES         = 'values';\n\nvar returnThis = function(){ return this; };\n\nmodule.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){\n  $iterCreate(Constructor, NAME, next);\n  var getMethod = function(kind){\n    if(!BUGGY && kind in proto)return proto[kind];\n    switch(kind){\n      case KEYS: return function keys(){ return new Constructor(this, kind); };\n      case VALUES: return function values(){ return new Constructor(this, kind); };\n    } return function entries(){ return new Constructor(this, kind); };\n  };\n  var TAG        = NAME + ' Iterator'\n    , DEF_VALUES = DEFAULT == VALUES\n    , VALUES_BUG = false\n    , proto      = Base.prototype\n    , $native    = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]\n    , $default   = $native || getMethod(DEFAULT)\n    , methods, key;\n  // Fix native\n  if($native){\n    var IteratorPrototype = getProto($default.call(new Base));\n    // Set @@toStringTag to native iterators\n    setToStringTag(IteratorPrototype, TAG, true);\n    // FF fix\n    if(!LIBRARY && has(proto, FF_ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);\n    // fix Array#{values, @@iterator}.name in V8 / FF\n    if(DEF_VALUES && $native.name !== VALUES){\n      VALUES_BUG = true;\n      $default = function values(){ return $native.call(this); };\n    }\n  }\n  // Define iterator\n  if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){\n    hide(proto, ITERATOR, $default);\n  }\n  // Plug for library\n  Iterators[NAME] = $default;\n  Iterators[TAG]  = returnThis;\n  if(DEFAULT){\n    methods = {\n      values:  DEF_VALUES  ? $default : getMethod(VALUES),\n      keys:    IS_SET      ? $default : getMethod(KEYS),\n      entries: !DEF_VALUES ? $default : getMethod('entries')\n    };\n    if(FORCED)for(key in methods){\n      if(!(key in proto))redefine(proto, key, methods[key]);\n    } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);\n  }\n  return methods;\n};\n},{\"./$\":52,\"./$.export\":33,\"./$.has\":38,\"./$.hide\":39,\"./$.iter-create\":47,\"./$.iterators\":51,\"./$.library\":54,\"./$.redefine\":60,\"./$.set-to-string-tag\":64,\"./$.wks\":75}],49:[function(require,module,exports){\nvar ITERATOR     = require('./$.wks')('iterator')\n  , SAFE_CLOSING = false;\n\ntry {\n  var riter = [7][ITERATOR]();\n  riter['return'] = function(){ SAFE_CLOSING = true; };\n  Array.from(riter, function(){ throw 2; });\n} catch(e){ /* empty */ }\n\nmodule.exports = function(exec, skipClosing){\n  if(!skipClosing && !SAFE_CLOSING)return false;\n  var safe = false;\n  try {\n    var arr  = [7]\n      , iter = arr[ITERATOR]();\n    iter.next = function(){ safe = true; };\n    arr[ITERATOR] = function(){ return iter; };\n    exec(arr);\n  } catch(e){ /* empty */ }\n  return safe;\n};\n},{\"./$.wks\":75}],50:[function(require,module,exports){\nmodule.exports = function(done, value){\n  return {value: value, done: !!done};\n};\n},{}],51:[function(require,module,exports){\nmodule.exports = {};\n},{}],52:[function(require,module,exports){\nvar $Object = Object;\nmodule.exports = {\n  create:     $Object.create,\n  getProto:   $Object.getPrototypeOf,\n  isEnum:     {}.propertyIsEnumerable,\n  getDesc:    $Object.getOwnPropertyDescriptor,\n  setDesc:    $Object.defineProperty,\n  setDescs:   $Object.defineProperties,\n  getKeys:    $Object.keys,\n  getNames:   $Object.getOwnPropertyNames,\n  getSymbols: $Object.getOwnPropertySymbols,\n  each:       [].forEach\n};\n},{}],53:[function(require,module,exports){\nvar $         = require('./$')\n  , toIObject = require('./$.to-iobject');\nmodule.exports = function(object, el){\n  var O      = toIObject(object)\n    , keys   = $.getKeys(O)\n    , length = keys.length\n    , index  = 0\n    , key;\n  while(length > index)if(O[key = keys[index++]] === el)return key;\n};\n},{\"./$\":52,\"./$.to-iobject\":71}],54:[function(require,module,exports){\nmodule.exports = true;\n},{}],55:[function(require,module,exports){\nvar global    = require('./$.global')\n  , macrotask = require('./$.task').set\n  , Observer  = global.MutationObserver || global.WebKitMutationObserver\n  , process   = global.process\n  , Promise   = global.Promise\n  , isNode    = require('./$.cof')(process) == 'process'\n  , head, last, notify;\n\nvar flush = function(){\n  var parent, domain, fn;\n  if(isNode && (parent = process.domain)){\n    process.domain = null;\n    parent.exit();\n  }\n  while(head){\n    domain = head.domain;\n    fn     = head.fn;\n    if(domain)domain.enter();\n    fn(); // <- currently we use it only for Promise - try / catch not required\n    if(domain)domain.exit();\n    head = head.next;\n  } last = undefined;\n  if(parent)parent.enter();\n};\n\n// Node.js\nif(isNode){\n  notify = function(){\n    process.nextTick(flush);\n  };\n// browsers with MutationObserver\n} else if(Observer){\n  var toggle = 1\n    , node   = document.createTextNode('');\n  new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new\n  notify = function(){\n    node.data = toggle = -toggle;\n  };\n// environments with maybe non-completely correct, but existent Promise\n} else if(Promise && Promise.resolve){\n  notify = function(){\n    Promise.resolve().then(flush);\n  };\n// for other environments - macrotask based on:\n// - setImmediate\n// - MessageChannel\n// - window.postMessag\n// - onreadystatechange\n// - setTimeout\n} else {\n  notify = function(){\n    // strange IE + webpack dev server bug - use .call(global)\n    macrotask.call(global, flush);\n  };\n}\n\nmodule.exports = function asap(fn){\n  var task = {fn: fn, next: undefined, domain: isNode && process.domain};\n  if(last)last.next = task;\n  if(!head){\n    head = task;\n    notify();\n  } last = task;\n};\n},{\"./$.cof\":26,\"./$.global\":37,\"./$.task\":69}],56:[function(require,module,exports){\n// 19.1.2.1 Object.assign(target, source, ...)\nvar $        = require('./$')\n  , toObject = require('./$.to-object')\n  , IObject  = require('./$.iobject');\n\n// should work with symbols and should have deterministic property order (V8 bug)\nmodule.exports = require('./$.fails')(function(){\n  var a = Object.assign\n    , A = {}\n    , B = {}\n    , S = Symbol()\n    , K = 'abcdefghijklmnopqrst';\n  A[S] = 7;\n  K.split('').forEach(function(k){ B[k] = k; });\n  return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K;\n}) ? function assign(target, source){ // eslint-disable-line no-unused-vars\n  var T     = toObject(target)\n    , $$    = arguments\n    , $$len = $$.length\n    , index = 1\n    , getKeys    = $.getKeys\n    , getSymbols = $.getSymbols\n    , isEnum     = $.isEnum;\n  while($$len > index){\n    var S      = IObject($$[index++])\n      , keys   = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)\n      , length = keys.length\n      , j      = 0\n      , key;\n    while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key];\n  }\n  return T;\n} : Object.assign;\n},{\"./$\":52,\"./$.fails\":34,\"./$.iobject\":42,\"./$.to-object\":73}],57:[function(require,module,exports){\n// most Object methods by ES6 should accept primitives\nvar $export = require('./$.export')\n  , core    = require('./$.core')\n  , fails   = require('./$.fails');\nmodule.exports = function(KEY, exec){\n  var fn  = (core.Object || {})[KEY] || Object[KEY]\n    , exp = {};\n  exp[KEY] = exec(fn);\n  $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp);\n};\n},{\"./$.core\":27,\"./$.export\":33,\"./$.fails\":34}],58:[function(require,module,exports){\nmodule.exports = function(bitmap, value){\n  return {\n    enumerable  : !(bitmap & 1),\n    configurable: !(bitmap & 2),\n    writable    : !(bitmap & 4),\n    value       : value\n  };\n};\n},{}],59:[function(require,module,exports){\nvar redefine = require('./$.redefine');\nmodule.exports = function(target, src){\n  for(var key in src)redefine(target, key, src[key]);\n  return target;\n};\n},{\"./$.redefine\":60}],60:[function(require,module,exports){\nmodule.exports = require('./$.hide');\n},{\"./$.hide\":39}],61:[function(require,module,exports){\n// 7.2.9 SameValue(x, y)\nmodule.exports = Object.is || function is(x, y){\n  return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n},{}],62:[function(require,module,exports){\n// Works with __proto__ only. Old v8 can't work with null proto objects.\n/* eslint-disable no-proto */\nvar getDesc  = require('./$').getDesc\n  , isObject = require('./$.is-object')\n  , anObject = require('./$.an-object');\nvar check = function(O, proto){\n  anObject(O);\n  if(!isObject(proto) && proto !== null)throw TypeError(proto + \": can't set as prototype!\");\n};\nmodule.exports = {\n  set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line\n    function(test, buggy, set){\n      try {\n        set = require('./$.ctx')(Function.call, getDesc(Object.prototype, '__proto__').set, 2);\n        set(test, []);\n        buggy = !(test instanceof Array);\n      } catch(e){ buggy = true; }\n      return function setPrototypeOf(O, proto){\n        check(O, proto);\n        if(buggy)O.__proto__ = proto;\n        else set(O, proto);\n        return O;\n      };\n    }({}, false) : undefined),\n  check: check\n};\n},{\"./$\":52,\"./$.an-object\":24,\"./$.ctx\":28,\"./$.is-object\":45}],63:[function(require,module,exports){\n'use strict';\nvar core        = require('./$.core')\n  , $           = require('./$')\n  , DESCRIPTORS = require('./$.descriptors')\n  , SPECIES     = require('./$.wks')('species');\n\nmodule.exports = function(KEY){\n  var C = core[KEY];\n  if(DESCRIPTORS && C && !C[SPECIES])$.setDesc(C, SPECIES, {\n    configurable: true,\n    get: function(){ return this; }\n  });\n};\n},{\"./$\":52,\"./$.core\":27,\"./$.descriptors\":30,\"./$.wks\":75}],64:[function(require,module,exports){\nvar def = require('./$').setDesc\n  , has = require('./$.has')\n  , TAG = require('./$.wks')('toStringTag');\n\nmodule.exports = function(it, tag, stat){\n  if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});\n};\n},{\"./$\":52,\"./$.has\":38,\"./$.wks\":75}],65:[function(require,module,exports){\nvar global = require('./$.global')\n  , SHARED = '__core-js_shared__'\n  , store  = global[SHARED] || (global[SHARED] = {});\nmodule.exports = function(key){\n  return store[key] || (store[key] = {});\n};\n},{\"./$.global\":37}],66:[function(require,module,exports){\n// 7.3.20 SpeciesConstructor(O, defaultConstructor)\nvar anObject  = require('./$.an-object')\n  , aFunction = require('./$.a-function')\n  , SPECIES   = require('./$.wks')('species');\nmodule.exports = function(O, D){\n  var C = anObject(O).constructor, S;\n  return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);\n};\n},{\"./$.a-function\":22,\"./$.an-object\":24,\"./$.wks\":75}],67:[function(require,module,exports){\nmodule.exports = function(it, Constructor, name){\n  if(!(it instanceof Constructor))throw TypeError(name + \": use the 'new' operator!\");\n  return it;\n};\n},{}],68:[function(require,module,exports){\nvar toInteger = require('./$.to-integer')\n  , defined   = require('./$.defined');\n// true  -> String#at\n// false -> String#codePointAt\nmodule.exports = function(TO_STRING){\n  return function(that, pos){\n    var s = String(defined(that))\n      , i = toInteger(pos)\n      , l = s.length\n      , a, b;\n    if(i < 0 || i >= l)return TO_STRING ? '' : undefined;\n    a = s.charCodeAt(i);\n    return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff\n      ? TO_STRING ? s.charAt(i) : a\n      : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;\n  };\n};\n},{\"./$.defined\":29,\"./$.to-integer\":70}],69:[function(require,module,exports){\nvar ctx                = require('./$.ctx')\n  , invoke             = require('./$.invoke')\n  , html               = require('./$.html')\n  , cel                = require('./$.dom-create')\n  , global             = require('./$.global')\n  , process            = global.process\n  , setTask            = global.setImmediate\n  , clearTask          = global.clearImmediate\n  , MessageChannel     = global.MessageChannel\n  , counter            = 0\n  , queue              = {}\n  , ONREADYSTATECHANGE = 'onreadystatechange'\n  , defer, channel, port;\nvar run = function(){\n  var id = +this;\n  if(queue.hasOwnProperty(id)){\n    var fn = queue[id];\n    delete queue[id];\n    fn();\n  }\n};\nvar listner = function(event){\n  run.call(event.data);\n};\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif(!setTask || !clearTask){\n  setTask = function setImmediate(fn){\n    var args = [], i = 1;\n    while(arguments.length > i)args.push(arguments[i++]);\n    queue[++counter] = function(){\n      invoke(typeof fn == 'function' ? fn : Function(fn), args);\n    };\n    defer(counter);\n    return counter;\n  };\n  clearTask = function clearImmediate(id){\n    delete queue[id];\n  };\n  // Node.js 0.8-\n  if(require('./$.cof')(process) == 'process'){\n    defer = function(id){\n      process.nextTick(ctx(run, id, 1));\n    };\n  // Browsers with MessageChannel, includes WebWorkers\n  } else if(MessageChannel){\n    channel = new MessageChannel;\n    port    = channel.port2;\n    channel.port1.onmessage = listner;\n    defer = ctx(port.postMessage, port, 1);\n  // Browsers with postMessage, skip WebWorkers\n  // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n  } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){\n    defer = function(id){\n      global.postMessage(id + '', '*');\n    };\n    global.addEventListener('message', listner, false);\n  // IE8-\n  } else if(ONREADYSTATECHANGE in cel('script')){\n    defer = function(id){\n      html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){\n        html.removeChild(this);\n        run.call(id);\n      };\n    };\n  // Rest old browsers\n  } else {\n    defer = function(id){\n      setTimeout(ctx(run, id, 1), 0);\n    };\n  }\n}\nmodule.exports = {\n  set:   setTask,\n  clear: clearTask\n};\n},{\"./$.cof\":26,\"./$.ctx\":28,\"./$.dom-create\":31,\"./$.global\":37,\"./$.html\":40,\"./$.invoke\":41}],70:[function(require,module,exports){\n// 7.1.4 ToInteger\nvar ceil  = Math.ceil\n  , floor = Math.floor;\nmodule.exports = function(it){\n  return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);\n};\n},{}],71:[function(require,module,exports){\n// to indexed object, toObject with fallback for non-array-like ES3 strings\nvar IObject = require('./$.iobject')\n  , defined = require('./$.defined');\nmodule.exports = function(it){\n  return IObject(defined(it));\n};\n},{\"./$.defined\":29,\"./$.iobject\":42}],72:[function(require,module,exports){\n// 7.1.15 ToLength\nvar toInteger = require('./$.to-integer')\n  , min       = Math.min;\nmodule.exports = function(it){\n  return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991\n};\n},{\"./$.to-integer\":70}],73:[function(require,module,exports){\n// 7.1.13 ToObject(argument)\nvar defined = require('./$.defined');\nmodule.exports = function(it){\n  return Object(defined(it));\n};\n},{\"./$.defined\":29}],74:[function(require,module,exports){\nvar id = 0\n  , px = Math.random();\nmodule.exports = function(key){\n  return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));\n};\n},{}],75:[function(require,module,exports){\nvar store  = require('./$.shared')('wks')\n  , uid    = require('./$.uid')\n  , Symbol = require('./$.global').Symbol;\nmodule.exports = function(name){\n  return store[name] || (store[name] =\n    Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name));\n};\n},{\"./$.global\":37,\"./$.shared\":65,\"./$.uid\":74}],76:[function(require,module,exports){\nvar classof   = require('./$.classof')\n  , ITERATOR  = require('./$.wks')('iterator')\n  , Iterators = require('./$.iterators');\nmodule.exports = require('./$.core').getIteratorMethod = function(it){\n  if(it != undefined)return it[ITERATOR]\n    || it['@@iterator']\n    || Iterators[classof(it)];\n};\n},{\"./$.classof\":25,\"./$.core\":27,\"./$.iterators\":51,\"./$.wks\":75}],77:[function(require,module,exports){\n'use strict';\nvar addToUnscopables = require('./$.add-to-unscopables')\n  , step             = require('./$.iter-step')\n  , Iterators        = require('./$.iterators')\n  , toIObject        = require('./$.to-iobject');\n\n// 22.1.3.4 Array.prototype.entries()\n// 22.1.3.13 Array.prototype.keys()\n// 22.1.3.29 Array.prototype.values()\n// 22.1.3.30 Array.prototype[@@iterator]()\nmodule.exports = require('./$.iter-define')(Array, 'Array', function(iterated, kind){\n  this._t = toIObject(iterated); // target\n  this._i = 0;                   // next index\n  this._k = kind;                // kind\n// 22.1.5.2.1 %ArrayIteratorPrototype%.next()\n}, function(){\n  var O     = this._t\n    , kind  = this._k\n    , index = this._i++;\n  if(!O || index >= O.length){\n    this._t = undefined;\n    return step(1);\n  }\n  if(kind == 'keys'  )return step(0, index);\n  if(kind == 'values')return step(0, O[index]);\n  return step(0, [index, O[index]]);\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)\nIterators.Arguments = Iterators.Array;\n\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n},{\"./$.add-to-unscopables\":23,\"./$.iter-define\":48,\"./$.iter-step\":50,\"./$.iterators\":51,\"./$.to-iobject\":71}],78:[function(require,module,exports){\n// 19.1.3.1 Object.assign(target, source)\nvar $export = require('./$.export');\n\n$export($export.S + $export.F, 'Object', {assign: require('./$.object-assign')});\n},{\"./$.export\":33,\"./$.object-assign\":56}],79:[function(require,module,exports){\n// 19.1.2.9 Object.getPrototypeOf(O)\nvar toObject = require('./$.to-object');\n\nrequire('./$.object-sap')('getPrototypeOf', function($getPrototypeOf){\n  return function getPrototypeOf(it){\n    return $getPrototypeOf(toObject(it));\n  };\n});\n},{\"./$.object-sap\":57,\"./$.to-object\":73}],80:[function(require,module,exports){\n// 19.1.2.14 Object.keys(O)\nvar toObject = require('./$.to-object');\n\nrequire('./$.object-sap')('keys', function($keys){\n  return function keys(it){\n    return $keys(toObject(it));\n  };\n});\n},{\"./$.object-sap\":57,\"./$.to-object\":73}],81:[function(require,module,exports){\n// 19.1.3.19 Object.setPrototypeOf(O, proto)\nvar $export = require('./$.export');\n$export($export.S, 'Object', {setPrototypeOf: require('./$.set-proto').set});\n},{\"./$.export\":33,\"./$.set-proto\":62}],82:[function(require,module,exports){\n\n},{}],83:[function(require,module,exports){\n'use strict';\nvar $          = require('./$')\n  , LIBRARY    = require('./$.library')\n  , global     = require('./$.global')\n  , ctx        = require('./$.ctx')\n  , classof    = require('./$.classof')\n  , $export    = require('./$.export')\n  , isObject   = require('./$.is-object')\n  , anObject   = require('./$.an-object')\n  , aFunction  = require('./$.a-function')\n  , strictNew  = require('./$.strict-new')\n  , forOf      = require('./$.for-of')\n  , setProto   = require('./$.set-proto').set\n  , same       = require('./$.same-value')\n  , SPECIES    = require('./$.wks')('species')\n  , speciesConstructor = require('./$.species-constructor')\n  , asap       = require('./$.microtask')\n  , PROMISE    = 'Promise'\n  , process    = global.process\n  , isNode     = classof(process) == 'process'\n  , P          = global[PROMISE]\n  , Wrapper;\n\nvar testResolve = function(sub){\n  var test = new P(function(){});\n  if(sub)test.constructor = Object;\n  return P.resolve(test) === test;\n};\n\nvar USE_NATIVE = function(){\n  var works = false;\n  function P2(x){\n    var self = new P(x);\n    setProto(self, P2.prototype);\n    return self;\n  }\n  try {\n    works = P && P.resolve && testResolve();\n    setProto(P2, P);\n    P2.prototype = $.create(P.prototype, {constructor: {value: P2}});\n    // actual Firefox has broken subclass support, test that\n    if(!(P2.resolve(5).then(function(){}) instanceof P2)){\n      works = false;\n    }\n    // actual V8 bug, https://code.google.com/p/v8/issues/detail?id=4162\n    if(works && require('./$.descriptors')){\n      var thenableThenGotten = false;\n      P.resolve($.setDesc({}, 'then', {\n        get: function(){ thenableThenGotten = true; }\n      }));\n      works = thenableThenGotten;\n    }\n  } catch(e){ works = false; }\n  return works;\n}();\n\n// helpers\nvar sameConstructor = function(a, b){\n  // library wrapper special case\n  if(LIBRARY && a === P && b === Wrapper)return true;\n  return same(a, b);\n};\nvar getConstructor = function(C){\n  var S = anObject(C)[SPECIES];\n  return S != undefined ? S : C;\n};\nvar isThenable = function(it){\n  var then;\n  return isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\nvar PromiseCapability = function(C){\n  var resolve, reject;\n  this.promise = new C(function($$resolve, $$reject){\n    if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');\n    resolve = $$resolve;\n    reject  = $$reject;\n  });\n  this.resolve = aFunction(resolve),\n  this.reject  = aFunction(reject)\n};\nvar perform = function(exec){\n  try {\n    exec();\n  } catch(e){\n    return {error: e};\n  }\n};\nvar notify = function(record, isReject){\n  if(record.n)return;\n  record.n = true;\n  var chain = record.c;\n  asap(function(){\n    var value = record.v\n      , ok    = record.s == 1\n      , i     = 0;\n    var run = function(reaction){\n      var handler = ok ? reaction.ok : reaction.fail\n        , resolve = reaction.resolve\n        , reject  = reaction.reject\n        , result, then;\n      try {\n        if(handler){\n          if(!ok)record.h = true;\n          result = handler === true ? value : handler(value);\n          if(result === reaction.promise){\n            reject(TypeError('Promise-chain cycle'));\n          } else if(then = isThenable(result)){\n            then.call(result, resolve, reject);\n          } else resolve(result);\n        } else reject(value);\n      } catch(e){\n        reject(e);\n      }\n    };\n    while(chain.length > i)run(chain[i++]); // variable length - can't use forEach\n    chain.length = 0;\n    record.n = false;\n    if(isReject)setTimeout(function(){\n      var promise = record.p\n        , handler, console;\n      if(isUnhandled(promise)){\n        if(isNode){\n          process.emit('unhandledRejection', value, promise);\n        } else if(handler = global.onunhandledrejection){\n          handler({promise: promise, reason: value});\n        } else if((console = global.console) && console.error){\n          console.error('Unhandled promise rejection', value);\n        }\n      } record.a = undefined;\n    }, 1);\n  });\n};\nvar isUnhandled = function(promise){\n  var record = promise._d\n    , chain  = record.a || record.c\n    , i      = 0\n    , reaction;\n  if(record.h)return false;\n  while(chain.length > i){\n    reaction = chain[i++];\n    if(reaction.fail || !isUnhandled(reaction.promise))return false;\n  } return true;\n};\nvar $reject = function(value){\n  var record = this;\n  if(record.d)return;\n  record.d = true;\n  record = record.r || record; // unwrap\n  record.v = value;\n  record.s = 2;\n  record.a = record.c.slice();\n  notify(record, true);\n};\nvar $resolve = function(value){\n  var record = this\n    , then;\n  if(record.d)return;\n  record.d = true;\n  record = record.r || record; // unwrap\n  try {\n    if(record.p === value)throw TypeError(\"Promise can't be resolved itself\");\n    if(then = isThenable(value)){\n      asap(function(){\n        var wrapper = {r: record, d: false}; // wrap\n        try {\n          then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));\n        } catch(e){\n          $reject.call(wrapper, e);\n        }\n      });\n    } else {\n      record.v = value;\n      record.s = 1;\n      notify(record, false);\n    }\n  } catch(e){\n    $reject.call({r: record, d: false}, e); // wrap\n  }\n};\n\n// constructor polyfill\nif(!USE_NATIVE){\n  // 25.4.3.1 Promise(executor)\n  P = function Promise(executor){\n    aFunction(executor);\n    var record = this._d = {\n      p: strictNew(this, P, PROMISE),         // <- promise\n      c: [],                                  // <- awaiting reactions\n      a: undefined,                           // <- checked in isUnhandled reactions\n      s: 0,                                   // <- state\n      d: false,                               // <- done\n      v: undefined,                           // <- value\n      h: false,                               // <- handled rejection\n      n: false                                // <- notify\n    };\n    try {\n      executor(ctx($resolve, record, 1), ctx($reject, record, 1));\n    } catch(err){\n      $reject.call(record, err);\n    }\n  };\n  require('./$.redefine-all')(P.prototype, {\n    // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)\n    then: function then(onFulfilled, onRejected){\n      var reaction = new PromiseCapability(speciesConstructor(this, P))\n        , promise  = reaction.promise\n        , record   = this._d;\n      reaction.ok   = typeof onFulfilled == 'function' ? onFulfilled : true;\n      reaction.fail = typeof onRejected == 'function' && onRejected;\n      record.c.push(reaction);\n      if(record.a)record.a.push(reaction);\n      if(record.s)notify(record, false);\n      return promise;\n    },\n    // 25.4.5.1 Promise.prototype.catch(onRejected)\n    'catch': function(onRejected){\n      return this.then(undefined, onRejected);\n    }\n  });\n}\n\n$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: P});\nrequire('./$.set-to-string-tag')(P, PROMISE);\nrequire('./$.set-species')(PROMISE);\nWrapper = require('./$.core')[PROMISE];\n\n// statics\n$export($export.S + $export.F * !USE_NATIVE, PROMISE, {\n  // 25.4.4.5 Promise.reject(r)\n  reject: function reject(r){\n    var capability = new PromiseCapability(this)\n      , $$reject   = capability.reject;\n    $$reject(r);\n    return capability.promise;\n  }\n});\n$export($export.S + $export.F * (!USE_NATIVE || testResolve(true)), PROMISE, {\n  // 25.4.4.6 Promise.resolve(x)\n  resolve: function resolve(x){\n    // instanceof instead of internal slot check because we should fix it without replacement native Promise core\n    if(x instanceof P && sameConstructor(x.constructor, this))return x;\n    var capability = new PromiseCapability(this)\n      , $$resolve  = capability.resolve;\n    $$resolve(x);\n    return capability.promise;\n  }\n});\n$export($export.S + $export.F * !(USE_NATIVE && require('./$.iter-detect')(function(iter){\n  P.all(iter)['catch'](function(){});\n})), PROMISE, {\n  // 25.4.4.1 Promise.all(iterable)\n  all: function all(iterable){\n    var C          = getConstructor(this)\n      , capability = new PromiseCapability(C)\n      , resolve    = capability.resolve\n      , reject     = capability.reject\n      , values     = [];\n    var abrupt = perform(function(){\n      forOf(iterable, false, values.push, values);\n      var remaining = values.length\n        , results   = Array(remaining);\n      if(remaining)$.each.call(values, function(promise, index){\n        var alreadyCalled = false;\n        C.resolve(promise).then(function(value){\n          if(alreadyCalled)return;\n          alreadyCalled = true;\n          results[index] = value;\n          --remaining || resolve(results);\n        }, reject);\n      });\n      else resolve(results);\n    });\n    if(abrupt)reject(abrupt.error);\n    return capability.promise;\n  },\n  // 25.4.4.4 Promise.race(iterable)\n  race: function race(iterable){\n    var C          = getConstructor(this)\n      , capability = new PromiseCapability(C)\n      , reject     = capability.reject;\n    var abrupt = perform(function(){\n      forOf(iterable, false, function(promise){\n        C.resolve(promise).then(capability.resolve, reject);\n      });\n    });\n    if(abrupt)reject(abrupt.error);\n    return capability.promise;\n  }\n});\n},{\"./$\":52,\"./$.a-function\":22,\"./$.an-object\":24,\"./$.classof\":25,\"./$.core\":27,\"./$.ctx\":28,\"./$.descriptors\":30,\"./$.export\":33,\"./$.for-of\":35,\"./$.global\":37,\"./$.is-object\":45,\"./$.iter-detect\":49,\"./$.library\":54,\"./$.microtask\":55,\"./$.redefine-all\":59,\"./$.same-value\":61,\"./$.set-proto\":62,\"./$.set-species\":63,\"./$.set-to-string-tag\":64,\"./$.species-constructor\":66,\"./$.strict-new\":67,\"./$.wks\":75}],84:[function(require,module,exports){\n'use strict';\nvar $at  = require('./$.string-at')(true);\n\n// 21.1.3.27 String.prototype[@@iterator]()\nrequire('./$.iter-define')(String, 'String', function(iterated){\n  this._t = String(iterated); // target\n  this._i = 0;                // next index\n// 21.1.5.2.1 %StringIteratorPrototype%.next()\n}, function(){\n  var O     = this._t\n    , index = this._i\n    , point;\n  if(index >= O.length)return {value: undefined, done: true};\n  point = $at(O, index);\n  this._i += point.length;\n  return {value: point, done: false};\n});\n},{\"./$.iter-define\":48,\"./$.string-at\":68}],85:[function(require,module,exports){\n'use strict';\n// ECMAScript 6 symbols shim\nvar $              = require('./$')\n  , global         = require('./$.global')\n  , has            = require('./$.has')\n  , DESCRIPTORS    = require('./$.descriptors')\n  , $export        = require('./$.export')\n  , redefine       = require('./$.redefine')\n  , $fails         = require('./$.fails')\n  , shared         = require('./$.shared')\n  , setToStringTag = require('./$.set-to-string-tag')\n  , uid            = require('./$.uid')\n  , wks            = require('./$.wks')\n  , keyOf          = require('./$.keyof')\n  , $names         = require('./$.get-names')\n  , enumKeys       = require('./$.enum-keys')\n  , isArray        = require('./$.is-array')\n  , anObject       = require('./$.an-object')\n  , toIObject      = require('./$.to-iobject')\n  , createDesc     = require('./$.property-desc')\n  , getDesc        = $.getDesc\n  , setDesc        = $.setDesc\n  , _create        = $.create\n  , getNames       = $names.get\n  , $Symbol        = global.Symbol\n  , $JSON          = global.JSON\n  , _stringify     = $JSON && $JSON.stringify\n  , setter         = false\n  , HIDDEN         = wks('_hidden')\n  , isEnum         = $.isEnum\n  , SymbolRegistry = shared('symbol-registry')\n  , AllSymbols     = shared('symbols')\n  , useNative      = typeof $Symbol == 'function'\n  , ObjectProto    = Object.prototype;\n\n// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687\nvar setSymbolDesc = DESCRIPTORS && $fails(function(){\n  return _create(setDesc({}, 'a', {\n    get: function(){ return setDesc(this, 'a', {value: 7}).a; }\n  })).a != 7;\n}) ? function(it, key, D){\n  var protoDesc = getDesc(ObjectProto, key);\n  if(protoDesc)delete ObjectProto[key];\n  setDesc(it, key, D);\n  if(protoDesc && it !== ObjectProto)setDesc(ObjectProto, key, protoDesc);\n} : setDesc;\n\nvar wrap = function(tag){\n  var sym = AllSymbols[tag] = _create($Symbol.prototype);\n  sym._k = tag;\n  DESCRIPTORS && setter && setSymbolDesc(ObjectProto, tag, {\n    configurable: true,\n    set: function(value){\n      if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;\n      setSymbolDesc(this, tag, createDesc(1, value));\n    }\n  });\n  return sym;\n};\n\nvar isSymbol = function(it){\n  return typeof it == 'symbol';\n};\n\nvar $defineProperty = function defineProperty(it, key, D){\n  if(D && has(AllSymbols, key)){\n    if(!D.enumerable){\n      if(!has(it, HIDDEN))setDesc(it, HIDDEN, createDesc(1, {}));\n      it[HIDDEN][key] = true;\n    } else {\n      if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;\n      D = _create(D, {enumerable: createDesc(0, false)});\n    } return setSymbolDesc(it, key, D);\n  } return setDesc(it, key, D);\n};\nvar $defineProperties = function defineProperties(it, P){\n  anObject(it);\n  var keys = enumKeys(P = toIObject(P))\n    , i    = 0\n    , l = keys.length\n    , key;\n  while(l > i)$defineProperty(it, key = keys[i++], P[key]);\n  return it;\n};\nvar $create = function create(it, P){\n  return P === undefined ? _create(it) : $defineProperties(_create(it), P);\n};\nvar $propertyIsEnumerable = function propertyIsEnumerable(key){\n  var E = isEnum.call(this, key);\n  return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key]\n    ? E : true;\n};\nvar $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){\n  var D = getDesc(it = toIObject(it), key);\n  if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;\n  return D;\n};\nvar $getOwnPropertyNames = function getOwnPropertyNames(it){\n  var names  = getNames(toIObject(it))\n    , result = []\n    , i      = 0\n    , key;\n  while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key);\n  return result;\n};\nvar $getOwnPropertySymbols = function getOwnPropertySymbols(it){\n  var names  = getNames(toIObject(it))\n    , result = []\n    , i      = 0\n    , key;\n  while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]);\n  return result;\n};\nvar $stringify = function stringify(it){\n  if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined\n  var args = [it]\n    , i    = 1\n    , $$   = arguments\n    , replacer, $replacer;\n  while($$.length > i)args.push($$[i++]);\n  replacer = args[1];\n  if(typeof replacer == 'function')$replacer = replacer;\n  if($replacer || !isArray(replacer))replacer = function(key, value){\n    if($replacer)value = $replacer.call(this, key, value);\n    if(!isSymbol(value))return value;\n  };\n  args[1] = replacer;\n  return _stringify.apply($JSON, args);\n};\nvar buggyJSON = $fails(function(){\n  var S = $Symbol();\n  // MS Edge converts symbol values to JSON as {}\n  // WebKit converts symbol values to JSON as null\n  // V8 throws on boxed symbols\n  return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';\n});\n\n// 19.4.1.1 Symbol([description])\nif(!useNative){\n  $Symbol = function Symbol(){\n    if(isSymbol(this))throw TypeError('Symbol is not a constructor');\n    return wrap(uid(arguments.length > 0 ? arguments[0] : undefined));\n  };\n  redefine($Symbol.prototype, 'toString', function toString(){\n    return this._k;\n  });\n\n  isSymbol = function(it){\n    return it instanceof $Symbol;\n  };\n\n  $.create     = $create;\n  $.isEnum     = $propertyIsEnumerable;\n  $.getDesc    = $getOwnPropertyDescriptor;\n  $.setDesc    = $defineProperty;\n  $.setDescs   = $defineProperties;\n  $.getNames   = $names.get = $getOwnPropertyNames;\n  $.getSymbols = $getOwnPropertySymbols;\n\n  if(DESCRIPTORS && !require('./$.library')){\n    redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);\n  }\n}\n\nvar symbolStatics = {\n  // 19.4.2.1 Symbol.for(key)\n  'for': function(key){\n    return has(SymbolRegistry, key += '')\n      ? SymbolRegistry[key]\n      : SymbolRegistry[key] = $Symbol(key);\n  },\n  // 19.4.2.5 Symbol.keyFor(sym)\n  keyFor: function keyFor(key){\n    return keyOf(SymbolRegistry, key);\n  },\n  useSetter: function(){ setter = true; },\n  useSimple: function(){ setter = false; }\n};\n// 19.4.2.2 Symbol.hasInstance\n// 19.4.2.3 Symbol.isConcatSpreadable\n// 19.4.2.4 Symbol.iterator\n// 19.4.2.6 Symbol.match\n// 19.4.2.8 Symbol.replace\n// 19.4.2.9 Symbol.search\n// 19.4.2.10 Symbol.species\n// 19.4.2.11 Symbol.split\n// 19.4.2.12 Symbol.toPrimitive\n// 19.4.2.13 Symbol.toStringTag\n// 19.4.2.14 Symbol.unscopables\n$.each.call((\n  'hasInstance,isConcatSpreadable,iterator,match,replace,search,' +\n  'species,split,toPrimitive,toStringTag,unscopables'\n).split(','), function(it){\n  var sym = wks(it);\n  symbolStatics[it] = useNative ? sym : wrap(sym);\n});\n\nsetter = true;\n\n$export($export.G + $export.W, {Symbol: $Symbol});\n\n$export($export.S, 'Symbol', symbolStatics);\n\n$export($export.S + $export.F * !useNative, 'Object', {\n  // 19.1.2.2 Object.create(O [, Properties])\n  create: $create,\n  // 19.1.2.4 Object.defineProperty(O, P, Attributes)\n  defineProperty: $defineProperty,\n  // 19.1.2.3 Object.defineProperties(O, Properties)\n  defineProperties: $defineProperties,\n  // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)\n  getOwnPropertyDescriptor: $getOwnPropertyDescriptor,\n  // 19.1.2.7 Object.getOwnPropertyNames(O)\n  getOwnPropertyNames: $getOwnPropertyNames,\n  // 19.1.2.8 Object.getOwnPropertySymbols(O)\n  getOwnPropertySymbols: $getOwnPropertySymbols\n});\n\n// 24.3.2 JSON.stringify(value [, replacer [, space]])\n$JSON && $export($export.S + $export.F * (!useNative || buggyJSON), 'JSON', {stringify: $stringify});\n\n// 19.4.3.5 Symbol.prototype[@@toStringTag]\nsetToStringTag($Symbol, 'Symbol');\n// 20.2.1.9 Math[@@toStringTag]\nsetToStringTag(Math, 'Math', true);\n// 24.3.3 JSON[@@toStringTag]\nsetToStringTag(global.JSON, 'JSON', true);\n},{\"./$\":52,\"./$.an-object\":24,\"./$.descriptors\":30,\"./$.enum-keys\":32,\"./$.export\":33,\"./$.fails\":34,\"./$.get-names\":36,\"./$.global\":37,\"./$.has\":38,\"./$.is-array\":44,\"./$.keyof\":53,\"./$.library\":54,\"./$.property-desc\":58,\"./$.redefine\":60,\"./$.set-to-string-tag\":64,\"./$.shared\":65,\"./$.to-iobject\":71,\"./$.uid\":74,\"./$.wks\":75}],86:[function(require,module,exports){\nrequire('./es6.array.iterator');\nvar Iterators = require('./$.iterators');\nIterators.NodeList = Iterators.HTMLCollection = Iterators.Array;\n},{\"./$.iterators\":51,\"./es6.array.iterator\":77}],87:[function(require,module,exports){\n// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n    draining = false;\n    if (currentQueue.length) {\n        queue = currentQueue.concat(queue);\n    } else {\n        queueIndex = -1;\n    }\n    if (queue.length) {\n        drainQueue();\n    }\n}\n\nfunction drainQueue() {\n    if (draining) {\n        return;\n    }\n    var timeout = setTimeout(cleanUpNextTick);\n    draining = true;\n\n    var len = queue.length;\n    while(len) {\n        currentQueue = queue;\n        queue = [];\n        while (++queueIndex < len) {\n            if (currentQueue) {\n                currentQueue[queueIndex].run();\n            }\n        }\n        queueIndex = -1;\n        len = queue.length;\n    }\n    currentQueue = null;\n    draining = false;\n    clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n    var args = new Array(arguments.length - 1);\n    if (arguments.length > 1) {\n        for (var i = 1; i < arguments.length; i++) {\n            args[i - 1] = arguments[i];\n        }\n    }\n    queue.push(new Item(fun, args));\n    if (queue.length === 1 && !draining) {\n        setTimeout(drainQueue, 0);\n    }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n    this.fun = fun;\n    this.array = array;\n}\nItem.prototype.run = function () {\n    this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n    throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n    throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n},{}],88:[function(require,module,exports){\n\n/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n               && 'undefined' != typeof chrome.storage\n                  ? chrome.storage.local\n                  : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n  'lightseagreen',\n  'forestgreen',\n  'goldenrod',\n  'dodgerblue',\n  'darkorchid',\n  'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n  // is webkit? http://stackoverflow.com/a/16459606/376773\n  return ('WebkitAppearance' in document.documentElement.style) ||\n    // is firebug? http://stackoverflow.com/a/398120/376773\n    (window.console && (console.firebug || (console.exception && console.table))) ||\n    // is firefox >= v31?\n    // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n    (navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31);\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n  return JSON.stringify(v);\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs() {\n  var args = arguments;\n  var useColors = this.useColors;\n\n  args[0] = (useColors ? '%c' : '')\n    + this.namespace\n    + (useColors ? ' %c' : ' ')\n    + args[0]\n    + (useColors ? '%c ' : ' ')\n    + '+' + exports.humanize(this.diff);\n\n  if (!useColors) return args;\n\n  var c = 'color: ' + this.color;\n  args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));\n\n  // the final \"%c\" is somewhat tricky, because there could be other\n  // arguments passed either before or after the %c, so we need to\n  // figure out the correct index to insert the CSS into\n  var index = 0;\n  var lastC = 0;\n  args[0].replace(/%[a-z%]/g, function(match) {\n    if ('%%' === match) return;\n    index++;\n    if ('%c' === match) {\n      // we only are interested in the *last* %c\n      // (the user may have provided their own)\n      lastC = index;\n    }\n  });\n\n  args.splice(lastC, 0, c);\n  return args;\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n  // this hackery is required for IE8/9, where\n  // the `console.log` function doesn't have 'apply'\n  return 'object' === typeof console\n    && console.log\n    && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n  try {\n    if (null == namespaces) {\n      exports.storage.removeItem('debug');\n    } else {\n      exports.storage.debug = namespaces;\n    }\n  } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n  var r;\n  try {\n    r = exports.storage.debug;\n  } catch(e) {}\n  return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage(){\n  try {\n    return window.localStorage;\n  } catch (e) {}\n}\n\n},{\"./debug\":89}],89:[function(require,module,exports){\n\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = debug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lowercased letter, i.e. \"n\".\n */\n\nexports.formatters = {};\n\n/**\n * Previously assigned color.\n */\n\nvar prevColor = 0;\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n *\n * @return {Number}\n * @api private\n */\n\nfunction selectColor() {\n  return exports.colors[prevColor++ % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction debug(namespace) {\n\n  // define the `disabled` version\n  function disabled() {\n  }\n  disabled.enabled = false;\n\n  // define the `enabled` version\n  function enabled() {\n\n    var self = enabled;\n\n    // set `diff` timestamp\n    var curr = +new Date();\n    var ms = curr - (prevTime || curr);\n    self.diff = ms;\n    self.prev = prevTime;\n    self.curr = curr;\n    prevTime = curr;\n\n    // add the `color` if not set\n    if (null == self.useColors) self.useColors = exports.useColors();\n    if (null == self.color && self.useColors) self.color = selectColor();\n\n    var args = Array.prototype.slice.call(arguments);\n\n    args[0] = exports.coerce(args[0]);\n\n    if ('string' !== typeof args[0]) {\n      // anything else let's inspect with %o\n      args = ['%o'].concat(args);\n    }\n\n    // apply any `formatters` transformations\n    var index = 0;\n    args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {\n      // if we encounter an escaped % then don't increase the array index\n      if (match === '%%') return match;\n      index++;\n      var formatter = exports.formatters[format];\n      if ('function' === typeof formatter) {\n        var val = args[index];\n        match = formatter.call(self, val);\n\n        // now we need to remove `args[index]` since it's inlined in the `format`\n        args.splice(index, 1);\n        index--;\n      }\n      return match;\n    });\n\n    if ('function' === typeof exports.formatArgs) {\n      args = exports.formatArgs.apply(self, args);\n    }\n    var logFn = enabled.log || exports.log || console.log.bind(console);\n    logFn.apply(self, args);\n  }\n  enabled.enabled = true;\n\n  var fn = exports.enabled(namespace) ? enabled : disabled;\n\n  fn.namespace = namespace;\n\n  return fn;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n  exports.save(namespaces);\n\n  var split = (namespaces || '').split(/[\\s,]+/);\n  var len = split.length;\n\n  for (var i = 0; i < len; i++) {\n    if (!split[i]) continue; // ignore empty strings\n    namespaces = split[i].replace(/\\*/g, '.*?');\n    if (namespaces[0] === '-') {\n      exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n    } else {\n      exports.names.push(new RegExp('^' + namespaces + '$'));\n    }\n  }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n  exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n  var i, len;\n  for (i = 0, len = exports.skips.length; i < len; i++) {\n    if (exports.skips[i].test(name)) {\n      return false;\n    }\n  }\n  for (i = 0, len = exports.names.length; i < len; i++) {\n    if (exports.names[i].test(name)) {\n      return true;\n    }\n  }\n  return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n  if (val instanceof Error) return val.stack || val.message;\n  return val;\n}\n\n},{\"ms\":90}],90:[function(require,module,exports){\n/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n *  - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} options\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options){\n  options = options || {};\n  if ('string' == typeof val) return parse(val);\n  return options.long\n    ? long(val)\n    : short(val);\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n  str = '' + str;\n  if (str.length > 10000) return;\n  var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);\n  if (!match) return;\n  var n = parseFloat(match[1]);\n  var type = (match[2] || 'ms').toLowerCase();\n  switch (type) {\n    case 'years':\n    case 'year':\n    case 'yrs':\n    case 'yr':\n    case 'y':\n      return n * y;\n    case 'days':\n    case 'day':\n    case 'd':\n      return n * d;\n    case 'hours':\n    case 'hour':\n    case 'hrs':\n    case 'hr':\n    case 'h':\n      return n * h;\n    case 'minutes':\n    case 'minute':\n    case 'mins':\n    case 'min':\n    case 'm':\n      return n * m;\n    case 'seconds':\n    case 'second':\n    case 'secs':\n    case 'sec':\n    case 's':\n      return n * s;\n    case 'milliseconds':\n    case 'millisecond':\n    case 'msecs':\n    case 'msec':\n    case 'ms':\n      return n;\n  }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction short(ms) {\n  if (ms >= d) return Math.round(ms / d) + 'd';\n  if (ms >= h) return Math.round(ms / h) + 'h';\n  if (ms >= m) return Math.round(ms / m) + 'm';\n  if (ms >= s) return Math.round(ms / s) + 's';\n  return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction long(ms) {\n  return plural(ms, d, 'day')\n    || plural(ms, h, 'hour')\n    || plural(ms, m, 'minute')\n    || plural(ms, s, 'second')\n    || ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n  if (ms < n) return;\n  if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;\n  return Math.ceil(ms / n) + ' ' + name + 's';\n}\n\n},{}],91:[function(require,module,exports){\n'use strict';\n\n//\n// We store our EE objects in a plain object whose properties are event names.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// `~` to make sure that the built-in object properties are not overridden or\n// used as an attack vector.\n// We also assume that `Object.create(null)` is available when the event name\n// is an ES6 Symbol.\n//\nvar prefix = typeof Object.create !== 'function' ? '~' : false;\n\n/**\n * Representation of a single EventEmitter function.\n *\n * @param {Function} fn Event handler to be called.\n * @param {Mixed} context Context for function execution.\n * @param {Boolean} once Only emit once\n * @api private\n */\nfunction EE(fn, context, once) {\n  this.fn = fn;\n  this.context = context;\n  this.once = once || false;\n}\n\n/**\n * Minimal EventEmitter interface that is molded against the Node.js\n * EventEmitter interface.\n *\n * @constructor\n * @api public\n */\nfunction EventEmitter() { /* Nothing to set */ }\n\n/**\n * Holds the assigned EventEmitters by name.\n *\n * @type {Object}\n * @private\n */\nEventEmitter.prototype._events = undefined;\n\n/**\n * Return a list of assigned event listeners.\n *\n * @param {String} event The events that should be listed.\n * @param {Boolean} exists We only need to know if there are listeners.\n * @returns {Array|Boolean}\n * @api public\n */\nEventEmitter.prototype.listeners = function listeners(event, exists) {\n  var evt = prefix ? prefix + event : event\n    , available = this._events && this._events[evt];\n\n  if (exists) return !!available;\n  if (!available) return [];\n  if (available.fn) return [available.fn];\n\n  for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {\n    ee[i] = available[i].fn;\n  }\n\n  return ee;\n};\n\n/**\n * Emit an event to all registered event listeners.\n *\n * @param {String} event The name of the event.\n * @returns {Boolean} Indication if we've emitted an event.\n * @api public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n  var evt = prefix ? prefix + event : event;\n\n  if (!this._events || !this._events[evt]) return false;\n\n  var listeners = this._events[evt]\n    , len = arguments.length\n    , args\n    , i;\n\n  if ('function' === typeof listeners.fn) {\n    if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n    switch (len) {\n      case 1: return listeners.fn.call(listeners.context), true;\n      case 2: return listeners.fn.call(listeners.context, a1), true;\n      case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n      case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n      case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n      case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n    }\n\n    for (i = 1, args = new Array(len -1); i < len; i++) {\n      args[i - 1] = arguments[i];\n    }\n\n    listeners.fn.apply(listeners.context, args);\n  } else {\n    var length = listeners.length\n      , j;\n\n    for (i = 0; i < length; i++) {\n      if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n      switch (len) {\n        case 1: listeners[i].fn.call(listeners[i].context); break;\n        case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n        case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n        default:\n          if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n            args[j - 1] = arguments[j];\n          }\n\n          listeners[i].fn.apply(listeners[i].context, args);\n      }\n    }\n  }\n\n  return true;\n};\n\n/**\n * Register a new EventListener for the given event.\n *\n * @param {String} event Name of the event.\n * @param {Functon} fn Callback function.\n * @param {Mixed} context The context of the function.\n * @api public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n  var listener = new EE(fn, context || this)\n    , evt = prefix ? prefix + event : event;\n\n  if (!this._events) this._events = prefix ? {} : Object.create(null);\n  if (!this._events[evt]) this._events[evt] = listener;\n  else {\n    if (!this._events[evt].fn) this._events[evt].push(listener);\n    else this._events[evt] = [\n      this._events[evt], listener\n    ];\n  }\n\n  return this;\n};\n\n/**\n * Add an EventListener that's only called once.\n *\n * @param {String} event Name of the event.\n * @param {Function} fn Callback function.\n * @param {Mixed} context The context of the function.\n * @api public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n  var listener = new EE(fn, context || this, true)\n    , evt = prefix ? prefix + event : event;\n\n  if (!this._events) this._events = prefix ? {} : Object.create(null);\n  if (!this._events[evt]) this._events[evt] = listener;\n  else {\n    if (!this._events[evt].fn) this._events[evt].push(listener);\n    else this._events[evt] = [\n      this._events[evt], listener\n    ];\n  }\n\n  return this;\n};\n\n/**\n * Remove event listeners.\n *\n * @param {String} event The event we want to remove.\n * @param {Function} fn The listener that we need to find.\n * @param {Mixed} context Only remove listeners matching this context.\n * @param {Boolean} once Only remove once listeners.\n * @api public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n  var evt = prefix ? prefix + event : event;\n\n  if (!this._events || !this._events[evt]) return this;\n\n  var listeners = this._events[evt]\n    , events = [];\n\n  if (fn) {\n    if (listeners.fn) {\n      if (\n           listeners.fn !== fn\n        || (once && !listeners.once)\n        || (context && listeners.context !== context)\n      ) {\n        events.push(listeners);\n      }\n    } else {\n      for (var i = 0, length = listeners.length; i < length; i++) {\n        if (\n             listeners[i].fn !== fn\n          || (once && !listeners[i].once)\n          || (context && listeners[i].context !== context)\n        ) {\n          events.push(listeners[i]);\n        }\n      }\n    }\n  }\n\n  //\n  // Reset the array, or remove it completely if we have no more listeners.\n  //\n  if (events.length) {\n    this._events[evt] = events.length === 1 ? events[0] : events;\n  } else {\n    delete this._events[evt];\n  }\n\n  return this;\n};\n\n/**\n * Remove all listeners or only the listeners for the specified event.\n *\n * @param {String} event The event want to remove all listeners for.\n * @api public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n  if (!this._events) return this;\n\n  if (event) delete this._events[prefix ? prefix + event : event];\n  else this._events = prefix ? {} : Object.create(null);\n\n  return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// This function doesn't apply anymore.\n//\nEventEmitter.prototype.setMaxListeners = function setMaxListeners() {\n  return this;\n};\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n  module.exports = EventEmitter;\n}\n\n},{}],92:[function(require,module,exports){\n/**\n * Indicates that navigation was caused by a call to history.push.\n */\n'use strict';\n\nexports.__esModule = true;\nvar PUSH = 'PUSH';\n\nexports.PUSH = PUSH;\n/**\n * Indicates that navigation was caused by a call to history.replace.\n */\nvar REPLACE = 'REPLACE';\n\nexports.REPLACE = REPLACE;\n/**\n * Indicates that navigation was caused by some other action such\n * as using a browser's back/forward buttons and/or manually manipulating\n * the URL in a browser's location bar. This is the default.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate\n * for more information.\n */\nvar POP = 'POP';\n\nexports.POP = POP;\nexports['default'] = {\n  PUSH: PUSH,\n  REPLACE: REPLACE,\n  POP: POP\n};\n},{}],93:[function(require,module,exports){\n\"use strict\";\n\nexports.__esModule = true;\nexports.loopAsync = loopAsync;\n\nfunction loopAsync(turns, work, callback) {\n  var currentTurn = 0;\n  var isDone = false;\n\n  function done() {\n    isDone = true;\n    callback.apply(this, arguments);\n  }\n\n  function next() {\n    if (isDone) return;\n\n    if (currentTurn < turns) {\n      work.call(this, currentTurn++, next, done);\n    } else {\n      done.apply(this, arguments);\n    }\n  }\n\n  next();\n}\n},{}],94:[function(require,module,exports){\n(function (process){\n/*eslint-disable no-empty */\n'use strict';\n\nexports.__esModule = true;\nexports.saveState = saveState;\nexports.readState = readState;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar KeyPrefix = '@@History/';\nvar QuotaExceededError = 'QuotaExceededError';\nvar SecurityError = 'SecurityError';\n\nfunction createKey(key) {\n  return KeyPrefix + key;\n}\n\nfunction saveState(key, state) {\n  try {\n    window.sessionStorage.setItem(createKey(key), JSON.stringify(state));\n  } catch (error) {\n    if (error.name === SecurityError) {\n      // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any\n      // attempt to access window.sessionStorage.\n      process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available due to security settings') : undefined;\n\n      return;\n    }\n\n    if (error.name === QuotaExceededError && window.sessionStorage.length === 0) {\n      // Safari \"private mode\" throws QuotaExceededError.\n      process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available in Safari private mode') : undefined;\n\n      return;\n    }\n\n    throw error;\n  }\n}\n\nfunction readState(key) {\n  var json = undefined;\n  try {\n    json = window.sessionStorage.getItem(createKey(key));\n  } catch (error) {\n    if (error.name === SecurityError) {\n      // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any\n      // attempt to access window.sessionStorage.\n      process.env.NODE_ENV !== 'production' ? _warning2['default'](false, '[history] Unable to read state; sessionStorage is not available due to security settings') : undefined;\n\n      return null;\n    }\n  }\n\n  if (json) {\n    try {\n      return JSON.parse(json);\n    } catch (error) {\n      // Ignore invalid JSON.\n    }\n  }\n\n  return null;\n}\n}).call(this,require('_process'))\n},{\"_process\":87,\"warning\":117}],95:[function(require,module,exports){\n'use strict';\n\nexports.__esModule = true;\nexports.addEventListener = addEventListener;\nexports.removeEventListener = removeEventListener;\nexports.getHashPath = getHashPath;\nexports.replaceHashPath = replaceHashPath;\nexports.getWindowPath = getWindowPath;\nexports.go = go;\nexports.getUserConfirmation = getUserConfirmation;\nexports.supportsHistory = supportsHistory;\nexports.supportsGoWithoutReloadUsingHash = supportsGoWithoutReloadUsingHash;\n\nfunction addEventListener(node, event, listener) {\n  if (node.addEventListener) {\n    node.addEventListener(event, listener, false);\n  } else {\n    node.attachEvent('on' + event, listener);\n  }\n}\n\nfunction removeEventListener(node, event, listener) {\n  if (node.removeEventListener) {\n    node.removeEventListener(event, listener, false);\n  } else {\n    node.detachEvent('on' + event, listener);\n  }\n}\n\nfunction getHashPath() {\n  // We can't use window.location.hash here because it's not\n  // consistent across browsers - Firefox will pre-decode it!\n  return window.location.href.split('#')[1] || '';\n}\n\nfunction replaceHashPath(path) {\n  window.location.replace(window.location.pathname + window.location.search + '#' + path);\n}\n\nfunction getWindowPath() {\n  return window.location.pathname + window.location.search + window.location.hash;\n}\n\nfunction go(n) {\n  if (n) window.history.go(n);\n}\n\nfunction getUserConfirmation(message, callback) {\n  callback(window.confirm(message));\n}\n\n/**\n * Returns true if the HTML5 history API is supported. Taken from Modernizr.\n *\n * https://github.com/Modernizr/Modernizr/blob/master/LICENSE\n * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js\n * changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586\n */\n\nfunction supportsHistory() {\n  var ua = navigator.userAgent;\n  if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) {\n    return false;\n  }\n  // FIXME: Work around our browser history not working correctly on Chrome\n  // iOS: https://github.com/rackt/react-router/issues/2565\n  if (ua.indexOf('CriOS') !== -1) {\n    return false;\n  }\n  return window.history && 'pushState' in window.history;\n}\n\n/**\n * Returns false if using go(n) with hash history causes a full page reload.\n */\n\nfunction supportsGoWithoutReloadUsingHash() {\n  var ua = navigator.userAgent;\n  return ua.indexOf('Firefox') === -1;\n}\n},{}],96:[function(require,module,exports){\n'use strict';\n\nexports.__esModule = true;\nvar canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);\nexports.canUseDOM = canUseDOM;\n},{}],97:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _invariant = require('invariant');\n\nvar _invariant2 = _interopRequireDefault(_invariant);\n\nvar _Actions = require('./Actions');\n\nvar _ExecutionEnvironment = require('./ExecutionEnvironment');\n\nvar _DOMUtils = require('./DOMUtils');\n\nvar _DOMStateStorage = require('./DOMStateStorage');\n\nvar _createDOMHistory = require('./createDOMHistory');\n\nvar _createDOMHistory2 = _interopRequireDefault(_createDOMHistory);\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\n/**\n * Creates and returns a history object that uses HTML5's history API\n * (pushState, replaceState, and the popstate event) to manage history.\n * This is the recommended method of managing history in browsers because\n * it provides the cleanest URLs.\n *\n * Note: In browsers that do not support the HTML5 history API full\n * page reloads will be used to preserve URLs.\n */\nfunction createBrowserHistory() {\n  var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n\n  !_ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? _invariant2['default'](false, 'Browser history needs a DOM') : _invariant2['default'](false) : undefined;\n\n  var forceRefresh = options.forceRefresh;\n\n  var isSupported = _DOMUtils.supportsHistory();\n  var useRefresh = !isSupported || forceRefresh;\n\n  function getCurrentLocation(historyState) {\n    historyState = historyState || window.history.state || {};\n\n    var path = _DOMUtils.getWindowPath();\n    var _historyState = historyState;\n    var key = _historyState.key;\n\n    var state = undefined;\n    if (key) {\n      state = _DOMStateStorage.readState(key);\n    } else {\n      state = null;\n      key = history.createKey();\n\n      if (isSupported) window.history.replaceState(_extends({}, historyState, { key: key }), null, path);\n    }\n\n    var location = _parsePath2['default'](path);\n\n    return history.createLocation(_extends({}, location, { state: state }), undefined, key);\n  }\n\n  function startPopStateListener(_ref) {\n    var transitionTo = _ref.transitionTo;\n\n    function popStateListener(event) {\n      if (event.state === undefined) return; // Ignore extraneous popstate events in WebKit.\n\n      transitionTo(getCurrentLocation(event.state));\n    }\n\n    _DOMUtils.addEventListener(window, 'popstate', popStateListener);\n\n    return function () {\n      _DOMUtils.removeEventListener(window, 'popstate', popStateListener);\n    };\n  }\n\n  function finishTransition(location) {\n    var basename = location.basename;\n    var pathname = location.pathname;\n    var search = location.search;\n    var hash = location.hash;\n    var state = location.state;\n    var action = location.action;\n    var key = location.key;\n\n    if (action === _Actions.POP) return; // Nothing to do.\n\n    _DOMStateStorage.saveState(key, state);\n\n    var path = (basename || '') + pathname + search + hash;\n    var historyState = {\n      key: key\n    };\n\n    if (action === _Actions.PUSH) {\n      if (useRefresh) {\n        window.location.href = path;\n        return false; // Prevent location update.\n      } else {\n          window.history.pushState(historyState, null, path);\n        }\n    } else {\n      // REPLACE\n      if (useRefresh) {\n        window.location.replace(path);\n        return false; // Prevent location update.\n      } else {\n          window.history.replaceState(historyState, null, path);\n        }\n    }\n  }\n\n  var history = _createDOMHistory2['default'](_extends({}, options, {\n    getCurrentLocation: getCurrentLocation,\n    finishTransition: finishTransition,\n    saveState: _DOMStateStorage.saveState\n  }));\n\n  var listenerCount = 0,\n      stopPopStateListener = undefined;\n\n  function listenBefore(listener) {\n    if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history);\n\n    var unlisten = history.listenBefore(listener);\n\n    return function () {\n      unlisten();\n\n      if (--listenerCount === 0) stopPopStateListener();\n    };\n  }\n\n  function listen(listener) {\n    if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history);\n\n    var unlisten = history.listen(listener);\n\n    return function () {\n      unlisten();\n\n      if (--listenerCount === 0) stopPopStateListener();\n    };\n  }\n\n  // deprecated\n  function registerTransitionHook(hook) {\n    if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history);\n\n    history.registerTransitionHook(hook);\n  }\n\n  // deprecated\n  function unregisterTransitionHook(hook) {\n    history.unregisterTransitionHook(hook);\n\n    if (--listenerCount === 0) stopPopStateListener();\n  }\n\n  return _extends({}, history, {\n    listenBefore: listenBefore,\n    listen: listen,\n    registerTransitionHook: registerTransitionHook,\n    unregisterTransitionHook: unregisterTransitionHook\n  });\n}\n\nexports['default'] = createBrowserHistory;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./Actions\":92,\"./DOMStateStorage\":94,\"./DOMUtils\":95,\"./ExecutionEnvironment\":96,\"./createDOMHistory\":98,\"./parsePath\":108,\"_process\":87,\"invariant\":116}],98:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _invariant = require('invariant');\n\nvar _invariant2 = _interopRequireDefault(_invariant);\n\nvar _ExecutionEnvironment = require('./ExecutionEnvironment');\n\nvar _DOMUtils = require('./DOMUtils');\n\nvar _createHistory = require('./createHistory');\n\nvar _createHistory2 = _interopRequireDefault(_createHistory);\n\nfunction createDOMHistory(options) {\n  var history = _createHistory2['default'](_extends({\n    getUserConfirmation: _DOMUtils.getUserConfirmation\n  }, options, {\n    go: _DOMUtils.go\n  }));\n\n  function listen(listener) {\n    !_ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? _invariant2['default'](false, 'DOM history needs a DOM') : _invariant2['default'](false) : undefined;\n\n    return history.listen(listener);\n  }\n\n  return _extends({}, history, {\n    listen: listen\n  });\n}\n\nexports['default'] = createDOMHistory;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./DOMUtils\":95,\"./ExecutionEnvironment\":96,\"./createHistory\":100,\"_process\":87,\"invariant\":116}],99:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _invariant = require('invariant');\n\nvar _invariant2 = _interopRequireDefault(_invariant);\n\nvar _Actions = require('./Actions');\n\nvar _ExecutionEnvironment = require('./ExecutionEnvironment');\n\nvar _DOMUtils = require('./DOMUtils');\n\nvar _DOMStateStorage = require('./DOMStateStorage');\n\nvar _createDOMHistory = require('./createDOMHistory');\n\nvar _createDOMHistory2 = _interopRequireDefault(_createDOMHistory);\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\nfunction isAbsolutePath(path) {\n  return typeof path === 'string' && path.charAt(0) === '/';\n}\n\nfunction ensureSlash() {\n  var path = _DOMUtils.getHashPath();\n\n  if (isAbsolutePath(path)) return true;\n\n  _DOMUtils.replaceHashPath('/' + path);\n\n  return false;\n}\n\nfunction addQueryStringValueToPath(path, key, value) {\n  return path + (path.indexOf('?') === -1 ? '?' : '&') + (key + '=' + value);\n}\n\nfunction stripQueryStringValueFromPath(path, key) {\n  return path.replace(new RegExp('[?&]?' + key + '=[a-zA-Z0-9]+'), '');\n}\n\nfunction getQueryStringValueFromPath(path, key) {\n  var match = path.match(new RegExp('\\\\?.*?\\\\b' + key + '=(.+?)\\\\b'));\n  return match && match[1];\n}\n\nvar DefaultQueryKey = '_k';\n\nfunction createHashHistory() {\n  var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n\n  !_ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? _invariant2['default'](false, 'Hash history needs a DOM') : _invariant2['default'](false) : undefined;\n\n  var queryKey = options.queryKey;\n\n  if (queryKey === undefined || !!queryKey) queryKey = typeof queryKey === 'string' ? queryKey : DefaultQueryKey;\n\n  function getCurrentLocation() {\n    var path = _DOMUtils.getHashPath();\n\n    var key = undefined,\n        state = undefined;\n    if (queryKey) {\n      key = getQueryStringValueFromPath(path, queryKey);\n      path = stripQueryStringValueFromPath(path, queryKey);\n\n      if (key) {\n        state = _DOMStateStorage.readState(key);\n      } else {\n        state = null;\n        key = history.createKey();\n        _DOMUtils.replaceHashPath(addQueryStringValueToPath(path, queryKey, key));\n      }\n    } else {\n      key = state = null;\n    }\n\n    var location = _parsePath2['default'](path);\n\n    return history.createLocation(_extends({}, location, { state: state }), undefined, key);\n  }\n\n  function startHashChangeListener(_ref) {\n    var transitionTo = _ref.transitionTo;\n\n    function hashChangeListener() {\n      if (!ensureSlash()) return; // Always make sure hashes are preceeded with a /.\n\n      transitionTo(getCurrentLocation());\n    }\n\n    ensureSlash();\n    _DOMUtils.addEventListener(window, 'hashchange', hashChangeListener);\n\n    return function () {\n      _DOMUtils.removeEventListener(window, 'hashchange', hashChangeListener);\n    };\n  }\n\n  function finishTransition(location) {\n    var basename = location.basename;\n    var pathname = location.pathname;\n    var search = location.search;\n    var state = location.state;\n    var action = location.action;\n    var key = location.key;\n\n    if (action === _Actions.POP) return; // Nothing to do.\n\n    var path = (basename || '') + pathname + search;\n\n    if (queryKey) {\n      path = addQueryStringValueToPath(path, queryKey, key);\n      _DOMStateStorage.saveState(key, state);\n    } else {\n      // Drop key and state.\n      location.key = location.state = null;\n    }\n\n    var currentHash = _DOMUtils.getHashPath();\n\n    if (action === _Actions.PUSH) {\n      if (currentHash !== path) {\n        window.location.hash = path;\n      } else {\n        process.env.NODE_ENV !== 'production' ? _warning2['default'](false, 'You cannot PUSH the same path using hash history') : undefined;\n      }\n    } else if (currentHash !== path) {\n      // REPLACE\n      _DOMUtils.replaceHashPath(path);\n    }\n  }\n\n  var history = _createDOMHistory2['default'](_extends({}, options, {\n    getCurrentLocation: getCurrentLocation,\n    finishTransition: finishTransition,\n    saveState: _DOMStateStorage.saveState\n  }));\n\n  var listenerCount = 0,\n      stopHashChangeListener = undefined;\n\n  function listenBefore(listener) {\n    if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history);\n\n    var unlisten = history.listenBefore(listener);\n\n    return function () {\n      unlisten();\n\n      if (--listenerCount === 0) stopHashChangeListener();\n    };\n  }\n\n  function listen(listener) {\n    if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history);\n\n    var unlisten = history.listen(listener);\n\n    return function () {\n      unlisten();\n\n      if (--listenerCount === 0) stopHashChangeListener();\n    };\n  }\n\n  function push(location) {\n    process.env.NODE_ENV !== 'production' ? _warning2['default'](queryKey || location.state == null, 'You cannot use state without a queryKey it will be dropped') : undefined;\n\n    history.push(location);\n  }\n\n  function replace(location) {\n    process.env.NODE_ENV !== 'production' ? _warning2['default'](queryKey || location.state == null, 'You cannot use state without a queryKey it will be dropped') : undefined;\n\n    history.replace(location);\n  }\n\n  var goIsSupportedWithoutReload = _DOMUtils.supportsGoWithoutReloadUsingHash();\n\n  function go(n) {\n    process.env.NODE_ENV !== 'production' ? _warning2['default'](goIsSupportedWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : undefined;\n\n    history.go(n);\n  }\n\n  function createHref(path) {\n    return '#' + history.createHref(path);\n  }\n\n  // deprecated\n  function registerTransitionHook(hook) {\n    if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history);\n\n    history.registerTransitionHook(hook);\n  }\n\n  // deprecated\n  function unregisterTransitionHook(hook) {\n    history.unregisterTransitionHook(hook);\n\n    if (--listenerCount === 0) stopHashChangeListener();\n  }\n\n  // deprecated\n  function pushState(state, path) {\n    process.env.NODE_ENV !== 'production' ? _warning2['default'](queryKey || state == null, 'You cannot use state without a queryKey it will be dropped') : undefined;\n\n    history.pushState(state, path);\n  }\n\n  // deprecated\n  function replaceState(state, path) {\n    process.env.NODE_ENV !== 'production' ? _warning2['default'](queryKey || state == null, 'You cannot use state without a queryKey it will be dropped') : undefined;\n\n    history.replaceState(state, path);\n  }\n\n  return _extends({}, history, {\n    listenBefore: listenBefore,\n    listen: listen,\n    push: push,\n    replace: replace,\n    go: go,\n    createHref: createHref,\n\n    registerTransitionHook: registerTransitionHook, // deprecated - warning is in createHistory\n    unregisterTransitionHook: unregisterTransitionHook, // deprecated - warning is in createHistory\n    pushState: pushState, // deprecated - warning is in createHistory\n    replaceState: replaceState // deprecated - warning is in createHistory\n  });\n}\n\nexports['default'] = createHashHistory;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./Actions\":92,\"./DOMStateStorage\":94,\"./DOMUtils\":95,\"./ExecutionEnvironment\":96,\"./createDOMHistory\":98,\"./parsePath\":108,\"_process\":87,\"invariant\":116,\"warning\":117}],100:[function(require,module,exports){\n//import warning from 'warning'\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _deepEqual = require('deep-equal');\n\nvar _deepEqual2 = _interopRequireDefault(_deepEqual);\n\nvar _AsyncUtils = require('./AsyncUtils');\n\nvar _Actions = require('./Actions');\n\nvar _createLocation2 = require('./createLocation');\n\nvar _createLocation3 = _interopRequireDefault(_createLocation2);\n\nvar _runTransitionHook = require('./runTransitionHook');\n\nvar _runTransitionHook2 = _interopRequireDefault(_runTransitionHook);\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nfunction createRandomKey(length) {\n  return Math.random().toString(36).substr(2, length);\n}\n\nfunction locationsAreEqual(a, b) {\n  return a.pathname === b.pathname && a.search === b.search &&\n  //a.action === b.action && // Different action !== location change.\n  a.key === b.key && _deepEqual2['default'](a.state, b.state);\n}\n\nvar DefaultKeyLength = 6;\n\nfunction createHistory() {\n  var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n  var getCurrentLocation = options.getCurrentLocation;\n  var finishTransition = options.finishTransition;\n  var saveState = options.saveState;\n  var go = options.go;\n  var keyLength = options.keyLength;\n  var getUserConfirmation = options.getUserConfirmation;\n\n  if (typeof keyLength !== 'number') keyLength = DefaultKeyLength;\n\n  var transitionHooks = [];\n\n  function listenBefore(hook) {\n    transitionHooks.push(hook);\n\n    return function () {\n      transitionHooks = transitionHooks.filter(function (item) {\n        return item !== hook;\n      });\n    };\n  }\n\n  var allKeys = [];\n  var changeListeners = [];\n  var location = undefined;\n\n  function getCurrent() {\n    if (pendingLocation && pendingLocation.action === _Actions.POP) {\n      return allKeys.indexOf(pendingLocation.key);\n    } else if (location) {\n      return allKeys.indexOf(location.key);\n    } else {\n      return -1;\n    }\n  }\n\n  function updateLocation(newLocation) {\n    var current = getCurrent();\n\n    location = newLocation;\n\n    if (location.action === _Actions.PUSH) {\n      allKeys = [].concat(allKeys.slice(0, current + 1), [location.key]);\n    } else if (location.action === _Actions.REPLACE) {\n      allKeys[current] = location.key;\n    }\n\n    changeListeners.forEach(function (listener) {\n      listener(location);\n    });\n  }\n\n  function listen(listener) {\n    changeListeners.push(listener);\n\n    if (location) {\n      listener(location);\n    } else {\n      var _location = getCurrentLocation();\n      allKeys = [_location.key];\n      updateLocation(_location);\n    }\n\n    return function () {\n      changeListeners = changeListeners.filter(function (item) {\n        return item !== listener;\n      });\n    };\n  }\n\n  function confirmTransitionTo(location, callback) {\n    _AsyncUtils.loopAsync(transitionHooks.length, function (index, next, done) {\n      _runTransitionHook2['default'](transitionHooks[index], location, function (result) {\n        if (result != null) {\n          done(result);\n        } else {\n          next();\n        }\n      });\n    }, function (message) {\n      if (getUserConfirmation && typeof message === 'string') {\n        getUserConfirmation(message, function (ok) {\n          callback(ok !== false);\n        });\n      } else {\n        callback(message !== false);\n      }\n    });\n  }\n\n  var pendingLocation = undefined;\n\n  function transitionTo(nextLocation) {\n    if (location && locationsAreEqual(location, nextLocation)) return; // Nothing to do.\n\n    pendingLocation = nextLocation;\n\n    confirmTransitionTo(nextLocation, function (ok) {\n      if (pendingLocation !== nextLocation) return; // Transition was interrupted.\n\n      if (ok) {\n        // treat PUSH to current path like REPLACE to be consistent with browsers\n        if (nextLocation.action === _Actions.PUSH) {\n          var prevPath = createPath(location);\n          var nextPath = createPath(nextLocation);\n\n          if (nextPath === prevPath) nextLocation.action = _Actions.REPLACE;\n        }\n\n        if (finishTransition(nextLocation) !== false) updateLocation(nextLocation);\n      } else if (location && nextLocation.action === _Actions.POP) {\n        var prevIndex = allKeys.indexOf(location.key);\n        var nextIndex = allKeys.indexOf(nextLocation.key);\n\n        if (prevIndex !== -1 && nextIndex !== -1) go(prevIndex - nextIndex); // Restore the URL.\n      }\n    });\n  }\n\n  function push(location) {\n    transitionTo(createLocation(location, _Actions.PUSH, createKey()));\n  }\n\n  function replace(location) {\n    transitionTo(createLocation(location, _Actions.REPLACE, createKey()));\n  }\n\n  function goBack() {\n    go(-1);\n  }\n\n  function goForward() {\n    go(1);\n  }\n\n  function createKey() {\n    return createRandomKey(keyLength);\n  }\n\n  function createPath(location) {\n    if (location == null || typeof location === 'string') return location;\n\n    var pathname = location.pathname;\n    var search = location.search;\n    var hash = location.hash;\n\n    var result = pathname;\n\n    if (search) result += search;\n\n    if (hash) result += hash;\n\n    return result;\n  }\n\n  function createHref(location) {\n    return createPath(location);\n  }\n\n  function createLocation(location, action) {\n    var key = arguments.length <= 2 || arguments[2] === undefined ? createKey() : arguments[2];\n\n    if (typeof action === 'object') {\n      //warning(\n      //  false,\n      //  'The state (2nd) argument to history.createLocation is deprecated; use a ' +\n      //  'location descriptor instead'\n      //)\n\n      if (typeof location === 'string') location = _parsePath2['default'](location);\n\n      location = _extends({}, location, { state: action });\n\n      action = key;\n      key = arguments[3] || createKey();\n    }\n\n    return _createLocation3['default'](location, action, key);\n  }\n\n  // deprecated\n  function setState(state) {\n    if (location) {\n      updateLocationState(location, state);\n      updateLocation(location);\n    } else {\n      updateLocationState(getCurrentLocation(), state);\n    }\n  }\n\n  function updateLocationState(location, state) {\n    location.state = _extends({}, location.state, state);\n    saveState(location.key, location.state);\n  }\n\n  // deprecated\n  function registerTransitionHook(hook) {\n    if (transitionHooks.indexOf(hook) === -1) transitionHooks.push(hook);\n  }\n\n  // deprecated\n  function unregisterTransitionHook(hook) {\n    transitionHooks = transitionHooks.filter(function (item) {\n      return item !== hook;\n    });\n  }\n\n  // deprecated\n  function pushState(state, path) {\n    if (typeof path === 'string') path = _parsePath2['default'](path);\n\n    push(_extends({ state: state }, path));\n  }\n\n  // deprecated\n  function replaceState(state, path) {\n    if (typeof path === 'string') path = _parsePath2['default'](path);\n\n    replace(_extends({ state: state }, path));\n  }\n\n  return {\n    listenBefore: listenBefore,\n    listen: listen,\n    transitionTo: transitionTo,\n    push: push,\n    replace: replace,\n    go: go,\n    goBack: goBack,\n    goForward: goForward,\n    createKey: createKey,\n    createPath: createPath,\n    createHref: createHref,\n    createLocation: createLocation,\n\n    setState: _deprecate2['default'](setState, 'setState is deprecated; use location.key to save state instead'),\n    registerTransitionHook: _deprecate2['default'](registerTransitionHook, 'registerTransitionHook is deprecated; use listenBefore instead'),\n    unregisterTransitionHook: _deprecate2['default'](unregisterTransitionHook, 'unregisterTransitionHook is deprecated; use the callback returned from listenBefore instead'),\n    pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'),\n    replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead')\n  };\n}\n\nexports['default'] = createHistory;\nmodule.exports = exports['default'];\n},{\"./Actions\":92,\"./AsyncUtils\":93,\"./createLocation\":101,\"./deprecate\":103,\"./parsePath\":108,\"./runTransitionHook\":109,\"deep-equal\":113}],101:[function(require,module,exports){\n//import warning from 'warning'\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _Actions = require('./Actions');\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\nfunction createLocation() {\n  var location = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0];\n  var action = arguments.length <= 1 || arguments[1] === undefined ? _Actions.POP : arguments[1];\n  var key = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];\n\n  var _fourthArg = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3];\n\n  if (typeof location === 'string') location = _parsePath2['default'](location);\n\n  if (typeof action === 'object') {\n    //warning(\n    //  false,\n    //  'The state (2nd) argument to createLocation is deprecated; use a ' +\n    //  'location descriptor instead'\n    //)\n\n    location = _extends({}, location, { state: action });\n\n    action = key || _Actions.POP;\n    key = _fourthArg;\n  }\n\n  var pathname = location.pathname || '/';\n  var search = location.search || '';\n  var hash = location.hash || '';\n  var state = location.state || null;\n\n  return {\n    pathname: pathname,\n    search: search,\n    hash: hash,\n    state: state,\n    action: action,\n    key: key\n  };\n}\n\nexports['default'] = createLocation;\nmodule.exports = exports['default'];\n},{\"./Actions\":92,\"./parsePath\":108}],102:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _invariant = require('invariant');\n\nvar _invariant2 = _interopRequireDefault(_invariant);\n\nvar _Actions = require('./Actions');\n\nvar _createHistory = require('./createHistory');\n\nvar _createHistory2 = _interopRequireDefault(_createHistory);\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\nfunction createStateStorage(entries) {\n  return entries.filter(function (entry) {\n    return entry.state;\n  }).reduce(function (memo, entry) {\n    memo[entry.key] = entry.state;\n    return memo;\n  }, {});\n}\n\nfunction createMemoryHistory() {\n  var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n\n  if (Array.isArray(options)) {\n    options = { entries: options };\n  } else if (typeof options === 'string') {\n    options = { entries: [options] };\n  }\n\n  var history = _createHistory2['default'](_extends({}, options, {\n    getCurrentLocation: getCurrentLocation,\n    finishTransition: finishTransition,\n    saveState: saveState,\n    go: go\n  }));\n\n  var _options = options;\n  var entries = _options.entries;\n  var current = _options.current;\n\n  if (typeof entries === 'string') {\n    entries = [entries];\n  } else if (!Array.isArray(entries)) {\n    entries = ['/'];\n  }\n\n  entries = entries.map(function (entry) {\n    var key = history.createKey();\n\n    if (typeof entry === 'string') return { pathname: entry, key: key };\n\n    if (typeof entry === 'object' && entry) return _extends({}, entry, { key: key });\n\n    !false ? process.env.NODE_ENV !== 'production' ? _invariant2['default'](false, 'Unable to create history entry from %s', entry) : _invariant2['default'](false) : undefined;\n  });\n\n  if (current == null) {\n    current = entries.length - 1;\n  } else {\n    !(current >= 0 && current < entries.length) ? process.env.NODE_ENV !== 'production' ? _invariant2['default'](false, 'Current index must be >= 0 and < %s, was %s', entries.length, current) : _invariant2['default'](false) : undefined;\n  }\n\n  var storage = createStateStorage(entries);\n\n  function saveState(key, state) {\n    storage[key] = state;\n  }\n\n  function readState(key) {\n    return storage[key];\n  }\n\n  function getCurrentLocation() {\n    var entry = entries[current];\n    var key = entry.key;\n    var basename = entry.basename;\n    var pathname = entry.pathname;\n    var search = entry.search;\n\n    var path = (basename || '') + pathname + (search || '');\n\n    var state = undefined;\n    if (key) {\n      state = readState(key);\n    } else {\n      state = null;\n      key = history.createKey();\n      entry.key = key;\n    }\n\n    var location = _parsePath2['default'](path);\n\n    return history.createLocation(_extends({}, location, { state: state }), undefined, key);\n  }\n\n  function canGo(n) {\n    var index = current + n;\n    return index >= 0 && index < entries.length;\n  }\n\n  function go(n) {\n    if (n) {\n      if (!canGo(n)) {\n        process.env.NODE_ENV !== 'production' ? _warning2['default'](false, 'Cannot go(%s) there is not enough history', n) : undefined;\n        return;\n      }\n\n      current += n;\n\n      var currentLocation = getCurrentLocation();\n\n      // change action to POP\n      history.transitionTo(_extends({}, currentLocation, { action: _Actions.POP }));\n    }\n  }\n\n  function finishTransition(location) {\n    switch (location.action) {\n      case _Actions.PUSH:\n        current += 1;\n\n        // if we are not on the top of stack\n        // remove rest and push new\n        if (current < entries.length) entries.splice(current);\n\n        entries.push(location);\n        saveState(location.key, location.state);\n        break;\n      case _Actions.REPLACE:\n        entries[current] = location;\n        saveState(location.key, location.state);\n        break;\n    }\n  }\n\n  return history;\n}\n\nexports['default'] = createMemoryHistory;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./Actions\":92,\"./createHistory\":100,\"./parsePath\":108,\"_process\":87,\"invariant\":116,\"warning\":117}],103:[function(require,module,exports){\n//import warning from 'warning'\n\n\"use strict\";\n\nexports.__esModule = true;\nfunction deprecate(fn) {\n  return fn;\n  //return function () {\n  //  warning(false, '[history] ' + message)\n  //  return fn.apply(this, arguments)\n  //}\n}\n\nexports[\"default\"] = deprecate;\nmodule.exports = exports[\"default\"];\n},{}],104:[function(require,module,exports){\n'use strict';\n\nexports.__esModule = true;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nvar _useBeforeUnload = require('./useBeforeUnload');\n\nvar _useBeforeUnload2 = _interopRequireDefault(_useBeforeUnload);\n\nexports['default'] = _deprecate2['default'](_useBeforeUnload2['default'], 'enableBeforeUnload is deprecated, use useBeforeUnload instead');\nmodule.exports = exports['default'];\n},{\"./deprecate\":103,\"./useBeforeUnload\":111}],105:[function(require,module,exports){\n'use strict';\n\nexports.__esModule = true;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nvar _useQueries = require('./useQueries');\n\nvar _useQueries2 = _interopRequireDefault(_useQueries);\n\nexports['default'] = _deprecate2['default'](_useQueries2['default'], 'enableQueries is deprecated, use useQueries instead');\nmodule.exports = exports['default'];\n},{\"./deprecate\":103,\"./useQueries\":112}],106:[function(require,module,exports){\n\"use strict\";\n\nexports.__esModule = true;\nfunction extractPath(string) {\n  var match = string.match(/^https?:\\/\\/[^\\/]*/);\n\n  if (match == null) return string;\n\n  return string.substring(match[0].length);\n}\n\nexports[\"default\"] = extractPath;\nmodule.exports = exports[\"default\"];\n},{}],107:[function(require,module,exports){\n'use strict';\n\nexports.__esModule = true;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nvar _createLocation2 = require('./createLocation');\n\nvar _createLocation3 = _interopRequireDefault(_createLocation2);\n\nvar _createBrowserHistory = require('./createBrowserHistory');\n\nvar _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory);\n\nexports.createHistory = _createBrowserHistory2['default'];\n\nvar _createHashHistory2 = require('./createHashHistory');\n\nvar _createHashHistory3 = _interopRequireDefault(_createHashHistory2);\n\nexports.createHashHistory = _createHashHistory3['default'];\n\nvar _createMemoryHistory2 = require('./createMemoryHistory');\n\nvar _createMemoryHistory3 = _interopRequireDefault(_createMemoryHistory2);\n\nexports.createMemoryHistory = _createMemoryHistory3['default'];\n\nvar _useBasename2 = require('./useBasename');\n\nvar _useBasename3 = _interopRequireDefault(_useBasename2);\n\nexports.useBasename = _useBasename3['default'];\n\nvar _useBeforeUnload2 = require('./useBeforeUnload');\n\nvar _useBeforeUnload3 = _interopRequireDefault(_useBeforeUnload2);\n\nexports.useBeforeUnload = _useBeforeUnload3['default'];\n\nvar _useQueries2 = require('./useQueries');\n\nvar _useQueries3 = _interopRequireDefault(_useQueries2);\n\nexports.useQueries = _useQueries3['default'];\n\nvar _Actions2 = require('./Actions');\n\nvar _Actions3 = _interopRequireDefault(_Actions2);\n\nexports.Actions = _Actions3['default'];\n\n// deprecated\n\nvar _enableBeforeUnload2 = require('./enableBeforeUnload');\n\nvar _enableBeforeUnload3 = _interopRequireDefault(_enableBeforeUnload2);\n\nexports.enableBeforeUnload = _enableBeforeUnload3['default'];\n\nvar _enableQueries2 = require('./enableQueries');\n\nvar _enableQueries3 = _interopRequireDefault(_enableQueries2);\n\nexports.enableQueries = _enableQueries3['default'];\nvar createLocation = _deprecate2['default'](_createLocation3['default'], 'Using createLocation without a history instance is deprecated; please use history.createLocation instead');\nexports.createLocation = createLocation;\n},{\"./Actions\":92,\"./createBrowserHistory\":97,\"./createHashHistory\":99,\"./createLocation\":101,\"./createMemoryHistory\":102,\"./deprecate\":103,\"./enableBeforeUnload\":104,\"./enableQueries\":105,\"./useBasename\":110,\"./useBeforeUnload\":111,\"./useQueries\":112}],108:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _extractPath = require('./extractPath');\n\nvar _extractPath2 = _interopRequireDefault(_extractPath);\n\nfunction parsePath(path) {\n  var pathname = _extractPath2['default'](path);\n  var search = '';\n  var hash = '';\n\n  process.env.NODE_ENV !== 'production' ? _warning2['default'](path === pathname, 'A path must be pathname + search + hash only, not a fully qualified URL like \"%s\"', path) : undefined;\n\n  var hashIndex = pathname.indexOf('#');\n  if (hashIndex !== -1) {\n    hash = pathname.substring(hashIndex);\n    pathname = pathname.substring(0, hashIndex);\n  }\n\n  var searchIndex = pathname.indexOf('?');\n  if (searchIndex !== -1) {\n    search = pathname.substring(searchIndex);\n    pathname = pathname.substring(0, searchIndex);\n  }\n\n  if (pathname === '') pathname = '/';\n\n  return {\n    pathname: pathname,\n    search: search,\n    hash: hash\n  };\n}\n\nexports['default'] = parsePath;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./extractPath\":106,\"_process\":87,\"warning\":117}],109:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nfunction runTransitionHook(hook, location, callback) {\n  var result = hook(location, callback);\n\n  if (hook.length < 2) {\n    // Assume the hook runs synchronously and automatically\n    // call the callback with the return value.\n    callback(result);\n  } else {\n    process.env.NODE_ENV !== 'production' ? _warning2['default'](result === undefined, 'You should not \"return\" in a transition hook with a callback argument; call the callback instead') : undefined;\n  }\n}\n\nexports['default'] = runTransitionHook;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"_process\":87,\"warning\":117}],110:[function(require,module,exports){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\nvar _ExecutionEnvironment = require('./ExecutionEnvironment');\n\nvar _runTransitionHook = require('./runTransitionHook');\n\nvar _runTransitionHook2 = _interopRequireDefault(_runTransitionHook);\n\nvar _extractPath = require('./extractPath');\n\nvar _extractPath2 = _interopRequireDefault(_extractPath);\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nfunction useBasename(createHistory) {\n  return function () {\n    var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n    var basename = options.basename;\n\n    var historyOptions = _objectWithoutProperties(options, ['basename']);\n\n    var history = createHistory(historyOptions);\n\n    // Automatically use the value of <base href> in HTML\n    // documents as basename if it's not explicitly given.\n    if (basename == null && _ExecutionEnvironment.canUseDOM) {\n      var base = document.getElementsByTagName('base')[0];\n\n      if (base) basename = _extractPath2['default'](base.href);\n    }\n\n    function addBasename(location) {\n      if (basename && location.basename == null) {\n        if (location.pathname.indexOf(basename) === 0) {\n          location.pathname = location.pathname.substring(basename.length);\n          location.basename = basename;\n\n          if (location.pathname === '') location.pathname = '/';\n        } else {\n          location.basename = '';\n        }\n      }\n\n      return location;\n    }\n\n    function prependBasename(location) {\n      if (!basename) return location;\n\n      if (typeof location === 'string') location = _parsePath2['default'](location);\n\n      var pname = location.pathname;\n      var normalizedBasename = basename.slice(-1) === '/' ? basename : basename + '/';\n      var normalizedPathname = pname.charAt(0) === '/' ? pname.slice(1) : pname;\n      var pathname = normalizedBasename + normalizedPathname;\n\n      return _extends({}, location, {\n        pathname: pathname\n      });\n    }\n\n    // Override all read methods with basename-aware versions.\n    function listenBefore(hook) {\n      return history.listenBefore(function (location, callback) {\n        _runTransitionHook2['default'](hook, addBasename(location), callback);\n      });\n    }\n\n    function listen(listener) {\n      return history.listen(function (location) {\n        listener(addBasename(location));\n      });\n    }\n\n    // Override all write methods with basename-aware versions.\n    function push(location) {\n      history.push(prependBasename(location));\n    }\n\n    function replace(location) {\n      history.replace(prependBasename(location));\n    }\n\n    function createPath(location) {\n      return history.createPath(prependBasename(location));\n    }\n\n    function createHref(location) {\n      return history.createHref(prependBasename(location));\n    }\n\n    function createLocation() {\n      return addBasename(history.createLocation.apply(history, arguments));\n    }\n\n    // deprecated\n    function pushState(state, path) {\n      if (typeof path === 'string') path = _parsePath2['default'](path);\n\n      push(_extends({ state: state }, path));\n    }\n\n    // deprecated\n    function replaceState(state, path) {\n      if (typeof path === 'string') path = _parsePath2['default'](path);\n\n      replace(_extends({ state: state }, path));\n    }\n\n    return _extends({}, history, {\n      listenBefore: listenBefore,\n      listen: listen,\n      push: push,\n      replace: replace,\n      createPath: createPath,\n      createHref: createHref,\n      createLocation: createLocation,\n\n      pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'),\n      replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead')\n    });\n  };\n}\n\nexports['default'] = useBasename;\nmodule.exports = exports['default'];\n},{\"./ExecutionEnvironment\":96,\"./deprecate\":103,\"./extractPath\":106,\"./parsePath\":108,\"./runTransitionHook\":109}],111:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _ExecutionEnvironment = require('./ExecutionEnvironment');\n\nvar _DOMUtils = require('./DOMUtils');\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nfunction startBeforeUnloadListener(getBeforeUnloadPromptMessage) {\n  function listener(event) {\n    var message = getBeforeUnloadPromptMessage();\n\n    if (typeof message === 'string') {\n      (event || window.event).returnValue = message;\n      return message;\n    }\n  }\n\n  _DOMUtils.addEventListener(window, 'beforeunload', listener);\n\n  return function () {\n    _DOMUtils.removeEventListener(window, 'beforeunload', listener);\n  };\n}\n\n/**\n * Returns a new createHistory function that can be used to create\n * history objects that know how to use the beforeunload event in web\n * browsers to cancel navigation.\n */\nfunction useBeforeUnload(createHistory) {\n  return function (options) {\n    var history = createHistory(options);\n\n    var stopBeforeUnloadListener = undefined;\n    var beforeUnloadHooks = [];\n\n    function getBeforeUnloadPromptMessage() {\n      var message = undefined;\n\n      for (var i = 0, len = beforeUnloadHooks.length; message == null && i < len; ++i) {\n        message = beforeUnloadHooks[i].call();\n      }return message;\n    }\n\n    function listenBeforeUnload(hook) {\n      beforeUnloadHooks.push(hook);\n\n      if (beforeUnloadHooks.length === 1) {\n        if (_ExecutionEnvironment.canUseDOM) {\n          stopBeforeUnloadListener = startBeforeUnloadListener(getBeforeUnloadPromptMessage);\n        } else {\n          process.env.NODE_ENV !== 'production' ? _warning2['default'](false, 'listenBeforeUnload only works in DOM environments') : undefined;\n        }\n      }\n\n      return function () {\n        beforeUnloadHooks = beforeUnloadHooks.filter(function (item) {\n          return item !== hook;\n        });\n\n        if (beforeUnloadHooks.length === 0 && stopBeforeUnloadListener) {\n          stopBeforeUnloadListener();\n          stopBeforeUnloadListener = null;\n        }\n      };\n    }\n\n    // deprecated\n    function registerBeforeUnloadHook(hook) {\n      if (_ExecutionEnvironment.canUseDOM && beforeUnloadHooks.indexOf(hook) === -1) {\n        beforeUnloadHooks.push(hook);\n\n        if (beforeUnloadHooks.length === 1) stopBeforeUnloadListener = startBeforeUnloadListener(getBeforeUnloadPromptMessage);\n      }\n    }\n\n    // deprecated\n    function unregisterBeforeUnloadHook(hook) {\n      if (beforeUnloadHooks.length > 0) {\n        beforeUnloadHooks = beforeUnloadHooks.filter(function (item) {\n          return item !== hook;\n        });\n\n        if (beforeUnloadHooks.length === 0) stopBeforeUnloadListener();\n      }\n    }\n\n    return _extends({}, history, {\n      listenBeforeUnload: listenBeforeUnload,\n\n      registerBeforeUnloadHook: _deprecate2['default'](registerBeforeUnloadHook, 'registerBeforeUnloadHook is deprecated; use listenBeforeUnload instead'),\n      unregisterBeforeUnloadHook: _deprecate2['default'](unregisterBeforeUnloadHook, 'unregisterBeforeUnloadHook is deprecated; use the callback returned from listenBeforeUnload instead')\n    });\n  };\n}\n\nexports['default'] = useBeforeUnload;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./DOMUtils\":95,\"./ExecutionEnvironment\":96,\"./deprecate\":103,\"_process\":87,\"warning\":117}],112:[function(require,module,exports){\n(function (process){\n'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\nfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _queryString = require('query-string');\n\nvar _runTransitionHook = require('./runTransitionHook');\n\nvar _runTransitionHook2 = _interopRequireDefault(_runTransitionHook);\n\nvar _parsePath = require('./parsePath');\n\nvar _parsePath2 = _interopRequireDefault(_parsePath);\n\nvar _deprecate = require('./deprecate');\n\nvar _deprecate2 = _interopRequireDefault(_deprecate);\n\nvar SEARCH_BASE_KEY = '$searchBase';\n\nfunction defaultStringifyQuery(query) {\n  return _queryString.stringify(query).replace(/%20/g, '+');\n}\n\nvar defaultParseQueryString = _queryString.parse;\n\nfunction isNestedObject(object) {\n  for (var p in object) {\n    if (object.hasOwnProperty(p) && typeof object[p] === 'object' && !Array.isArray(object[p]) && object[p] !== null) return true;\n  }return false;\n}\n\n/**\n * Returns a new createHistory function that may be used to create\n * history objects that know how to handle URL queries.\n */\nfunction useQueries(createHistory) {\n  return function () {\n    var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n    var stringifyQuery = options.stringifyQuery;\n    var parseQueryString = options.parseQueryString;\n\n    var historyOptions = _objectWithoutProperties(options, ['stringifyQuery', 'parseQueryString']);\n\n    var history = createHistory(historyOptions);\n\n    if (typeof stringifyQuery !== 'function') stringifyQuery = defaultStringifyQuery;\n\n    if (typeof parseQueryString !== 'function') parseQueryString = defaultParseQueryString;\n\n    function addQuery(location) {\n      if (location.query == null) {\n        var search = location.search;\n\n        location.query = parseQueryString(search.substring(1));\n        location[SEARCH_BASE_KEY] = { search: search, searchBase: '' };\n      }\n\n      // TODO: Instead of all the book-keeping here, this should just strip the\n      // stringified query from the search.\n\n      return location;\n    }\n\n    function appendQuery(location, query) {\n      var _extends2;\n\n      var queryString = undefined;\n      if (!query || (queryString = stringifyQuery(query)) === '') return location;\n\n      process.env.NODE_ENV !== 'production' ? _warning2['default'](stringifyQuery !== defaultStringifyQuery || !isNestedObject(query), 'useQueries does not stringify nested query objects by default; ' + 'use a custom stringifyQuery function') : undefined;\n\n      if (typeof location === 'string') location = _parsePath2['default'](location);\n\n      var searchBaseSpec = location[SEARCH_BASE_KEY];\n      var searchBase = undefined;\n      if (searchBaseSpec && location.search === searchBaseSpec.search) {\n        searchBase = searchBaseSpec.searchBase;\n      } else {\n        searchBase = location.search || '';\n      }\n\n      var search = searchBase + (searchBase ? '&' : '?') + queryString;\n\n      return _extends({}, location, (_extends2 = {\n        search: search\n      }, _extends2[SEARCH_BASE_KEY] = { search: search, searchBase: searchBase }, _extends2));\n    }\n\n    // Override all read methods with query-aware versions.\n    function listenBefore(hook) {\n      return history.listenBefore(function (location, callback) {\n        _runTransitionHook2['default'](hook, addQuery(location), callback);\n      });\n    }\n\n    function listen(listener) {\n      return history.listen(function (location) {\n        listener(addQuery(location));\n      });\n    }\n\n    // Override all write methods with query-aware versions.\n    function push(location) {\n      history.push(appendQuery(location, location.query));\n    }\n\n    function replace(location) {\n      history.replace(appendQuery(location, location.query));\n    }\n\n    function createPath(location, query) {\n      //warning(\n      //  !query,\n      //  'the query argument to createPath is deprecated; use a location descriptor instead'\n      //)\n      return history.createPath(appendQuery(location, query || location.query));\n    }\n\n    function createHref(location, query) {\n      //warning(\n      //  !query,\n      //  'the query argument to createHref is deprecated; use a location descriptor instead'\n      //)\n      return history.createHref(appendQuery(location, query || location.query));\n    }\n\n    function createLocation() {\n      return addQuery(history.createLocation.apply(history, arguments));\n    }\n\n    // deprecated\n    function pushState(state, path, query) {\n      if (typeof path === 'string') path = _parsePath2['default'](path);\n\n      push(_extends({ state: state }, path, { query: query }));\n    }\n\n    // deprecated\n    function replaceState(state, path, query) {\n      if (typeof path === 'string') path = _parsePath2['default'](path);\n\n      replace(_extends({ state: state }, path, { query: query }));\n    }\n\n    return _extends({}, history, {\n      listenBefore: listenBefore,\n      listen: listen,\n      push: push,\n      replace: replace,\n      createPath: createPath,\n      createHref: createHref,\n      createLocation: createLocation,\n\n      pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'),\n      replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead')\n    });\n  };\n}\n\nexports['default'] = useQueries;\nmodule.exports = exports['default'];\n}).call(this,require('_process'))\n},{\"./deprecate\":103,\"./parsePath\":108,\"./runTransitionHook\":109,\"_process\":87,\"query-string\":120,\"warning\":117}],113:[function(require,module,exports){\nvar pSlice = Array.prototype.slice;\nvar objectKeys = require('./lib/keys.js');\nvar isArguments = require('./lib/is_arguments.js');\n\nvar deepEqual = module.exports = function (actual, expected, opts) {\n  if (!opts) opts = {};\n  // 7.1. All identical values are equivalent, as determined by ===.\n  if (actual === expected) {\n    return true;\n\n  } else if (actual instanceof Date && expected instanceof Date) {\n    return actual.getTime() === expected.getTime();\n\n  // 7.3. Other pairs that do not both pass typeof value == 'object',\n  // equivalence is determined by ==.\n  } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {\n    return opts.strict ? actual === expected : actual == expected;\n\n  // 7.4. For all other Object pairs, including Array objects, equivalence is\n  // determined by having the same number of owned properties (as verified\n  // with Object.prototype.hasOwnProperty.call), the same set of keys\n  // (although not necessarily the same order), equivalent values for every\n  // corresponding key, and an identical 'prototype' property. Note: this\n  // accounts for both named and indexed properties on Arrays.\n  } else {\n    return objEquiv(actual, expected, opts);\n  }\n}\n\nfunction isUndefinedOrNull(value) {\n  return value === null || value === undefined;\n}\n\nfunction isBuffer (x) {\n  if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;\n  if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {\n    return false;\n  }\n  if (x.length > 0 && typeof x[0] !== 'number') return false;\n  return true;\n}\n\nfunction objEquiv(a, b, opts) {\n  var i, key;\n  if (isUndefinedOrNull(a) || isUndefinedOrNull(b))\n    return false;\n  // an identical 'prototype' property.\n  if (a.prototype !== b.prototype) return false;\n  //~~~I've managed to break Object.keys through screwy arguments passing.\n  //   Converting to array solves the problem.\n  if (isArguments(a)) {\n    if (!isArguments(b)) {\n      return false;\n    }\n    a = pSlice.call(a);\n    b = pSlice.call(b);\n    return deepEqual(a, b, opts);\n  }\n  if (isBuffer(a)) {\n    if (!isBuffer(b)) {\n      return false;\n    }\n    if (a.length !== b.length) return false;\n    for (i = 0; i < a.length; i++) {\n      if (a[i] !== b[i]) return false;\n    }\n    return true;\n  }\n  try {\n    var ka = objectKeys(a),\n        kb = objectKeys(b);\n  } catch (e) {//happens when one is a string literal and the other isn't\n    return false;\n  }\n  // having the same number of owned properties (keys incorporates\n  // hasOwnProperty)\n  if (ka.length != kb.length)\n    return false;\n  //the same set of keys (although not necessarily the same order),\n  ka.sort();\n  kb.sort();\n  //~~~cheap key test\n  for (i = ka.length - 1; i >= 0; i--) {\n    if (ka[i] != kb[i])\n      return false;\n  }\n  //equivalent values for every corresponding key, and\n  //~~~possibly expensive deep test\n  for (i = ka.length - 1; i >= 0; i--) {\n    key = ka[i];\n    if (!deepEqual(a[key], b[key], opts)) return false;\n  }\n  return typeof a === typeof b;\n}\n\n},{\"./lib/is_arguments.js\":114,\"./lib/keys.js\":115}],114:[function(require,module,exports){\nvar supportsArgumentsClass = (function(){\n  return Object.prototype.toString.call(arguments)\n})() == '[object Arguments]';\n\nexports = module.exports = supportsArgumentsClass ? supported : unsupported;\n\nexports.supported = supported;\nfunction supported(object) {\n  return Object.prototype.toString.call(object) == '[object Arguments]';\n};\n\nexports.unsupported = unsupported;\nfunction unsupported(object){\n  return object &&\n    typeof object == 'object' &&\n    typeof object.length == 'number' &&\n    Object.prototype.hasOwnProperty.call(object, 'callee') &&\n    !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||\n    false;\n};\n\n},{}],115:[function(require,module,exports){\nexports = module.exports = typeof Object.keys === 'function'\n  ? Object.keys : shim;\n\nexports.shim = shim;\nfunction shim (obj) {\n  var keys = [];\n  for (var key in obj) keys.push(key);\n  return keys;\n}\n\n},{}],116:[function(require,module,exports){\n(function (process){\n/**\n * Copyright 2013-2015, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n'use strict';\n\n/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nvar invariant = function(condition, format, a, b, c, d, e, f) {\n  if (process.env.NODE_ENV !== 'production') {\n    if (format === undefined) {\n      throw new Error('invariant requires an error message argument');\n    }\n  }\n\n  if (!condition) {\n    var error;\n    if (format === undefined) {\n      error = new Error(\n        'Minified exception occurred; use the non-minified dev environment ' +\n        'for the full error message and additional helpful warnings.'\n      );\n    } else {\n      var args = [a, b, c, d, e, f];\n      var argIndex = 0;\n      error = new Error(\n        format.replace(/%s/g, function() { return args[argIndex++]; })\n      );\n      error.name = 'Invariant Violation';\n    }\n\n    error.framesToPop = 1; // we don't care about invariant's own frame\n    throw error;\n  }\n};\n\nmodule.exports = invariant;\n\n}).call(this,require('_process'))\n},{\"_process\":87}],117:[function(require,module,exports){\n(function (process){\n/**\n * Copyright 2014-2015, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n'use strict';\n\n/**\n * Similar to invariant but only logs a warning if the condition is not met.\n * This can be used to log issues in development environments in critical\n * paths. Removing the logging code for production environments will keep the\n * same logic and follow the same code paths.\n */\n\nvar warning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n  warning = function(condition, format, args) {\n    var len = arguments.length;\n    args = new Array(len > 2 ? len - 2 : 0);\n    for (var key = 2; key < len; key++) {\n      args[key - 2] = arguments[key];\n    }\n    if (format === undefined) {\n      throw new Error(\n        '`warning(condition, format, ...args)` requires a warning ' +\n        'message argument'\n      );\n    }\n\n    if (format.length < 10 || (/^[s\\W]*$/).test(format)) {\n      throw new Error(\n        'The warning format should be able to uniquely identify this ' +\n        'warning. Please, use a more descriptive format than: ' + format\n      );\n    }\n\n    if (!condition) {\n      var argIndex = 0;\n      var message = 'Warning: ' +\n        format.replace(/%s/g, function() {\n          return args[argIndex++];\n        });\n      if (typeof console !== 'undefined') {\n        console.error(message);\n      }\n      try {\n        // This error was thrown as a convenience so that you can use this stack\n        // to find the callsite that caused this warning to fire.\n        throw new Error(message);\n      } catch(x) {}\n    }\n  };\n}\n\nmodule.exports = warning;\n\n}).call(this,require('_process'))\n},{\"_process\":87}],118:[function(require,module,exports){\nvar isarray = require('isarray')\n\n/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n  // Match escaped characters that would otherwise appear in future matches.\n  // This allows the user to escape special characters that won't transform.\n  '(\\\\\\\\.)',\n  // Match Express-style parameters and un-named parameters with a prefix\n  // and optional suffixes. Matches appear as:\n  //\n  // \"/:test(\\\\d+)?\" => [\"/\", \"test\", \"\\d+\", undefined, \"?\", undefined]\n  // \"/route(\\\\d+)\"  => [undefined, undefined, undefined, \"\\d+\", undefined, undefined]\n  // \"/*\"            => [\"/\", undefined, undefined, undefined, undefined, \"*\"]\n  '([\\\\/.])?(?:(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^()])+)\\\\))([+*?])?|(\\\\*))'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param  {String} str\n * @return {Array}\n */\nfunction parse (str) {\n  var tokens = []\n  var key = 0\n  var index = 0\n  var path = ''\n  var res\n\n  while ((res = PATH_REGEXP.exec(str)) != null) {\n    var m = res[0]\n    var escaped = res[1]\n    var offset = res.index\n    path += str.slice(index, offset)\n    index = offset + m.length\n\n    // Ignore already escaped sequences.\n    if (escaped) {\n      path += escaped[1]\n      continue\n    }\n\n    // Push the current path onto the tokens.\n    if (path) {\n      tokens.push(path)\n      path = ''\n    }\n\n    var prefix = res[2]\n    var name = res[3]\n    var capture = res[4]\n    var group = res[5]\n    var suffix = res[6]\n    var asterisk = res[7]\n\n    var repeat = suffix === '+' || suffix === '*'\n    var optional = suffix === '?' || suffix === '*'\n    var delimiter = prefix || '/'\n    var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?')\n\n    tokens.push({\n      name: name || key++,\n      prefix: prefix || '',\n      delimiter: delimiter,\n      optional: optional,\n      repeat: repeat,\n      pattern: escapeGroup(pattern)\n    })\n  }\n\n  // Match any characters still remaining.\n  if (index < str.length) {\n    path += str.substr(index)\n  }\n\n  // If the path exists, push it onto the end.\n  if (path) {\n    tokens.push(path)\n  }\n\n  return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param  {String}   str\n * @return {Function}\n */\nfunction compile (str) {\n  return tokensToFunction(parse(str))\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens) {\n  // Compile all the tokens into regexps.\n  var matches = new Array(tokens.length)\n\n  // Compile all the patterns before compilation.\n  for (var i = 0; i < tokens.length; i++) {\n    if (typeof tokens[i] === 'object') {\n      matches[i] = new RegExp('^' + tokens[i].pattern + '$')\n    }\n  }\n\n  return function (obj) {\n    var path = ''\n    var data = obj || {}\n\n    for (var i = 0; i < tokens.length; i++) {\n      var token = tokens[i]\n\n      if (typeof token === 'string') {\n        path += token\n\n        continue\n      }\n\n      var value = data[token.name]\n      var segment\n\n      if (value == null) {\n        if (token.optional) {\n          continue\n        } else {\n          throw new TypeError('Expected \"' + token.name + '\" to be defined')\n        }\n      }\n\n      if (isarray(value)) {\n        if (!token.repeat) {\n          throw new TypeError('Expected \"' + token.name + '\" to not repeat, but received \"' + value + '\"')\n        }\n\n        if (value.length === 0) {\n          if (token.optional) {\n            continue\n          } else {\n            throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n          }\n        }\n\n        for (var j = 0; j < value.length; j++) {\n          segment = encodeURIComponent(value[j])\n\n          if (!matches[i].test(segment)) {\n            throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\", but received \"' + segment + '\"')\n          }\n\n          path += (j === 0 ? token.prefix : token.delimiter) + segment\n        }\n\n        continue\n      }\n\n      segment = encodeURIComponent(value)\n\n      if (!matches[i].test(segment)) {\n        throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but received \"' + segment + '\"')\n      }\n\n      path += token.prefix + segment\n    }\n\n    return path\n  }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param  {String} str\n * @return {String}\n */\nfunction escapeString (str) {\n  return str.replace(/([.+*?=^!:${}()[\\]|\\/])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param  {String} group\n * @return {String}\n */\nfunction escapeGroup (group) {\n  return group.replace(/([=!:$\\/()])/g, '\\\\$1')\n}\n\n/**\n * Attach the keys as a property of the regexp.\n *\n * @param  {RegExp} re\n * @param  {Array}  keys\n * @return {RegExp}\n */\nfunction attachKeys (re, keys) {\n  re.keys = keys\n  return re\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param  {Object} options\n * @return {String}\n */\nfunction flags (options) {\n  return options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param  {RegExp} path\n * @param  {Array}  keys\n * @return {RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n  // Use a negative lookahead to match only capturing groups.\n  var groups = path.source.match(/\\((?!\\?)/g)\n\n  if (groups) {\n    for (var i = 0; i < groups.length; i++) {\n      keys.push({\n        name: i,\n        prefix: null,\n        delimiter: null,\n        optional: false,\n        repeat: false,\n        pattern: null\n      })\n    }\n  }\n\n  return attachKeys(path, keys)\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param  {Array}  path\n * @param  {Array}  keys\n * @param  {Object} options\n * @return {RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n  var parts = []\n\n  for (var i = 0; i < path.length; i++) {\n    parts.push(pathToRegexp(path[i], keys, options).source)\n  }\n\n  var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options))\n\n  return attachKeys(regexp, keys)\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param  {String} path\n * @param  {Array}  keys\n * @param  {Object} options\n * @return {RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n  var tokens = parse(path)\n  var re = tokensToRegExp(tokens, options)\n\n  // Attach keys back to the regexp.\n  for (var i = 0; i < tokens.length; i++) {\n    if (typeof tokens[i] !== 'string') {\n      keys.push(tokens[i])\n    }\n  }\n\n  return attachKeys(re, keys)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param  {Array}  tokens\n * @param  {Array}  keys\n * @param  {Object} options\n * @return {RegExp}\n */\nfunction tokensToRegExp (tokens, options) {\n  options = options || {}\n\n  var strict = options.strict\n  var end = options.end !== false\n  var route = ''\n  var lastToken = tokens[tokens.length - 1]\n  var endsWithSlash = typeof lastToken === 'string' && /\\/$/.test(lastToken)\n\n  // Iterate over the tokens and create our regexp string.\n  for (var i = 0; i < tokens.length; i++) {\n    var token = tokens[i]\n\n    if (typeof token === 'string') {\n      route += escapeString(token)\n    } else {\n      var prefix = escapeString(token.prefix)\n      var capture = token.pattern\n\n      if (token.repeat) {\n        capture += '(?:' + prefix + capture + ')*'\n      }\n\n      if (token.optional) {\n        if (prefix) {\n          capture = '(?:' + prefix + '(' + capture + '))?'\n        } else {\n          capture = '(' + capture + ')?'\n        }\n      } else {\n        capture = prefix + '(' + capture + ')'\n      }\n\n      route += capture\n    }\n  }\n\n  // In non-strict mode we allow a slash at the end of match. If the path to\n  // match already ends with a slash, we remove it for consistency. The slash\n  // is valid at the end of a path match, not in the middle. This is important\n  // in non-ending mode, where \"/test/\" shouldn't match \"/test//route\".\n  if (!strict) {\n    route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\\\/(?=$))?'\n  }\n\n  if (end) {\n    route += '$'\n  } else {\n    // In non-ending mode, we need the capturing groups to match as much as\n    // possible by using a positive lookahead to the end or next path segment.\n    route += strict && endsWithSlash ? '' : '(?=\\\\/|$)'\n  }\n\n  return new RegExp('^' + route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param  {(String|RegExp|Array)} path\n * @param  {Array}                 [keys]\n * @param  {Object}                [options]\n * @return {RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n  keys = keys || []\n\n  if (!isarray(keys)) {\n    options = keys\n    keys = []\n  } else if (!options) {\n    options = {}\n  }\n\n  if (path instanceof RegExp) {\n    return regexpToRegexp(path, keys, options)\n  }\n\n  if (isarray(path)) {\n    return arrayToRegexp(path, keys, options)\n  }\n\n  return stringToRegexp(path, keys, options)\n}\n\n},{\"isarray\":119}],119:[function(require,module,exports){\nmodule.exports = Array.isArray || function (arr) {\n  return Object.prototype.toString.call(arr) == '[object Array]';\n};\n\n},{}],120:[function(require,module,exports){\n'use strict';\nvar strictUriEncode = require('strict-uri-encode');\n\nexports.extract = function (str) {\n\treturn str.split('?')[1] || '';\n};\n\nexports.parse = function (str) {\n\tif (typeof str !== 'string') {\n\t\treturn {};\n\t}\n\n\tstr = str.trim().replace(/^(\\?|#|&)/, '');\n\n\tif (!str) {\n\t\treturn {};\n\t}\n\n\treturn str.split('&').reduce(function (ret, param) {\n\t\tvar parts = param.replace(/\\+/g, ' ').split('=');\n\t\t// Firefox (pre 40) decodes `%3D` to `=`\n\t\t// https://github.com/sindresorhus/query-string/pull/37\n\t\tvar key = parts.shift();\n\t\tvar val = parts.length > 0 ? parts.join('=') : undefined;\n\n\t\tkey = decodeURIComponent(key);\n\n\t\t// missing `=` should be `null`:\n\t\t// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters\n\t\tval = val === undefined ? null : decodeURIComponent(val);\n\n\t\tif (!ret.hasOwnProperty(key)) {\n\t\t\tret[key] = val;\n\t\t} else if (Array.isArray(ret[key])) {\n\t\t\tret[key].push(val);\n\t\t} else {\n\t\t\tret[key] = [ret[key], val];\n\t\t}\n\n\t\treturn ret;\n\t}, {});\n};\n\nexports.stringify = function (obj) {\n\treturn obj ? Object.keys(obj).sort().map(function (key) {\n\t\tvar val = obj[key];\n\n\t\tif (val === undefined) {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (val === null) {\n\t\t\treturn key;\n\t\t}\n\n\t\tif (Array.isArray(val)) {\n\t\t\treturn val.sort().map(function (val2) {\n\t\t\t\treturn strictUriEncode(key) + '=' + strictUriEncode(val2);\n\t\t\t}).join('&');\n\t\t}\n\n\t\treturn strictUriEncode(key) + '=' + strictUriEncode(val);\n\t}).filter(function (x) {\n\t\treturn x.length > 0;\n\t}).join('&') : '';\n};\n\n},{\"strict-uri-encode\":121}],121:[function(require,module,exports){\n'use strict';\nmodule.exports = function (str) {\n\treturn encodeURIComponent(str).replace(/[!'()*]/g, function (c) {\n\t\treturn '%' + c.charCodeAt(0).toString(16);\n\t});\n};\n\n},{}],122:[function(require,module,exports){\n'use strict';\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _vue = require('vue');\n\nvar _vue2 = _interopRequireDefault(_vue);\n\nvar _debug = require('debug');\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar debug = (0, _debug2.default)('voie:directive');\n\n_vue2.default.elementDirective('v-view', {\n  bind: function bind() {\n    var _vm$$options = this.vm.$options;\n    var state = _vm$$options.state;\n    var manager = _vm$$options.manager;\n\n    manager.mountPoints[state.name] = {\n      hostVm: this.vm,\n      viewEl: this.el,\n      viewElChildren: [].slice.call(this.el.children)\n    };\n    debug('registered v-view', this.el);\n  },\n  unbind: function unbind() {\n    var _vm$$options2 = this.vm.$options;\n    var state = _vm$$options2.state;\n    var manager = _vm$$options2.manager;\n\n    delete manager.mountPoints[state.name];\n    debug('unregistered v-view', this.el);\n  }\n});\n\n_vue2.default.directive('link', {\n  bind: function bind() {\n    this.manager = resolveManager(this.vm);\n    if (!this.manager) {\n      throw new Error('Can\\'t locate state manager.');\n    }\n    this.manager.on('context_updated', this.updateElement, this);\n  },\n  unbind: function unbind() {\n    this.manager.off('context_updated', this.updateElement, this);\n  },\n  update: function update(value) {\n    var _this = this;\n\n    if (!value) {\n      throw new Error('v-link: expression \"' + this.expression + '\" should resolve to { name: ..., params... }}');\n    }\n    var manager = this.manager;\n    var name = null;\n    if (typeof value == 'string') {\n      name = value;\n      this.params = {};\n    } else {\n      name = value.name;\n      this.params = value.params || {};\n    }\n    this.state = manager.get(name);\n    if (!this.state) {\n      /* eslint-disable no-console */\n      console.warn('State \"' + name + '\" not found.');\n      /* eslint-enable no-console */\n      return;\n    }\n    this.el.onclick = function (ev) {\n      ev.preventDefault();\n      manager.go({\n        name: name,\n        params: _this.params\n      });\n    };\n    this.updateElement();\n  },\n  updateElement: function updateElement() {\n    var manager = this.manager;\n    var ctx = manager.context;\n    var state = this.state;\n    if (!state) {\n      return;\n    }\n    var params = (0, _assign2.default)({}, ctx.params, this.params);\n    this.el.setAttribute('href', state.createHref(params));\n    // Add/remove active class\n    this.el.classList.remove(manager.activeClass);\n    if (ctx.state) {\n      var paramsMatch = (0, _keys2.default)(params).every(function (key) {\n        return ctx.params[key] === params[key];\n      });\n      var active = ctx.state.includes(state) && paramsMatch;\n      if (active) {\n        this.el.classList.add(manager.activeClass);\n      } else {\n        this.el.classList.remove(manager.activeClass);\n      }\n    }\n  }\n});\n\nfunction resolveManager(vm) {\n  var manager = vm.$options.manager;\n  if (manager) {\n    return manager;\n  }\n  if (vm.$parent) {\n    return resolveManager(vm.$parent);\n  }\n  return null;\n}\n\n},{\"babel-runtime/core-js/object/assign\":1,\"babel-runtime/core-js/object/keys\":5,\"debug\":88,\"vue\":\"vue\"}],123:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.RedirectLoopError = exports.StateNotFoundError = undefined;\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar StateNotFoundError = exports.StateNotFoundError = (function (_Error) {\n  (0, _inherits3.default)(StateNotFoundError, _Error);\n\n  function StateNotFoundError(name) {\n    (0, _classCallCheck3.default)(this, StateNotFoundError);\n\n    var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(StateNotFoundError).call(this, 'State \"' + name + '\" not found.'));\n\n    _this.name = name;\n    return _this;\n  }\n\n  return StateNotFoundError;\n})(Error);\n\nvar RedirectLoopError = exports.RedirectLoopError = (function (_Error2) {\n  (0, _inherits3.default)(RedirectLoopError, _Error2);\n\n  function RedirectLoopError(transition) {\n    (0, _classCallCheck3.default)(this, RedirectLoopError);\n\n    var _this2 = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(RedirectLoopError).call(this, 'Redirect loop detected ' + '(set maxRedirects on state manager to configure max redirects per transition)'));\n\n    _this2.transition = transition;\n    return _this2;\n  }\n\n  return RedirectLoopError;\n})(Error);\n\n},{\"babel-runtime/core-js/object/get-prototype-of\":4,\"babel-runtime/helpers/classCallCheck\":9,\"babel-runtime/helpers/inherits\":11,\"babel-runtime/helpers/possibleConstructorReturn\":12}],124:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.Transition = exports.State = exports.StateManager = undefined;\n\nvar _stateManager = require('./state-manager');\n\nvar _stateManager2 = _interopRequireDefault(_stateManager);\n\nvar _state = require('./state');\n\nvar _state2 = _interopRequireDefault(_state);\n\nvar _transition = require('./transition');\n\nvar _transition2 = _interopRequireDefault(_transition);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.StateManager = _stateManager2.default;\nexports.State = _state2.default;\nexports.Transition = _transition2.default;\n\n},{\"./state\":126,\"./state-manager\":125,\"./transition\":127}],125:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _typeof2 = require('babel-runtime/helpers/typeof');\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _debug = require('debug');\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nvar _eventemitter = require('eventemitter3');\n\nvar _eventemitter2 = _interopRequireDefault(_eventemitter);\n\nvar _state = require('./state');\n\nvar _state2 = _interopRequireDefault(_state);\n\nvar _transition = require('./transition');\n\nvar _transition2 = _interopRequireDefault(_transition);\n\nvar _history = require('history');\n\nrequire('./directives');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar debug = (0, _debug2.default)('voie:manager');\n\n/**\n * State manager holds the hierarchy of application states,\n * exposes methods for navigating around states and\n * keeps track of current state and its `context`\n * (object `{ state, params, data, ... }`).\n *\n * A typical application will have a single instance\n * of state manager exposed as a module.\n *\n * ```es6\n * import { StateManager } from 'voie';\n *\n * export default new StateManager({ ... });\n * ```\n *\n * State manager emits following events:\n *\n *   * `history_updated`\n *   * `context_updated`\n *   * `transition_finished`\n *\n */\n\nvar StateManager = (function (_EventEmitter) {\n  (0, _inherits3.default)(StateManager, _EventEmitter);\n\n  /**\n   * Instantiates new state manager.\n   *\n   * Options:\n   *\n   *   * `el` — required, root DOM element for rendering views\n   *     (can be either `HTMLElement` or selector string)\n   *\n   *   * history — a history object (see `rackt/history`)\n   *\n   *   * base — (only used when `history` is not specified), base href\n   *     for application (URL pathname prefix)\n   *\n   *   * `maxRedirects` — maximum number of redirects within\n   *     a single transition, when exceeded transition will fail with\n   *     `RedirectLoopError` (default is 10)\n   *\n   *   * `activeClass` — active class for `v-link` directive\n   *     (default is \"active\")'\n   *\n   *   * `handleUncaught` — `function(err) => Promise` invoked\n   *     when transition fails with error\n   *\n   *   * `beforeEach` — `function(ctx) => Promise` invoked\n   *     before each `enter` hook\n   */\n\n  function StateManager(spec) {\n    (0, _classCallCheck3.default)(this, StateManager);\n\n    var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(StateManager).call(this));\n\n    _this._setupEl(spec);\n    _this._setupHistory(spec);\n    _this._setupOptions(spec);\n    _this._setupHooks(spec);\n    _this._setupState();\n    return _this;\n  }\n\n  (0, _createClass3.default)(StateManager, [{\n    key: '_setupEl',\n    value: function _setupEl(spec) {\n      this.el = spec.el instanceof HTMLElement ? spec.el : document.querySelector(spec.el);\n      if (!this.el) {\n        throw new Error('Please specify `el` as an entry-point node of your app.');\n      }\n    }\n  }, {\n    key: '_setupHistory',\n    value: function _setupHistory(spec) {\n      if (spec.history) {\n        this.history = spec.history;\n      } else {\n        this._setupDefaultHtml5History(spec);\n      }\n    }\n  }, {\n    key: '_setupDefaultHtml5History',\n    value: function _setupDefaultHtml5History(spec) {\n      var base = spec.base;\n      // Try to take base from `<base href=\"\"/>`\n      if (!base) {\n        var baseEl = document.querySelector('base');\n        base = baseEl && baseEl.getAttribute('href');\n      }\n      base = (base || '').replace(/\\/+$/, '');\n      this.history = (0, _history.useBasename)(_history.createHistory)({ basename: base });\n    }\n  }, {\n    key: '_setupOptions',\n    value: function _setupOptions(spec) {\n      if (spec.handleUncaught) {\n        this.handleUncaught = spec.handleUncaught;\n      }\n      this.maxRedirects = Number(spec.maxRedirects) || 10;\n      this.activeClass = spec.activeClass || 'active';\n    }\n  }, {\n    key: '_setupHooks',\n    value: function _setupHooks(spec) {\n      if (spec.beforeEach) {\n        this.beforeEach = spec.beforeEach;\n      }\n      if (spec.afterEach) {\n        this.afterEach = spec.afterEach;\n      }\n    }\n  }, {\n    key: '_setupState',\n    value: function _setupState() {\n      this.states = {};\n      this.context = {\n        parent: null,\n        state: null, // root state\n        vm: null,\n        params: {},\n        data: {}\n      };\n      this.mountPoints = {\n        '': {\n          viewEl: this.el,\n          viewElChildren: [].slice.call(this.el.children)\n        }\n      };\n      this.transition = null;\n    }\n\n    /**\n     * Executed before `enter` hooks on each state.\n     * \n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'beforeEach',\n    value: function beforeEach() {}\n\n    /**\n     * Executed after `leave` hooks on each state.\n     * \n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'afterEach',\n    value: function afterEach() {}\n\n    /**\n     * Handles errors uncaught during transition.\n     * Used for overriding on a per-instance basis.\n     *\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'handleUncaught',\n    value: function handleUncaught(err) {\n      return _promise2.default.reject(err);\n    }\n\n    /**\n     * Registers a new state with specified `name`.\n     *\n     * You can use one of two styles:\n     *\n     * ```es6\n     * sm.add('foo', { ... });\n     * sm.add({ name: 'foo', ... });\n     * ```\n     *\n     * All options are passed to `State` constructor.\n     *\n     * @returns {State}\n     */\n\n  }, {\n    key: 'add',\n    value: function add(name, spec) {\n      if ((typeof name === 'undefined' ? 'undefined' : (0, _typeof3.default)(name)) == 'object') {\n        spec = name;\n        name = spec.name;\n      }\n      if (!name) {\n        throw new Error('State `name` is mandatory.');\n      }\n      if (this.states[name]) {\n        throw new Error('State \"' + name + '\" already added');\n      }\n      spec.name = name;\n      var state = new _state2.default(this, spec);\n      debug('add %s', name);\n      this.states[name] = state;\n      return state;\n    }\n\n    /**\n     * Retrieves a state previously registered via `add`.\n     *\n     * @returns {State}\n     */\n\n  }, {\n    key: 'get',\n    value: function get(name) {\n      return this.states[name];\n    }\n\n    /**\n     * Navigates to a state with specified `name`.\n     * Navigation is performed asynchronously, allowing\n     * state enter/leave hook to perform async tasks\n     * (e.g. fetch data).\n     *\n     * Throws an exception if another transition is\n     * taking place.\n     *\n     * Options:\n     *\n     *   * `name` — target state name (if null, will transition to same state\n     *     with updated params)\n     *   * `params` — object containing state parameters\n     *     (either path variables or query string parameters)\n     *   * `replace` — if `true` don't create a separate record\n     *     in browser history (default is `false`)\n     *\n     * Transition process:\n     *\n     *   * find nearest common ancestor state with matching parameters\n     *   * go \"upstream\", leaving states, cleaning up states,\n     *     destroying components\n     *   * go \"downstream\", entering states, instantiating and rendering\n     *     components\n     *   * update browser history to reflect target state\n     *     (e.g. set new URL in address bar)\n     *\n     *  Note that it is the responsibility of the state to compute\n     *  target URL.\n     *\n     *  @returns {Promise} resolved when navigation is finished.\n     */\n\n  }, {\n    key: 'go',\n    value: function go(options) {\n      var _this2 = this;\n\n      if (this.transition) {\n        throw new Error('Transition is in progress.');\n      }\n      this.transition = new _transition2.default(this);\n      var currentState = this.context.state;\n      var name = null;\n      if (typeof options === 'string') {\n        name = options;\n        options = {};\n      } else if (options.name) {\n        name = options.name;\n      } else if (currentState) {\n        name = currentState.name;\n      } else {\n        throw new Error('Destination state not specified');\n      }\n      return _promise2.default.resolve().then(function () {\n        return _this2.transition.go(name, options.params || {});\n      }).then(function (result) {\n        _this2.transition = null;\n        _this2.emit('transition_finished');\n        return result;\n      }).catch(function (err) {\n        _this2.transition = null;\n        _this2.emit('transition_finished', err);\n        return _this2.handleUncaught(err);\n      }).then(function () {\n        return _this2._updateHistory(options.replace || false);\n      });\n    }\n\n    /**\n     * Updates browser history without actually performing\n     * any transitions.\n     *\n     * Typically used to serialize parameters into query string\n     * without performing navigation (e.g. when params are used\n     * only in Vue components).\n     */\n\n  }, {\n    key: 'update',\n    value: function update(params, replace) {\n      var _this3 = this;\n\n      (0, _assign2.default)(this.context.params, params);\n      this.emit('context_updated', this.context);\n      return _promise2.default.resolve().then(function () {\n        return _this3._updateHistory(replace);\n      });\n    }\n\n    /**\n     * Resolves nearest mount point in current context tree.\n     *\n     * Mount point is a \"slot\" that corresponds to `v-view` directive\n     * (and the component that hosts it).\n     */\n\n  }, {\n    key: '_getMountPoint',\n    value: function _getMountPoint() {\n      var ctx = this.context;\n      var el = null;\n      while (ctx && !el) {\n        var state = ctx.state;\n        if (state) {\n          el = this.mountPoints[state.name];\n        } else {\n          el = this.mountPoints[''];\n        }\n        ctx = ctx.parent;\n      }\n      return el;\n    }\n\n    /**\n     * Begins listening for history events (e.g. browser back button)\n     * and performs initial navigation by matching current URL.\n     *\n     * @returns {Promise} resolved when initial navigation is finished.\n     */\n\n  }, {\n    key: 'start',\n    value: function start() {\n      var _this4 = this;\n\n      if (this._unlisten) {\n        return _promise2.default.resolve();\n      }\n      this._unlisten = this.history.listen(function (location) {\n        return _this4._matchLocation(location);\n      });\n      return new _promise2.default(function (resolve) {\n        return _this4.once('history_updated', resolve);\n      });\n    }\n\n    /**\n     * Stops listening for history events.\n     */\n\n  }, {\n    key: 'stop',\n    value: function stop() {\n      if (!this._unlisten) {\n        return;\n      }\n      this._unlisten();\n      delete this._unlisten;\n    }\n  }, {\n    key: '_matchLocation',\n    value: function _matchLocation(location) {\n      var _this5 = this;\n\n      var url = location.pathname + location.search;\n      if (url === this.context.url) {\n        return;\n      }\n      var found = (0, _keys2.default)(this.states).find(function (name) {\n        var state = _this5.states[name];\n        var matched = state._match(location);\n        if (matched) {\n          debug('match url %s -> %s', location.pathname, name);\n          _this5.go({\n            name: name,\n            params: matched,\n            replace: true\n          });\n          return true;\n        }\n      });\n      if (!found) {\n        /* eslint-disable no-console */\n        console.warn('No states match URL: ' + location.pathname);\n        /* eslint-enable no-console */\n        this._updateHistory(true);\n      }\n    }\n  }, {\n    key: '_updateHistory',\n    value: function _updateHistory(replace) {\n      var state = this.context.state;\n      var url = state ? state._makeUrl(this.context.params) : '/';\n      if (url === this.context.url) {\n        return;\n      }\n      this.context.url = url;\n      if (replace) {\n        this.history.replace(url);\n      } else {\n        this.history.push(url);\n      }\n      this.emit('history_updated', {\n        url: url,\n        ctx: this.context\n      });\n    }\n  }]);\n  return StateManager;\n})(_eventemitter2.default);\n\nexports.default = StateManager;\n;\n\n},{\"./directives\":122,\"./state\":126,\"./transition\":127,\"babel-runtime/core-js/object/assign\":1,\"babel-runtime/core-js/object/get-prototype-of\":4,\"babel-runtime/core-js/object/keys\":5,\"babel-runtime/core-js/promise\":7,\"babel-runtime/helpers/classCallCheck\":9,\"babel-runtime/helpers/createClass\":10,\"babel-runtime/helpers/inherits\":11,\"babel-runtime/helpers/possibleConstructorReturn\":12,\"babel-runtime/helpers/typeof\":13,\"debug\":88,\"eventemitter3\":91,\"history\":107}],126:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _pathToRegexp = require('path-to-regexp');\n\nvar _pathToRegexp2 = _interopRequireDefault(_pathToRegexp);\n\nvar _queryString = require('query-string');\n\nvar _queryString2 = _interopRequireDefault(_queryString);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Represents a node in application states hierarchy.\n *\n * Most state features are optional, the only required\n * setting is a unique `name` and a reference to `parent` state.\n *\n * Depending on features a state can represent:\n *\n *   * an abstract view (e.g. layout containing a component with `<v-view>`\n *     directive)\n *   * a concrete view\n *   * a route with path pattern and query parameters\n *   * a data resolver that provides data to its descendants\n *   * a mix of above\n *\n * Invoking constructor directly is not recommended,\n * use `StateManager#add` instead.\n *\n * @private\n */\n\nvar State = (function () {\n\n  /**\n   * Options:\n   *\n   *   * `name` — required, state name; if contains dots `.`\n   *     then parent state will be inferred from this name\n   *     (e.g. `layout.users` will become a parent of `layout.users.list`)\n   *     unless `parent` is specified explicitly\n   *\n   *   * `parent` — optional, parent state (this option disables\n   *     parent-from-name inference)\n   *\n   *   * `path` — optional pathname pattern for matching URLs and\n   *     extracting parameters (e.g. `/user/:userId`). If started with `/`,\n   *     then path is treated as an absolute pathname, otherwise\n   *     path is treated as a fragment (absolute pathname is inherited\n   *     from parent)\n   *\n   *   * `params` — optional object that specifies default values for\n   *     additional params that this state accepts; these params\n   *     will be encoded into query string\n   *\n   *   * `component` — optional Vue component to be rendered\n   *     when entering this state\n   *\n   *   * `redirect` — optional state name to redirect when navigating\n   *     to this state; typically used in \"abstract\" states (e.g. layouts,\n   *     data-preparation, etc.) to specify default sub-state\n   *\n   *   * `enter` — optional `function(ctx, transition) => Promise` hook invoked\n   *     when transitioning into this state or its descendants\n   *\n   *   * `leave` — optional `function(ctx, transition) => Promise` hook invoked\n   *     when transitioning from this state or its descendants\n   *\n   *   * `handleError` — optional `function(err, ctx) => Promise` invoked\n   *     when error occurs during transition into/over this state\n   *\n   * @param manager\n   * @param spec\n   */\n\n  function State(manager, spec) {\n    (0, _classCallCheck3.default)(this, State);\n\n    this.manager = manager;\n    this._setupName(spec);\n    this._setupHierarchy(spec);\n    this._setupComponent(spec);\n    this._setupHooks(spec);\n    this._setupPath(spec);\n    this._setupParams(spec);\n    this._setupOptions(spec);\n  }\n\n  (0, _createClass3.default)(State, [{\n    key: '_setupName',\n    value: function _setupName(spec) {\n      this.name = spec.name;\n      if (!this.name) {\n        throw new Error('State `name` is required');\n      }\n    }\n  }, {\n    key: '_setupHierarchy',\n    value: function _setupHierarchy(spec) {\n      this.parentState = this.manager.get(spec.parent || this.name.split('.').slice(0, -1).join('.')) || null;\n      this.lineage = this.parentState ? this.parentState.lineage.concat([this]) : [this];\n    }\n  }, {\n    key: '_setupComponent',\n    value: function _setupComponent(spec) {\n      if (spec.component) {\n        this.component = spec.component;\n        if (!this.component.name) {\n          this.component.name = this.name.replace(/\\./g, '-');\n        }\n      }\n    }\n  }, {\n    key: '_setupHooks',\n    value: function _setupHooks(spec) {\n      if (spec.enter) {\n        this.enter = spec.enter;\n      }\n      if (spec.leave) {\n        this.leave = spec.leave;\n      }\n      if (spec.handleError) {\n        this.handleError = spec.handleError;\n      }\n    }\n  }, {\n    key: '_setupPath',\n    value: function _setupPath(spec) {\n      if (!spec.path && spec.url) {\n        /* eslint-disable no-console */\n        console.warn('state.url is deprecated; use state.path instead');\n        /* eslint-enable no-console */\n        spec.path = spec.url;\n      }\n      this.path = spec.path || '';\n      if (this.path.indexOf('/') === 0) {\n        this.fullPath = this.path;\n      } else {\n        var parentPath = this.parentState ? this.parentState.fullPath : '/';\n        this.fullPath = parentPath.replace(/\\/+$/, '') + (this.path ? '/' + this.path : '');\n      }\n      if (!this.fullPath) {\n        this.fullPath = '/';\n      }\n      this._pathParams = [];\n      this._pathRegex = (0, _pathToRegexp2.default)(this.fullPath, this._pathParams);\n      this._pathFormat = _pathToRegexp2.default.compile(this.fullPath);\n    }\n  }, {\n    key: '_setupParams',\n    value: function _setupParams(spec) {\n      var _this = this;\n\n      this._paramsSpec = {};\n      this._pathParams.forEach(function (param) {\n        _this._paramsSpec[param.name] = null;\n      });\n      (0, _assign2.default)(this._paramsSpec, spec.params);\n    }\n  }, {\n    key: '_setupOptions',\n    value: function _setupOptions(spec) {\n      if (spec.redirect) {\n        this.redirect = spec.redirect;\n      }\n    }\n\n    /**\n     * Invoked when going \"downstream\" (either into this state or\n     * through this state to one of its descendants).\n     *\n     * Primary usage is to process `ctx.params` and populate `ctx.data`.\n     *\n     * Can redirect to another state by resolving `{ redirect: anotherStateName }`\n     * (e.g. for authentication).\n     *\n     * It is also possible to render a custom Vue component instead\n     * by resolving `{ component: customVueComponent }`.\n     *\n     * @param ctx — object `{ state, params, data }`\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'enter',\n    value: function enter(ctx) {\n      return _promise2.default.resolve();\n    }\n\n    /**\n     * Invoked when going \"upstream\" (either from this state or\n     * through this state from one of its descendants).\n     * Typically used from cleaning up stuff used by this state.\n     *\n     * Like with `enter`, it is possible to redirect to another state\n     * by resolving `{ redirect: anotherStateName }`.\n     *\n     * @param ctx — object `{ state, params, data }`\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'leave',\n    value: function leave(ctx) {\n      return _promise2.default.resolve();\n    }\n\n    /**\n     * Invoked when error occurs during entering this state.\n     *\n     * Can redirect to another state by resolving `{ redirect: anotherStateName }`\n     * (e.g. for authentication).\n     *\n     * It is also possible to render a custom Vue component instead\n     * by resolving `{ component: customVueComponent }`.\n     *\n     * @param ctx — object `{ state, params, data }`\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'handleError',\n    value: function handleError(err, ctx) {\n      return _promise2.default.reject(err);\n    }\n\n    /**\n     * Returns true if this state is equal to `stateOrName`\n     * or contains `stateOrName` somewhere up the hierarchy.\n     *\n     * @param {string|State} stateOrName\n     * @return {boolean}\n     */\n\n  }, {\n    key: 'includes',\n    value: function includes(stateOrName) {\n      var state = stateOrName instanceof State ? stateOrName : this.manager.get(stateOrName);\n      return this.lineage.indexOf(state) > -1;\n    }\n\n    /**\n     * Attempts to match `location` to this state's `path` pattern.\n     *\n     * @param {{ pathname, search }} location\n     * @returns an object with extracted params or `null` if don't match.\n     * @private\n     */\n\n  }, {\n    key: '_match',\n    value: function _match(location) {\n      var matched = this._pathRegex.exec(location.pathname);\n      if (!matched) {\n        return null;\n      }\n      var params = this._pathParams.reduce(function (params, p, i) {\n        params[p.name] = matched[i + 1];\n        return params;\n      }, {});\n      try {\n        var query = _queryString2.default.parse(location.search);\n        (0, _assign2.default)(params, query);\n      } catch (e) {\n        // No query string or parsing failed — we don't care\n      }\n      return params;\n    }\n\n    /**\n     * Constructs a `params` object by dropping any parameters\n     * not specified in `_paramsSpec` of this state.\n     * Values from `_paramsSpec` act as defaults.\n     *\n     * @param {object} params\n     * @private\n     */\n\n  }, {\n    key: '_makeParams',\n    value: function _makeParams(params) {\n      var _this2 = this;\n\n      return (0, _keys2.default)(this._paramsSpec).reduce(function (result, name) {\n        result[name] = name in params ? params[name] : _this2._paramsSpec[name];\n        return result;\n      }, {});\n    }\n\n    /**\n     * Constructs search string by serializing query params.\n     *\n     * @param params\n     * @return {string} search\n     * @private\n     */\n\n  }, {\n    key: '_makeSearch',\n    value: function _makeSearch(params) {\n      var query = (0, _keys2.default)(params).reduce(function (query, key) {\n        var value = params[key];\n        if (value != null) {\n          query[key] = value;\n        }\n        return query;\n      }, {});\n      this._pathParams.forEach(function (p) {\n        delete query[p.name];\n      });\n      try {\n        var search = _queryString2.default.stringify(query);\n        if (search) {\n          return '?' + search;\n        }\n      } catch (e) {\n        // No query string or serialization failed — we don't care\n      }\n      return '';\n    }\n\n    /**\n     * Constructs an URL by encoding `params` into URL pattern and query string.\n     *\n     * Note: params not mentioned in `_paramsSpec` are dropped.\n     *\n     * @param params\n     * @return {string} url\n     * @private\n     */\n\n  }, {\n    key: '_makeUrl',\n    value: function _makeUrl(params) {\n      return this._pathFormat(params) + this._makeSearch(params);\n    }\n\n    /**\n     * Creates href suitable for links (taking into account base URL and\n     * hash-based histories).\n     *\n     * @param params\n     * @return {string} href\n     */\n\n  }, {\n    key: 'createHref',\n    value: function createHref(params) {\n      return this.manager.history.createHref(this._makeUrl(params));\n    }\n  }]);\n  return State;\n})();\n\nexports.default = State;\n;\n\n},{\"babel-runtime/core-js/object/assign\":1,\"babel-runtime/core-js/object/keys\":5,\"babel-runtime/core-js/promise\":7,\"babel-runtime/helpers/classCallCheck\":9,\"babel-runtime/helpers/createClass\":10,\"path-to-regexp\":118,\"query-string\":120}],127:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _typeof2 = require('babel-runtime/helpers/typeof');\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _debug = require('debug');\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nvar _error = require('./error');\n\nvar _utils = require('./utils');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar debug = (0, _debug2.default)('voie:transition');\n\nvar Transition = (function () {\n  function Transition(manager) {\n    (0, _classCallCheck3.default)(this, Transition);\n\n    this.manager = manager;\n    this.redirectsCount = 0;\n    this.params = (0, _assign2.default)({}, manager.context.params);\n  }\n\n  (0, _createClass3.default)(Transition, [{\n    key: 'go',\n    value: function go(name, params, isRedirect) {\n      var _this = this;\n\n      debug(isRedirect ? 'redirect to %s' : 'go to %s', name);\n      (0, _assign2.default)(this.params, params || {});\n      var state = this.manager.get(name);\n      if (!state) {\n        throw new _error.StateNotFoundError(name);\n      }\n      this.dstState = state;\n      if (state.redirect) {\n        return this.handleRedirect(state.redirect);\n      }\n      return this.goUpstream().then(function () {\n        return _this.goDownstream();\n      });\n    }\n  }, {\n    key: 'handleRedirect',\n    value: function handleRedirect(redirect) {\n      var _this2 = this;\n\n      this.redirectsCount++;\n      if (this.redirectsCount > this.manager.maxRedirects) {\n        throw new _error.RedirectLoopError(this);\n      }\n      switch (typeof redirect === 'undefined' ? 'undefined' : (0, _typeof3.default)(redirect)) {\n        case 'string':\n          return this.go(redirect, {}, true);\n        case 'object':\n          return this.go(redirect.name, redirect.params, true);\n        case 'function':\n          return _promise2.default.resolve().then(function () {\n            return redirect(_this2);\n          }).then(function (redirect) {\n            return _this2.handleRedirect(redirect);\n          });\n        default:\n          throw new Error('Unknown redirect: ' + redirect);\n      }\n    }\n  }, {\n    key: 'goUpstream',\n    value: function goUpstream() {\n      var _this3 = this;\n\n      var ctx = this.manager.context;\n      if (!ctx.state) {\n        // We're at root state, no cleanup is necessary\n        return _promise2.default.resolve();\n      }\n      // Stop going up if state is common with dst branch\n      var state = ctx.state;\n      if (this.dstState.includes(state)) {\n        // All ctx params must match target ones\n        // (e.g. when going from /user/1 to /user/2)\n        var paramsMatch = (0, _keys2.default)(ctx.params).every(function (key) {\n          return ctx.params[key] === _this3.params[key];\n        });\n        if (paramsMatch) {\n          return _promise2.default.resolve();\n        }\n      }\n      return _promise2.default.resolve().then(function () {\n        return state.leave(ctx);\n      }).then(function () {\n        return _this3.manager.afterEach(ctx);\n      }).then(function () {\n        debug(' <- left %s', state.name);\n        _this3.cleanup(ctx);\n      }).then(function () {\n        return _this3.goUpstream();\n      });\n    }\n  }, {\n    key: 'cleanup',\n    value: function cleanup(ctx) {\n      if (ctx.vm) {\n        // Destroy vm and restore v-view element\n        var el = ctx.vm.$el;\n        var mp = ctx.mountPoint;\n        ctx.vm.$destroy();\n        if (mp) {\n          (function () {\n            var viewEl = ctx.mountPoint.viewEl;\n            el.parentNode.replaceChild(viewEl, el);\n            mp.viewElChildren.forEach(function (el) {\n              return viewEl.appendChild(el);\n            });\n          })();\n        }\n      }\n      this.manager.context = ctx.parent;\n      this.manager.emit('context_updated', this.manager.context);\n    }\n  }, {\n    key: 'goDownstream',\n    value: function goDownstream() {\n      var _this4 = this;\n\n      var prevCtx = this.manager.context;\n      var dstLineage = this.dstState.lineage;\n      var nextState = dstLineage[dstLineage.indexOf(prevCtx.state) + 1];\n      if (!nextState) {\n        return _promise2.default.resolve();\n      }\n\n      // New context inherits params and data from parent\n      var nextContext = {\n        parent: prevCtx,\n        state: nextState,\n        params: (0, _assign2.default)({}, prevCtx.params, nextState._makeParams(this.params)),\n        data: (0, _assign2.default)({}, prevCtx.data)\n      };\n\n      return _promise2.default.resolve(true).then(function () {\n        return _this4.manager.beforeEach(nextContext);\n      }).catch(function (err) {\n        return nextState.handleError(err, nextContext);\n      }).then(function (obj) {\n        return _this4._handleEnterHook(obj, nextContext);\n      }).then(function (proceed) {\n        if (!proceed) {\n          return false;\n        }\n        return _promise2.default.resolve().then(function () {\n          return nextState.enter(nextContext);\n        }).catch(function (err) {\n          return nextState.handleError(err, nextContext);\n        }).then(function (obj) {\n          return _this4._handleEnterHook(obj, nextContext);\n        });\n      }).then(function (proceed) {\n        if (!proceed) {\n          return false;\n        }\n        _this4.manager.context = nextContext;\n        _this4.manager.emit('context_updated', _this4.manager.context);\n        _this4.render(nextContext, nextState.component);\n        if (nextState !== _this4.dstState) {\n          return _this4.goDownstream();\n        }\n      });\n    }\n\n    /**\n     * @return {Boolean} proceed\n     * @private\n     */\n\n  }, {\n    key: '_handleEnterHook',\n    value: function _handleEnterHook(obj, nextContext) {\n      obj = obj || {};\n      var nextState = nextContext.state;\n      debug(' -> entered %s', nextState.name);\n      // hooks can return { redirect: 'new.state.name' }\n      // or { redirect: { name, params } }\n      if (obj.redirect) {\n        return this.handleRedirect(obj.redirect).then(function () {\n          return false;\n        });\n      }\n      // hooks can also return { component: <VueComponent> }\n      var rendered = this.render(nextContext, obj.component);\n      return !rendered;\n    }\n  }, {\n    key: 'render',\n    value: function render(ctx, comp) {\n      if (!comp) {\n        return false;\n      }\n      var Comp = (0, _utils.toVueComponent)(comp);\n      var mp = this.manager._getMountPoint();\n      ctx.mountPoint = mp;\n      ctx.vm = new Comp({\n        data: ctx.data,\n        el: mp.viewEl,\n        parent: mp.hostVm,\n        params: ctx.params,\n        ctx: ctx,\n        state: ctx.state,\n        manager: this.manager\n      });\n      return true;\n    }\n  }, {\n    key: 'to',\n    get: function get() {\n      return this.dstState;\n    }\n  }]);\n  return Transition;\n})();\n\nexports.default = Transition;\n\n},{\"./error\":123,\"./utils\":128,\"babel-runtime/core-js/object/assign\":1,\"babel-runtime/core-js/object/keys\":5,\"babel-runtime/core-js/promise\":7,\"babel-runtime/helpers/classCallCheck\":9,\"babel-runtime/helpers/createClass\":10,\"babel-runtime/helpers/typeof\":13,\"debug\":88}],128:[function(require,module,exports){\n'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.toVueComponent = toVueComponent;\n\nvar _vue = require('vue');\n\nvar _vue2 = _interopRequireDefault(_vue);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction toVueComponent(obj) {\n  if (obj.name === 'VueComponent') {\n    return obj;\n  }\n  return _vue2.default.extend(obj);\n}\n\n},{\"vue\":\"vue\"}]},{},[124])(124)\n});"
  },
  {
    "path": "lib/directives.js",
    "content": "'use strict';\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _vue = require('vue');\n\nvar _vue2 = _interopRequireDefault(_vue);\n\nvar _debug = require('debug');\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar debug = (0, _debug2.default)('voie:directive');\n\n_vue2.default.elementDirective('v-view', {\n  bind: function bind() {\n    var _vm$$options = this.vm.$options;\n    var state = _vm$$options.state;\n    var manager = _vm$$options.manager;\n\n    manager.mountPoints[state.name] = {\n      hostVm: this.vm,\n      viewEl: this.el,\n      viewElChildren: [].slice.call(this.el.children)\n    };\n    debug('registered v-view', this.el);\n  },\n  unbind: function unbind() {\n    var _vm$$options2 = this.vm.$options;\n    var state = _vm$$options2.state;\n    var manager = _vm$$options2.manager;\n\n    delete manager.mountPoints[state.name];\n    debug('unregistered v-view', this.el);\n  }\n});\n\n_vue2.default.directive('link', {\n  bind: function bind() {\n    this.manager = resolveManager(this.vm);\n    if (!this.manager) {\n      throw new Error('Can\\'t locate state manager.');\n    }\n    this.manager.on('context_updated', this.updateElement, this);\n  },\n  unbind: function unbind() {\n    this.manager.off('context_updated', this.updateElement, this);\n  },\n  update: function update(value) {\n    var _this = this;\n\n    if (!value) {\n      throw new Error('v-link: expression \"' + this.expression + '\" should resolve to { name: ..., params... }}');\n    }\n    var manager = this.manager;\n    var name = null;\n    if (typeof value == 'string') {\n      name = value;\n      this.params = {};\n    } else {\n      name = value.name;\n      this.params = value.params || {};\n    }\n    this.state = manager.get(name);\n    if (!this.state) {\n      /* eslint-disable no-console */\n      console.warn('State \"' + name + '\" not found.');\n      /* eslint-enable no-console */\n      return;\n    }\n    this.el.onclick = function (ev) {\n      ev.preventDefault();\n      manager.go({\n        name: name,\n        params: _this.params\n      });\n    };\n    this.updateElement();\n  },\n  updateElement: function updateElement() {\n    var manager = this.manager;\n    var ctx = manager.context;\n    var state = this.state;\n    if (!state) {\n      return;\n    }\n    var params = (0, _assign2.default)({}, ctx.params, this.params);\n    this.el.setAttribute('href', state.createHref(params));\n    // Add/remove active class\n    this.el.classList.remove(manager.activeClass);\n    if (ctx.state) {\n      var paramsMatch = (0, _keys2.default)(params).every(function (key) {\n        return ctx.params[key] === params[key];\n      });\n      var active = ctx.state.includes(state) && paramsMatch;\n      if (active) {\n        this.el.classList.add(manager.activeClass);\n      } else {\n        this.el.classList.remove(manager.activeClass);\n      }\n    }\n  }\n});\n\nfunction resolveManager(vm) {\n  var manager = vm.$options.manager;\n  if (manager) {\n    return manager;\n  }\n  if (vm.$parent) {\n    return resolveManager(vm.$parent);\n  }\n  return null;\n}"
  },
  {
    "path": "lib/error.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.RedirectLoopError = exports.StateNotFoundError = undefined;\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar StateNotFoundError = exports.StateNotFoundError = (function (_Error) {\n  (0, _inherits3.default)(StateNotFoundError, _Error);\n\n  function StateNotFoundError(name) {\n    (0, _classCallCheck3.default)(this, StateNotFoundError);\n\n    var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(StateNotFoundError).call(this, 'State \"' + name + '\" not found.'));\n\n    _this.name = name;\n    return _this;\n  }\n\n  return StateNotFoundError;\n})(Error);\n\nvar RedirectLoopError = exports.RedirectLoopError = (function (_Error2) {\n  (0, _inherits3.default)(RedirectLoopError, _Error2);\n\n  function RedirectLoopError(transition) {\n    (0, _classCallCheck3.default)(this, RedirectLoopError);\n\n    var _this2 = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(RedirectLoopError).call(this, 'Redirect loop detected ' + '(set maxRedirects on state manager to configure max redirects per transition)'));\n\n    _this2.transition = transition;\n    return _this2;\n  }\n\n  return RedirectLoopError;\n})(Error);"
  },
  {
    "path": "lib/index.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.Transition = exports.State = exports.StateManager = undefined;\n\nvar _stateManager = require('./state-manager');\n\nvar _stateManager2 = _interopRequireDefault(_stateManager);\n\nvar _state = require('./state');\n\nvar _state2 = _interopRequireDefault(_state);\n\nvar _transition = require('./transition');\n\nvar _transition2 = _interopRequireDefault(_transition);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.StateManager = _stateManager2.default;\nexports.State = _state2.default;\nexports.Transition = _transition2.default;"
  },
  {
    "path": "lib/state-manager.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _typeof2 = require('babel-runtime/helpers/typeof');\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _debug = require('debug');\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nvar _eventemitter = require('eventemitter3');\n\nvar _eventemitter2 = _interopRequireDefault(_eventemitter);\n\nvar _state = require('./state');\n\nvar _state2 = _interopRequireDefault(_state);\n\nvar _transition = require('./transition');\n\nvar _transition2 = _interopRequireDefault(_transition);\n\nvar _history = require('history');\n\nrequire('./directives');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar debug = (0, _debug2.default)('voie:manager');\n\n/**\n * State manager holds the hierarchy of application states,\n * exposes methods for navigating around states and\n * keeps track of current state and its `context`\n * (object `{ state, params, data, ... }`).\n *\n * A typical application will have a single instance\n * of state manager exposed as a module.\n *\n * ```es6\n * import { StateManager } from 'voie';\n *\n * export default new StateManager({ ... });\n * ```\n *\n * State manager emits following events:\n *\n *   * `history_updated`\n *   * `context_updated`\n *   * `transition_finished`\n *\n */\n\nvar StateManager = (function (_EventEmitter) {\n  (0, _inherits3.default)(StateManager, _EventEmitter);\n\n  /**\n   * Instantiates new state manager.\n   *\n   * Options:\n   *\n   *   * `el` — required, root DOM element for rendering views\n   *     (can be either `HTMLElement` or selector string)\n   *\n   *   * history — a history object (see `rackt/history`)\n   *\n   *   * base — (only used when `history` is not specified), base href\n   *     for application (URL pathname prefix)\n   *\n   *   * `maxRedirects` — maximum number of redirects within\n   *     a single transition, when exceeded transition will fail with\n   *     `RedirectLoopError` (default is 10)\n   *\n   *   * `activeClass` — active class for `v-link` directive\n   *     (default is \"active\")'\n   *\n   *   * `handleUncaught` — `function(err) => Promise` invoked\n   *     when transition fails with error\n   *\n   *   * `beforeEach` — `function(ctx) => Promise` invoked\n   *     before each `enter` hook\n   */\n\n  function StateManager(spec) {\n    (0, _classCallCheck3.default)(this, StateManager);\n\n    var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(StateManager).call(this));\n\n    _this._setupEl(spec);\n    _this._setupHistory(spec);\n    _this._setupOptions(spec);\n    _this._setupHooks(spec);\n    _this._setupState();\n    return _this;\n  }\n\n  (0, _createClass3.default)(StateManager, [{\n    key: '_setupEl',\n    value: function _setupEl(spec) {\n      this.el = spec.el instanceof HTMLElement ? spec.el : document.querySelector(spec.el);\n      if (!this.el) {\n        throw new Error('Please specify `el` as an entry-point node of your app.');\n      }\n    }\n  }, {\n    key: '_setupHistory',\n    value: function _setupHistory(spec) {\n      if (spec.history) {\n        this.history = spec.history;\n      } else {\n        this._setupDefaultHtml5History(spec);\n      }\n    }\n  }, {\n    key: '_setupDefaultHtml5History',\n    value: function _setupDefaultHtml5History(spec) {\n      var base = spec.base;\n      // Try to take base from `<base href=\"\"/>`\n      if (!base) {\n        var baseEl = document.querySelector('base');\n        base = baseEl && baseEl.getAttribute('href');\n      }\n      base = (base || '').replace(/\\/+$/, '');\n      this.history = (0, _history.useBasename)(_history.createHistory)({ basename: base });\n    }\n  }, {\n    key: '_setupOptions',\n    value: function _setupOptions(spec) {\n      if (spec.handleUncaught) {\n        this.handleUncaught = spec.handleUncaught;\n      }\n      this.maxRedirects = Number(spec.maxRedirects) || 10;\n      this.activeClass = spec.activeClass || 'active';\n    }\n  }, {\n    key: '_setupHooks',\n    value: function _setupHooks(spec) {\n      if (spec.beforeEach) {\n        this.beforeEach = spec.beforeEach;\n      }\n      if (spec.afterEach) {\n        this.afterEach = spec.afterEach;\n      }\n    }\n  }, {\n    key: '_setupState',\n    value: function _setupState() {\n      this.states = {};\n      this.context = {\n        parent: null,\n        state: null, // root state\n        vm: null,\n        params: {},\n        data: {}\n      };\n      this.mountPoints = {\n        '': {\n          viewEl: this.el,\n          viewElChildren: [].slice.call(this.el.children)\n        }\n      };\n      this.transition = null;\n    }\n\n    /**\n     * Executed before `enter` hooks on each state.\n     * \n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'beforeEach',\n    value: function beforeEach() {}\n\n    /**\n     * Executed after `leave` hooks on each state.\n     * \n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'afterEach',\n    value: function afterEach() {}\n\n    /**\n     * Handles errors uncaught during transition.\n     * Used for overriding on a per-instance basis.\n     *\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'handleUncaught',\n    value: function handleUncaught(err) {\n      return _promise2.default.reject(err);\n    }\n\n    /**\n     * Registers a new state with specified `name`.\n     *\n     * You can use one of two styles:\n     *\n     * ```es6\n     * sm.add('foo', { ... });\n     * sm.add({ name: 'foo', ... });\n     * ```\n     *\n     * All options are passed to `State` constructor.\n     *\n     * @returns {State}\n     */\n\n  }, {\n    key: 'add',\n    value: function add(name, spec) {\n      if ((typeof name === 'undefined' ? 'undefined' : (0, _typeof3.default)(name)) == 'object') {\n        spec = name;\n        name = spec.name;\n      }\n      if (!name) {\n        throw new Error('State `name` is mandatory.');\n      }\n      if (this.states[name]) {\n        throw new Error('State \"' + name + '\" already added');\n      }\n      spec.name = name;\n      var state = new _state2.default(this, spec);\n      debug('add %s', name);\n      this.states[name] = state;\n      return state;\n    }\n\n    /**\n     * Retrieves a state previously registered via `add`.\n     *\n     * @returns {State}\n     */\n\n  }, {\n    key: 'get',\n    value: function get(name) {\n      return this.states[name];\n    }\n\n    /**\n     * Navigates to a state with specified `name`.\n     * Navigation is performed asynchronously, allowing\n     * state enter/leave hook to perform async tasks\n     * (e.g. fetch data).\n     *\n     * Throws an exception if another transition is\n     * taking place.\n     *\n     * Options:\n     *\n     *   * `name` — target state name (if null, will transition to same state\n     *     with updated params)\n     *   * `params` — object containing state parameters\n     *     (either path variables or query string parameters)\n     *   * `replace` — if `true` don't create a separate record\n     *     in browser history (default is `false`)\n     *\n     * Transition process:\n     *\n     *   * find nearest common ancestor state with matching parameters\n     *   * go \"upstream\", leaving states, cleaning up states,\n     *     destroying components\n     *   * go \"downstream\", entering states, instantiating and rendering\n     *     components\n     *   * update browser history to reflect target state\n     *     (e.g. set new URL in address bar)\n     *\n     *  Note that it is the responsibility of the state to compute\n     *  target URL.\n     *\n     *  @returns {Promise} resolved when navigation is finished.\n     */\n\n  }, {\n    key: 'go',\n    value: function go(options) {\n      var _this2 = this;\n\n      if (this.transition) {\n        throw new Error('Transition is in progress.');\n      }\n      this.transition = new _transition2.default(this);\n      var currentState = this.context.state;\n      var name = null;\n      if (typeof options === 'string') {\n        name = options;\n        options = {};\n      } else if (options.name) {\n        name = options.name;\n      } else if (currentState) {\n        name = currentState.name;\n      } else {\n        throw new Error('Destination state not specified');\n      }\n      return _promise2.default.resolve().then(function () {\n        return _this2.transition.go(name, options.params || {});\n      }).then(function (result) {\n        _this2.transition = null;\n        _this2.emit('transition_finished');\n        return result;\n      }).catch(function (err) {\n        _this2.transition = null;\n        _this2.emit('transition_finished', err);\n        return _this2.handleUncaught(err);\n      }).then(function () {\n        return _this2._updateHistory(options.replace || false);\n      });\n    }\n\n    /**\n     * Updates browser history without actually performing\n     * any transitions.\n     *\n     * Typically used to serialize parameters into query string\n     * without performing navigation (e.g. when params are used\n     * only in Vue components).\n     */\n\n  }, {\n    key: 'update',\n    value: function update(params, replace) {\n      var _this3 = this;\n\n      (0, _assign2.default)(this.context.params, params);\n      this.emit('context_updated', this.context);\n      return _promise2.default.resolve().then(function () {\n        return _this3._updateHistory(replace);\n      });\n    }\n\n    /**\n     * Resolves nearest mount point in current context tree.\n     *\n     * Mount point is a \"slot\" that corresponds to `v-view` directive\n     * (and the component that hosts it).\n     */\n\n  }, {\n    key: '_getMountPoint',\n    value: function _getMountPoint() {\n      var ctx = this.context;\n      var el = null;\n      while (ctx && !el) {\n        var state = ctx.state;\n        if (state) {\n          el = this.mountPoints[state.name];\n        } else {\n          el = this.mountPoints[''];\n        }\n        ctx = ctx.parent;\n      }\n      return el;\n    }\n\n    /**\n     * Begins listening for history events (e.g. browser back button)\n     * and performs initial navigation by matching current URL.\n     *\n     * @returns {Promise} resolved when initial navigation is finished.\n     */\n\n  }, {\n    key: 'start',\n    value: function start() {\n      var _this4 = this;\n\n      if (this._unlisten) {\n        return _promise2.default.resolve();\n      }\n      this._unlisten = this.history.listen(function (location) {\n        return _this4._matchLocation(location);\n      });\n      return new _promise2.default(function (resolve) {\n        return _this4.once('history_updated', resolve);\n      });\n    }\n\n    /**\n     * Stops listening for history events.\n     */\n\n  }, {\n    key: 'stop',\n    value: function stop() {\n      if (!this._unlisten) {\n        return;\n      }\n      this._unlisten();\n      delete this._unlisten;\n    }\n  }, {\n    key: '_matchLocation',\n    value: function _matchLocation(location) {\n      var _this5 = this;\n\n      var url = location.pathname + location.search;\n      if (url === this.context.url) {\n        return;\n      }\n      var found = (0, _keys2.default)(this.states).find(function (name) {\n        var state = _this5.states[name];\n        var matched = state._match(location);\n        if (matched) {\n          debug('match url %s -> %s', location.pathname, name);\n          _this5.go({\n            name: name,\n            params: matched,\n            replace: true\n          });\n          return true;\n        }\n      });\n      if (!found) {\n        /* eslint-disable no-console */\n        console.warn('No states match URL: ' + location.pathname);\n        /* eslint-enable no-console */\n        this._updateHistory(true);\n      }\n    }\n  }, {\n    key: '_updateHistory',\n    value: function _updateHistory(replace) {\n      var state = this.context.state;\n      var url = state ? state._makeUrl(this.context.params) : '/';\n      if (url === this.context.url) {\n        return;\n      }\n      this.context.url = url;\n      if (replace) {\n        this.history.replace(url);\n      } else {\n        this.history.push(url);\n      }\n      this.emit('history_updated', {\n        url: url,\n        ctx: this.context\n      });\n    }\n  }]);\n  return StateManager;\n})(_eventemitter2.default);\n\nexports.default = StateManager;\n;"
  },
  {
    "path": "lib/state.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _pathToRegexp = require('path-to-regexp');\n\nvar _pathToRegexp2 = _interopRequireDefault(_pathToRegexp);\n\nvar _queryString = require('query-string');\n\nvar _queryString2 = _interopRequireDefault(_queryString);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Represents a node in application states hierarchy.\n *\n * Most state features are optional, the only required\n * setting is a unique `name` and a reference to `parent` state.\n *\n * Depending on features a state can represent:\n *\n *   * an abstract view (e.g. layout containing a component with `<v-view>`\n *     directive)\n *   * a concrete view\n *   * a route with path pattern and query parameters\n *   * a data resolver that provides data to its descendants\n *   * a mix of above\n *\n * Invoking constructor directly is not recommended,\n * use `StateManager#add` instead.\n *\n * @private\n */\n\nvar State = (function () {\n\n  /**\n   * Options:\n   *\n   *   * `name` — required, state name; if contains dots `.`\n   *     then parent state will be inferred from this name\n   *     (e.g. `layout.users` will become a parent of `layout.users.list`)\n   *     unless `parent` is specified explicitly\n   *\n   *   * `parent` — optional, parent state (this option disables\n   *     parent-from-name inference)\n   *\n   *   * `path` — optional pathname pattern for matching URLs and\n   *     extracting parameters (e.g. `/user/:userId`). If started with `/`,\n   *     then path is treated as an absolute pathname, otherwise\n   *     path is treated as a fragment (absolute pathname is inherited\n   *     from parent)\n   *\n   *   * `params` — optional object that specifies default values for\n   *     additional params that this state accepts; these params\n   *     will be encoded into query string\n   *\n   *   * `component` — optional Vue component to be rendered\n   *     when entering this state\n   *\n   *   * `redirect` — optional state name to redirect when navigating\n   *     to this state; typically used in \"abstract\" states (e.g. layouts,\n   *     data-preparation, etc.) to specify default sub-state\n   *\n   *   * `enter` — optional `function(ctx, transition) => Promise` hook invoked\n   *     when transitioning into this state or its descendants\n   *\n   *   * `leave` — optional `function(ctx, transition) => Promise` hook invoked\n   *     when transitioning from this state or its descendants\n   *\n   *   * `handleError` — optional `function(err, ctx) => Promise` invoked\n   *     when error occurs during transition into/over this state\n   *\n   * @param manager\n   * @param spec\n   */\n\n  function State(manager, spec) {\n    (0, _classCallCheck3.default)(this, State);\n\n    this.manager = manager;\n    this._setupName(spec);\n    this._setupHierarchy(spec);\n    this._setupComponent(spec);\n    this._setupHooks(spec);\n    this._setupPath(spec);\n    this._setupParams(spec);\n    this._setupOptions(spec);\n  }\n\n  (0, _createClass3.default)(State, [{\n    key: '_setupName',\n    value: function _setupName(spec) {\n      this.name = spec.name;\n      if (!this.name) {\n        throw new Error('State `name` is required');\n      }\n    }\n  }, {\n    key: '_setupHierarchy',\n    value: function _setupHierarchy(spec) {\n      this.parentState = this.manager.get(spec.parent || this.name.split('.').slice(0, -1).join('.')) || null;\n      this.lineage = this.parentState ? this.parentState.lineage.concat([this]) : [this];\n    }\n  }, {\n    key: '_setupComponent',\n    value: function _setupComponent(spec) {\n      if (spec.component) {\n        this.component = spec.component;\n        if (!this.component.name) {\n          this.component.name = this.name.replace(/\\./g, '-');\n        }\n      }\n    }\n  }, {\n    key: '_setupHooks',\n    value: function _setupHooks(spec) {\n      if (spec.enter) {\n        this.enter = spec.enter;\n      }\n      if (spec.leave) {\n        this.leave = spec.leave;\n      }\n      if (spec.handleError) {\n        this.handleError = spec.handleError;\n      }\n    }\n  }, {\n    key: '_setupPath',\n    value: function _setupPath(spec) {\n      if (!spec.path && spec.url) {\n        /* eslint-disable no-console */\n        console.warn('state.url is deprecated; use state.path instead');\n        /* eslint-enable no-console */\n        spec.path = spec.url;\n      }\n      this.path = spec.path || '';\n      if (this.path.indexOf('/') === 0) {\n        this.fullPath = this.path;\n      } else {\n        var parentPath = this.parentState ? this.parentState.fullPath : '/';\n        this.fullPath = parentPath.replace(/\\/+$/, '') + (this.path ? '/' + this.path : '');\n      }\n      if (!this.fullPath) {\n        this.fullPath = '/';\n      }\n      this._pathParams = [];\n      this._pathRegex = (0, _pathToRegexp2.default)(this.fullPath, this._pathParams);\n      this._pathFormat = _pathToRegexp2.default.compile(this.fullPath);\n    }\n  }, {\n    key: '_setupParams',\n    value: function _setupParams(spec) {\n      var _this = this;\n\n      this._paramsSpec = {};\n      this._pathParams.forEach(function (param) {\n        _this._paramsSpec[param.name] = null;\n      });\n      (0, _assign2.default)(this._paramsSpec, spec.params);\n    }\n  }, {\n    key: '_setupOptions',\n    value: function _setupOptions(spec) {\n      if (spec.redirect) {\n        this.redirect = spec.redirect;\n      }\n    }\n\n    /**\n     * Invoked when going \"downstream\" (either into this state or\n     * through this state to one of its descendants).\n     *\n     * Primary usage is to process `ctx.params` and populate `ctx.data`.\n     *\n     * Can redirect to another state by resolving `{ redirect: anotherStateName }`\n     * (e.g. for authentication).\n     *\n     * It is also possible to render a custom Vue component instead\n     * by resolving `{ component: customVueComponent }`.\n     *\n     * @param ctx — object `{ state, params, data }`\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'enter',\n    value: function enter(ctx) {\n      return _promise2.default.resolve();\n    }\n\n    /**\n     * Invoked when going \"upstream\" (either from this state or\n     * through this state from one of its descendants).\n     * Typically used from cleaning up stuff used by this state.\n     *\n     * Like with `enter`, it is possible to redirect to another state\n     * by resolving `{ redirect: anotherStateName }`.\n     *\n     * @param ctx — object `{ state, params, data }`\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'leave',\n    value: function leave(ctx) {\n      return _promise2.default.resolve();\n    }\n\n    /**\n     * Invoked when error occurs during entering this state.\n     *\n     * Can redirect to another state by resolving `{ redirect: anotherStateName }`\n     * (e.g. for authentication).\n     *\n     * It is also possible to render a custom Vue component instead\n     * by resolving `{ component: customVueComponent }`.\n     *\n     * @param ctx — object `{ state, params, data }`\n     * @returns {Promise}\n     */\n\n  }, {\n    key: 'handleError',\n    value: function handleError(err, ctx) {\n      return _promise2.default.reject(err);\n    }\n\n    /**\n     * Returns true if this state is equal to `stateOrName`\n     * or contains `stateOrName` somewhere up the hierarchy.\n     *\n     * @param {string|State} stateOrName\n     * @return {boolean}\n     */\n\n  }, {\n    key: 'includes',\n    value: function includes(stateOrName) {\n      var state = stateOrName instanceof State ? stateOrName : this.manager.get(stateOrName);\n      return this.lineage.indexOf(state) > -1;\n    }\n\n    /**\n     * Attempts to match `location` to this state's `path` pattern.\n     *\n     * @param {{ pathname, search }} location\n     * @returns an object with extracted params or `null` if don't match.\n     * @private\n     */\n\n  }, {\n    key: '_match',\n    value: function _match(location) {\n      var matched = this._pathRegex.exec(location.pathname);\n      if (!matched) {\n        return null;\n      }\n      var params = this._pathParams.reduce(function (params, p, i) {\n        params[p.name] = matched[i + 1];\n        return params;\n      }, {});\n      try {\n        var query = _queryString2.default.parse(location.search);\n        (0, _assign2.default)(params, query);\n      } catch (e) {\n        // No query string or parsing failed — we don't care\n      }\n      return params;\n    }\n\n    /**\n     * Constructs a `params` object by dropping any parameters\n     * not specified in `_paramsSpec` of this state.\n     * Values from `_paramsSpec` act as defaults.\n     *\n     * @param {object} params\n     * @private\n     */\n\n  }, {\n    key: '_makeParams',\n    value: function _makeParams(params) {\n      var _this2 = this;\n\n      return (0, _keys2.default)(this._paramsSpec).reduce(function (result, name) {\n        result[name] = name in params ? params[name] : _this2._paramsSpec[name];\n        return result;\n      }, {});\n    }\n\n    /**\n     * Constructs search string by serializing query params.\n     *\n     * @param params\n     * @return {string} search\n     * @private\n     */\n\n  }, {\n    key: '_makeSearch',\n    value: function _makeSearch(params) {\n      var query = (0, _keys2.default)(params).reduce(function (query, key) {\n        var value = params[key];\n        if (value != null) {\n          query[key] = value;\n        }\n        return query;\n      }, {});\n      this._pathParams.forEach(function (p) {\n        delete query[p.name];\n      });\n      try {\n        var search = _queryString2.default.stringify(query);\n        if (search) {\n          return '?' + search;\n        }\n      } catch (e) {\n        // No query string or serialization failed — we don't care\n      }\n      return '';\n    }\n\n    /**\n     * Constructs an URL by encoding `params` into URL pattern and query string.\n     *\n     * Note: params not mentioned in `_paramsSpec` are dropped.\n     *\n     * @param params\n     * @return {string} url\n     * @private\n     */\n\n  }, {\n    key: '_makeUrl',\n    value: function _makeUrl(params) {\n      return this._pathFormat(params) + this._makeSearch(params);\n    }\n\n    /**\n     * Creates href suitable for links (taking into account base URL and\n     * hash-based histories).\n     *\n     * @param params\n     * @return {string} href\n     */\n\n  }, {\n    key: 'createHref',\n    value: function createHref(params) {\n      return this.manager.history.createHref(this._makeUrl(params));\n    }\n  }]);\n  return State;\n})();\n\nexports.default = State;\n;"
  },
  {
    "path": "lib/transition.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _keys = require('babel-runtime/core-js/object/keys');\n\nvar _keys2 = _interopRequireDefault(_keys);\n\nvar _promise = require('babel-runtime/core-js/promise');\n\nvar _promise2 = _interopRequireDefault(_promise);\n\nvar _typeof2 = require('babel-runtime/helpers/typeof');\n\nvar _typeof3 = _interopRequireDefault(_typeof2);\n\nvar _assign = require('babel-runtime/core-js/object/assign');\n\nvar _assign2 = _interopRequireDefault(_assign);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _debug = require('debug');\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nvar _error = require('./error');\n\nvar _utils = require('./utils');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar debug = (0, _debug2.default)('voie:transition');\n\nvar Transition = (function () {\n  function Transition(manager) {\n    (0, _classCallCheck3.default)(this, Transition);\n\n    this.manager = manager;\n    this.redirectsCount = 0;\n    this.params = (0, _assign2.default)({}, manager.context.params);\n  }\n\n  (0, _createClass3.default)(Transition, [{\n    key: 'go',\n    value: function go(name, params, isRedirect) {\n      var _this = this;\n\n      debug(isRedirect ? 'redirect to %s' : 'go to %s', name);\n      (0, _assign2.default)(this.params, params || {});\n      var state = this.manager.get(name);\n      if (!state) {\n        throw new _error.StateNotFoundError(name);\n      }\n      this.dstState = state;\n      if (state.redirect) {\n        return this.handleRedirect(state.redirect);\n      }\n      return this.goUpstream().then(function () {\n        return _this.goDownstream();\n      });\n    }\n  }, {\n    key: 'handleRedirect',\n    value: function handleRedirect(redirect) {\n      var _this2 = this;\n\n      this.redirectsCount++;\n      if (this.redirectsCount > this.manager.maxRedirects) {\n        throw new _error.RedirectLoopError(this);\n      }\n      switch (typeof redirect === 'undefined' ? 'undefined' : (0, _typeof3.default)(redirect)) {\n        case 'string':\n          return this.go(redirect, {}, true);\n        case 'object':\n          return this.go(redirect.name, redirect.params, true);\n        case 'function':\n          return _promise2.default.resolve().then(function () {\n            return redirect(_this2);\n          }).then(function (redirect) {\n            return _this2.handleRedirect(redirect);\n          });\n        default:\n          throw new Error('Unknown redirect: ' + redirect);\n      }\n    }\n  }, {\n    key: 'goUpstream',\n    value: function goUpstream() {\n      var _this3 = this;\n\n      var ctx = this.manager.context;\n      if (!ctx.state) {\n        // We're at root state, no cleanup is necessary\n        return _promise2.default.resolve();\n      }\n      // Stop going up if state is common with dst branch\n      var state = ctx.state;\n      if (this.dstState.includes(state)) {\n        // All ctx params must match target ones\n        // (e.g. when going from /user/1 to /user/2)\n        var paramsMatch = (0, _keys2.default)(ctx.params).every(function (key) {\n          return ctx.params[key] === _this3.params[key];\n        });\n        if (paramsMatch) {\n          return _promise2.default.resolve();\n        }\n      }\n      return _promise2.default.resolve().then(function () {\n        return state.leave(ctx);\n      }).then(function () {\n        return _this3.manager.afterEach(ctx);\n      }).then(function () {\n        debug(' <- left %s', state.name);\n        _this3.cleanup(ctx);\n      }).then(function () {\n        return _this3.goUpstream();\n      });\n    }\n  }, {\n    key: 'cleanup',\n    value: function cleanup(ctx) {\n      if (ctx.vm) {\n        // Destroy vm and restore v-view element\n        var el = ctx.vm.$el;\n        var mp = ctx.mountPoint;\n        ctx.vm.$destroy();\n        if (mp) {\n          (function () {\n            var viewEl = ctx.mountPoint.viewEl;\n            el.parentNode.replaceChild(viewEl, el);\n            mp.viewElChildren.forEach(function (el) {\n              return viewEl.appendChild(el);\n            });\n          })();\n        }\n      }\n      this.manager.context = ctx.parent;\n      this.manager.emit('context_updated', this.manager.context);\n    }\n  }, {\n    key: 'goDownstream',\n    value: function goDownstream() {\n      var _this4 = this;\n\n      var prevCtx = this.manager.context;\n      var dstLineage = this.dstState.lineage;\n      var nextState = dstLineage[dstLineage.indexOf(prevCtx.state) + 1];\n      if (!nextState) {\n        return _promise2.default.resolve();\n      }\n\n      // New context inherits params and data from parent\n      var nextContext = {\n        parent: prevCtx,\n        state: nextState,\n        params: (0, _assign2.default)({}, prevCtx.params, nextState._makeParams(this.params)),\n        data: (0, _assign2.default)({}, prevCtx.data)\n      };\n\n      return _promise2.default.resolve(true).then(function () {\n        return _this4.manager.beforeEach(nextContext);\n      }).catch(function (err) {\n        return nextState.handleError(err, nextContext);\n      }).then(function (obj) {\n        return _this4._handleEnterHook(obj, nextContext);\n      }).then(function (proceed) {\n        if (!proceed) {\n          return false;\n        }\n        return _promise2.default.resolve().then(function () {\n          return nextState.enter(nextContext);\n        }).catch(function (err) {\n          return nextState.handleError(err, nextContext);\n        }).then(function (obj) {\n          return _this4._handleEnterHook(obj, nextContext);\n        });\n      }).then(function (proceed) {\n        if (!proceed) {\n          return false;\n        }\n        _this4.manager.context = nextContext;\n        _this4.manager.emit('context_updated', _this4.manager.context);\n        _this4.render(nextContext, nextState.component);\n        if (nextState !== _this4.dstState) {\n          return _this4.goDownstream();\n        }\n      });\n    }\n\n    /**\n     * @return {Boolean} proceed\n     * @private\n     */\n\n  }, {\n    key: '_handleEnterHook',\n    value: function _handleEnterHook(obj, nextContext) {\n      obj = obj || {};\n      var nextState = nextContext.state;\n      debug(' -> entered %s', nextState.name);\n      // hooks can return { redirect: 'new.state.name' }\n      // or { redirect: { name, params } }\n      if (obj.redirect) {\n        return this.handleRedirect(obj.redirect).then(function () {\n          return false;\n        });\n      }\n      // hooks can also return { component: <VueComponent> }\n      var rendered = this.render(nextContext, obj.component);\n      return !rendered;\n    }\n  }, {\n    key: 'render',\n    value: function render(ctx, comp) {\n      if (!comp) {\n        return false;\n      }\n      var Comp = (0, _utils.toVueComponent)(comp);\n      var mp = this.manager._getMountPoint();\n      ctx.mountPoint = mp;\n      ctx.vm = new Comp({\n        data: ctx.data,\n        el: mp.viewEl,\n        parent: mp.hostVm,\n        params: ctx.params,\n        ctx: ctx,\n        state: ctx.state,\n        manager: this.manager\n      });\n      return true;\n    }\n  }, {\n    key: 'to',\n    get: function get() {\n      return this.dstState;\n    }\n  }]);\n  return Transition;\n})();\n\nexports.default = Transition;"
  },
  {
    "path": "lib/utils.js",
    "content": "'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.toVueComponent = toVueComponent;\n\nvar _vue = require('vue');\n\nvar _vue2 = _interopRequireDefault(_vue);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction toVueComponent(obj) {\n  if (obj.name === 'VueComponent') {\n    return obj;\n  }\n  return _vue2.default.extend(obj);\n}"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"voie\",\n  \"version\": \"0.7.0\",\n  \"description\": \"Voie.js — simple router / layout manager for Vue\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/inca/voie\"\n  },\n  \"main\": \"lib/index.js\",\n  \"dependencies\": {\n    \"debug\": \"^2.2.0\",\n    \"eslint\": \"^2.8.0\",\n    \"eventemitter3\": \"^1.1.1\",\n    \"history\": \"^3.2.0\",\n    \"path-to-regexp\": \"^1.2.1\",\n    \"query-string\": \"^3.0.0\",\n    \"vue\": \"^1.0.10\"\n  },\n  \"devDependencies\": {\n    \"babel-cli\": \"^6.3.15\",\n    \"babel-plugin-transform-runtime\": \"^6.3.13\",\n    \"babel-preset-es2015\": \"^6.3.13\",\n    \"babel-runtime\": \"^5.8.34\",\n    \"babelify\": \"^7.2.0\",\n    \"browserify\": \"^13.0.0\",\n    \"chai\": \"^3.4.1\",\n    \"karma\": \"^0.13.15\",\n    \"karma-browserify\": \"^4.4.2\",\n    \"karma-chai\": \"^0.1.0\",\n    \"karma-chrome-launcher\": \"^0.2.2\",\n    \"karma-mocha\": \"^0.2.1\",\n    \"karma-spec-reporter\": \"0.0.23\",\n    \"mocha\": \"^2.3.4\",\n    \"pre-commit\": \"^1.1.2\",\n    \"uglify-js\": \"^2.6.1\",\n    \"vue-hot-reload-api\": \"^1.2.2\",\n    \"vueify\": \"^7.1.0\",\n    \"vueify-insert-css\": \"^1.0.0\"\n  },\n  \"scripts\": {\n    \"check\": \"eslint .\",\n    \"dev\": \"karma start ./test/karma.dev.conf.js\",\n    \"build\": \"npm run build:compile && npm run build:standalone && npm run build:minify\",\n    \"build:compile\": \"babel src --out-dir lib\",\n    \"build:standalone\": \"browserify -s voie -x vue -e src/index.js -o dist/voie.js\",\n    \"build:minify\": \"uglifyjs -o dist/voie.min.js -- dist/voie.js\",\n    \"preversion\": \"npm run build\"\n  },\n  \"pre-commit\": [\n    \"check\"\n  ],\n  \"browserify\": {\n    \"transform\": [\n      \"babelify\"\n    ]\n  },\n  \"browser\": \"src/index.js\",\n  \"keywords\": [\n    \"vue\",\n    \"router\",\n    \"layout\",\n    \"manager\",\n    \"ui\",\n    \"browser\"\n  ],\n  \"author\": \"Boris Okunskiy\",\n  \"license\": \"ISC\",\n  \"bugs\": {\n    \"url\": \"https://github.com/inca/voie/issues\"\n  },\n  \"homepage\": \"https://github.com/inca/voie\"\n}\n"
  },
  {
    "path": "src/directives.js",
    "content": "import Vue from 'vue';\nimport Debug from 'debug';\n\nconst debug = Debug('voie:directive');\n\nVue.elementDirective('v-view', {\n\n  bind() {\n    const { state, manager } = this.vm.$options;\n    manager.mountPoints[state.name] = {\n      hostVm: this.vm,\n      viewEl: this.el,\n      viewElChildren: [].slice.call(this.el.children)\n    };\n    debug('registered v-view', this.el);\n  },\n\n  unbind() {\n    const { state, manager } = this.vm.$options;\n    delete manager.mountPoints[state.name];\n    debug('unregistered v-view', this.el);\n  }\n\n});\n\nVue.directive('link', {\n\n  bind() {\n    this.manager = resolveManager(this.vm);\n    if (!this.manager) {\n      throw new Error('Can\\'t locate state manager.')\n    }\n    this.manager.on('context_updated', this.updateElement, this);\n  },\n\n  unbind() {\n    this.manager.off('context_updated', this.updateElement, this);\n  },\n\n  update(value) {\n    if (!value) {\n      throw new Error('v-link: expression \"' +\n        this.expression + '\" should resolve to { name: ..., params... }}')\n    }\n    const manager = this.manager;\n    let name = null;\n    if (typeof value == 'string') {\n      name = value;\n      this.params = {};\n    } else {\n      name = value.name;\n      this.params = value.params || {};\n    }\n    this.state = manager.get(name);\n    if (!this.state) {\n      /* eslint-disable no-console */\n      console.warn('State \"' + name + '\" not found.');\n      /* eslint-enable no-console */\n      return;\n    }\n    this.el.onclick = (ev) => {\n      ev.preventDefault();\n      manager.go({\n        name: name,\n        params: this.params\n      });\n    };\n    this.updateElement();\n\n  },\n\n  updateElement() {\n    const manager = this.manager;\n    const ctx = manager.context;\n    const state = this.state;\n    if (!state) {\n      return;\n    }\n    const params = Object.assign({}, ctx.params, this.params);\n    this.el.setAttribute('href', state.createHref(params));\n    // Add/remove active class\n    this.el.classList.remove(manager.activeClass);\n    if (ctx.state) {\n      const paramsMatch = Object.keys(params)\n        .every(key => ctx.params[key] === params[key]);\n      const active = ctx.state.includes(state) && paramsMatch;\n      if (active) {\n        this.el.classList.add(manager.activeClass);\n      } else {\n        this.el.classList.remove(manager.activeClass);\n      }\n    }\n  }\n\n});\n\nfunction resolveManager(vm) {\n  const manager = vm.$options.manager;\n  if (manager) {\n    return manager;\n  }\n  if (vm.$parent) {\n    return resolveManager(vm.$parent);\n  }\n  return null;\n}\n"
  },
  {
    "path": "src/error.js",
    "content": "'use strict';\n\nexport class StateNotFoundError extends Error {\n\n  constructor(name) {\n    super('State \"' + name + '\" not found.');\n    this.name = name;\n  }\n\n}\n\nexport class RedirectLoopError extends Error {\n\n  constructor(transition) {\n    super('Redirect loop detected ' +\n      '(set maxRedirects on state manager to configure max redirects per transition)');\n    this.transition = transition;\n  }\n\n}\n"
  },
  {
    "path": "src/index.js",
    "content": "import StateManager from './state-manager';\nimport State from './state';\nimport Transition from './transition';\n\nexport {\n  StateManager,\n  State,\n  Transition\n};\n"
  },
  {
    "path": "src/state-manager.js",
    "content": "import Debug from 'debug';\n\nconst debug = Debug('voie:manager');\n\nimport EventEmitter from 'eventemitter3';\nimport State from './state';\nimport Transition from './transition';\nimport createHistory from 'history/createBrowserHistory';\nimport './directives';\n\n/**\n * State manager holds the hierarchy of application states,\n * exposes methods for navigating around states and\n * keeps track of current state and its `context`\n * (object `{ state, params, data, ... }`).\n *\n * A typical application will have a single instance\n * of state manager exposed as a module.\n *\n * ```es6\n * import { StateManager } from 'voie';\n *\n * export default new StateManager({ ... });\n * ```\n *\n * State manager emits following events:\n *\n *   * `history_updated`\n *   * `context_updated`\n *   * `transition_finished`\n *\n */\nexport default class StateManager extends EventEmitter {\n\n  /**\n   * Instantiates new state manager.\n   *\n   * Options:\n   *\n   *   * `el` — required, root DOM element for rendering views\n   *     (can be either `HTMLElement` or selector string)\n   *\n   *   * history — a history object (see `rackt/history`)\n   *\n   *   * base — (only used when `history` is not specified), base href\n   *     for application (URL pathname prefix)\n   *\n   *   * `maxRedirects` — maximum number of redirects within\n   *     a single transition, when exceeded transition will fail with\n   *     `RedirectLoopError` (default is 10)\n   *\n   *   * `activeClass` — active class for `v-link` directive\n   *     (default is \"active\")'\n   *\n   *   * `handleUncaught` — `function(err) => Promise` invoked\n   *     when transition fails with error\n   *\n   *   * `beforeEach` — `function(ctx) => Promise` invoked\n   *     before each `enter` hook\n   */\n  constructor(spec) {\n    super();\n    this._setupEl(spec);\n    this._setupHistory(spec);\n    this._setupOptions(spec);\n    this._setupHooks(spec);\n    this._setupState();\n  }\n\n  _setupEl(spec) {\n    this.el = spec.el instanceof HTMLElement ?\n      spec.el : document.querySelector(spec.el);\n    if (!this.el) {\n      throw new Error('Please specify `el` as an entry-point node of your app.')\n    }\n  }\n\n  _setupHistory(spec) {\n    if (spec.history) {\n      this.history = spec.history;\n    } else {\n      this._setupDefaultHtml5History(spec);\n    }\n  }\n\n  _setupDefaultHtml5History(spec) {\n    let base = spec.base;\n    // Try to take base from `<base href=\"\"/>`\n    if (!base) {\n      const baseEl = document.querySelector('base');\n      base = baseEl && baseEl.getAttribute('href');\n    }\n    base = (base || '').replace(/\\/+$/, '');\n    this.history = createHistory({ basename: base });\n  }\n\n  _setupOptions(spec) {\n    if (spec.handleUncaught) {\n      this.handleUncaught = spec.handleUncaught;\n    }\n    this.maxRedirects = Number(spec.maxRedirects) || 10;\n    this.activeClass = spec.activeClass || 'active';\n  }\n\n  _setupHooks(spec) {\n    if (spec.beforeEach) {\n      this.beforeEach = spec.beforeEach;\n    }\n    if (spec.afterEach) {\n      this.afterEach = spec.afterEach;\n    }\n  }\n\n  _setupState() {\n    this.states = {};\n    this.context = {\n      parent: null,\n      state: null,  // root state\n      vm: null,\n      params: {},\n      data: {}\n    };\n    this.mountPoints = {\n      '': {\n        viewEl: this.el,\n        viewElChildren: [].slice.call(this.el.children)\n      }\n    };\n    this.transition = null;\n  }\n\n  /**\n   * Executed before `enter` hooks on each state.\n   *\n   * @returns {Promise}\n   */\n  beforeEach() {}\n\n  /**\n   * Executed after `leave` hooks on each state.\n   *\n   * @returns {Promise}\n   */\n  afterEach() {}\n\n  /**\n   * Handles errors uncaught during transition.\n   * Used for overriding on a per-instance basis.\n   *\n   * @returns {Promise}\n   */\n  handleUncaught(err) {\n    return Promise.reject(err);\n  }\n\n  /**\n   * Registers a new state with specified `name`.\n   *\n   * You can use one of two styles:\n   *\n   * ```es6\n   * sm.add('foo', { ... });\n   * sm.add({ name: 'foo', ... });\n   * ```\n   *\n   * All options are passed to `State` constructor.\n   *\n   * @returns {State}\n   */\n  add(name, spec) {\n    if (typeof name == 'object') {\n      spec = name;\n      name = spec.name\n    }\n    if (!name) {\n      throw new Error('State `name` is mandatory.')\n    }\n    if (this.states[name]) {\n      throw new Error('State \"' + name + '\" already added');\n    }\n    spec.name = name;\n    const state = new State(this, spec);\n    debug('add %s', name);\n    this.states[name] = state;\n    return state;\n  }\n\n  /**\n   * Retrieves a state previously registered via `add`.\n   *\n   * @returns {State}\n   */\n  get(name) {\n    return this.states[name];\n  }\n\n  /**\n   * Navigates to a state with specified `name`.\n   * Navigation is performed asynchronously, allowing\n   * state enter/leave hook to perform async tasks\n   * (e.g. fetch data).\n   *\n   * Throws an exception if another transition is\n   * taking place.\n   *\n   * Options:\n   *\n   *   * `name` — target state name (if null, will transition to same state\n   *     with updated params)\n   *   * `params` — object containing state parameters\n   *     (either path variables or query string parameters)\n   *   * `replace` — if `true` don't create a separate record\n   *     in browser history (default is `false`)\n   *\n   * Transition process:\n   *\n   *   * find nearest common ancestor state with matching parameters\n   *   * go \"upstream\", leaving states, cleaning up states,\n   *     destroying components\n   *   * go \"downstream\", entering states, instantiating and rendering\n   *     components\n   *   * update browser history to reflect target state\n   *     (e.g. set new URL in address bar)\n   *\n   *  Note that it is the responsibility of the state to compute\n   *  target URL.\n   *\n   *  @returns {Promise} resolved when navigation is finished.\n   */\n  go(options) {\n    if (this.transition) {\n      throw new Error('Transition is in progress.')\n    }\n    this.transition = new Transition(this);\n    const currentState = this.context.state;\n    let name = null;\n    if (typeof options === 'string') {\n      name = options;\n      options = {};\n    } else if (options.name) {\n      name = options.name;\n    } else if (currentState) {\n      name = currentState.name;\n    } else {\n      throw new Error('Destination state not specified');\n    }\n    return Promise.resolve()\n      .then(() => this.transition.go(name, options.params || {}))\n      .then(result => {\n        this.transition = null;\n        this.emit('transition_finished');\n        return result;\n      })\n      .catch(err => {\n        this.transition = null;\n        this.emit('transition_finished', err);\n        return this.handleUncaught(err);\n      })\n      .then(() => this._updateHistory(options.replace || false));\n  }\n\n  /**\n   * Updates browser history without actually performing\n   * any transitions.\n   *\n   * Typically used to serialize parameters into query string\n   * without performing navigation (e.g. when params are used\n   * only in Vue components).\n   */\n  update(params, replace) {\n    Object.assign(this.context.params, params);\n    this.emit('context_updated', this.context);\n    return Promise.resolve()\n      .then(() => this._updateHistory(replace));\n  }\n\n  /**\n   * Resolves nearest mount point in current context tree.\n   *\n   * Mount point is a \"slot\" that corresponds to `v-view` directive\n   * (and the component that hosts it).\n   */\n  _getMountPoint() {\n    let ctx = this.context;\n    let el = null;\n    while (ctx && !el) {\n      const state = ctx.state;\n      if (state) {\n        el = this.mountPoints[state.name];\n      } else {\n        el = this.mountPoints[''];\n      }\n      ctx = ctx.parent;\n    }\n    return el;\n  }\n\n  /**\n   * Begins listening for history events (e.g. browser back button)\n   * and performs initial navigation by matching current URL.\n   *\n   * @returns {Promise} resolved when initial navigation is finished.\n   */\n  start() {\n    if (this._unlisten) {\n      return Promise.resolve();\n    }\n    this._matchLocation(window.location)\n    this._unlisten = this.history.listen((location, action) => {this._matchLocation(location)});\n    return new Promise(resolve => this.once('history_updated', resolve));\n  }\n\n  /**\n   * Stops listening for history events.\n   */\n  stop() {\n    if (!this._unlisten) {\n      return;\n    }\n    this._unlisten();\n    delete this._unlisten;\n  }\n\n  _matchLocation(location) {\n    const url = location.pathname + location.search;\n    if (url === this.context.url) {\n      return;\n    }\n    const found = Object.keys(this.states).find(name => {\n      const state = this.states[name];\n      const matched = state._match(location);\n      if (matched) {\n        debug('match url %s -> %s', location.pathname, name);\n        this.go({\n          name: name,\n          params: matched,\n          replace: true\n        });\n        return true;\n      }\n    });\n    if (!found) {\n      /* eslint-disable no-console */\n      console.warn('No states match URL: ' + location.pathname);\n      /* eslint-enable no-console */\n      this._updateHistory(true);\n    }\n  }\n\n  _updateHistory(replace) {\n    const state = this.context.state;\n    const url = state ? state._makeUrl(this.context.params) : '/';\n    if (url === this.context.url) {\n      return;\n    }\n    this.context.url = url;\n    if (replace) {\n      this.history.replace(url);\n    } else {\n      this.history.push(url);\n    }\n    this.emit('history_updated', {\n      url: url,\n      ctx: this.context\n    });\n  }\n\n};\n"
  },
  {
    "path": "src/state.js",
    "content": "import pathToRegexp from 'path-to-regexp';\nimport querystring from 'query-string';\n\n/**\n * Represents a node in application states hierarchy.\n *\n * Most state features are optional, the only required\n * setting is a unique `name` and a reference to `parent` state.\n *\n * Depending on features a state can represent:\n *\n *   * an abstract view (e.g. layout containing a component with `<v-view>`\n *     directive)\n *   * a concrete view\n *   * a route with path pattern and query parameters\n *   * a data resolver that provides data to its descendants\n *   * a mix of above\n *\n * Invoking constructor directly is not recommended,\n * use `StateManager#add` instead.\n *\n * @private\n */\nexport default class State {\n\n  /**\n   * Options:\n   *\n   *   * `name` — required, state name; if contains dots `.`\n   *     then parent state will be inferred from this name\n   *     (e.g. `layout.users` will become a parent of `layout.users.list`)\n   *     unless `parent` is specified explicitly\n   *\n   *   * `parent` — optional, parent state (this option disables\n   *     parent-from-name inference)\n   *\n   *   * `path` — optional pathname pattern for matching URLs and\n   *     extracting parameters (e.g. `/user/:userId`). If started with `/`,\n   *     then path is treated as an absolute pathname, otherwise\n   *     path is treated as a fragment (absolute pathname is inherited\n   *     from parent)\n   *\n   *   * `params` — optional object that specifies default values for\n   *     additional params that this state accepts; these params\n   *     will be encoded into query string\n   *\n   *   * `component` — optional Vue component to be rendered\n   *     when entering this state\n   *\n   *   * `redirect` — optional state name to redirect when navigating\n   *     to this state; typically used in \"abstract\" states (e.g. layouts,\n   *     data-preparation, etc.) to specify default sub-state\n   *\n   *   * `enter` — optional `function(ctx, transition) => Promise` hook invoked\n   *     when transitioning into this state or its descendants\n   *\n   *   * `leave` — optional `function(ctx, transition) => Promise` hook invoked\n   *     when transitioning from this state or its descendants\n   *\n   *   * `handleError` — optional `function(err, ctx) => Promise` invoked\n   *     when error occurs during transition into/over this state\n   *\n   * @param manager\n   * @param spec\n   */\n  constructor(manager, spec) {\n    this.manager = manager;\n    this._setupName(spec);\n    this._setupHierarchy(spec);\n    this._setupComponent(spec);\n    this._setupHooks(spec);\n    this._setupPath(spec);\n    this._setupParams(spec);\n    this._setupOptions(spec);\n  }\n\n  _setupName(spec) {\n    this.name = spec.name;\n    if (!this.name) {\n      throw new Error('State `name` is required');\n    }\n  }\n\n  _setupHierarchy(spec) {\n    this.parentState = this.manager.get(spec.parent || this.name.split('.').slice(0, -1).join('.')) || null;\n    this.lineage = this.parentState ?\n      this.parentState.lineage.concat([this]) : [this];\n  }\n\n  _setupComponent(spec) {\n    if (spec.component) {\n      this.component = spec.component;\n      if (!this.component.name) {\n        this.component.name = this.name.replace(/\\./g, '-');\n      }\n    }\n  }\n\n  _setupHooks(spec) {\n    if (spec.enter) {\n      this.enter = spec.enter;\n    }\n    if (spec.leave) {\n      this.leave = spec.leave;\n    }\n    if (spec.handleError) {\n      this.handleError = spec.handleError;\n    }\n  }\n\n  _setupPath(spec) {\n    if (!spec.path && spec.url) {\n      /* eslint-disable no-console */\n      console.warn('state.url is deprecated; use state.path instead');\n      /* eslint-enable no-console */\n      spec.path = spec.url;\n    }\n    this.path = spec.path || '';\n    if (this.path.indexOf('/') === 0) {\n      this.fullPath = this.path;\n    } else {\n      const parentPath = this.parentState ? this.parentState.fullPath : '/';\n      this.fullPath = parentPath.replace(/\\/+$/, '') +\n        (this.path ? '/' + this.path : '');\n    }\n    if (!this.fullPath) {\n      this.fullPath = '/';\n    }\n    this._pathParams = [];\n    this._pathRegex = pathToRegexp(this.fullPath, this._pathParams);\n    this._pathFormat = pathToRegexp.compile(this.fullPath);\n  }\n\n  _setupParams(spec) {\n    this._paramsSpec = {};\n    this._pathParams.forEach(param => {\n      this._paramsSpec[param.name] = null;\n    });\n    Object.assign(this._paramsSpec, spec.params);\n  }\n\n  _setupOptions(spec) {\n    if (spec.redirect) {\n      this.redirect = spec.redirect;\n    }\n  }\n\n  /**\n   * Invoked when going \"downstream\" (either into this state or\n   * through this state to one of its descendants).\n   *\n   * Primary usage is to process `ctx.params` and populate `ctx.data`.\n   *\n   * Can redirect to another state by resolving `{ redirect: anotherStateName }`\n   * (e.g. for authentication).\n   *\n   * It is also possible to render a custom Vue component instead\n   * by resolving `{ component: customVueComponent }`.\n   *\n   * @param ctx — object `{ state, params, data }`\n   * @returns {Promise}\n   */\n  enter(ctx) {\n    return Promise.resolve();\n  }\n\n  /**\n   * Invoked when going \"upstream\" (either from this state or\n   * through this state from one of its descendants).\n   * Typically used from cleaning up stuff used by this state.\n   *\n   * Like with `enter`, it is possible to redirect to another state\n   * by resolving `{ redirect: anotherStateName }`.\n   *\n   * @param ctx — object `{ state, params, data }`\n   * @returns {Promise}\n   */\n  leave(ctx) {\n    return Promise.resolve();\n  }\n\n  /**\n   * Invoked when error occurs during entering this state.\n   *\n   * Can redirect to another state by resolving `{ redirect: anotherStateName }`\n   * (e.g. for authentication).\n   *\n   * It is also possible to render a custom Vue component instead\n   * by resolving `{ component: customVueComponent }`.\n   *\n   * @param ctx — object `{ state, params, data }`\n   * @returns {Promise}\n   */\n  handleError(err, ctx) {\n    return Promise.reject(err);\n  }\n\n  /**\n   * Returns true if this state is equal to `stateOrName`\n   * or contains `stateOrName` somewhere up the hierarchy.\n   *\n   * @param {string|State} stateOrName\n   * @return {boolean}\n   */\n  includes(stateOrName) {\n    const state = stateOrName instanceof State ?\n      stateOrName : this.manager.get(stateOrName);\n    return this.lineage.indexOf(state) > -1;\n  }\n\n  /**\n   * Attempts to match `location` to this state's `path` pattern.\n   *\n   * @param {{ pathname, search }} location\n   * @returns an object with extracted params or `null` if don't match.\n   * @private\n   */\n  _match(location) {\n    const matched = this._pathRegex.exec(location.pathname);\n    if (!matched) {\n      return null;\n    }\n    const params = this._pathParams.reduce((params, p, i) => {\n      params[p.name] = matched[i + 1];\n      return params;\n    }, {});\n    try {\n      const query = querystring.parse(location.search);\n      Object.assign(params, query);\n    } catch (e) {\n      // No query string or parsing failed — we don't care\n    }\n    return params;\n  }\n\n  /**\n   * Constructs a `params` object by dropping any parameters\n   * not specified in `_paramsSpec` of this state.\n   * Values from `_paramsSpec` act as defaults.\n   *\n   * @param {object} params\n   * @private\n   */\n  _makeParams(params) {\n    return Object.keys(this._paramsSpec).reduce((result, name) => {\n      result[name] = name in params ? params[name] : this._paramsSpec[name];\n      return result;\n    }, {});\n  }\n\n  /**\n   * Constructs search string by serializing query params.\n   *\n   * @param params\n   * @return {string} search\n   * @private\n   */\n  _makeSearch(params) {\n    const query = Object.keys(params).reduce((query, key) => {\n      const value = params[key];\n      if (value != null) {\n        query[key] = value;\n      }\n      return query;\n    }, {});\n    this._pathParams.forEach(p => {\n      delete query[p.name];\n    });\n    try {\n      const search = querystring.stringify(query);\n      if (search) {\n        return '?' + search;\n      }\n    } catch (e) {\n      // No query string or serialization failed — we don't care\n    }\n    return '';\n  }\n\n  /**\n   * Constructs an URL by encoding `params` into URL pattern and query string.\n   *\n   * Note: params not mentioned in `_paramsSpec` are dropped.\n   *\n   * @param params\n   * @return {string} url\n   * @private\n   */\n  _makeUrl(params) {\n    return this._pathFormat(params) + this._makeSearch(params);\n  }\n\n  /**\n   * Creates href suitable for links (taking into account base URL and\n   * hash-based histories).\n   *\n   * @param params\n   * @return {string} href\n   */\n  createHref(params) {\n    return this.manager.history.createHref(this._makeUrl(params));\n  }\n\n};\n"
  },
  {
    "path": "src/transition.js",
    "content": "import Debug from 'debug';\nimport { StateNotFoundError, RedirectLoopError } from './error';\nimport { toVueComponent } from './utils';\n\nconst debug = Debug('voie:transition');\n\nexport default class Transition {\n\n  constructor(manager) {\n    this.manager = manager;\n    this.redirectsCount = 0;\n    this.params = Object.assign({}, manager.context.params);\n  }\n\n  get to() {\n    return this.dstState;\n  }\n\n  go(name, params, isRedirect) {\n    debug(isRedirect ? 'redirect to %s' : 'go to %s', name);\n    Object.assign(this.params, params || {});\n    const state = this.manager.get(name);\n    if (!state) {\n      throw new StateNotFoundError(name);\n    }\n    this.dstState = state;\n    if (state.redirect) {\n      return this.handleRedirect(state.redirect);\n    }\n    return this.goUpstream()\n      .then(() => this.goDownstream());\n  }\n\n  handleRedirect(redirect) {\n    this.redirectsCount++;\n    if (this.redirectsCount > this.manager.maxRedirects) {\n      throw new RedirectLoopError(this);\n    }\n    switch (typeof redirect) {\n      case 'string':\n        return this.go(redirect, {}, true);\n      case 'object':\n        return this.go(redirect.name, redirect.params, true);\n      case 'function':\n        return Promise.resolve()\n          .then(() => redirect(this))\n          .then(redirect => this.handleRedirect(redirect));\n      default:\n        throw new Error('Unknown redirect: ' + redirect);\n    }\n  }\n\n  goUpstream() {\n    const ctx = this.manager.context;\n    if (!ctx.state) {\n      // We're at root state, no cleanup is necessary\n      return Promise.resolve();\n    }\n    // Stop going up if state is common with dst branch\n    const state = ctx.state;\n    if (this.dstState.includes(state)) {\n      // All ctx params must match target ones\n      // (e.g. when going from /user/1 to /user/2)\n      const paramsMatch = Object.keys(ctx.params)\n        .every(key => ctx.params[key] === this.params[key]);\n      if (paramsMatch) {\n        return Promise.resolve();\n      }\n    }\n    return Promise.resolve()\n      .then(() => state.leave(ctx))\n      .then(() => this.manager.afterEach(ctx))\n      .then(() => {\n        debug(' <- left %s', state.name);\n        this.cleanup(ctx);\n      })\n      .then(() => this.goUpstream());\n  }\n\n  cleanup(ctx) {\n    if (ctx.vm) {\n      // Destroy vm and restore v-view element\n      const el = ctx.vm.$el;\n      const mp = ctx.mountPoint;\n      ctx.vm.$destroy();\n      if (mp) {\n        const viewEl = ctx.mountPoint.viewEl;\n        el.parentNode.replaceChild(viewEl, el);\n        mp.viewElChildren.forEach(el => viewEl.appendChild(el));\n      }\n    }\n    this.manager.context = ctx.parent;\n    this.manager.emit('context_updated', this.manager.context);\n  }\n\n  goDownstream() {\n    const prevCtx = this.manager.context;\n    const dstLineage = this.dstState.lineage;\n    const nextState = dstLineage[dstLineage.indexOf(prevCtx.state) + 1];\n    if (!nextState) {\n      return Promise.resolve();\n    }\n\n    // New context inherits params and data from parent\n    const nextContext = {\n      parent: prevCtx,\n      state: nextState,\n      params: Object.assign({}, prevCtx.params, nextState._makeParams(this.params)),\n      data: Object.assign({}, prevCtx.data)\n    };\n\n    return Promise.resolve(true)\n      .then(() => this.manager.beforeEach(nextContext))\n      .catch(err => nextState.handleError(err, nextContext))\n      .then(obj => this._handleEnterHook(obj, nextContext))\n      .then(proceed => {\n        if (!proceed) {\n          return false;\n        }\n        return Promise.resolve()\n          .then(() => nextState.enter(nextContext))\n          .catch(err => nextState.handleError(err, nextContext))\n          .then(obj => this._handleEnterHook(obj, nextContext));\n      })\n      .then(proceed => {\n        if (!proceed) {\n          return false;\n        }\n        this.manager.context = nextContext;\n        this.manager.emit('context_updated', this.manager.context);\n        this.render(nextContext, nextState.component);\n        if (nextState !== this.dstState) {\n          return this.goDownstream();\n        }\n      });\n  }\n\n  /**\n   * @return {Boolean} proceed\n   * @private\n   */\n  _handleEnterHook(obj, nextContext) {\n    obj = obj || {};\n    const nextState = nextContext.state;\n    debug(' -> entered %s', nextState.name);\n    // hooks can return { redirect: 'new.state.name' }\n    // or { redirect: { name, params } }\n    if (obj.redirect) {\n      return this.handleRedirect(obj.redirect)\n        .then(() => false);\n    }\n    // hooks can also return { component: <VueComponent> }\n    const rendered = this.render(nextContext, obj.component);\n    return !rendered;\n  }\n\n  render(ctx, comp) {\n    if (!comp) {\n      return false;\n    }\n    const Comp = toVueComponent(comp);\n    const mp = this.manager._getMountPoint();\n    ctx.mountPoint = mp;\n    ctx.vm = new Comp({\n      data: ctx.data,\n      el: mp.viewEl,\n      parent: mp.hostVm,\n      params: ctx.params,\n      ctx: ctx,\n      state: ctx.state,\n      manager: this.manager\n    });\n    return true;\n  }\n\n}\n"
  },
  {
    "path": "src/utils.js",
    "content": "import Vue from 'vue';\n\nexport function toVueComponent(obj) {\n  if (obj.name === 'VueComponent') {\n    return obj\n  }\n  return Vue.extend(obj);\n}\n"
  },
  {
    "path": "test/.eslintrc",
    "content": "{\n  \"globals\": {\n    \"describe\": false,\n    \"context\": false,\n    \"it\": false,\n    \"before\": false,\n    \"beforeEach\": false,\n    \"after\": false,\n    \"afterEach\": false,\n    \"assert\": false\n  }\n}\n"
  },
  {
    "path": "test/karma.dev.conf.js",
    "content": "'use strict';\n\nmodule.exports = function(config) {\n  config.set({\n\n    basePath: '..',\n\n    port: 9876,\n\n    files: [\n      'src/**/*.js',\n      'test/specs/**/*.js'\n    ],\n\n    autoWatch: true,\n\n    frameworks: ['mocha', 'chai', 'browserify'],\n\n    preprocessors: {\n      'src/**/*.js': ['browserify'],\n      'test/specs/**/*.js': ['browserify']\n    },\n\n    browserify: {\n      debug: true,\n      transform: [\n        [ 'babelify', { presets: [ 'es2015' ] } ]\n      ]\n    },\n\n    reporters: ['spec'],\n\n    client: {\n      mocha: {\n        reporter: 'html'\n      }\n    },\n\n    colors: true,\n\n    logLevel: config.LOG_INFO,\n\n    browsers: ['Chrome'],\n\n    singleRun: false,\n\n    concurrency: Infinity\n\n  });\n};\n"
  },
  {
    "path": "test/specs/query.js",
    "content": "import StateManager from '../../src/state-manager';\nimport { createHashHistory } from 'history';\n\ndescribe('Query support', function() {\n\n  beforeEach(() => {\n    const root = document.createElement('div');\n    root.setAttribute('id', 'root');\n    document.body.appendChild(root);\n  });\n\n  afterEach(() => {\n    const root = document.getElementById('root');\n    document.body.removeChild(root);\n    // We use hash history here to simplify test infrastructure\n    location.hash = '';\n  });\n\n  it('should format URL with query strings', function() {\n    const sm = createStateManager();\n    const qs = sm.get('user')._makeUrl({\n      userName: 'Alice',\n      collapsed: true,\n      tags: ['one', 'two']\n    });\n    assert.equal(qs, '/user/Alice?collapsed=true&tags=one&tags=two');\n  });\n\n  it('should inherit default query params from hierarchy', function() {\n    const sm = createStateManager();\n    return sm.go({\n      name: 'user',\n      params: {\n        userName: 'Alice'\n      }\n    }).then(() => {\n      assert.equal(sm.context.url, '/user/Alice?collapsed=false');\n    });\n  });\n\n  it('should override both inherited and own params', function() {\n    const sm = createStateManager();\n    return sm.go({\n      name: 'user',\n      params: {\n        userName: 'Alice',\n        section: 'some',\n        collapsed: true\n      }\n    }).then(() => {\n      assert.equal(sm.context.url, '/user/Alice?collapsed=true&section=some');\n    });\n  });\n\n  it('should drop nulls in query params', function() {\n    const sm = createStateManager();\n    return sm.go({\n      name: 'user',\n      params: {\n        userName: 'Alice',\n        section: null,\n        collapsed: null\n      }\n    }).then(() => {\n      assert.equal(sm.context.url, '/user/Alice');\n    });\n  });\n\n  it('should parse query params from location', function() {\n    const sm = createStateManager();\n    location.hash = '#/user/Alice?collapsed=true&section=any&tags=foo&tags=bar';\n    return sm.start().then(() => {\n      const ctx = sm.context;\n      assert.equal(ctx.params.collapsed, 'true');\n      assert.equal(ctx.params.section, 'any');\n      assert.lengthOf(ctx.params.tags, 2);\n    })\n      .then(() => sm.stop());\n  });\n\n  it('should update history', function() {\n    const sm = createStateManager();\n    return sm.go({\n      name: 'user',\n      params: {\n        userName: 'Alice'\n      }\n    }).then(() => sm.update({ collapsed: true }))\n      .then(() => {\n        assert.equal(location.hash, '#/user/Alice?collapsed=true')\n      });\n  });\n\n  function createStateManager() {\n\n    const sm = new StateManager({\n      el: '#root',\n      history: createHashHistory({\n        queryKey: false\n      })\n    });\n\n    sm.add({\n      name: 'user',\n      redirect: 'user.info',\n      path: '/user/:userName',\n      params: {\n        collapsed: false,\n        tags: []\n      }\n    });\n\n    sm.add({\n      name: 'user.info',\n      params: {\n        section: null\n      }\n    });\n\n    return sm;\n  }\n\n});\n"
  },
  {
    "path": "test/specs/routing.js",
    "content": "import StateManager from '../../src/state-manager';\nimport { createHashHistory } from 'history';\n\ndescribe('URL routing', function() {\n\n  beforeEach(() => {\n    const root = document.createElement('div');\n    root.setAttribute('id', 'root');\n    document.body.appendChild(root);\n  });\n\n  afterEach(() => {\n    const root = document.getElementById('root');\n    document.body.removeChild(root);\n    // We use hash history here to simplify test infrastructure\n    location.hash = '';\n  });\n\n  it('should register URL patterns', function() {\n    const sm = createStateManager();\n    assert.equal(sm.get('app').fullPath, '/');\n    assert.equal(sm.get('users').fullPath, '/users');\n    assert.equal(sm.get('users.list').fullPath, '/users/list');\n    assert.equal(sm.get('user').fullPath, '/user/:userName');\n    assert.equal(sm.get('user.dashboard').fullPath, '/user/:userName');\n    assert.equal(sm.get('user.messages').fullPath, '/user/:userName/messages');\n  });\n\n  it('should register named URL params', function() {\n    const sm = createStateManager();\n    assert.lengthOf(sm.get('users')._pathParams, 0);\n    assert.lengthOf(sm.get('user')._pathParams, 1);\n    assert.equal(sm.get('user')._pathParams[0].name, 'userName');\n  });\n\n  it('should match simple URLs', function() {\n    const sm = createStateManager();\n    assert.ok(sm.get('app')._match({ pathname: '/' }));\n    assert.ok(sm.get('app')._match({ pathname: '' }));\n    assert.notOk(sm.get('app')._match({ pathname: '/users' }));\n    assert.ok(sm.get('users')._match({ pathname: '/users' }));\n    assert.ok(sm.get('users')._match({ pathname: '/users/' }));\n    assert.notOk(sm.get('users')._match({ pathname: '/users/list' }));\n  });\n\n  it('should match URLs with parameters', function() {\n    const sm = createStateManager();\n    assert.notOk(sm.get('user')._match({ pathname: '/user/' }));\n    assert.ok(sm.get('user')._match({ pathname: '/user/Jane' }));\n  });\n\n  it('should extract named params from URL', function() {\n    const sm = createStateManager();\n    const st = sm.get('user.messages');\n    assert.equal(st._match({ pathname: '/user/Alice/messages' }).userName, 'Alice');\n  });\n\n  it('should format URLs with parameters', function() {\n    const sm = createStateManager();\n    const st = sm.get('user.messages');\n    assert.equal(st._pathFormat({ userName: 'Alice' }), '/user/Alice/messages');\n  });\n\n  it('should visit root state automatically after start', function() {\n    const sm = createStateManager();\n    return sm.start()\n      .then(() => {\n        assert.equal(sm.context.state.name, 'users.list');\n      })\n      .then(() => sm.stop());\n  });\n\n  it('should update URL after start', function() {\n    const sm = createStateManager();\n    return sm.start()\n      .then(() => {\n        assert.equal(location.hash, '#/users/list');\n      })\n      .then(() => sm.stop());\n  });\n\n  it('should update URL after visiting another state', function() {\n    const sm = createStateManager();\n    return sm.start()\n      .then(() => sm.go({ name: 'user.messages', params: { userName: 'Alice' } }))\n      .then(() => {\n        assert.equal(location.hash, '#/user/Alice/messages');\n      })\n      .then(() => sm.stop());\n  });\n\n  it('should update URL after visiting same state with different params', function() {\n    const sm = createStateManager();\n    return sm.start()\n      .then(() => sm.go({ name: 'user', params: { userName: 'Alice' } }))\n      .then(() => {\n        assert.equal(sm.context.state.name, 'user.dashboard');\n        assert.equal(location.hash, '#/user/Alice');\n      })\n      .then(() => sm.go({ name: 'user', params: { userName: 'Bob' } }))\n      .then(() => {\n        assert.equal(sm.context.state.name, 'user.dashboard');\n        assert.equal(location.hash, '#/user/Bob');\n      })\n      .then(() => sm.stop());\n  });\n\n  it('should support optional URL params with defaults', function() {\n    const sm = createStateManager();\n    return sm.start()\n      .then(() => sm.go({ name: 'hello' }))\n      .then(() => {\n        assert.equal(sm.context.state.name, 'hello');\n        assert.equal(location.hash, '#/hello/World');\n        assert.equal(sm.context.params.name, 'World');\n      })\n      .then(() => sm.go({ name: 'hello', params: { name: 'Alice' } }))\n      .then(() => {\n        assert.equal(sm.context.state.name, 'hello');\n        assert.equal(location.hash, '#/hello/Alice');\n        assert.equal(sm.context.params.name, 'Alice');\n      })\n      .then(() => sm.stop());\n  });\n\n  function createStateManager() {\n\n    const sm = new StateManager({\n      el: '#root',\n      history: createHashHistory({\n        queryKey: false\n      })\n    });\n\n    sm.add({\n      name: 'app',\n      redirect: 'users'\n    });\n\n    sm.add({\n      name: 'users',\n      path: '/users',\n      parent: 'app',\n      redirect: 'users.list'\n    });\n\n    sm.add({\n      name: 'users.list',\n      path: 'list'\n    });\n\n    sm.add({\n      name: 'user',\n      parent: 'users',\n      redirect: 'user.dashboard',\n      path: '/user/:userName'\n    });\n\n    sm.add({\n      name: 'user.dashboard'\n    });\n\n    sm.add({\n      name: 'user.messages',\n      path: 'messages'\n    });\n\n    sm.add({\n      name: 'hello',\n      path: '/hello/:name?',\n      params: {\n        name: 'World'\n      }\n    });\n\n    return sm;\n  }\n\n});\n"
  },
  {
    "path": "test/specs/states.js",
    "content": "import StateManager from '../../src/state-manager';\nimport { createMemoryHistory } from 'history';\n\ndescribe('States', function() {\n\n  describe('hierarchy', function() {\n\n    const sm = new StateManager({\n      el: document.body,\n      history: createMemoryHistory()\n    });\n    sm.add({ name: 'app' });\n    sm.add({ name: 'app.welcome' });\n    sm.add({ name: 'app.welcome.hello' });\n    sm.add({ name: 'users', parent: 'app' });\n    sm.add({ name: 'users.list' });\n    sm.add({ name: 'groups', parent: 'app' });\n\n    it('state manager should register states', function() {\n      assert.ok(sm.get('app'));\n      assert.ok(sm.get('app.welcome'));\n      assert.notOk(sm.get('app.wut'));\n    });\n\n    it('parents are inferred from names', function() {\n      assert.equal(sm.get('app.welcome').parentState, sm.get('app'));\n      assert.equal(sm.get('app.welcome.hello').parentState, sm.get('app.welcome'));\n    });\n\n    it('parent states can be specified explicitly', function() {\n      assert.equal(sm.get('users').parentState, sm.get('app'));\n      assert.equal(sm.get('groups').parentState, sm.get('app'));\n    });\n\n    it('lineage shows upstream path from state to root', function() {\n      const usersList = sm.get('users.list');\n      const groups = sm.get('groups');\n      assert.lengthOf(usersList.lineage, 3);\n      assert.equal(usersList.lineage[0], sm.get('app'));\n      assert.equal(usersList.lineage[1], sm.get('users'));\n      assert.equal(usersList.lineage[2], usersList);\n      assert.lengthOf(groups.lineage, 2);\n      assert.equal(groups.lineage[0], sm.get('app'));\n      assert.equal(groups.lineage[1], groups);\n    });\n\n    it('should detect included state (check if self or ancestor)', function() {\n      assert.ok(sm.get('users.list').includes('users'));\n      assert.notOk(sm.get('users.list').includes('groups'));\n      // By state\n      assert.ok(sm.get('users').includes(sm.get('app')));\n    });\n\n  });\n\n  describe('params processing', function() {\n\n    const sm = new StateManager({\n      el: document.body,\n      history: createMemoryHistory()\n    });\n\n    sm.add({\n      name: 'user',\n      params: {\n        name: null,\n        display: 'short',\n        greeting: 'Hello'\n      }\n    });\n\n    it('should apply param defaults from spec', function() {\n      const params = sm.get('user')._makeParams({\n        name: 'Alice',\n        display: 'full'\n      });\n      assert.equal(params.name, 'Alice');     // overridden\n      assert.equal(params.display, 'full');   // overridden\n      assert.equal(params.greeting, 'Hello'); // default\n    });\n\n    it('should drop param not from spec', function() {\n      const params = sm.get('user')._makeParams({\n        name: 'Alice',\n        something: '?'\n      });\n      assert.notOk(params.something);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "test/specs/transitions.js",
    "content": "import StateManager from '../../src/state-manager';\nimport { createMemoryHistory } from 'history';\n\ndescribe('Transitions', function() {\n\n  beforeEach(() => {\n    const root = document.createElement('div');\n    root.setAttribute('id', 'root');\n    document.body.appendChild(root);\n  });\n\n  afterEach(() => {\n    const root = document.getElementById('root');\n    document.body.removeChild(root);\n  });\n\n  it('should leave upstream and enter downstream states', function() {\n    const sm = createStateManager();\n    const entered = [];\n    const left = [];\n    ['app', 'users', 'users.list', 'groups', 'groups.list'].forEach(name => {\n      const state = sm.get(name);\n      const e = state.enter;\n      const l = state.leave;\n      state.enter = (ctx) => { entered.push(state.name); return e(ctx); };\n      state.leave = (ctx) => { left.push(state.name); return l(ctx) };\n    });\n    return sm.go('users.list')\n      .then(() => {\n        assert.include(entered, 'app');\n        assert.include(entered, 'users');\n        assert.include(entered, 'users.list');\n        assert.notInclude(entered, 'groups');\n        assert.notInclude(entered, 'groups.list');\n        assert.notInclude(left, 'users.list');\n        assert.notInclude(left, 'users');\n        return sm.go('groups.list');\n      })\n      .then(() => {\n        assert.include(left, 'users.list');\n        assert.include(left, 'users');\n        assert.notInclude(left, 'app');\n        assert.notInclude(left, 'groups');\n        assert.notInclude(left, 'groups.list');\n        assert.include(entered, 'groups');\n        assert.include(entered, 'groups.list');\n      });\n  });\n\n  it('should allow visiting redirect-only states', function() {\n    const sm = createStateManager();\n    return sm.go('users')\n      .then(() => {\n        assert.equal(sm.context.state.name, 'users.list');\n      });\n  });\n\n  it('should redirect with params', function() {\n    const sm = createStateManager();\n    return sm.go('groups')\n      .then(() => {\n        assert.equal(sm.context.state.name, 'groups.list');\n        assert.equal(sm.context.params.sort, '+name');\n      });\n  });\n\n  it('should load state data and render component in layout hierarchy', function() {\n    const sm = createStateManager();\n    return sm.go('users')\n      .then(() => {\n        assert.equal(document.querySelector('#root h1').innerText, 'Users');\n        assert.lengthOf(document.querySelectorAll('#root li'), 3);\n        assert.equal(document.querySelector('#root li:first-child').innerText, 'Alice');\n      });\n  });\n\n  it('should dispose of stale components and render new data', function() {\n    const sm = createStateManager();\n    return sm.go('users')\n      .then(() => sm.go('groups'))\n      .then(() => {\n        assert.lengthOf(document.querySelectorAll('#root h1'), 0);\n        assert.lengthOf(document.querySelectorAll('#root li'), 2);\n        assert.equal(document.querySelector('#root li:first-child').innerText, 'Admins');\n      });\n  });\n\n  it('should support redirect via state.enter hook', function() {\n    const sm = createStateManager();\n    sm.get('groups.list').enter = () => ({ redirect: 'users' });\n    return sm.go('groups')\n      .then(() => {\n        assert.equal(sm.context.state.name, 'users.list');\n      });\n  });\n\n  it('should support rendering component via state.enter hook', function() {\n    const sm = createStateManager();\n    sm.get('groups.list').enter = () => ({\n      component: { template: '<h2>Groups</h2>' }\n    });\n    return sm.go('groups')\n      .then(() => {\n        assert.equal(document.querySelector('h2#root').innerText, 'Groups');\n      });\n  });\n\n  it('should detect redirect loops', function(done) {\n    const sm = createStateManager();\n    sm.get('groups.list').enter = () => ({ redirect: 'users' });\n    sm.get('users.list').enter = () => ({ redirect: 'groups' });\n    sm.go('groups')\n      .then(() => done(new Error('Redirect loop not detected.')))\n      .catch(err => {\n        assert.isDefined(err.transition);\n        done();\n      });\n  });\n\n  it('should handle uncaught errors ', function() {\n    const sm = createStateManager();\n    let handled = null;\n    sm.handleUncaught = function(err) {\n      handled = err;\n    };\n    sm.get('users.list').enter = () => {\n      throw new Error('oopsie');\n    };\n    return sm.go('users.list')\n      .then(() => {\n        assert.ok(handled);\n        assert.equal(handled.message, 'oopsie');\n      });\n  });\n\n  it('should allow redirecting on errors', function() {\n    const sm = createStateManager();\n    let handled = false;\n    sm.get('users.list').enter = () => {\n      throw new Error('oopsie');\n    };\n    sm.get('users.list').handleError = () => {\n      handled = true;\n      return { redirect: 'groups.list' };\n    };\n    return sm.go('users.list')\n      .then(() => {\n        assert.equal(handled, true);\n        assert.equal(sm.context.state.name, 'groups.list');\n      });\n  });\n\n  it('should render custom components on errors', function() {\n    const sm = createStateManager();\n    let handled = false;\n    sm.get('users.list').enter = () => {\n      throw new Error('oopsie');\n    };\n    sm.get('users.list').handleError = () => {\n      handled = true;\n      return { component: { template: '<h2>Error</h2>' } };\n    };\n    return sm.go('users.list')\n      .then(() => {\n        assert.equal(handled, true);\n        assert.equal(document.querySelector('#root h2').innerText, 'Error');\n      });\n  });\n\n  function createStateManager() {\n    const sm = new StateManager({\n      el: '#root',\n      history: createMemoryHistory()\n    });\n\n    sm.add({ name: 'app' });\n\n    sm.add({\n      name: 'users',\n      parent: 'app',\n      redirect: 'users.list',\n      component: {\n        template: '<div class=\"users\"><h1>Users</h1><v-view/></div>'\n      }\n    });\n\n    sm.add({\n      name: 'users.list',\n      enter: (ctx) => {\n        ctx.data.users = [\n          { name: 'Alice' },\n          { name: 'Bob' },\n          { name: 'Greg' }\n        ];\n      },\n      component: {\n        template: '<ul><li v-for=\"user in users\">{{ user.name }}</li></ul>'\n      }\n    });\n\n    sm.add({\n      name: 'groups',\n      parent: 'app',\n      redirect: {\n        name: 'groups.list',\n        params: {\n          sort: '+name'\n        }\n      },\n      enter: (ctx) => {\n        ctx.data.groups = [\n          { name: 'Admins' },\n          { name: 'Guests'}\n        ];\n      }\n    });\n\n    sm.add({\n      name: 'groups.list',\n      params: {\n        sort: null\n      },\n      component: {\n        template: '<ul><li v-for=\"group in groups\">{{ group.name }}</li></ul>'\n      }\n    });\n\n    return sm;\n  }\n\n});\n"
  }
]