From ccc9f74102e4432ac8341395174b0004b1435e32 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 16 Sep 2018 16:46:37 +0200 Subject: surface sequence/dataset count... --- app/client/common/augmentationGrid.component.js | 2 ++ app/client/common/taskList.component.js | 2 +- app/client/modules/pix2pixhd/pix2pixhd.actions.js | 7 +++-- app/client/modules/pix2pixhd/pix2pixhd.reducer.js | 10 ++++++ .../modules/pix2pixhd/views/pix2pixhd.train.js | 2 ++ app/client/types.js | 2 +- public/bundle.js | 36 +++++++++++++++++----- public/bundle.js.map | 2 +- 8 files changed, 50 insertions(+), 13 deletions(-) diff --git a/app/client/common/augmentationGrid.component.js b/app/client/common/augmentationGrid.component.js index 69bdc8a..536136a 100644 --- a/app/client/common/augmentationGrid.component.js +++ b/app/client/common/augmentationGrid.component.js @@ -27,6 +27,8 @@ export default class AugmentationGrid extends Component { {this.state.x} {this.state.x * this.state.y} {this.state.sum} + {this.state.checkpoint.sequenceCount} + {this.state.checkpoint.datasetCount} \n // )\n }\n }, {\n key: 'renderLiveButtons',\n value: function renderLiveButtons() {\n var _this4 = this;\n\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n _common.Button,\n {\n title: 'Save frame',\n onClick: _player.saveFrame\n },\n 'Save'\n ),\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Record video',\n name: 'store_b',\n noDim: true,\n onToggle: function onToggle(value) {\n // now storing frames on server...\n }\n },\n (0, _preact.h)(_common.TextInput, {\n title: 'Video name',\n name: 'final_tag',\n value: this.props.opt.final_tag,\n onSave: function onSave(value) {\n _this4.props.actions.live.set_param('final_tag', value);\n }\n })\n )\n );\n }\n }]);\n\n return Pix2PixHDLive;\n}(_preact.Component);\n\nfunction timeInSeconds(n) {\n return n.toFixed(1) + ' s.';\n}\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n last_message: state.live.last_message,\n fullscreen: state.live.fullscreen,\n opt: state.live.opt,\n frame: state.live.frame,\n checkpoints: state.live.checkpoints,\n epochs: state.live.epochs,\n sequences: state.live.sequences,\n runner: state.system.runner,\n pix2pixhd: state.module.pix2pixhd\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: {\n live: (0, _redux.bindActionCreators)(liveActions, dispatch),\n queue: (0, _redux.bindActionCreators)(queueActions, dispatch),\n pix2pixhd: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch),\n tasks: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch), s: s\n }\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDLive);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _reactRouterDom = require('react-router-dom');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _common = require('../../../common');\n\nvar _pix2pixhd = require('../pix2pixhd.actions');\n\nvar pix2pixhdActions = _interopRequireWildcard(_pix2pixhd);\n\nvar _pix2pixhd2 = require('../pix2pixhd.module');\n\nvar _pix2pixhd3 = _interopRequireDefault(_pix2pixhd2);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction Pix2PixHDNew(props) {\n return (0, _preact.h)(_common.Views.New, {\n db: props.pix2pixhd,\n path: '/pix2pixhd/sequences/',\n actions: props.actions,\n module: _pix2pixhd3.default,\n history: props.history\n });\n}\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n pix2pixhd: state.module.pix2pixhd\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDNew);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRouterDom = require('react-router-dom');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _actions = require('../../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nvar _pix2pixhd = require('../pix2pixhd.actions');\n\nvar pix2pixhdActions = _interopRequireWildcard(_pix2pixhd);\n\nvar _pix2pixhd2 = require('../pix2pixhd.tasks');\n\nvar pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd2);\n\nvar _loading = require('../../../common/loading.component');\n\nvar _loading2 = _interopRequireDefault(_loading);\n\nvar _fileList = require('../../../common/fileList.component');\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar yes_count = 0;\n\nvar Pix2pixHDResults = function (_Component) {\n _inherits(Pix2pixHDResults, _Component);\n\n function Pix2pixHDResults(props) {\n _classCallCheck(this, Pix2pixHDResults);\n\n var _this = _possibleConstructorReturn(this, (Pix2pixHDResults.__proto__ || Object.getPrototypeOf(Pix2pixHDResults)).call(this));\n\n if (!props.pix2pixhd.results) props.actions.load_results();\n return _this;\n }\n\n _createClass(Pix2pixHDResults, [{\n key: 'componentDidMount',\n value: function componentDidMount() {\n yes_count = 0;\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n if (!this.props.pix2pixhd.results) return (0, _preact.h)(_loading2.default, { progress: this.props.pix2pixhd.progress });\n\n var _props$pix2pixhd$resu = this.props.pix2pixhd.results,\n resultsFolder = _props$pix2pixhd$resu.resultsFolder,\n results = _props$pix2pixhd$resu.results,\n renders = _props$pix2pixhd$resu.renders,\n files = _props$pix2pixhd$resu.files;\n // console.log(resultsFolder, results)\n\n return (0, _preact.h)(\n 'div',\n { className: 'app pix2pixhd' },\n (0, _preact.h)(\n 'div',\n { className: 'heading row middle' },\n (0, _preact.h)(\n 'h1',\n null,\n 'Pix2PixHD Results'\n )\n ),\n (0, _preact.h)(\n 'div',\n { 'class': 'rows params renders' },\n (0, _preact.h)(_fileList.FileList, {\n linkFiles: true,\n files: files,\n orderBy: 'date desc',\n fields: 'name date size delete',\n onDelete: function onDelete(file) {\n var yes = void 0;\n if (yes_count < 3) {\n yes = confirm('Are you sure you want to delete this file?');\n } else {\n yes = true;\n }\n if (yes) {\n yes_count += 1;\n console.log('delete: confirmed');\n _actions2.default.file.destroy(file);\n }\n }\n }),\n (0, _preact.h)('br', null),\n (0, _preact.h)(\n 'h3',\n null,\n 'renders on server'\n ),\n (0, _preact.h)(_fileList.FileList, {\n files: renders,\n orderBy: 'date desc',\n fields: 'name date size',\n onClick: function onClick(file, e) {\n e.preventDefault();\n e.stopPropagation();\n console.log('picked a result', file);\n _this2.handlePick(file);\n }\n }),\n (0, _preact.h)('br', null),\n (0, _preact.h)(\n 'h3',\n null,\n 'folders on server'\n ),\n (0, _preact.h)(_fileList.FileList, {\n files: results,\n orderBy: 'date desc',\n fields: 'name date count',\n onClick: function onClick(file, e) {\n e.preventDefault();\n e.stopPropagation();\n console.log('picked a result', file);\n _this2.handlePick(file);\n }\n })\n )\n );\n }\n }, {\n key: 'handlePick',\n value: function handlePick(file) {\n // this.props.audioPlayer.play(file)\n }\n }]);\n\n return Pix2pixHDResults;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n pix2pixhd: state.module.pix2pixhd\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch),\n remote: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch)\n // audioPlayer: bindActionCreators(audioPlayerActions, dispatch),\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2pixHDResults);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _pix2pixhd = require('../pix2pixhd.actions');\n\nvar pix2pixhdActions = _interopRequireWildcard(_pix2pixhd);\n\nvar _pix2pixhd2 = require('../pix2pixhd.tasks');\n\nvar pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd2);\n\nvar _common = require('../../../common');\n\nvar _dataset = require('../../../dataset/dataset.form');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nvar _dataset3 = require('../../../dataset/dataset.new');\n\nvar _dataset4 = _interopRequireDefault(_dataset3);\n\nvar _upload = require('../../../dataset/upload.status');\n\nvar _upload2 = _interopRequireDefault(_upload);\n\nvar _dataset5 = require('../../../dataset/dataset.component');\n\nvar _dataset6 = _interopRequireDefault(_dataset5);\n\nvar _pix2pixhd3 = require('../pix2pixhd.module');\n\nvar _pix2pixhd4 = _interopRequireDefault(_pix2pixhd3);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar Pix2PixHDShow = function (_Component) {\n _inherits(Pix2PixHDShow, _Component);\n\n function Pix2PixHDShow(props) {\n _classCallCheck(this, Pix2PixHDShow);\n\n var _this = _possibleConstructorReturn(this, (Pix2PixHDShow.__proto__ || Object.getPrototypeOf(Pix2PixHDShow)).call(this, props));\n\n _this.datasetActions = _this.datasetActions.bind(_this);\n return _this;\n }\n\n _createClass(Pix2PixHDShow, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n var id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id');\n console.log('load dataset:', id);\n var _props = this.props,\n match = _props.match,\n pix2pixhd = _props.pix2pixhd,\n actions = _props.actions;\n\n if (id === 'new') return;\n if (id) {\n if (parseInt(id)) localStorage.setItem('pix2pixhd.last_id', id);\n if (!pix2pixhd.folder || pix2pixhd.folder.id !== id) {\n actions.load_directories(id);\n }\n } else {\n this.props.history.push('/pix2pixhd/new/');\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _props2 = this.props,\n pix2pixhd = _props2.pix2pixhd,\n match = _props2.match,\n history = _props2.history;\n\n var _ref = pix2pixhd.data || {},\n folderLookup = _ref.folderLookup;\n\n var folder = (folderLookup || {})[pix2pixhd.folder_id] || {};\n\n return (0, _preact.h)(\n 'div',\n { className: 'app pix2pixhd' },\n (0, _preact.h)(\n 'div',\n { 'class': 'heading' },\n (0, _preact.h)(\n 'div',\n { 'class': 'spaced' },\n (0, _preact.h)(\n 'h1',\n null,\n folder ? folder.name : (0, _preact.h)(_common.Loading, null)\n ),\n (0, _preact.h)(_upload2.default, null)\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'row' },\n folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, {\n title: 'Add Files',\n module: _pix2pixhd4.default,\n folder: folder,\n canUpload: true, canAddURL: true\n }),\n (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(_upload2.default, null),\n (0, _preact.h)(_common.CurrentTask, null)\n )\n ),\n (0, _preact.h)(_dataset6.default, {\n loading: pix2pixhd.loading,\n progress: pix2pixhd.progress,\n id: pix2pixhd.folder_id,\n module: _pix2pixhd4.default,\n data: pix2pixhd.data,\n folder: folder,\n history: history,\n onPickFile: function onPickFile(file, e) {\n e.preventDefault();\n e.stopPropagation();\n console.log('picked a file', file);\n },\n datasetActions: this.datasetActions\n })\n );\n }\n }, {\n key: 'datasetActions',\n value: function datasetActions(dataset) {\n var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n var _props3 = this.props,\n pix2pixhd = _props3.pix2pixhd,\n remote = _props3.remote;\n\n var input = pix2pixhd.data.fileLookup[dataset.input[0]];\n if (!input) return null;\n if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null;\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n 'div',\n { 'class': 'actions' },\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2pixhd.folder_id, 1);\n } },\n 'train'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2pixhd.folder_id, 5);\n } },\n '5x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2pixhd.folder_id, 10);\n } },\n '10x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2pixhd.folder_id, 20);\n } },\n '20x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2pixhd.folder_id, 50);\n } },\n '50x'\n )\n ),\n dataset.isBuilt ? (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n 'fetched ',\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.clear_cache_task(dataset);\n } },\n 'rm'\n )\n ) : isFetching ? (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n 'fetching'\n ) : (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.fetch_task(input.url, input.id, dataset.name);\n } },\n 'fetch'\n )\n )\n );\n }\n }]);\n\n return Pix2PixHDShow;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n pix2pixhd: state.module.pix2pixhd\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch),\n remote: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDShow);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _pix2pixhd = require('../pix2pixhd.actions');\n\nvar pix2pixhdActions = _interopRequireWildcard(_pix2pixhd);\n\nvar _pix2pixhd2 = require('../pix2pixhd.tasks');\n\nvar pix2pixhdTasks = _interopRequireWildcard(_pix2pixhd2);\n\nvar _common = require('../../../common');\n\nvar _dataset = require('../../../dataset/dataset.form');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nvar _dataset3 = require('../../../dataset/dataset.new');\n\nvar _dataset4 = _interopRequireDefault(_dataset3);\n\nvar _upload = require('../../../dataset/upload.status');\n\nvar _upload2 = _interopRequireDefault(_upload);\n\nvar _dataset5 = require('../../../dataset/dataset.component');\n\nvar _dataset6 = _interopRequireDefault(_dataset5);\n\nvar _pix2pixhd3 = require('../pix2pixhd.module');\n\nvar _pix2pixhd4 = _interopRequireDefault(_pix2pixhd3);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar Pix2PixHDTrain = function (_Component) {\n _inherits(Pix2PixHDTrain, _Component);\n\n function Pix2PixHDTrain(props) {\n _classCallCheck(this, Pix2PixHDTrain);\n\n var _this = _possibleConstructorReturn(this, (Pix2PixHDTrain.__proto__ || Object.getPrototypeOf(Pix2PixHDTrain)).call(this, props));\n\n _this.handleChange = _this.handleChange.bind(_this);\n _this.state = {\n checkpoint_name: 'PLACEHOLDER',\n epoch: 'latest',\n augment_name: '',\n augment_take: 100,\n augment_make: 20\n };\n return _this;\n }\n\n _createClass(Pix2PixHDTrain, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n var id = this.props.match.params.id || localStorage.getItem('pix2pixhd.last_id');\n console.log('load dataset:', id);\n var _props = this.props,\n match = _props.match,\n pix2pixhd = _props.pix2pixhd,\n actions = _props.actions;\n\n if (id === 'new') return;\n if (id) {\n if (parseInt(id)) localStorage.setItem('pix2pixhd.last_id', id);\n if (!pix2pixhd.folder || pix2pixhd.folder.id !== id) {\n actions.load_directories(id);\n }\n } else {\n this.props.history.push('/pix2pixhd/new/');\n }\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate(prevProps, prevState) {\n if (prevState.checkpoint_name !== this.state.checkpoint_name) {\n this.setState({ epoch: 'latest' });\n this.props.actions.list_epochs(this.state.checkpoint_name);\n }\n }\n }, {\n key: 'handleChange',\n value: function handleChange(name, value) {\n console.log('name', name, 'value', value);\n this.setState(_defineProperty({}, name, value));\n }\n }, {\n key: 'interrupt',\n value: function interrupt() {\n this.props.actions.queue.stop_task('gpu');\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n if (this.props.pix2pixhd.loading) {\n return (0, _preact.h)(_common.Loading, { progress: this.props.pix2pixhd.progress });\n }\n var _props2 = this.props,\n pix2pixhd = _props2.pix2pixhd,\n match = _props2.match,\n history = _props2.history,\n queue = _props2.queue;\n\n var _ref = pix2pixhd.data || {},\n folderLookup = _ref.folderLookup,\n datasetLookup = _ref.datasetLookup;\n\n var folder = (folderLookup || {})[pix2pixhd.folder_id] || {};\n // console.log(pix2pixhd)\n\n var checkpointGroups = Object.keys(folderLookup).map(function (id) {\n var folder = _this2.props.pix2pixhd.data.folderLookup[id];\n if (folder.name === 'results') return;\n var datasets = folder.datasets.map(function (name) {\n var dataset = datasetLookup[name];\n if (dataset.checkpoints.length) {\n return name;\n }\n return null;\n }).filter(function (n) {\n return !!n;\n });\n return {\n name: folder.name,\n options: datasets.sort()\n };\n }).filter(function (n) {\n return !!n && !!n.options.length;\n }).sort(function (a, b) {\n return a.name.localeCompare(b.name);\n });\n\n // console.log('state', this.props.pix2pixhd.data.epochs)\n // console.log(this.state.checkpoint_name, this.state.epoch)\n // console.log(queue)\n return (0, _preact.h)(\n 'div',\n { className: 'app pix2pixhd' },\n (0, _preact.h)(\n 'div',\n { className: 'heading' },\n (0, _preact.h)(\n 'h1',\n null,\n 'pix2pixhd training'\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'columns' },\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(\n _common.Group,\n { title: 'Dataset' },\n (0, _preact.h)(_common.SelectGroup, {\n name: 'checkpoint_name',\n title: 'Dataset',\n options: checkpointGroups,\n onChange: this.handleChange,\n placeholder: 'Pick a dataset',\n value: this.state.checkpoint_name\n }),\n (0, _preact.h)(_common.Select, {\n title: 'Epoch',\n name: 'epoch',\n options: this.props.pix2pixhd.data.epochs,\n onChange: this.handleChange,\n value: this.state.epoch\n })\n ),\n (0, _preact.h)(\n _common.Group,\n { title: 'Augment' },\n (0, _preact.h)(_common.NumberInput, {\n name: 'augment_take',\n title: 'Pick N random frames',\n value: this.state.augment_take,\n onChange: this.handleChange,\n type: 'int',\n min: '1',\n max: '1000'\n }),\n (0, _preact.h)(_common.NumberInput, {\n name: 'augment_make',\n title: 'Generate N recursively',\n value: this.state.augment_make,\n onChange: this.handleChange,\n type: 'int',\n min: '1',\n max: '1000'\n }),\n (0, _preact.h)(_common.Button, {\n title: 'Augment dataset',\n value: 'Augment',\n onClick: function onClick() {\n return _this2.props.remote.augment_task(_this2.state.checkpoint_name, _this2.state);\n }\n }),\n (0, _preact.h)(_common.Button, {\n title: 'Make a movie without augmenting',\n value: 'Generate',\n onClick: function onClick() {\n _this2.props.remote.augment_task(_this2.state.checkpoint_name, _extends({}, _this2.state, {\n no_symlinks: true,\n mov: true,\n folder_id: _this2.props.pix2pixhd.data.resultsFolder.id\n }));\n }\n })\n ),\n (0, _preact.h)(\n _common.Group,\n { title: 'Augmentation Grid' },\n (0, _preact.h)(_common.AugmentationGrid, {\n take: [1, 2, 3, 4, 5, 10, 15, 20, 25, 50, 75, 100, 200, 300, 400, 500, 1000],\n make: [1, 2, 3, 4, 5, 10, 15, 20, 25, 50, 75, 100, 200],\n onAugment: function onAugment(augment_take, augment_make) {\n _this2.props.remote.augment_task(_this2.state.checkpoint_name, _extends({}, _this2.state, {\n augment_take: augment_take,\n augment_make: augment_make\n }));\n },\n onTrain: function onTrain() {\n _this2.props.remote.train_task(_this2.state.checkpoint_name, pix2pixhd.folder_id, 1);\n setTimeout(function () {\n // auto-generate epoch demo\n _this2.props.remote.augment_task(_this2.state.checkpoint_name, _extends({}, _this2.state, {\n augment_take: 10,\n augment_make: 150,\n no_symlinks: true,\n mov: true,\n folder_id: _this2.props.pix2pixhd.data.resultsFolder.id\n }));\n }, 250);\n }\n })\n ),\n (0, _preact.h)(\n _common.Group,\n { title: 'Status' },\n (0, _preact.h)(_common.Button, {\n title: 'GPU',\n value: this.props.runner.gpu.status === 'IDLE' ? \"Idle\" : \"Interrupt\",\n onClick: function onClick() {\n return _this2.interrupt();\n }\n }),\n (0, _preact.h)(_common.CurrentTask, null)\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(\n _common.Group,\n { title: 'Upcoming Tasks' },\n (0, _preact.h)(_common.TaskList, { tasks: queue.queue.map(function (id) {\n return queue.tasks[id];\n }), sort: 'date asc' })\n )\n )\n )\n );\n }\n }]);\n\n return Pix2PixHDTrain;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n pix2pixhd: state.module.pix2pixhd,\n runner: state.system.runner,\n queue: state.queue\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(pix2pixhdActions, dispatch),\n remote: (0, _redux.bindActionCreators)(pix2pixhdTasks, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2PixHDTrain);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _reactRouterDom = require('react-router-dom');\n\nvar _actions = require('../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nvar _util = require('../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _pix2wav = require('./views/pix2wav.new');\n\nvar _pix2wav2 = _interopRequireDefault(_pix2wav);\n\nvar _pix2wav3 = require('./views/pix2wav.show');\n\nvar _pix2wav4 = _interopRequireDefault(_pix2wav3);\n\nvar _pix2wav5 = require('./views/pix2wav.live');\n\nvar _pix2wav6 = _interopRequireDefault(_pix2wav5);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar router = function () {\n function router() {\n _classCallCheck(this, router);\n }\n\n _createClass(router, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n _actions2.default.system.changeTool('pix2wav');\n document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #bdf, #def)';\n }\n }, {\n key: 'componentWillReceiveProps',\n value: function componentWillReceiveProps() {\n _actions2.default.system.changeTool('pix2wav');\n document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #bdf, #def)';\n }\n }, {\n key: 'render',\n value: function render() {\n return (0, _preact.h)(\n 'section',\n null,\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/new/', component: _pix2wav2.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/datasets/', component: _pix2wav4.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/datasets/:id/', component: _pix2wav4.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/live/', component: _pix2wav6.default })\n );\n }\n }]);\n\n return router;\n}();\n\nfunction links() {\n return [{ url: '/pix2wav/new/', name: 'new' }, { url: '/pix2wav/datasets/', name: 'datasets' }, { url: '/pix2wav/live/', name: 'live' }];\n}\n\nexports.default = {\n name: 'pix2wav',\n router: router, links: links\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.load_directories = undefined;\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _v = require('uuid/v1');\n\nvar _v2 = _interopRequireDefault(_v);\n\nvar _socket = require('../../socket');\n\nvar _socket2 = _interopRequireDefault(_socket);\n\nvar _types = require('../../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _dataset = require('../../dataset/dataset.loader');\n\nvar datasetLoader = _interopRequireWildcard(_dataset);\n\nvar _actions = require('../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nvar _util = require('../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _pix2wav = require('./pix2wav.module');\n\nvar _pix2wav2 = _interopRequireDefault(_pix2wav);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar load_directories = exports.load_directories = function load_directories(id) {\n return function (dispatch) {\n var module = _pix2wav2.default.name;\n _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'sequences/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'datasets/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'checkpoints/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'checkpoints/pix2pix/' })], function (percent, i, n) {\n console.log('progress', i, n);\n dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } });\n }).then(function (res) {\n var _res = _slicedToArray(res, 5),\n datasetApiReport = _res[0],\n sequences = _res[1],\n datasets = _res[2],\n checkpoints = _res[3],\n pix2pixCheckpoints = _res[4];\n\n var folderLookup = datasetApiReport.folderLookup,\n fileLookup = datasetApiReport.fileLookup,\n datasetLookup = datasetApiReport.datasetLookup,\n folders = datasetApiReport.folders,\n files = datasetApiReport.files,\n unsortedFolder = datasetApiReport.unsortedFolder;\n\n\n var sequenceDirectories = sequences.filter(function (s) {\n return s.dir;\n });\n sequenceDirectories.forEach(function (dir) {\n var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name);\n dataset.isBuilt = true;\n });\n\n datasets.filter(function (s) {\n return s.dir;\n }).forEach(function (dir) {\n var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name);\n dataset.hasDataset = true;\n });\n\n var checkpointDirectories = checkpoints.filter(function (s) {\n return s.dir;\n });\n checkpointDirectories.forEach(function (dir) {\n var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name);\n dataset.hasCheckpoints = true;\n dir.module = 'pix2wav';\n });\n\n var pix2pixCheckpointDirectories = pix2pixCheckpoints.filter(function (s) {\n return s.dir;\n });\n pix2pixCheckpointDirectories.forEach(function (dir) {\n var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name);\n dataset.hasCheckpoints = true;\n dir.module = 'pix2pix';\n });\n\n console.log(res);\n console.log(checkpointDirectories);\n console.log(pix2pixCheckpointDirectories);\n\n dispatch({\n type: _types2.default.dataset.load,\n data: {\n module: module,\n folderLookup: folderLookup,\n fileLookup: fileLookup,\n datasetLookup: datasetLookup,\n folders: folders, files: files,\n sequences: sequenceDirectories,\n datasets: datasets,\n checkpoints: checkpointDirectories.concat(pix2pixCheckpointDirectories)\n }\n });\n }).catch(function (e) {\n console.error(e);\n });\n if (id) {\n console.log('folder id', id);\n dispatch({\n type: _types2.default.dataset.set_folder,\n data: {\n folder_id: id,\n module: module\n }\n });\n }\n };\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nvar pix2wavModule = {\n name: 'pix2wav',\n displayName: 'Pix2Wav',\n datatype: 'spectrogram'\n};\n\nexports.default = pix2wavModule;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _types = require('../../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _dataset = require('../../dataset/dataset.reducer');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nvar _util = require('../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar pix2wavInitialState = {\n loading: true,\n progress: { i: 0, n: 0 },\n status: '',\n error: null,\n folder_id: 0,\n data: null\n};\n\nvar pix2wavReducer = function pix2wavReducer() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : pix2wavInitialState;\n var action = arguments[1];\n\n if (action.data && action.data.module === 'pix2wav') {\n state = (0, _dataset2.default)(state, action);\n }\n\n switch (action.type) {\n case _types2.default.wav2pix.load:\n return _extends({}, state, {\n status: 'Loaded buffer'\n });\n case _types2.default.wav2pix.progress:\n return _extends({}, state, {\n status: 'Rendering frame ' + action.count\n });\n case _types2.default.wav2pix.finish:\n return _extends({}, state, {\n status: action.message || 'Render complete'\n });\n case _types2.default.wav2pix.zip:\n return _extends({}, state, {\n status: 'Built zip file ' + _util2.default.hush_size(state.size)[1]\n });\n case _types2.default.wav2pix.uploading:\n return _extends({}, state, {\n status: 'Uploading zip file'\n });\n default:\n return state;\n }\n};\n\nexports.default = pix2wavReducer;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.live_task = undefined;\n\nvar _v = require('uuid/v1');\n\nvar _v2 = _interopRequireDefault(_v);\n\nvar _socket = require('../../socket');\n\nvar _socket2 = _interopRequireDefault(_socket);\n\nvar _types = require('../../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _actions = require('../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar live_task = exports.live_task = function live_task(sequence, checkpoint) {\n return function (dispatch) {\n var task = {\n module: 'pix2wav',\n activity: 'live',\n dataset: sequence,\n checkpoint: checkpoint,\n opt: {\n poll_delay: 0.2\n }\n };\n console.log(task);\n console.log('add live task');\n return _actions2.default.queue.add_task(task);\n };\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _common = require('../../../common/');\n\nvar _player = require('../../../live/player');\n\nvar playerActions = _interopRequireWildcard(_player);\n\nvar _live = require('../../../live/live.actions');\n\nvar liveActions = _interopRequireWildcard(_live);\n\nvar _queue = require('../../../queue/queue.actions');\n\nvar queueActions = _interopRequireWildcard(_queue);\n\nvar _pix2wav = require('../pix2wav.tasks');\n\nvar pix2wavTasks = _interopRequireWildcard(_pix2wav);\n\nvar _pix2wav2 = require('../pix2wav.actions');\n\nvar pix2wavActions = _interopRequireWildcard(_pix2wav2);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar Pix2WavLive = function (_Component) {\n _inherits(Pix2WavLive, _Component);\n\n function Pix2WavLive(props) {\n _classCallCheck(this, Pix2WavLive);\n\n var _this = _possibleConstructorReturn(this, (Pix2WavLive.__proto__ || Object.getPrototypeOf(Pix2WavLive)).call(this));\n\n props.actions.pix2wav.load_directories();\n props.actions.live.get_params();\n _this.changeCheckpoint = _this.changeCheckpoint.bind(_this);\n _this.changeEpoch = _this.changeEpoch.bind(_this);\n _this.changeSequence = _this.changeSequence.bind(_this);\n _this.seek = _this.seek.bind(_this);\n _this.togglePlaying = _this.togglePlaying.bind(_this);\n _this.toggleRecording = _this.toggleRecording.bind(_this);\n return _this;\n }\n\n _createClass(Pix2WavLive, [{\n key: 'componentWillUpdate',\n value: function componentWillUpdate(nextProps) {\n if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) {\n console.log('fetch checkpoint', nextProps.opt.checkpoint_name);\n this.props.actions.live.list_epochs('pix2wav', nextProps.opt.checkpoint_name);\n }\n }\n }, {\n key: 'changeCheckpoint',\n value: function changeCheckpoint(field, checkpoint_name) {\n this.props.actions.live.load_epoch(checkpoint_name, 'latest');\n }\n }, {\n key: 'changeEpoch',\n value: function changeEpoch(field, epoch_name) {\n this.props.actions.live.load_epoch(this.props.opt.checkpoint_name, epoch_name);\n }\n }, {\n key: 'changeSequence',\n value: function changeSequence(field, sequence) {\n console.log('got sequence', sequence);\n this.props.actions.live.load_sequence(sequence);\n }\n }, {\n key: 'seek',\n value: function seek(percentage) {\n var frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1);\n this.props.actions.live.seek(frame);\n }\n }, {\n key: 'start',\n value: function start() {\n // console.log(this.props)\n console.log(this.props.pix2wav.data);\n var sequence = this.props.pix2wav.data.sequences[0].name || '';\n var checkpoint = this.props.pix2wav.data.checkpoints[0].name || '';\n console.log('starting up!', sequence, checkpoint);\n this.props.actions.tasks.live_task(sequence, checkpoint);\n }\n }, {\n key: 'interrupt',\n value: function interrupt() {\n this.props.actions.queue.stop_task('gpu');\n }\n }, {\n key: 'exit',\n value: function exit() {\n this.props.actions.queue.stop_task('gpu', { sigkill: true });\n }\n }, {\n key: 'togglePlaying',\n value: function togglePlaying() {\n if (this.props.opt.processing) {\n this.props.actions.live.pause();\n } else {\n this.props.actions.live.play();\n }\n }\n }, {\n key: 'toggleRecording',\n value: function toggleRecording() {\n if (this.props.opt.recording) {\n (0, _player.stopRecording)();\n this.props.actions.live.pause();\n } else {\n (0, _player.startRecording)();\n }\n }\n }, {\n key: 'render',\n value: function render() {\n // console.log(this.props)\n if (this.props.pix2wav.loading) {\n return (0, _preact.h)(_common.Loading, null);\n }\n // console.log('sequence', this.props.opt)\n return (0, _preact.h)(\n 'div',\n { className: 'app pix2wav centered' },\n (0, _preact.h)(\n 'div',\n { className: 'row' },\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(_common.Player, { width: 256, height: 256 })\n ),\n (0, _preact.h)(\n 'div',\n { className: 'params column audioParams' },\n (0, _preact.h)(\n _common.Group,\n { title: 'Audio playback' },\n (0, _preact.h)(\n _common.Button,\n { title: 'Start playback',\n onClick: function onClick() {\n return playerActions.startSynthesizing();\n }\n },\n 'Start'\n ),\n (0, _preact.h)(\n _common.Button,\n { title: 'Stop playback',\n onClick: function onClick() {\n return playerActions.stopSynthesizing();\n }\n },\n 'Stop'\n )\n )\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'params row' },\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Playback',\n noToggle: true\n },\n (0, _preact.h)(_common.Select, {\n name: 'send_image',\n title: 'view mode',\n options: ['a', 'b', 'sequence', 'recursive'],\n onChange: this.props.actions.live.set_param\n }),\n (0, _preact.h)(_common.Select, {\n name: 'sequence_name',\n title: 'sequence',\n options: this.props.pix2wav.data.sequences,\n onChange: this.changeSequence\n }),\n (0, _preact.h)(_common.Select, {\n name: 'output_format',\n title: 'format',\n options: ['JPEG', 'PNG']\n }),\n (0, _preact.h)(_common.Select, {\n name: 'checkpoint_name',\n title: 'checkpoint',\n options: this.props.pix2wav.data.checkpoints,\n onChange: this.changeCheckpoint\n }),\n (0, _preact.h)(_common.Select, {\n name: 'epoch',\n title: 'epoch',\n options: this.props.epochs,\n onChange: this.changeEpoch\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'position',\n min: 0.0, max: 1.0, type: 'float',\n value: (this.props.frame.sequence_i || 0) / (this.props.frame.sequence_len || 1),\n onChange: this.seek\n }),\n this.renderRestartButton(),\n (0, _preact.h)(\n _common.Button,\n {\n title: this.props.opt.savingVideo ? 'Saving video...' : this.props.opt.recording ? 'Recording (' + timeInSeconds(this.props.opt.recordFrames) + ')' : 'Record video',\n onClick: this.toggleRecording\n },\n this.props.opt.savingVideo ? 'Saving' : this.props.opt.recording ? 'Recording' : 'Record'\n ),\n (0, _preact.h)(\n _common.Button,\n {\n title: 'Save frame',\n onClick: _player.saveFrame\n },\n 'Save'\n ),\n (0, _preact.h)(\n 'p',\n { 'class': 'last_message' },\n this.props.last_message\n )\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Transition',\n name: 'transition'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'transition_period',\n min: 10, max: 5000, type: 'int'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'transition_min',\n min: 0.001, max: 0.2, type: 'float'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'transition_max',\n min: 0.1, max: 1.0, type: 'float'\n })\n ),\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Recursion',\n name: 'recursive'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'recursive_frac',\n min: 0.0, max: 0.5, type: 'float'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'recurse_roll',\n min: -64, max: 64, type: 'int'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'recurse_roll_axis',\n min: 0, max: 1, type: 'int'\n })\n ),\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Sequence',\n name: 'sequence'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'sequence_frac',\n min: 0.0, max: 1, type: 'float'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'process_frac',\n min: 0, max: 1, type: 'float'\n })\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Clahe',\n name: 'clahe'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'clip_limit',\n min: 1.0, max: 4.0, type: 'float'\n })\n ),\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Posterize',\n name: 'posterize'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'spatial_window',\n min: 2, max: 128, type: 'int'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'color_window',\n min: 2, max: 128, type: 'int'\n })\n ),\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Blur',\n name: 'blur'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'blur_radius',\n min: 3, max: 7, type: 'odd'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'blur_sigma',\n min: 0, max: 2, type: 'float'\n })\n ),\n (0, _preact.h)(\n _common.ParamGroup,\n {\n title: 'Canny Edge Detection',\n name: 'canny'\n },\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'canny_lo',\n min: 10, max: 200, type: 'int'\n }),\n (0, _preact.h)(_common.Slider, { live: true,\n name: 'canny_hi',\n min: 10, max: 200, type: 'int'\n })\n )\n )\n )\n );\n }\n }, {\n key: 'renderRestartButton',\n value: function renderRestartButton() {\n var _this2 = this;\n\n if (this.props.runner.gpu.status === 'IDLE') {\n return (0, _preact.h)(\n _common.Button,\n {\n title: 'GPU Idle',\n onClick: function onClick() {\n return _this2.start();\n }\n },\n 'Start'\n );\n }\n if (this.props.runner.gpu.task.module !== 'pix2pix' && this.props.runner.gpu.task.module !== 'pix2wav') {\n return (0, _preact.h)(\n _common.Button,\n {\n title: 'GPU Busy',\n onClick: function onClick() {\n return _this2.interrupt();\n }\n },\n 'Interrupt'\n );\n }\n if (!this.props.opt.processing) {\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n _common.Button,\n {\n title: 'Not processing',\n onClick: this.togglePlaying\n },\n 'Restart'\n ),\n (0, _preact.h)(\n _common.Button,\n {\n title: 'GPU Busy',\n onClick: function onClick() {\n return _this2.interrupt();\n }\n },\n 'Interrupt'\n ),\n (0, _preact.h)(\n _common.Button,\n {\n title: 'Last resort',\n onClick: function onClick() {\n return _this2.exit();\n }\n },\n 'Exit'\n )\n );\n }\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n _common.Button,\n {\n title: 'Processing',\n onClick: this.togglePlaying\n },\n 'Pause'\n ),\n (0, _preact.h)(\n _common.Button,\n {\n title: 'GPU Busy',\n onClick: function onClick() {\n return _this2.interrupt();\n }\n },\n 'Interrupt'\n ),\n (0, _preact.h)(\n _common.Button,\n {\n title: 'Last resort',\n onClick: function onClick() {\n return _this2.exit();\n }\n },\n 'Exit'\n )\n );\n }\n }]);\n\n return Pix2WavLive;\n}(_preact.Component);\n\nfunction timeInSeconds(n) {\n return (n / 10).toFixed(1) + ' s.';\n}\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n last_message: state.live.last_message,\n opt: state.live.opt,\n frame: state.live.frame,\n checkpoints: state.live.checkpoints,\n epochs: state.live.epochs,\n sequences: state.live.sequences,\n runner: state.system.runner,\n pix2wav: state.module.pix2wav\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: {\n live: (0, _redux.bindActionCreators)(liveActions, dispatch),\n queue: (0, _redux.bindActionCreators)(queueActions, dispatch),\n pix2wav: (0, _redux.bindActionCreators)(pix2wavActions, dispatch),\n tasks: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch), s: s\n }\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2WavLive);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = Pix2WavNew;\n\nvar _preact = require('preact');\n\nvar _dataset = require('../../../dataset/dataset.new');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nvar _pix2wav = require('../pix2wav.module');\n\nvar _pix2wav2 = _interopRequireDefault(_pix2wav);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction Pix2WavNew(_ref) {\n var history = _ref.history;\n\n return (0, _preact.h)(\n 'div',\n { 'class': 'app pix2wav' },\n (0, _preact.h)(_dataset2.default, { module: _pix2wav2.default, history: history })\n );\n}","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _pix2wav = require('../pix2wav.actions');\n\nvar pix2wavActions = _interopRequireWildcard(_pix2wav);\n\nvar _pix2wav2 = require('../pix2wav.tasks');\n\nvar pix2wavTasks = _interopRequireWildcard(_pix2wav2);\n\nvar _loading = require('../../../common/loading.component');\n\nvar _loading2 = _interopRequireDefault(_loading);\n\nvar _dataset = require('../../../dataset/dataset.form');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nvar _dataset3 = require('../../../dataset/dataset.new');\n\nvar _dataset4 = _interopRequireDefault(_dataset3);\n\nvar _upload = require('../../../dataset/upload.status');\n\nvar _upload2 = _interopRequireDefault(_upload);\n\nvar _fileList = require('../../../common/fileList.component');\n\nvar _spectrogram = require('./spectrogram.upload');\n\nvar _spectrogram2 = _interopRequireDefault(_spectrogram);\n\nvar _dataset5 = require('../../../dataset/dataset.component');\n\nvar _dataset6 = _interopRequireDefault(_dataset5);\n\nvar _pix2wav3 = require('../pix2wav.module');\n\nvar _pix2wav4 = _interopRequireDefault(_pix2wav3);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar Pix2wavShow = function (_Component) {\n _inherits(Pix2wavShow, _Component);\n\n function Pix2wavShow(props) {\n _classCallCheck(this, Pix2wavShow);\n\n var _this = _possibleConstructorReturn(this, (Pix2wavShow.__proto__ || Object.getPrototypeOf(Pix2wavShow)).call(this, props));\n\n _this.datasetActions = _this.datasetActions.bind(_this);\n return _this;\n }\n\n _createClass(Pix2wavShow, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n var id = this.props.match.params.id || localStorage.getItem('pix2wav.last_id');\n console.log('load dataset:', id);\n var _props = this.props,\n match = _props.match,\n pix2wav = _props.pix2wav,\n actions = _props.actions;\n\n if (id === 'new') return;\n if (id) {\n if (parseInt(id)) localStorage.setItem('pix2wav.last_id', id);\n if (!pix2wav.folder || pix2wav.folder.id !== id) {\n actions.load_directories(id);\n }\n } else {\n this.props.history.push('/pix2wav/new/');\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _props2 = this.props,\n pix2wav = _props2.pix2wav,\n match = _props2.match,\n history = _props2.history;\n\n var _ref = pix2wav.data || {},\n folderLookup = _ref.folderLookup;\n\n var folder = (folderLookup || {})[pix2wav.folder_id] || {};\n\n return (0, _preact.h)(\n 'div',\n { className: 'app pix2wav' },\n (0, _preact.h)(\n 'div',\n { 'class': 'heading' },\n (0, _preact.h)(\n 'div',\n { 'class': 'spaced' },\n (0, _preact.h)(\n 'h1',\n null,\n folder ? folder.name : (0, _preact.h)(_loading2.default, null)\n ),\n (0, _preact.h)(_upload2.default, null)\n )\n ),\n (0, _preact.h)(_spectrogram2.default, {\n loading: pix2wav.loading,\n progress: pix2wav.progress,\n id: pix2wav.folder_id,\n module: _pix2wav4.default,\n data: pix2wav.data,\n folder: folder\n }),\n (0, _preact.h)(_dataset6.default, {\n loading: pix2wav.loading,\n progress: pix2wav.progress,\n id: pix2wav.folder_id,\n module: _pix2wav4.default,\n data: pix2wav.data,\n folder: folder,\n history: history,\n onPickFile: function onPickFile(file, e) {\n e.preventDefault();\n e.stopPropagation();\n console.log('picked a file', file);\n },\n datasetActions: this.datasetActions\n })\n );\n }\n }, {\n key: 'datasetActions',\n value: function datasetActions(dataset) {\n var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n var _props3 = this.props,\n pix2wav = _props3.pix2wav,\n remote = _props3.remote;\n\n var input = pix2wav.data.fileLookup[dataset.input[0]];\n if (!input) return null;\n if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null;\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n 'div',\n { 'class': 'actions' },\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2wav.folder_id, 1);\n } },\n 'train'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2wav.folder_id, 2);\n } },\n '2x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2wav.folder_id, 4);\n } },\n '4x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2wav.folder_id, 6);\n } },\n '6x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, pix2wav.folder_id, 18);\n } },\n '18x'\n )\n ),\n dataset.isBuilt ? (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n 'fetched ',\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.clear_cache_task(dataset);\n } },\n 'rm'\n )\n ) : isFetching ? (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n 'fetching'\n ) : (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.fetch_task(input.url, input.id, dataset.name);\n } },\n 'fetch'\n )\n )\n );\n }\n }]);\n\n return Pix2wavShow;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n pix2wav: state.module.pix2wav\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(pix2wavActions, dispatch),\n remote: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2wavShow);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _moment = require('moment/min/moment.min');\n\nvar _moment2 = _interopRequireDefault(_moment);\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _pix2wav = require('../pix2wav.actions');\n\nvar pix2wavActions = _interopRequireWildcard(_pix2wav);\n\nvar _pix2wav2 = require('../pix2wav.tasks');\n\nvar pix2wavTasks = _interopRequireWildcard(_pix2wav2);\n\nvar _common = require('../../../common');\n\nvar _dataset = require('../../../dataset/dataset.actions');\n\nvar datasetActions = _interopRequireWildcard(_dataset);\n\nvar _wav2pix = require('../../../audio/wav2pix');\n\nvar wav2pixActions = _interopRequireWildcard(_wav2pix);\n\nvar _pix2wav3 = require('../../../audio/pix2wav');\n\nvar pix2wavPlayer = _interopRequireWildcard(_pix2wav3);\n\nvar _pix2wav4 = require('../pix2wav.module');\n\nvar _pix2wav5 = _interopRequireDefault(_pix2wav4);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar date_stamp = function date_stamp() {\n return (0, _moment2.default)().format(\"_YYYYMMDD_HHmm\");\n};\n\nvar SpectrogramUpload = function (_Component) {\n _inherits(SpectrogramUpload, _Component);\n\n function SpectrogramUpload(props) {\n _classCallCheck(this, SpectrogramUpload);\n\n var _this = _possibleConstructorReturn(this, (SpectrogramUpload.__proto__ || Object.getPrototypeOf(SpectrogramUpload)).call(this, props));\n\n _this.state = {\n file: null,\n pcm: null,\n name: \"\",\n datasetName: \"\",\n frames: [],\n frame_start: 0,\n max: 1000,\n preview_count: 8 * 4,\n frame_step: wav2pixActions.FRAME_STEP\n };\n var audioElement = document.createElement('audio');\n audioElement.addEventListener('loadedmetadata', function () {\n var duration = audioElement.duration;\n var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / _this.state.frame_step);\n _this.setState({\n duration: duration,\n max: Math.min(_this.state.max, total_frame_count, 1000)\n });\n });\n _this.audioElement = audioElement;\n return _this;\n }\n\n _createClass(SpectrogramUpload, [{\n key: 'pickFile',\n value: function pickFile(file) {\n var _this2 = this;\n\n var name = file.name.split('.')[0].replace(/\\s+/g, '_').replace(/-/g, '_').replace(/_+/g, '_');\n this.setState({\n file: file,\n name: name + date_stamp(),\n datasetName: name,\n pcm: ''\n }, function () {\n _this2.rebuildFrames();\n });\n this.audioElement.src = URL.createObjectURL(file);\n }\n }, {\n key: 'rebuildFrames',\n value: function rebuildFrames() {\n var _this3 = this;\n\n var _state = this.state,\n file = _state.file,\n pcm = _state.pcm,\n frame_step = _state.frame_step,\n frame_start = _state.frame_start,\n preview_count = _state.preview_count;\n\n this.props.wav2pix.renderFrames(pcm || file, { frame_start: frame_start, frame_step: frame_step, max: preview_count }).then(function (data) {\n console.log('got frames', data.frames.length);\n _this3.setState(_extends({}, _this3.state, {\n frames: data.frames,\n pcm: data.pcm\n }));\n });\n }\n }, {\n key: 'buildZip',\n value: function buildZip() {\n var _this4 = this;\n\n var _state2 = this.state,\n pcm = _state2.pcm,\n file = _state2.file,\n max = _state2.max,\n frame_step = _state2.frame_step,\n frame_start = _state2.frame_start;\n\n this.props.wav2pix.buildZip(this.state.name, pcm || file, { frame_start: frame_start, frame_step: frame_step, max: max }).then(function (_ref) {\n var zip = _ref.zip,\n filename = _ref.filename,\n count = _ref.count;\n\n _this4.props.datasetActions.uploadFile(_this4.props.module, _this4.props.folder, zip, filename, { count: count, max: max, frame_step: frame_step, frame_size: wav2pixActions.FRAME_LENGTH / 44100 });\n });\n }\n }, {\n key: 'playFrame',\n value: function playFrame(i) {\n var _this5 = this;\n\n return function () {\n var frame = _this5.state.frames[i];\n pix2wavPlayer.play(frame);\n };\n }\n }, {\n key: 'render',\n value: function render() {\n var _this6 = this;\n\n // loading={pix2wav.loading}\n // progress={pix2wav.progress}\n // id={pix2wav.folder_id}\n // module={pix2wavModule}\n // data={pix2wav.data}\n // folder={folder}\n var _state3 = this.state,\n file = _state3.file,\n frames = _state3.frames,\n preview_count = _state3.preview_count;\n\n var canvases = [];\n for (var i = 0, _len = preview_count; i < _len; i++) {\n canvases.push((0, _preact.h)('canvas', { key: i, onClick: this.playFrame(i) }));\n }\n return (0, _preact.h)(\n 'div',\n { className: 'row' },\n (0, _preact.h)(\n 'div',\n { className: 'col spectrogramBuilder' },\n (0, _preact.h)(\n _common.Group,\n { title: 'Spectrogram Builder' },\n (0, _preact.h)(\n 'p',\n null,\n \"Convert your sounds into spectrograms. \",\n \"Sound files can be WAV, MP3, AIFF, or FLAC. \"\n ),\n (0, _preact.h)(_common.FileUpload, {\n title: 'Choose a sound file',\n accept: 'audio/*',\n onUpload: function onUpload(file) {\n return _this6.pickFile(file);\n }\n }),\n file && this.renderMetadata(file)\n )\n ),\n (0, _preact.h)(\n 'div',\n { ref: function ref(c) {\n _this6.canvases = c;\n }, className: 'thumbs', id: 'pix2wav_canvases' },\n canvases\n )\n );\n }\n }, {\n key: 'renderMetadata',\n value: function renderMetadata(file) {\n var _this7 = this;\n\n var _state4 = this.state,\n duration = _state4.duration,\n preview_count = _state4.preview_count;\n\n var size = _util2.default.hush_size(file.size);\n var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / this.state.frame_step);\n var frame_size = Math.round(wav2pixActions.FRAME_LENGTH / 44100 * 1000) + ' ms.';\n var frame_step = Math.round(this.state.frame_step / 44100 * 1000) + ' ms.';\n return (0, _preact.h)(\n 'div',\n { className: 'fileMetadata' },\n (0, _preact.h)(\n _common.Group,\n { title: 'Metadata' },\n (0, _preact.h)(\n _common.Param,\n { title: 'Name' },\n file.name\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'Type' },\n file.type\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'Size' },\n (0, _preact.h)(\n 'span',\n { className: size[0] },\n size[1]\n )\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'Date' },\n (0, _moment2.default)(file.lastModifiedDate).format(\"YYYY-MM-DD h:mm a\")\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'Duration' },\n Math.floor(duration) + ' s.'\n ),\n (0, _preact.h)('br', null),\n (0, _preact.h)(\n _common.Param,\n { title: 'Frames' },\n total_frame_count\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'Frame Size' },\n frame_size\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'Frame Step' },\n frame_step\n ),\n (0, _preact.h)(\n _common.Param,\n { title: 'FFT Size' },\n wav2pixActions.spectrum.fft_size\n ),\n (0, _preact.h)('br', null),\n (0, _preact.h)(\n _common.Param,\n { title: 'Status' },\n this.props.pix2wav.status\n ),\n (0, _preact.h)('br', null)\n ),\n (0, _preact.h)(\n _common.Group,\n { title: 'Data settings' },\n (0, _preact.h)(_common.TextInput, {\n title: 'Dataset name',\n onChange: function onChange(e) {\n return _this7.setState({ name: e.target.value });\n },\n value: this.state.name\n }),\n (0, _preact.h)(_common.Slider, {\n name: 'Starting Frame',\n min: 0, max: 1, type: 'float',\n value: this.state.frame_start,\n defaultValue: 0,\n onChange: function onChange(frame_start) {\n _this7.setState({\n frame_start: frame_start\n }, function () {\n _this7.rebuildFrames();\n });\n }\n }),\n (0, _preact.h)(_common.Slider, {\n name: 'No. Frames',\n min: 10, max: Math.min(total_frame_count, 1000), type: 'int',\n value: this.state.max,\n defaultValue: Math.min(total_frame_count, 300),\n onChange: function onChange(max) {\n return _this7.setState({ max: max });\n }\n }),\n (0, _preact.h)(_common.Slider, {\n name: 'Frame step',\n min: 10, max: 20000, type: 'int',\n value: this.state.frame_step,\n defaultValue: wav2pixActions.FRAME_STEP,\n onChange: function onChange(frame_step) {\n var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / frame_step);\n _this7.setState({\n name: _this7.state.datasetName + '_step_' + frame_step + date_stamp(),\n frame_step: frame_step,\n max: Math.min(_this7.state.max, total_frame_count)\n }, function () {\n _this7.rebuildFrames();\n });\n }\n }),\n (0, _preact.h)(\n _common.Button,\n {\n onClick: function onClick() {\n return _this7.buildZip();\n }\n },\n 'Upload Frames'\n )\n ),\n (0, _preact.h)(_common.Progress, null)\n );\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n var _this8 = this;\n\n (this.state.frames || []).map(function (frame, i) {\n var canvas = _this8.canvases.children[i];\n var ctx = canvas.getContext('2d-lodpi');\n canvas.width = frame.canvas.width;\n canvas.height = frame.canvas.height;\n ctx.drawImage(frame.canvas, 0, 0);\n });\n }\n }]);\n\n return SpectrogramUpload;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n pix2wav: state.module.pix2wav,\n upload: state.upload\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n datasetActions: (0, _redux.bindActionCreators)(datasetActions, dispatch),\n actions: (0, _redux.bindActionCreators)(pix2wavActions, dispatch),\n remote: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch),\n wav2pix: (0, _redux.bindActionCreators)(wav2pixActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SpectrogramUpload);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _reactRouterDom = require('react-router-dom');\n\nvar _actions = require('../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nvar _util = require('../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _samplernn = require('./views/samplernn.new');\n\nvar _samplernn2 = _interopRequireDefault(_samplernn);\n\nvar _samplernn3 = require('./views/samplernn.show');\n\nvar _samplernn4 = _interopRequireDefault(_samplernn3);\n\nvar _samplernn5 = require('./views/samplernn.import');\n\nvar _samplernn6 = _interopRequireDefault(_samplernn5);\n\nvar _samplernn7 = require('./views/samplernn.results');\n\nvar _samplernn8 = _interopRequireDefault(_samplernn7);\n\nvar _samplernn9 = require('./views/samplernn.graph');\n\nvar _samplernn10 = _interopRequireDefault(_samplernn9);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar router = function () {\n function router() {\n _classCallCheck(this, router);\n }\n\n _createClass(router, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n _actions2.default.system.changeTool('samplernn');\n document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #eef, #fef)';\n }\n }, {\n key: 'componentWillReceiveProps',\n value: function componentWillReceiveProps() {\n _actions2.default.system.changeTool('samplernn');\n document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #eef, #fef)';\n }\n }, {\n key: 'render',\n value: function render() {\n return (0, _preact.h)(\n 'section',\n null,\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/new', component: _samplernn2.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/datasets', component: _samplernn4.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/datasets/:id', component: _samplernn4.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/import', component: _samplernn6.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/results', component: _samplernn8.default }),\n (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/graph', component: _samplernn10.default })\n );\n }\n }]);\n\n return router;\n}();\n\nfunction links() {\n return [{ url: '/samplernn/new/', name: 'new' }, { url: '/samplernn/datasets/', name: 'datasets' }, { url: '/samplernn/graph/', name: 'graph' }, { url: '/samplernn/results/', name: 'results' }];\n}\n\nexports.default = {\n name: 'samplernn',\n router: router, links: links\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.import_files = exports.load_loss = exports.load_graph = exports.load_directories = undefined;\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _v = require('uuid/v1');\n\nvar _v2 = _interopRequireDefault(_v);\n\nvar _socket = require('../../socket');\n\nvar _socket2 = _interopRequireDefault(_socket);\n\nvar _types = require('../../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _dataset = require('../../dataset/dataset.loader');\n\nvar datasetLoader = _interopRequireWildcard(_dataset);\n\nvar _actions = require('../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nvar _util = require('../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _samplernn = require('./samplernn.module');\n\nvar _samplernn2 = _interopRequireDefault(_samplernn);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }\n\nvar load_directories = exports.load_directories = function load_directories(id) {\n return function (dispatch) {\n var module = _samplernn2.default.name;\n _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: module, dir: 'datasets' }), _actions2.default.socket.list_directory({ module: module, dir: 'results' }), _actions2.default.socket.list_directory({ module: module, dir: 'output' }), _actions2.default.socket.disk_usage({ module: module, dir: 'datasets' }), load_loss()(dispatch)], function (percent, i, n) {\n dispatch({\n type: _types2.default.app.load_progress,\n progress: { i: i, n: n },\n data: { module: 'samplernn' }\n });\n }).then(function (res) {\n // console.log(res)\n var _res = _slicedToArray(res, 6),\n datasetApiReport = _res[0],\n datasets = _res[1],\n results = _res[2],\n output = _res[3],\n datasetUsage = _res[4],\n lossReport = _res[5];\n\n var folderLookup = datasetApiReport.folderLookup,\n fileLookup = datasetApiReport.fileLookup,\n datasetLookup = datasetApiReport.datasetLookup,\n folders = datasetApiReport.folders,\n files = datasetApiReport.files,\n unsortedFolder = datasetApiReport.unsortedFolder;\n\n console.log(datasetUsage);\n\n // also show the various flat audio files we have, in the input area..\n var flatDatasets = datasets.filter(function (s) {\n return s.name.match(/(wav|aiff?|flac|mp3)$/) && !s.dir;\n });\n var builtDatasets = datasets.filter(function (s) {\n return s.dir;\n });\n builtDatasets.forEach(function (dir) {\n var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name, unsortedFolder, dir.date);\n dataset.isBuilt = true;\n });\n\n flatDatasets.forEach(function (file) {\n file.uuid = (0, _v2.default)();\n fileLookup[file.uuid] = file;\n var name = file.name.split('.')[0];\n var dataset = datasetLoader.getDataset(module, datasetLookup, name, unsortedFolder, file.date);\n file.persisted = false;\n dataset.input.push(file.uuid);\n });\n\n // exp:coccokit_3-frame_sizes:8,2-n_rnn:2-dataset:coccokit_3\n var checkpoints = results.filter(function (s) {\n return s.dir;\n }).map(function (s) {\n var checkpoint = s.name.split('-').map(function (s) {\n return s.split(':');\n }).filter(function (b) {\n return b.length && b[1];\n }).reduce(function (a, b) {\n return (a[b[0]] = b[1]) && a;\n }, {});\n checkpoint.name = checkpoint.name || checkpoint.dataset || checkpoint.exp;\n checkpoint.date = s.date;\n checkpoint.dir = s;\n checkpoint.persisted = false;\n var dataset = datasetLoader.getDataset(module, datasetLookup, checkpoint.name, unsortedFolder, checkpoint.date);\n var loss = lossReport[checkpoint.name];\n if (loss) {\n dataset.epoch = checkpoint.epoch = loss.length;\n checkpoint.training_loss = loss;\n }\n dataset.checkpoints.push(checkpoint);\n return checkpoint;\n });\n\n output.map(function (file) {\n file.uuid = (0, _v2.default)();\n fileLookup[file.uuid] = file;\n var pair = file.name.split('.')[0].split('-');\n var dataset = datasetLoader.getDataset(module, datasetLookup, pair[0], unsortedFolder, file.date);\n file.persisted = false;\n file.epoch = parseInt(file.epoch || pair[1].replace(/^\\D+/, '')) || 0;\n dataset.epoch = Math.max(file.epoch, dataset.epoch || 0);\n // here check if the file exists in dataset, if so just check that it's persisted\n var found = dataset.output.some(function (file_id) {\n // if (f.name === \n if (fileLookup[file_id].name === file.name) {\n fileLookup[file_id].persisted = true;\n return true;\n }\n return false;\n });\n if (!found) {\n dataset.output.push(file.uuid);\n }\n });\n\n dispatch({\n type: _types2.default.dataset.load,\n data: {\n module: module,\n folderLookup: folderLookup,\n fileLookup: fileLookup,\n datasetLookup: datasetLookup,\n folders: folders, files: files,\n checkpoints: checkpoints,\n output: output\n }\n });\n }).catch(function (e) {\n console.error(e);\n });\n if (id) {\n dispatch({\n type: _types2.default.dataset.set_folder,\n data: {\n folder_id: id,\n module: module\n }\n });\n }\n };\n};\n\nvar load_graph = exports.load_graph = function load_graph() {\n return function (dispatch) {\n var module = _samplernn2.default.name;\n _util2.default.allProgress([load_loss()(dispatch), _actions2.default.socket.list_directory({ module: module, dir: 'results' })], function (percent, i, n) {\n dispatch({\n type: _types2.default.app.load_progress,\n progress: { i: i, n: n },\n data: { module: 'samplernn' }\n });\n }).then(function (res) {\n var _res2 = _slicedToArray(res, 2),\n lossReport = _res2[0],\n results = _res2[1];\n\n dispatch({\n type: _types2.default.samplernn.load_graph,\n lossReport: lossReport,\n results: results\n });\n });\n };\n};\n\nvar load_loss = exports.load_loss = function load_loss() {\n return function (dispatch) {\n return _actions2.default.socket.run_script({ module: 'samplernn', activity: 'report' }).then(function (report) {\n var lossReport = {};\n report.stdout.split('\\n\\n').filter(function (a) {\n return !!a;\n }).forEach(function (data) {\n var _data$split = data.split('\\n'),\n _data$split2 = _toArray(_data$split),\n name = _data$split2[0],\n lines = _data$split2.slice(1);\n\n lossReport[name] = lines.map(function (s) {\n return s.split('\\t').reduce(function (a, s) {\n var b = s.split(': ');\n a[b[0]] = b[1];\n return a;\n }, {});\n });\n // console.log(data, name, lossReport[name])\n });\n dispatch({\n type: _types2.default.samplernn.load_loss,\n lossReport: lossReport\n });\n return lossReport;\n });\n };\n};\n\nvar import_files = exports.import_files = function import_files(state, datasetLookup, fileLookup) {\n return function (dispatch) {\n var selected = state.selected,\n folder_id = state.folder_id,\n url_base = state.url_base,\n import_action = state.import_action;\n\n var names = Object.keys(selected).filter(function (k) {\n return selected[k];\n });\n var promises = void 0;\n switch (import_action) {\n case 'Hotlink':\n // in this case, create a new file for each file we see.\n promises = names.reduce(function (a, name) {\n return datasetLookup[name].output.map(function (id) {\n return fileLookup[id];\n }).map(function (file) {\n var partz = file.name.split('.');\n var ext = partz.pop();\n return _actions2.default.file.create({\n folder_id: folder_id,\n name: file.name,\n url: url_base + file.name,\n mime: 'audio/' + ext,\n epoch: file.epoch,\n size: file.size,\n module: 'samplernn',\n dataset: name,\n activity: 'train',\n datatype: 'audio',\n generated: true,\n created_at: new Date(file.date),\n updated_at: new Date(file.date)\n });\n }).concat(a);\n }, []);\n break;\n case 'Upload':\n promises = names.reduce(function (a, name) {\n return datasetLookup[name].input.map(function (id) {\n return fileLookup[id];\n }).map(function (file) {\n if (file.persisted) return null;\n var partz = file.name.split('.');\n var ext = partz.pop();\n if (ext === 'wav' || ext === 'flac') return;\n console.log(file);\n return _actions2.default.socket.upload_file({\n folder_id: folder_id,\n module: 'samplernn',\n activity: 'train',\n path: 'datasets',\n filename: file.name,\n generated: false,\n processed: false,\n datatype: 'audio',\n ttl: 60000\n });\n }).concat(a);\n }, []).filter(function (a) {\n return !!a;\n });\n break;\n default:\n break;\n }\n console.log(promises);\n return Promise.all(promises).then(function (data) {\n console.log(data);\n window.location.href = '/samplernn/datasets/' + folder_id + '/';\n }).catch(function (e) {\n console.error(e);\n });\n };\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nvar samplernnModule = {\n name: 'samplernn',\n displayName: 'SampleRNN',\n datatype: 'audio'\n};\n\nexports.default = samplernnModule;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _types = require('../../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _dataset = require('../../dataset/dataset.reducer');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar samplernnInitialState = {\n loading: true,\n progress: { i: 0, n: 0 },\n error: null,\n folders: [],\n folder_id: 0,\n data: null,\n lossReport: null,\n results: null\n};\n\nvar samplernnReducer = function samplernnReducer() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : samplernnInitialState;\n var action = arguments[1];\n\n if (action.data && action.data.module === 'samplernn') {\n return (0, _dataset2.default)(state, action);\n }\n\n switch (action.type) {\n case _types2.default.samplernn.load_loss:\n return _extends({}, state, {\n lossReport: action.lossReport\n });\n case _types2.default.samplernn.load_graph:\n return _extends({}, state, {\n lossReport: action.lossReport,\n results: action.results\n });\n default:\n return state;\n }\n};\n\nexports.default = samplernnReducer;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.clear_cache_task = exports.log_task = exports.fetch_task = exports.train_task = undefined;\n\nvar _v = require('uuid/v1');\n\nvar _v2 = _interopRequireDefault(_v);\n\nvar _socket = require('../../socket');\n\nvar _socket2 = _interopRequireDefault(_socket);\n\nvar _types = require('../../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _actions = require('../../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar train_task = exports.train_task = function train_task(dataset, folder_id) {\n var epochs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;\n return function (dispatch) {\n var task = {\n module: 'samplernn',\n activity: 'train',\n dataset: dataset.name,\n epoch: dataset.checkpoints.length ? dataset.checkpoints[0].epoch || 0 : 0,\n epochs: epochs,\n folder_id: folder_id,\n opt: {\n sample_length: 44100 * 5,\n n_samples: 6,\n keep_old_checkpoints: false\n }\n };\n console.log(task);\n return _actions2.default.queue.add_task(task);\n };\n};\nvar fetch_task = exports.fetch_task = function fetch_task(url, folder_id, file_id, dataset) {\n return function (dispatch) {\n if (!url) return console.log('input file inaccessible (no url)');\n var task = {\n module: 'samplernn',\n activity: 'fetch',\n dataset: dataset,\n folder_id: folder_id,\n opt: {\n url: url,\n file_id: file_id,\n dataset: dataset\n }\n };\n return _actions2.default.queue.add_task(task);\n };\n};\nvar log_task = exports.log_task = function log_task(dataset) {\n return function (dispatch) {\n var task = {\n module: 'samplernn',\n activity: 'log',\n dataset: dataset.name\n };\n return _actions2.default.queue.add_task(task);\n };\n};\nvar clear_cache_task = exports.clear_cache_task = function clear_cache_task(dataset) {\n return function (dispatch) {\n var task = {\n module: 'samplernn',\n activity: 'clear_cache',\n dataset: dataset.name\n };\n return _actions2.default.queue.add_task(task);\n };\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _samplernn = require('../samplernn.actions');\n\nvar samplernnActions = _interopRequireWildcard(_samplernn);\n\nvar _group = require('../../../common/group.component');\n\nvar _group2 = _interopRequireDefault(_group);\n\nvar _slider = require('../../../common/slider.component');\n\nvar _slider2 = _interopRequireDefault(_slider);\n\nvar _select = require('../../../common/select.component');\n\nvar _select2 = _interopRequireDefault(_select);\n\nvar _button = require('../../../common/button.component');\n\nvar _button2 = _interopRequireDefault(_button);\n\nvar _fileList = require('../../../common/fileList.component');\n\nvar _textInput = require('../../../common/textInput.component');\n\nvar _textInput2 = _interopRequireDefault(_textInput);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar lerp = _util2.default.lerp,\n norm = _util2.default.norm,\n randint = _util2.default.randint,\n randrange = _util2.default.randrange;\n\nvar SampleRNNGraph = function (_Component) {\n _inherits(SampleRNNGraph, _Component);\n\n function SampleRNNGraph(props) {\n _classCallCheck(this, SampleRNNGraph);\n\n var _this = _possibleConstructorReturn(this, (SampleRNNGraph.__proto__ || Object.getPrototypeOf(SampleRNNGraph)).call(this));\n\n props.actions.load_graph();\n return _this;\n }\n\n _createClass(SampleRNNGraph, [{\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n this.refs = {};\n return (0, _preact.h)(\n 'div',\n { className: 'app lossGraph' },\n (0, _preact.h)(\n 'div',\n { className: 'heading' },\n (0, _preact.h)(\n 'h3',\n null,\n 'SampleRNN Loss Graph'\n ),\n (0, _preact.h)('canvas', { ref: function ref(_ref) {\n return _this2.refs['canvas'] = _ref;\n } })\n )\n );\n }\n }, {\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n var _props$samplernn = this.props.samplernn,\n lossReport = _props$samplernn.lossReport,\n results = _props$samplernn.results;\n\n if (!lossReport || !results) return;\n var canvas = this.refs.canvas;\n canvas.width = window.innerWidth;\n canvas.height = window.innerHeight;\n canvas.style.width = canvas.width + 'px';\n canvas.style.height = canvas.height + 'px';\n\n var ctx = canvas.getContext('2d');\n var w = canvas.width;\n var h = canvas.height;\n ctx.clearRect(0, 0, w, h);\n\n var resultsByDate = results.map(function (file) {\n if (!file.name.match(/^exp:/)) return null;\n var dataset = file.name.split(\"-\")[3].split(\":\")[1];\n return [+new Date(file.date), dataset];\n }).filter(function (a) {\n return !!a;\n }).sort(function (a, b) {\n return a[0] - a[1];\n });\n\n var keys = Object.keys(lossReport).filter(function (k) {\n return !!lossReport[k].length;\n });\n var scaleMax = 0;\n var scaleMin = Infinity;\n var epochsMax = 0;\n keys.forEach(function (key) {\n var loss = lossReport[key];\n epochsMax = Math.max(loss.length, epochsMax);\n loss.forEach(function (a) {\n var v = parseFloat(a.training_loss);\n if (!v) return;\n scaleMax = Math.max(v, scaleMax);\n scaleMin = Math.min(v, scaleMin);\n });\n });\n // scaleMax *= 10\n // console.log(scaleMax, scaleMin, epochsMax)\n\n scaleMax = 3;\n scaleMin = 0;\n var margin = 0;\n var wmin = 0;\n var wmax = w / 2;\n var hmin = 0;\n var hmax = h / 2;\n var epochsScaleFactor = 1; // 3/2\n\n ctx.save();\n var X = void 0,\n Y = void 0;\n for (var ii = 0; ii < epochsMax; ii++) {\n X = lerp(ii / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax);\n ctx.strokeStyle = 'rgba(0,0,0,0.3)';\n ctx.beginPath(0, 0);\n ctx.moveTo(X, 0);\n ctx.lineTo(X, h);\n ctx.lineWidth = 0.5;\n // ctx.stroke()\n if ((ii + 1) % 6 === 0) {\n ctx.lineWidth = 0.5;\n ctx.stroke();\n var fontSize = 12;\n ctx.font = 'italic ' + fontSize + 'px \"Georgia\"';\n ctx.fillStyle = 'rgba(0,12,28,0.6)';\n ctx.fillText(ii / 5 * 6, X + 8, h - (fontSize + 4));\n }\n }\n for (var ii = scaleMin; ii < scaleMax; ii += 1) {\n Y = lerp(ii / scaleMax, hmin, hmax);\n // ctx.strokeStyle = 'rgba(255,255,255,1.0)'\n ctx.beginPath(0, 0);\n ctx.moveTo(0, h - Y);\n ctx.lineTo(w, h - Y);\n ctx.lineWidth = 1;\n // ctx.stroke() \n // if ( (ii % 1) < 0.1) {\n // ctx.strokeStyle = 'rgba(255,255,255,1.0)'\n ctx.lineWidth = 2;\n ctx.setLineDash([4, 4]);\n ctx.stroke();\n ctx.stroke();\n ctx.stroke();\n ctx.setLineDash([1, 1]);\n var _fontSize = 12;\n ctx.font = 'italic ' + _fontSize + 'px \"Georgia\"';\n ctx.fillStyle = 'rgba(0,12,28,0.6)';\n ctx.fillText(ii.toFixed(1), w - 50, h - Y + _fontSize + 10);\n // }\n }\n ctx.lineWidth = 1;\n ctx.restore();\n\n var min_date = resultsByDate[0][0];\n var max_date = resultsByDate[resultsByDate.length - 1][0];\n resultsByDate.forEach(function (pair) {\n var date = pair[0];\n var key = pair[1];\n var loss = lossReport[key];\n if (!key || !loss || !loss.length) return;\n var vf = parseFloat(loss[loss.length - 1].training_loss) || 0;\n var vg = parseFloat(loss[0].training_loss) || 5;\n // console.log(vf)\n var vv = 1 - norm(vf, scaleMin, scaleMax / 2);\n ctx.lineWidth = (1 - norm(vf, scaleMin, scaleMax)) * 4;\n // ctx.lineWidth = norm(date, min_date, max_date) * 3\n // console.log(date, min_date, max_date)\n ctx.strokeStyle = 'rgba(' + [randrange(30, 190), randrange(30, 150), randrange(60, 120)].join(',') + ',' + 0.8 + ')';\n var begun = false;\n loss.forEach(function (a, i) {\n var v = parseFloat(a.training_loss);\n if (!v) return;\n var x = lerp(i / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax);\n var y = lerp(norm(v, scaleMin, scaleMax), hmax, hmin);\n if (!begun) {\n begun = true;\n ctx.beginPath(0, 0);\n ctx.moveTo(x, y);\n } else {\n ctx.lineTo(x, y);\n // ctx.stroke()\n }\n });\n ctx.stroke();\n var i = loss.length - 1;\n var v = parseFloat(loss[i].training_loss);\n var x = lerp(i / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax);\n var y = lerp(norm(v, scaleMin, scaleMax), hmax, hmin);\n var fontSize = 9;\n ctx.font = 'italic ' + fontSize + 'px \"Georgia\"';\n ctx.fillStyle = 'rgba(0,12,28,0.6)';\n ctx.fillText(key, x + 4, y + fontSize / 2);\n });\n }\n }]);\n\n return SampleRNNGraph;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n samplernn: state.module.samplernn\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNGraph);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _samplernn = require('../samplernn.actions');\n\nvar samplernnActions = _interopRequireWildcard(_samplernn);\n\nvar _select = require('../../../common/select.component');\n\nvar _select2 = _interopRequireDefault(_select);\n\nvar _textInput = require('../../../common/textInput.component');\n\nvar _textInput2 = _interopRequireDefault(_textInput);\n\nvar _button = require('../../../common/button.component');\n\nvar _button2 = _interopRequireDefault(_button);\n\nvar _dataset = require('../../../dataset/dataset.component');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar samplernnModule = {\n name: 'samplernn',\n datatype: 'audio'\n};\n\nvar SampleRNNImport = function (_Component) {\n _inherits(SampleRNNImport, _Component);\n\n function SampleRNNImport() {\n _classCallCheck(this, SampleRNNImport);\n\n var _this = _possibleConstructorReturn(this, (SampleRNNImport.__proto__ || Object.getPrototypeOf(SampleRNNImport)).call(this));\n\n _this.state = {\n folder_id: 1,\n import_action: 'Hotlink',\n url_base: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4279/',\n selected: {}\n };\n return _this;\n }\n\n _createClass(SampleRNNImport, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n var id = this.props.match.params.id || localStorage.getItem('samplernn.last_id');\n console.log('load dataset:', id);\n var _props = this.props,\n match = _props.match,\n samplernn = _props.samplernn,\n samplernnActions = _props.samplernnActions;\n\n if (id === 'new') return;\n if (id) {\n if (parseInt(id)) localStorage.setItem('samplernn.last_id', id);\n if (!samplernn.folder || samplernn.folder.id !== id) {\n this.props.actions.load_directories(id);\n }\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n var samplernn = this.props.samplernn;\n\n var datasets = [],\n folder = void 0;\n if (this.props.samplernn.data) {\n datasets = (this.props.samplernn.data.folders || []).map(function (folder) {\n return [folder.name, folder.id];\n });\n folder = this.props.samplernn.data.folderLookup.unsorted;\n }\n return (0, _preact.h)(\n 'div',\n { className: 'app top' },\n (0, _preact.h)(\n 'div',\n { 'class': 'heading' },\n (0, _preact.h)(\n 'h1',\n null,\n 'Import'\n )\n ),\n (0, _preact.h)(\n 'div',\n { 'class': 'params form row datasets' },\n (0, _preact.h)(\n 'div',\n { 'class': 'row dataset' },\n (0, _preact.h)('div', { 'class': 'col' }),\n (0, _preact.h)('div', { 'class': 'col' }),\n (0, _preact.h)('div', { 'class': 'col' }),\n (0, _preact.h)(\n 'div',\n { 'class': 'col' },\n (0, _preact.h)(\n 'h2',\n null,\n 'Import to dataset'\n ),\n (0, _preact.h)(_select2.default, {\n title: 'Destination dataset',\n options: datasets,\n name: 'folder_id',\n opt: this.state,\n onChange: function onChange(name, value) {\n return _this2.setState({ folder_id: value });\n }\n }),\n (0, _preact.h)(_select2.default, {\n title: 'Import action',\n options: ['Hotlink', 'Upload'],\n name: 'import_action',\n opt: this.state,\n onChange: function onChange(name, value) {\n return _this2.setState({ import_action: value });\n }\n }),\n (0, _preact.h)(_textInput2.default, {\n title: 'Remote URL base',\n value: this.state.url_base,\n placeholder: 'http://',\n onSave: function onSave(value) {\n return _this2.setState({ url_base: value });\n }\n }),\n (0, _preact.h)(\n _button2.default,\n {\n title: '',\n onClick: function onClick() {\n return _this2.doImport();\n }\n },\n 'Import'\n )\n )\n )\n ),\n (0, _preact.h)(_dataset2.default, {\n loading: samplernn.loading,\n progress: samplernn.progress,\n module: samplernnModule,\n data: samplernn.data,\n id: 'unsorted',\n folder: folder,\n history: this.props.history,\n onPickDataset: function onPickDataset(dataset) {\n return _this2.toggle(dataset.name, _this2.state.selected[name]);\n },\n beforeRow: function beforeRow(dataset) {\n return _this2.beforeRow(dataset);\n },\n afterRow: function afterRow(dataset) {\n return _this2.afterRow(dataset);\n }\n })\n );\n }\n }, {\n key: 'toggle',\n value: function toggle(name) {\n this.setState(_extends({}, this.state, {\n selected: _extends({}, this.state.selected, _defineProperty({}, name, !this.state.selected[name]))\n }));\n }\n }, {\n key: 'beforeRow',\n value: function beforeRow(dataset) {\n // console.log(dataset)\n }\n }, {\n key: 'afterRow',\n value: function afterRow(dataset) {\n var name = dataset.name;\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)('input', {\n type: 'checkbox',\n value: name,\n checked: !!this.state.selected[name]\n })\n );\n }\n }, {\n key: 'doImport',\n value: function doImport() {\n var samplernn = this.props.samplernn;\n\n console.log(this.state);\n this.props.actions.import_files(this.state, samplernn.data.datasetLookup, samplernn.data.fileLookup);\n }\n }]);\n\n return SampleRNNImport;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n samplernn: state.module.samplernn,\n runner: state.system.runner,\n task: state.task\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNImport);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _reactRouterDom = require('react-router-dom');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _common = require('../../../common');\n\nvar _samplernn = require('../samplernn.actions');\n\nvar samplernnActions = _interopRequireWildcard(_samplernn);\n\nvar _samplernn2 = require('../samplernn.module');\n\nvar _samplernn3 = _interopRequireDefault(_samplernn2);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction SampleRNNNew(props) {\n return (0, _preact.h)(_common.Views.New, {\n db: props.samplernn,\n path: '/samplernn/datasets/',\n actions: props.actions,\n module: _samplernn3.default,\n history: props.history\n });\n}\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n samplernn: state.module.samplernn\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNNew);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRouterDom = require('react-router-dom');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _samplernn = require('../samplernn.actions');\n\nvar samplernnActions = _interopRequireWildcard(_samplernn);\n\nvar _audioPlayer = require('../../../common/audioPlayer/audioPlayer.actions');\n\nvar audioPlayerActions = _interopRequireWildcard(_audioPlayer);\n\nvar _loading = require('../../../common/loading.component');\n\nvar _loading2 = _interopRequireDefault(_loading);\n\nvar _fileList = require('../../../common/fileList.component');\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar SampleRNNResults = function (_Component) {\n _inherits(SampleRNNResults, _Component);\n\n function SampleRNNResults(props) {\n _classCallCheck(this, SampleRNNResults);\n\n var _this = _possibleConstructorReturn(this, (SampleRNNResults.__proto__ || Object.getPrototypeOf(SampleRNNResults)).call(this));\n\n if (!props.samplernn.data) props.actions.load_directories();\n return _this;\n }\n\n _createClass(SampleRNNResults, [{\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n if (this.props.samplernn.loading) return (0, _preact.h)(_loading2.default, { progress: this.props.samplernn.progress });\n var _props$samplernn$data = this.props.samplernn.data,\n folderLookup = _props$samplernn$data.folderLookup,\n fileLookup = _props$samplernn$data.fileLookup,\n datasetLookup = _props$samplernn$data.datasetLookup;\n // const { folderLookup } = samplernn\n\n var renders = Object.keys(folderLookup).sort(_util2.default.sort.stringSort.asc).map(function (key) {\n var folder = folderLookup[key];\n\n var _util$sort$orderByFn = _util2.default.sort.orderByFn('epoch desc'),\n mapFn = _util$sort$orderByFn.mapFn,\n sortFn = _util$sort$orderByFn.sortFn;\n\n var datasetPairs = folder.datasets.map(function (name) {\n return datasetLookup[name];\n }).map(mapFn).sort(sortFn);\n var bestRenders = datasetPairs.map(function (pair) {\n return pair[1];\n }).filter(function (dataset) {\n return dataset.output.length;\n }).map(function (dataset) {\n var output = dataset.output;\n\n return output.map(function (id) {\n return fileLookup[id];\n }).map(mapFn).sort(sortFn)[0][1];\n });\n // console.log(bestRenders.map(r => r.epoch))\n var path = folder.name === 'unsorted' ? \"/samplernn/import/\" : \"/samplernn/datasets/\" + folder.id + \"/\";\n return (0, _preact.h)(\n 'div',\n { className: 'col bestRenders' },\n (0, _preact.h)(\n 'h3',\n null,\n (0, _preact.h)(\n _reactRouterDom.Link,\n { to: path },\n folder.name\n )\n ),\n (0, _preact.h)(_fileList.FileList, {\n linkFiles: true,\n files: bestRenders,\n orderBy: 'date desc',\n fields: 'name date epoch size',\n onClick: function onClick(file, e) {\n e.preventDefault();\n e.stopPropagation();\n console.log('picked a file', file);\n _this2.handlePick(file);\n }\n })\n );\n });\n\n return (0, _preact.h)(\n 'div',\n { className: 'app samplernn' },\n (0, _preact.h)(\n 'div',\n { className: 'heading row middle' },\n (0, _preact.h)(\n 'h1',\n null,\n 'SampleRNN Results'\n )\n ),\n (0, _preact.h)(\n 'div',\n { 'class': 'rows params renders' },\n renders\n )\n );\n }\n }, {\n key: 'handlePick',\n value: function handlePick(file) {\n this.props.audioPlayer.play(file);\n }\n }]);\n\n return SampleRNNResults;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n samplernn: state.module.samplernn\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch),\n audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNResults);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _util = require('../../../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _samplernn = require('../samplernn.actions');\n\nvar samplernnActions = _interopRequireWildcard(_samplernn);\n\nvar _samplernn2 = require('../samplernn.tasks');\n\nvar samplernnTasks = _interopRequireWildcard(_samplernn2);\n\nvar _audioPlayer = require('../../../common/audioPlayer/audioPlayer.actions');\n\nvar audioPlayerActions = _interopRequireWildcard(_audioPlayer);\n\nvar _common = require('../../../common');\n\nvar _dataset = require('../../../dataset/dataset.form');\n\nvar _dataset2 = _interopRequireDefault(_dataset);\n\nvar _upload = require('../../../dataset/upload.status');\n\nvar _upload2 = _interopRequireDefault(_upload);\n\nvar _dataset3 = require('../../../dataset/dataset.component');\n\nvar _dataset4 = _interopRequireDefault(_dataset3);\n\nvar _samplernn3 = require('../samplernn.module');\n\nvar _samplernn4 = _interopRequireDefault(_samplernn3);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar SampleRNNShow = function (_Component) {\n _inherits(SampleRNNShow, _Component);\n\n function SampleRNNShow(props) {\n _classCallCheck(this, SampleRNNShow);\n\n var _this = _possibleConstructorReturn(this, (SampleRNNShow.__proto__ || Object.getPrototypeOf(SampleRNNShow)).call(this, props));\n\n _this.datasetActions = _this.datasetActions.bind(_this);\n return _this;\n }\n\n _createClass(SampleRNNShow, [{\n key: 'componentWillMount',\n value: function componentWillMount() {\n var id = this.props.match.params.id || localStorage.getItem('samplernn.last_id');\n console.log('load dataset:', id);\n var _props = this.props,\n match = _props.match,\n samplernn = _props.samplernn,\n actions = _props.actions;\n\n if (id === 'new') return;\n if (id) {\n if (parseInt(id)) localStorage.setItem('samplernn.last_id', id);\n if (!samplernn.folder || samplernn.folder.id !== id) {\n // console.log('looooooooooad', id)\n actions.load_directories(id);\n }\n } else {\n this.props.history.push('/samplernn/new/');\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n var _props2 = this.props,\n samplernn = _props2.samplernn,\n runner = _props2.runner,\n match = _props2.match,\n history = _props2.history;\n\n var _ref = samplernn.data || {},\n folderLookup = _ref.folderLookup;\n // console.log(runner)\n\n\n var folder = (folderLookup || {})[samplernn.folder_id] || {};\n return (0, _preact.h)(\n 'div',\n { className: 'app samplernn' },\n (0, _preact.h)(\n 'div',\n { className: 'heading' },\n (0, _preact.h)(\n 'h1',\n null,\n folder ? folder.name : (0, _preact.h)(_common.Loading, null)\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'row' },\n folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, {\n title: 'Add Files',\n module: _samplernn4.default,\n folder: folder,\n canUpload: true, canAddURL: true\n }),\n (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(_upload2.default, null),\n (0, _preact.h)(_common.CurrentTask, { processor: 'gpu' })\n )\n ),\n (0, _preact.h)(_dataset4.default, {\n loading: samplernn.loading,\n progress: samplernn.progress,\n id: samplernn.folder_id,\n module: _samplernn4.default,\n data: samplernn.data,\n folder: folder,\n history: history,\n onPickFile: function onPickFile(file, e) {\n e.preventDefault();\n e.stopPropagation();\n // console.log('picked a file', file)\n _this2.handlePick(file);\n },\n datasetActions: this.datasetActions\n })\n );\n }\n }, {\n key: 'datasetActions',\n value: function datasetActions(dataset) {\n var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n var _props3 = this.props,\n samplernn = _props3.samplernn,\n remote = _props3.remote;\n\n var input = samplernn.data.fileLookup[dataset.input[0]];\n if (!input) return null;\n if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null;\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n 'div',\n { 'class': 'actions' },\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, samplernn.folder_id, 1);\n } },\n 'train'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, samplernn.folder_id, 2);\n } },\n '2x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, samplernn.folder_id, 4);\n } },\n '4x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, samplernn.folder_id, 6);\n } },\n '6x'\n ),\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.train_task(dataset, samplernn.folder_id, 18);\n } },\n '18x'\n )\n ),\n dataset.isBuilt ? (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n 'fetched ',\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.clear_cache_task(dataset);\n } },\n 'x'\n )\n ) : isFetching ? (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n 'fetching'\n ) : (0, _preact.h)(\n 'div',\n { 'class': 'subtext' },\n (0, _preact.h)(\n 'span',\n { 'class': 'link', onClick: function onClick() {\n return remote.fetch_task(input.url, samplernn.folder_id, input.id, dataset.name);\n } },\n 'fetch'\n )\n )\n );\n }\n }, {\n key: 'handlePick',\n value: function handlePick(file) {\n // console.log(file)\n this.props.audioPlayer.play(file);\n }\n }]);\n\n return SampleRNNShow;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return {\n samplernn: state.module.samplernn,\n runner: state.system.runner\n };\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch),\n remote: (0, _redux.bindActionCreators)(samplernnTasks, dispatch),\n audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch)\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNShow);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.stop_queue = exports.start_queue = exports.add_task = exports.stop_task = exports.start_task = undefined;\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\nvar _socket = require('../socket');\n\nvar _socket2 = _interopRequireDefault(_socket);\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _actions = require('../actions');\n\nvar _actions2 = _interopRequireDefault(_actions);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar start_task = exports.start_task = function start_task(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _socket2.default.task.start_task(task, opt);\n return _extends({ type: _types2.default.task.starting_task, task: task }, opt);\n};\n\nvar stop_task = exports.stop_task = function stop_task(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _socket2.default.task.stop_task(task, opt);\n return _extends({ type: _types2.default.task.stopping_task, task: task }, opt);\n};\n\nvar add_task = exports.add_task = function add_task(new_task) {\n return function (dispatch) {\n _actions2.default.task.create(new_task).then(function (task) {\n _socket2.default.task.add_task(task);\n });\n };\n};\n\nvar start_queue = exports.start_queue = function start_queue(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _socket2.default.task.start_queue(task, opt);\n return _extends({ type: _types2.default.task.starting_queue, task: task }, opt);\n};\n\nvar stop_queue = exports.stop_queue = function stop_queue(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _socket2.default.task.stop_queue(task, opt);\n return _extends({ type: _types2.default.task.stopping_queue, task: task }, opt);\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _util = require('../util');\n\nvar _util2 = _interopRequireDefault(_util);\n\nvar _moment = require('moment/min/moment.min');\n\nvar _moment2 = _interopRequireDefault(_moment);\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\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar queueInitialState = {\n loading: false,\n error: null,\n tasks: {},\n queue: [],\n completed: []\n};\n\nvar dateSort = _util2.default.sort.orderByFn('updated_at desc');\nvar prioritySort = _util2.default.sort.orderByFn('priority asc');\n\nvar queueReducer = function queueReducer() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : queueInitialState;\n var action = arguments[1];\n\n switch (action.type) {\n case _types2.default.task.index:\n return _extends({}, state, {\n tasks: action.data.reduce(function (a, b) {\n return a[b.id] = b, a;\n }, {}),\n queue: action.data.filter(function (a) {\n return !a.completed;\n }).map(dateSort.mapFn).sort(dateSort.sortFn).map(function (pair) {\n return pair[1].id;\n }),\n completed: action.data.filter(function (a) {\n return a.completed;\n }).map(prioritySort.mapFn).sort(prioritySort.sortFn).map(function (pair) {\n return pair[1].id;\n })\n });\n case _types2.default.task.create:\n console.log(action.data);\n return _extends({}, state, {\n tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data)),\n queue: state.queue.concat([action.data.id])\n });\n case _types2.default.task.update:\n return _extends({}, state, {\n tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data))\n });\n case _types2.default.task.destroy:\n var _state$tasks = state.tasks,\n deletedTask = _state$tasks[action.data.id],\n taskLookup = _objectWithoutProperties(_state$tasks, [action.data.id]);\n\n return _extends({}, state, {\n queue: state.queue.filter(function (id) {\n return id !== deletedTask.id;\n }),\n completed: state.completed.filter(function (id) {\n return id !== deletedTask.id;\n }),\n tasks: taskLookup\n });\n case _types2.default.task.task_finish:\n return _extends({}, state, {\n queue: state.queue.filter(function (a) {\n return a !== action.task.id;\n }),\n completed: [action.task.id].concat(state.completed)\n });\n default:\n return state;\n }\n};\n\nexports.default = queueReducer;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _store = require('../store');\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _socket = require('./socket.connection');\n\nvar _socket2 = require('./socket.actions');\n\nvar actions = _interopRequireWildcard(_socket2);\n\nvar _socket3 = require('./socket.system');\n\nvar system = _interopRequireWildcard(_socket3);\n\nvar _socket4 = require('./socket.live');\n\nvar live = _interopRequireWildcard(_socket4);\n\nvar _socket5 = require('./socket.task');\n\nvar task = _interopRequireWildcard(_socket5);\n\nvar _socket6 = require('./socket.api');\n\nvar api = _interopRequireWildcard(_socket6);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.default = {\n socket: _socket.socket,\n actions: actions,\n system: system,\n live: live,\n task: task,\n api: api\n};\n\n\n_socket.socket.on('status', function (data) {\n console.log('got status', data.key, data.value);\n _store.store.dispatch(_extends({ type: _types2.default.socket.status }, data));\n switch (data.key) {\n case 'processing':\n _store.store.dispatch(_extends({\n type: 'SET_PARAM'\n }, data));\n break;\n default:\n break;\n }\n});","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.syscall_async = exports.upload_file = exports.run_script = exports.list_sequences = exports.count_directory = exports.list_directory = exports.disk_usage = exports.run_system_command = undefined;\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\nvar _v = require('uuid/v1');\n\nvar _v2 = _interopRequireDefault(_v);\n\nvar _socket = require('./socket.connection');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar run_system_command = exports.run_system_command = function run_system_command(opt) {\n return syscall_async('run_system_command', opt);\n};\nvar disk_usage = exports.disk_usage = function disk_usage(opt) {\n return syscall_async('run_system_command', _extends({ cmd: 'du' }, opt));\n};\nvar list_directory = exports.list_directory = function list_directory(opt) {\n return syscall_async('list_directory', opt).then(function (res) {\n return res.files;\n });\n};\nvar count_directory = exports.count_directory = function count_directory(opt) {\n return syscall_async('count_directory', opt).then(function (res) {\n return res.count;\n });\n};\nvar list_sequences = exports.list_sequences = function list_sequences(opt) {\n return syscall_async('list_sequences', opt).then(function (res) {\n return res.sequences;\n });\n};\nvar run_script = exports.run_script = function run_script(opt) {\n return syscall_async('run_script', opt);\n};\nvar upload_file = exports.upload_file = function upload_file(opt) {\n return syscall_async('upload_file', opt);\n};\n\nvar syscall_async = exports.syscall_async = function syscall_async(tag, payload) {\n var ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000;\n\n ttl = payload.ttl || ttl;\n return new Promise(function (resolve, reject) {\n var uuid = (0, _v2.default)();\n var timeout = setTimeout(function () {\n _socket.socket.off('system_res', cb);\n reject('timeout');\n }, ttl);\n var cb = function cb(data) {\n if (!data.uuid) return;\n if (data.uuid === uuid) {\n clearTimeout(timeout);\n _socket.socket.off('system_res', cb);\n resolve(data);\n }\n };\n _socket.socket.emit('system', { cmd: tag, payload: payload, uuid: uuid });\n _socket.socket.on('system_res', cb);\n });\n};","'use strict';\n\nvar _store = require('../store');\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _socket = require('./socket.connection');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n_socket.socket.on('api_res', function (data) {\n // console.log('system response', data)\n data = parse(data);\n var type = _types2.default[data.datatype];\n console.log('api_res', data.type, data.datatype);\n if (!type) return console.error('socket:api_res bad datatype', data.datatype);\n switch (data.type) {\n case 'create':\n return (0, _store.dispatch)({\n type: type.create,\n source: 'socket',\n data: data.data\n });\n case 'update':\n return (0, _store.dispatch)({\n type: type.update,\n source: 'socket',\n data: data.data\n });\n case 'destroy':\n return (0, _store.dispatch)({\n type: type.destroy,\n source: 'socket',\n data: data.data\n });\n default:\n break;\n }\n});\n\nfunction parse(s) {\n if (typeof s === 'string') {\n try {\n var d = JSON.parse(s);\n return d;\n } catch (e) {\n console.error('not valid json');\n return s;\n }\n }\n return s;\n}","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.socket = undefined;\n\nvar _store = require('../store');\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar socket = exports.socket = io.connect('/client');\n\n// SOCKET ACTIONS\n\nsocket.on('connect', function () {\n return _store.store.dispatch({ type: _types2.default.socket.connect });\n});\nsocket.on('connect_error', function (error) {\n return _store.store.dispatch({ type: _types2.default.socket.connect_error, error: error });\n});\nsocket.on('reconnect', function (attempt) {\n return _store.store.dispatch({ type: _types2.default.socket.reconnect, attempt: attempt });\n});\nsocket.on('reconnecting', function () {\n return _store.store.dispatch({ type: _types2.default.socket.reconnecting });\n});\nsocket.on('reconnect_error', function (error) {\n return _store.store.dispatch({ type: _types2.default.socket.reconnect_error, error: error });\n});\nsocket.on('reconnect_failed', function (error) {\n return _store.store.dispatch({ type: _types2.default.socket.reconnect_failed, error: error });\n});\nsocket.on('disconnect', function () {\n return _store.store.dispatch({ type: _types2.default.socket.disconnect });\n});\nsocket.on('error', function (error) {\n return _store.store.dispatch({ type: _types2.default.socket.error, error: error });\n});","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.list_checkpoints = list_checkpoints;\nexports.list_all_checkpoints = list_all_checkpoints;\nexports.list_epochs = list_epochs;\nexports.list_sequences = list_sequences;\nexports.load_epoch = load_epoch;\nexports.load_sequence = load_sequence;\nexports.seek = seek;\nexports.pause = pause;\nexports.play = play;\nexports.get_params = get_params;\nexports.set_param = set_param;\n\nvar _store = require('../store');\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _player = require('../live/player');\n\nvar player = _interopRequireWildcard(_player);\n\nvar _socket = require('./socket.connection');\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n_socket.socket.on('res', function (data) {\n // console.log('socket:', data.cmd)\n switch (data.cmd) {\n case 'get_last_frame':\n if (data.res !== 'working') {\n _socket.socket.emit('cmd', {\n cmd: 'get_last_frame'\n });\n }\n break;\n case 'get_params':\n data.res && (0, _store.dispatch)({\n type: _types2.default.socket.load_params,\n opt: data.res\n });\n data.res && player.toggleFPS(data.res.processing);\n break;\n case 'list_checkpoints':\n (0, _store.dispatch)({\n type: _types2.default.socket.list_checkpoints,\n checkpoints: data.res\n });\n break;\n case 'list_all_checkpoints':\n (0, _store.dispatch)({\n type: _types2.default.socket.list_all_checkpoints,\n checkpoints: data.res\n });\n break;\n case 'list_epochs':\n (0, _store.dispatch)({\n type: _types2.default.socket.list_epochs,\n epochs: data.res\n });\n break;\n case 'list_sequences':\n (0, _store.dispatch)({\n type: _types2.default.socket.list_sequences,\n sequences: data.res\n });\n break;\n default:\n break;\n }\n // console.log(data)\n});\n\n_socket.socket.on('frame', player.onFrame);\n\nfunction list_checkpoints(module) {\n _socket.socket.emit('cmd', {\n cmd: 'list_checkpoints',\n payload: module\n });\n}\nfunction list_all_checkpoints(module) {\n _socket.socket.emit('cmd', {\n cmd: 'list_all_checkpoints',\n payload: module\n });\n}\nfunction list_epochs(module, checkpoint_name) {\n _socket.socket.emit('cmd', {\n cmd: 'list_epochs',\n payload: module === 'pix2pix' || module === 'pix2wav' ? module + '/' + checkpoint_name : checkpoint_name\n });\n}\nfunction list_sequences(module) {\n _socket.socket.emit('cmd', {\n cmd: 'list_sequences',\n payload: module\n });\n}\nfunction load_epoch(checkpoint_name, epoch) {\n console.log(\">> SWITCH CHECKPOINT\", checkpoint_name, epoch);\n _socket.socket.emit('cmd', {\n cmd: 'load_epoch',\n payload: checkpoint_name + ':' + epoch\n });\n}\nfunction load_sequence(sequence) {\n _socket.socket.emit('cmd', {\n cmd: 'load_sequence',\n payload: sequence\n });\n}\nfunction seek(frame) {\n _socket.socket.emit('cmd', {\n cmd: 'seek',\n payload: frame\n });\n}\nfunction pause(frame) {\n _socket.socket.emit('cmd', {\n cmd: 'pause'\n });\n}\nfunction play(frame) {\n _socket.socket.emit('cmd', {\n cmd: 'play'\n });\n}\nfunction get_params() {\n _socket.socket.emit('cmd', {\n cmd: 'get_params'\n });\n}\nfunction set_param(key, value) {\n _socket.socket.emit('cmd', {\n cmd: 'set_param',\n payload: {\n 'key': key,\n 'value': value\n }\n });\n}","'use strict';\n\nvar _store = require('../store');\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _socket = require('./socket.connection');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n_socket.socket.on('system_res', function (data) {\n // console.log('system response', data)\n switch (data.type) {\n case 'relay_connected':\n return (0, _store.dispatch)({\n type: _types2.default.system.relay_connected\n });\n case 'relay_disconnected':\n return (0, _store.dispatch)({\n type: _types2.default.system.relay_disconnected\n });\n case 'rpc_connected':\n return (0, _store.dispatch)({\n type: _types2.default.system.rpc_connected,\n runner: data.runner\n });\n case 'rpc_disconnected':\n return (0, _store.dispatch)({\n type: _types2.default.system.rpc_disconnected\n });\n case 'relay_status':\n return (0, _store.dispatch)({\n type: data.rpc_connected ? _types2.default.system.rpc_connected : _types2.default.system.rpc_disconnected,\n runner: data.runner\n });\n case 'site':\n return (0, _store.dispatch)({\n type: _types2.default.system.load_site,\n site: data.site\n });\n default:\n break;\n }\n});","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.stop_queue = exports.start_queue = exports.stop_task = exports.start_task = exports.remove_task = exports.add_task = undefined;\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\nexports.emit = emit;\n\nvar _store = require('../store');\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _socket = require('./socket.connection');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar finishTimeout = void 0;\n\n_socket.socket.on('task_res', function (raw_data) {\n // does not like the nested task object for some reason..\n var data = void 0;\n try {\n if (typeof raw_data === 'string') {\n data = JSON.parse(raw_data);\n if (typeof data === 'string') {\n data = JSON.parse(data);\n }\n } else {\n data = raw_data;\n }\n } catch (e) {\n console.warn('problem with json', e);\n return;\n }\n if (data.task) {\n (0, _store.dispatch)({ type: _types2.default.task.update, data: data.task });\n }\n // console.log('task', data.type)\n switch (data.type) {\n case 'start':\n // return dispatch({ type: types.system.rpc_connected, runner: data.runner })\n break;\n case 'stop':\n break;\n // begin and finish calls often arrive out of order, if the old task was preempted\n case 'task_begin':\n (0, _store.dispatch)({ type: _types2.default.task.task_begin, task: data.task });\n break;\n case 'task_finish':\n (0, _store.dispatch)({ type: _types2.default.task.task_finish, task: data.task });\n break;\n case 'kill':\n break;\n case 'stdout':\n return (0, _store.dispatch)({ type: _types2.default.system.stdout, data: data });\n break;\n case 'stderr':\n return (0, _store.dispatch)({ type: _types2.default.system.stderr, data: data });\n break;\n case 'add':\n break;\n case 'remove':\n break;\n case 'start_queue':\n break;\n case 'stop_queue':\n break;\n case 'list':\n break;\n case 'set_priority':\n break;\n case 'progress':\n (0, _store.dispatch)({ type: _types2.default.task.progress, task: data.task });\n break;\n case 'epoch':\n (0, _store.dispatch)({ type: _types2.default.task.epoch, task: data.task });\n break;\n case 'task_error':\n return console.log('task error', data);\n default:\n console.log(data);\n return console.log('no such task command', data.type);\n }\n});\n\nfunction emit(type) {\n var task = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n _socket.socket.emit('task', _extends({ type: type, task: task }, opt));\n}\n\nvar add_task = exports.add_task = function add_task(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return emit('add', task, opt);\n};\nvar remove_task = exports.remove_task = function remove_task(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return emit('remove', task, opt);\n};\nvar start_task = exports.start_task = function start_task(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return emit('start', task, opt);\n};\nvar stop_task = exports.stop_task = function stop_task(task) {\n var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return emit('stop', task, opt);\n};\nvar start_queue = exports.start_queue = function start_queue() {\n var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return emit('start_queue', {}, opt);\n};\nvar stop_queue = exports.stop_queue = function stop_queue() {\n var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return emit('stop_queue', {}, opt);\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.dispatch = exports.store = exports.history = undefined;\n\nvar _redux = require('redux');\n\nvar _reactRouterRedux = require('react-router-redux');\n\nvar _reduxThunk = require('redux-thunk');\n\nvar _reduxThunk2 = _interopRequireDefault(_reduxThunk);\n\nvar _createBrowserHistory = require('history/createBrowserHistory');\n\nvar _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory);\n\nvar _system = require('./system/system.reducer');\n\nvar _system2 = _interopRequireDefault(_system);\n\nvar _dashboard = require('./dashboard/dashboard.reducer');\n\nvar _dashboard2 = _interopRequireDefault(_dashboard);\n\nvar _live = require('./live/live.reducer');\n\nvar _live2 = _interopRequireDefault(_live);\n\nvar _upload = require('./dataset/upload.reducer');\n\nvar _upload2 = _interopRequireDefault(_upload);\n\nvar _queue = require('./queue/queue.reducer');\n\nvar _queue2 = _interopRequireDefault(_queue);\n\nvar _audioPlayer = require('./common/audioPlayer/audioPlayer.reducer');\n\nvar _audioPlayer2 = _interopRequireDefault(_audioPlayer);\n\nvar _module = require('./modules/module.reducer');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar appReducer = (0, _redux.combineReducers)({\n system: _system2.default,\n dashboard: _dashboard2.default,\n live: _live2.default,\n upload: _upload2.default,\n queue: _queue2.default,\n router: _reactRouterRedux.routerReducer,\n module: _module.moduleReducer,\n audioPlayer: _audioPlayer2.default\n});\n\n// import navReducer from './nav.reducer'\nvar history = exports.history = (0, _createBrowserHistory2.default)();\nvar store = exports.store = (0, _redux.createStore)(appReducer, (0, _redux.compose)((0, _redux.applyMiddleware)(\n// createLogger(),\n_reduxThunk2.default, (0, _reactRouterRedux.routerMiddleware)(history))));\n\nvar dispatch = exports.dispatch = store.dispatch;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.enqueue_test_task = exports.changeTool = exports.countDirectory = exports.listDirectory = exports.run = undefined;\n\nvar _socket = require('../socket');\n\nvar _socket2 = _interopRequireDefault(_socket);\n\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// import actions from '../actions'\n\nvar run = exports.run = function run(cmd) {\n return function (dispatch) {\n dispatch({ type: _types2.default.system.running_command, cmd: cmd });\n _socket2.default.actions.run_system_command({ cmd: cmd }).then(function (data) {\n dispatch({\n type: _types2.default.system.command_output,\n data: data\n });\n });\n };\n};\n\nvar listDirectory = exports.listDirectory = function listDirectory(opt) {\n return function (dispatch) {\n dispatch({ type: _types2.default.system.listing_directory, opt: opt });\n _socket2.default.actions.list_directory(opt).then(function (data) {\n dispatch({\n type: _types2.default.system.list_directory,\n data: data\n });\n });\n };\n};\n\nvar countDirectory = exports.countDirectory = function countDirectory(opt) {\n return function (dispatch) {\n dispatch({ type: _types2.default.system.counting_directory, opt: opt });\n _socket2.default.actions.count_directory(opt).then(function (data) {\n dispatch({\n type: _types2.default.system.count_directory,\n data: data\n });\n });\n };\n};\n\nvar changeTool = exports.changeTool = function changeTool(tool) {\n localStorage.setItem('system.last_tool', tool);\n return { type: _types2.default.app.change_tool, tool: tool };\n};\n\nvar enqueue_test_task = exports.enqueue_test_task = function enqueue_test_task(dataset) {\n return function (dispatch) {\n var task = {\n module: 'test',\n activity: 'cpu',\n dataset: dataset\n // return actions.queue.add_task(task)\n };\n };\n};\n\nwindow.addEventListener('keyDown', function (e) {\n if (e.altKey) {\n switch (e.keyCode) {\n case 192:\n // tilde - switch tool\n break;\n case 49:\n // 1\n break;\n case 50:\n // 2\n break;\n case 51:\n // 3\n break;\n case 52:\n // 4\n break;\n case 53:\n // 5\n break;\n case 54:\n // 6\n break;\n case 55:\n // 7\n break;\n case 56:\n // 8\n break;\n case 57:\n // 9\n break;\n case 48:\n // 0\n break;\n }\n }\n});","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _preact = require('preact');\n\nvar _redux = require('redux');\n\nvar _reactRedux = require('react-redux');\n\nvar _group = require('../common/group.component');\n\nvar _group2 = _interopRequireDefault(_group);\n\nvar _param = require('../common/param.component');\n\nvar _param2 = _interopRequireDefault(_param);\n\nvar _system = require('./system.actions');\n\nvar systemActions = _interopRequireWildcard(_system);\n\nvar _live = require('../live/live.actions');\n\nvar liveActions = _interopRequireWildcard(_live);\n\nvar _queue = require('../queue/queue.actions');\n\nvar queueActions = _interopRequireWildcard(_queue);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar cpu_test_task = {\n activity: 'cpu',\n module: 'test',\n dataset: 'test',\n epochs: 1,\n opt: {}\n};\nvar gpu_test_task = {\n activity: 'gpu',\n module: 'test',\n dataset: 'test',\n epochs: 1,\n opt: {}\n};\nvar live_test_task = {\n activity: 'live',\n module: 'test',\n dataset: 'test',\n epochs: 1,\n opt: {}\n};\nvar wait_test_task = {\n activity: 'wait',\n module: 'test',\n dataset: 'test',\n epochs: 1,\n opt: {}\n};\nvar fruits = [\"apple\", \"pear\", \"orange\", \"strawberry\"];\nfunction choice(a) {\n return a[Math.floor(Math.random() * a.length)];\n}\n\nvar System = function (_Component) {\n _inherits(System, _Component);\n\n function System(props) {\n _classCallCheck(this, System);\n\n return _possibleConstructorReturn(this, (System.__proto__ || Object.getPrototypeOf(System)).call(this));\n }\n\n _createClass(System, [{\n key: 'componentDidUpdate',\n value: function componentDidUpdate() {\n if (this._screen.scrollHeight > this._screen.scrollTop - this._screen.offsetHeight + 100) {\n this._screen.scrollTop = this._screen.scrollHeight;\n }\n }\n }, {\n key: 'render',\n value: function render() {\n var _props = this.props,\n site = _props.site,\n server = _props.server,\n relay = _props.relay,\n runner = _props.runner,\n rpc = _props.rpc,\n actions = _props.actions;\n\n return (0, _preact.h)(\n 'div',\n { className: 'app system' },\n (0, _preact.h)(\n 'div',\n { className: 'heading' },\n (0, _preact.h)(\n 'h1',\n null,\n site.name,\n ' system'\n )\n ),\n (0, _preact.h)(\n 'div',\n { className: 'row params' },\n (0, _preact.h)(\n 'div',\n { className: 'column' },\n (0, _preact.h)(\n _group2.default,\n { title: 'Status' },\n (0, _preact.h)(\n _param2.default,\n { title: 'Server' },\n server.status\n ),\n server.error && (0, _preact.h)(\n _param2.default,\n { title: 'Server error' },\n server.error.message\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'Relay' },\n relay.status\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'RPC' },\n rpc.status\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'CPU' },\n this.renderStatus(runner.cpu)\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'GPU' },\n this.renderStatus(runner.gpu)\n )\n ),\n (0, _preact.h)(\n _group2.default,\n { title: 'Diagnostics' },\n (0, _preact.h)(\n _param2.default,\n { title: 'Check GPU' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.system.run('nvidia-smi');\n } },\n 'nvidia-smi'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'List processes' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.system.run('ps');\n } },\n 'ps'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'List users' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.system.run('w');\n } },\n 'w'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'Disk free space' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.system.run('df');\n } },\n 'df'\n )\n )\n ),\n (0, _preact.h)(\n _group2.default,\n { title: 'Tasks' },\n (0, _preact.h)(\n _param2.default,\n { title: 'Kill task' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.stop_task('cpu');\n } },\n 'CPU'\n ),\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.stop_task('gpu');\n } },\n 'GPU'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'Queue' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.start_queue();\n } },\n 'Start'\n ),\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.stop_queue();\n } },\n 'Stop'\n )\n )\n ),\n (0, _preact.h)(\n _group2.default,\n { title: 'Test' },\n (0, _preact.h)(\n _param2.default,\n { title: 'CPU Test Task' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.start_task(cpu_test_task, { preempt: true, watch: true });\n } },\n 'Start'\n ),\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.stop_task(runner.cpu.task);\n } },\n 'Stop'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'GPU Test Task' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.start_task(gpu_test_task, { preempt: true, watch: true });\n } },\n 'Start'\n ),\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.stop_task(runner.gpu.task);\n } },\n 'Stop'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'Live Test Task' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.start_task(live_test_task, { preempt: true, watch: true });\n } },\n 'Start'\n ),\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.stop_task(runner.cpu.task);\n } },\n 'Stop'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'Test Live RPC' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.live.get_params();\n } },\n 'Get'\n ),\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.live.set_param('fruit', choice(fruits));\n } },\n 'Set'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: 'Queue Tests' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.system.enqueue_test_task(choice(fruits));\n } },\n '+Add test task'\n )\n ),\n (0, _preact.h)(\n _param2.default,\n { title: '' },\n (0, _preact.h)(\n 'button',\n { onClick: function onClick() {\n return actions.queue.start_task(wait_test_task, { preempt: true, watch: true });\n } },\n 'Wait and Buzz'\n )\n )\n )\n ),\n this.renderCommandOutput()\n )\n );\n }\n }, {\n key: 'renderStatus',\n value: function renderStatus(processor) {\n if (!processor) {\n return 'unknown';\n }\n if (processor.status === 'IDLE') {\n return 'idle';\n }\n var task = processor.task;\n return task.activity + ' ' + task.module;\n }\n }, {\n key: 'renderCommandOutput',\n value: function renderCommandOutput() {\n var _this2 = this;\n\n var _props2 = this.props,\n cmd = _props2.cmd,\n stdout = _props2.stdout,\n stderr = _props2.stderr;\n\n var output = void 0;\n if (cmd.loading) {\n output = 'Loading: ' + cmd.name;\n } else if (cmd.loaded) {\n if (cmd.error) {\n output = 'Error: ' + cmd.name + '\\n\\n' + JSON.stringify(cmd.error, null, 2);\n } else {\n output = cmd.stdout;\n if (cmd.stderr) {\n output += '\\n\\n_________________________________\\n\\n';\n output += cmd.stderr;\n }\n }\n } else {\n output = stdout;\n if (stderr.length) {\n output += '\\n\\n_________________________________\\n\\n';\n output += stderr;\n }\n }\n return (0, _preact.h)(\n 'div',\n null,\n (0, _preact.h)(\n 'div',\n { ref: function ref(_ref) {\n return _this2._screen = _ref;\n }, className: 'screen' },\n output\n )\n );\n }\n }]);\n\n return System;\n}(_preact.Component);\n\nvar mapStateToProps = function mapStateToProps(state) {\n return _extends({}, state.system, state.live);\n};\n\nvar mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {\n return {\n actions: {\n system: (0, _redux.bindActionCreators)(systemActions, dispatch),\n queue: (0, _redux.bindActionCreators)(queueActions, dispatch),\n live: (0, _redux.bindActionCreators)(liveActions, dispatch)\n }\n };\n};\n\nexports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(System);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _types = require('../types');\n\nvar _types2 = _interopRequireDefault(_types);\n\nvar _moment = require('moment/min/moment.min');\n\nvar _moment2 = _interopRequireDefault(_moment);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar FileSaver = require('file-saver');\n\nvar systemInitialState = {\n loading: false,\n error: null,\n\n site: {\n name: 'loading'\n },\n app: {\n tool: localStorage.getItem('system.last_tool') || 'pix2pix'\n },\n server: {\n connected: false,\n status: \"disconnected\",\n error: null\n },\n relay: {\n connected: false,\n status: \"unknown\",\n error: null\n },\n rpc: {\n connected: false,\n status: \"disconnected\",\n error: null\n },\n cmd: {\n loading: false,\n loaded: false,\n name: null,\n error: null,\n stdout: \"\",\n stderr: \"\"\n },\n runner: {\n cpu: { status: 'IDLE', task: {} },\n gpu: { status: 'IDLE', task: {} }\n },\n stdout: \"\",\n stderr: \"\"\n};\n\nvar modules = ['pix2pix', 'samplernn', 'pix2wav'].reduce(function (a, b) {\n return a[b] = b, a;\n}, {});\n\nvar systemReducer = function systemReducer() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : systemInitialState;\n var action = arguments[1];\n\n // console.log(action.type)\n var processor = null;\n switch (action.type) {\n case _types2.default.socket.connect:\n case _types2.default.socket.reconnecting:\n return _extends({}, state, {\n server: {\n status: 'connected',\n connected: true,\n error: null\n }\n });\n case _types2.default.socket.reconnect:\n return _extends({}, state, {\n server: {\n status: 'reconnecting (attempt ' + action.attempt + ')',\n connected: false,\n error: null\n }\n });\n case _types2.default.socket.connect_error:\n case _types2.default.socket.reconnect_error:\n case _types2.default.socket.disconnect:\n case _types2.default.socket.reconnect_failed:\n return _extends({}, state, {\n server: {\n status: 'disconnected',\n connected: false,\n error: action.error || null\n }\n });\n case _types2.default.socket.error:\n return _extends({}, state, {\n server: _extends({}, state.socket, {\n error: action.error\n })\n });\n case _types2.default.system.relay_connected:\n return _extends({}, state, {\n relay: {\n status: 'connected',\n connected: true,\n error: null\n }\n });\n case _types2.default.system.relay_disconnected:\n return _extends({}, state, {\n relay: {\n status: 'disconnected',\n connected: false,\n error: null\n },\n rpc: {\n status: 'disconnected',\n connected: false,\n error: null\n }\n });\n case _types2.default.system.rpc_connected:\n return _extends({}, state, {\n rpc: {\n status: 'connected',\n connected: true,\n error: null\n },\n runner: action.runner\n });\n case _types2.default.system.rpc_disconnected:\n return _extends({}, state, {\n rpc: {\n status: 'disconnected',\n connected: false,\n error: null\n },\n runner: action.runner || state.runner\n });\n case _types2.default.system.load_site:\n document.querySelector('title').innerHTML = action.site.name + '.cortex';\n var tool = state.app.tool;\n var path = window.location.pathname.split('/')[1];\n if (path in modules) {\n tool = path;\n }\n return _extends({}, state, {\n site: action.site,\n app: _extends({}, state.app, {\n tool: tool\n })\n });\n case _types2.default.system.running_command:\n return _extends({}, state, {\n cmd: {\n loading: true,\n loaded: false,\n name: action.cmd,\n error: null,\n stdout: null,\n stderr: null\n }\n });\n case _types2.default.system.command_output:\n return _extends({}, state, {\n cmd: {\n loading: false,\n loaded: true,\n name: action.data.cmd,\n error: action.data.error,\n stdout: action.data.stdout,\n stderr: action.data.stderr\n }\n });\n case _types2.default.task.task_begin:\n console.log('task begin', action.task, action.task.processor);\n return _extends({}, state, {\n runner: _extends({}, state.runner, _defineProperty({}, action.task.processor, { status: 'RUNNING', task: action.task })),\n cmd: _extends({}, state.cmd, {\n loaded: false,\n stdout: \"\",\n stderr: \"\"\n }),\n stdout: \"\",\n stderr: \"\"\n });\n case _types2.default.task.task_finish:\n if (action.task.processor === 'cpu' || state.runner.cpu.task && state.runner.cpu.task.uuid === action.task.uuid) {\n processor = 'cpu';\n } else if (action.task.processor === 'gpu' || state.runner.gpu.task && state.runner.gpu.task.uuid === action.task.uuid) {\n processor = 'gpu';\n } else {\n processor = null;\n }\n console.log('task finish', action);\n return _extends({}, state, {\n rpc: {\n connected: false,\n status: \"disconnected\",\n error: null\n },\n runner: processor ? _extends({}, state.runner, _defineProperty({}, processor, { status: 'IDLE', task: {} })) : state.runner\n });\n case _types2.default.app.change_tool:\n return _extends({}, state, {\n app: _extends({}, state.app, {\n tool: action.tool\n })\n });\n case _types2.default.system.stdout:\n if (action.data.processor && state.runner[action.data.processor]) {\n return _extends({}, state, {\n runner: _extends({}, state.runner, _defineProperty({}, action.data.processor, _extends({}, state.runner[action.data.processor], {\n last_message: action.data.data\n }))),\n stdout: state.stdout + action.data.data\n });\n }\n return _extends({}, state, {\n stdout: state.stdout + action.data.data\n });\n case _types2.default.system.stderr:\n return _extends({}, state, {\n last_message: action.data.data,\n stderr: state.stderr + action.data.data\n });\n default:\n return state;\n }\n};\n\nexports.default = systemReducer;","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _crud = require('./api/crud.types');\n\nexports.default = {\n\tsystem: {\n\t\tload_site: 'SYSTEM_LOAD_SITE',\n\t\trunning_command: 'SYSTEM_RUNNING_COMMAND',\n\t\tcommand_output: 'SYSTEM_COMMAND_OUTPUT',\n\t\trelay_connected: 'SYSTEM_RELAY_CONNECTED',\n\t\trelay_disconnected: 'SYSTEM_RELAY_DISCONNECTED',\n\t\trpc_connected: 'SYSTEM_RPC_CONNECTED',\n\t\trpc_disconnected: 'SYSTEM_RPC_DISCONNECTED',\n\t\tlist_directory: 'SYSTEM_LIST_DIRECTORY',\n\t\tlisting_directory: 'SYSTEM_LISTING_DIRECTORY',\n\t\tcount_directory: 'SYSTEM_COUNT_DIRECTORY',\n\t\tcounting_directory: 'SYSTEM_COUNTING_DIRECTORY',\n\t\tstdout: 'SYSTEM_STDOUT',\n\t\tstderr: 'SYSTEM_STDERR'\n\t},\n\tapp: {\n\t\tchange_tool: \"APP_CHANGE_TOOL\",\n\t\tload_progress: \"APP_LOAD_PROGRESS\"\n\t},\n\tfolder: (0, _crud.crud_type)('folder', []),\n\tfile: (0, _crud.crud_type)('file', []),\n\ttask: (0, _crud.crud_type)('task', ['starting_task', 'stopping_task', 'task_begin', 'task_finish', 'start_queue', 'stop_queue', 'starting_queue', 'stopping_queue', 'progress', 'epoch']),\n\tsocket: {\n\t\tconnect: 'SOCKET_CONNECT',\n\t\tconnect_error: 'SOCKET_CONNECT_ERROR',\n\t\treconnect: 'SOCKET_RECONNECT',\n\t\treconnecting: 'SOCKET_RECONNECTING',\n\t\treconnect_error: 'SOCKET_RECONNECT_ERROR',\n\t\treconnect_failed: 'SOCKET_RECONNECT_FAILED',\n\t\tdisconnect: 'SOCKET_DISCONNECT',\n\t\terror: 'SOCKET_ERROR',\n\t\tstatus: 'SOCKET_STATUS',\n\n\t\tload_params: 'SOCKET_LOAD_PARAMS',\n\t\tlist_checkpoints: 'SOCKET_LIST_CHECKPOINTS',\n\t\tlist_sequences: 'SOCKET_LIST_SEQUENCES',\n\t\tlist_epochs: 'SOCKET_LIST_EPOCHS'\n\t},\n\tplayer: {\n\t\tget_params: 'GET_PARAMS',\n\t\tset_param: 'SET_PARAM',\n\n\t\tloading_checkpoints: 'LOADING_CHECKPOINTS',\n\t\tloading_checkpoint: 'LOADING_CHECKPOINT',\n\t\tlist_checkpoints: 'LIST_CHECKPOINTS',\n\n\t\tloading_sequences: 'LOADING_SEQUENCES',\n\t\tloading_sequence: 'LOADING_SEQUENCE',\n\t\tload_sequence: 'LOAD_SEQUENCE',\n\n\t\tloading_epochs: 'LOADING_EPOCHS',\n\t\tload_epoch: 'LOAD_EPOCH',\n\n\t\tset_fps: 'SET_FPS',\n\t\tseeking: 'SEEKING',\n\t\tpausing: 'PAUSING',\n\t\tplaying: 'PLAYING',\n\t\tcurrent_frame: 'CURRENT_FRAME',\n\t\tstart_recording: 'START_RECORDING',\n\t\tadd_record_frame: 'ADD_RECORD_FRAME',\n\t\tsave_frame: 'SAVE_FRAME',\n\t\tsaving_video: 'SAVING_VIDEO',\n\t\tsave_video: 'SAVE_VIDEO',\n\n\t\tset_fullscreen: 'SET_FULLSCREEN'\n\t},\n\taudioPlayer: {\n\t\tplay: 'AUDIO_PLAY',\n\t\tpause: 'AUDIO_PAUSE',\n\t\tresume: 'AUDIO_RESUME',\n\t\tenqueue: 'AUDIO_ENQUEUE'\n\t},\n\tdataset: {\n\t\tload: 'DATASET_LOAD',\n\t\tset_folder: 'DATASET_SET_FOLDER',\n\t\tupload_files: 'DATASET_UPLOAD_FILES',\n\t\tfile_progress: 'DATASET_FILE_PROGRESS',\n\t\tfile_uploaded: 'DATASET_FILE_UPLOADED',\n\t\tfetch_url: 'DATASET_FETCH_URL',\n\t\tfetch_progress: 'DATASET_FETCH_PROGRESS',\n\t\tlist_epochs: 'DATASET_LIST_EPOCHS'\n\t},\n\tsamplernn: {\n\t\tinit: 'SAMPLERNN_INIT',\n\t\tset_folder: 'SAMPLERNN_SET_FOLDER',\n\t\tload_loss: 'SAMPLERNN_LOAD_LOSS',\n\t\tload_graph: 'SAMPLERNN_LOAD_GRAPH'\n\t\t// queue and train\n\t\t// update checkpoint settings\n\t\t// reset checkpoint settings\n\t\t// queue new checkpoint\n\t},\n\tpix2pix: (0, _crud.with_type)('pix2pix', ['init', 'set_folder']),\n\tpix2pixhd: (0, _crud.with_type)('pix2pixhd', ['init', 'set_folder', 'load_results']),\n\tpix2wav: (0, _crud.with_type)('pix2wav', ['init', 'set_folder']),\n\twav2pix: (0, _crud.with_type)('wav2pix', ['load', 'progress', 'finish', 'zip', 'uploading']),\n\tdashboard: (0, _crud.with_type)('dashboard', ['load']),\n\tmorph: (0, _crud.with_type)('morph', ['load'])\n};","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.timeInSeconds = timeInSeconds;\nexports.gerund = gerund;\nexports.commatize = commatize;\nexports.carbon_date = carbon_date;\nexports.hush_views = hush_views;\nexports.hush_threads = hush_threads;\nexports.hush_size = hush_size;\nexports.hush_null = hush_null;\nexports.get_age = get_age;\nexports.courtesy_s = courtesy_s;\nfunction timeInSeconds(n) {\n return (n / 10).toFixed(1) + ' s.';\n}\nfunction gerund(s) {\n return s.replace(/e?$/, 'ing');\n}\nfunction commatize(n, radix) {\n radix = radix || 1024;\n var nums = [],\n i,\n counter = 0,\n r = Math.floor;\n if (n > radix) {\n n /= radix;\n nums.unshift(r(n * 10 % 10));\n nums.unshift(\".\");\n }\n do {\n i = n % 10;\n n = r(n / 10);\n if (n && !(++counter % 3)) {\n i = ' ' + r(i);\n }\n nums.unshift(r(i));\n } while (n);\n return nums.join(\"\");\n}\nfunction carbon_date(date, no_bold) {\n var span = (+new Date() - new Date(date)) / 1000,\n color;\n if (!no_bold && span < 86400) // modified today\n {\n color = \"new\";\n } else if (span < 604800) // modifed this week\n {\n color = \"recent\";\n } else if (span < 1209600) // modifed 2 weeks ago\n {\n color = \"med\";\n } else if (span < 3024000) // modifed 5 weeks ago\n {\n color = \"old\";\n } else if (span < 12315200) // modifed 6 months ago\n {\n color = \"older\";\n } else {\n color = \"quiet\";\n }\n return color;\n}\nfunction hush_views(n, bias, no_bold) {\n var txt = commatize(n, 1000);\n bias = bias || 1;\n n = n || 0;\n if (n < 30) {\n return [\"quiet\", n + \" v.\"];\n }\n if (n < 200) {\n return [\"quiet\", txt + \" v.\"];\n } else if (n < 500) {\n return [\"quiet\", txt + \" v.\"];\n } else if (n < 1000) {\n return [\"old\", txt + \" v.\"];\n } else if (n < 5000) {\n return [\"med\", txt + \" kv.\"];\n } else if (no_bold || n < 10000) {\n return [\"recent\", txt + \" kv.\"];\n } else {\n return [\"new\", txt + \" kv.\"];\n }\n}\nfunction hush_threads(n, bias, no_bold) {\n var txt = commatize(n, 1000);\n bias = bias || 1;\n n = n || 0;\n if (n < 10) {\n return [\"quiet\", n + \" t.\"];\n } else if (n < 25) {\n return [\"old\", txt + \" t.\"];\n } else if (n < 50) {\n return [\"med\", txt + \" t.\"];\n } else if (no_bold || n < 100) {\n return [\"recent\", txt + \" t.\"];\n } else {\n return [\"new\", txt + \" t.\"];\n }\n}\nfunction hush_size(n, bias, no_bold) {\n var txt = commatize(Math.round(n / 1024));\n bias = 1 || bias;\n n = n || 0;\n if (!n) {\n return ['', ''];\n }\n if (n < 1000) {\n return [\"quiet\", n + \" b.\"];\n }\n if (n < 1000000) {\n return [\"quiet\", txt + \" kb.\"];\n } else if (n < 20000000 / bias) {\n return [\"quiet\", txt + \" mb.\"];\n } else if (n < 50000000 / bias) {\n return [\"old\", txt + \" mb.\"];\n } else if (n < 80000000 / bias) {\n return [\"med\", txt + \" mb.\"];\n } else if (no_bold || n < 170000000 / bias) {\n return [\"recent\", txt + \" mb.\"];\n } else {\n return [\"new\", txt + \" mb.\"];\n }\n}\nfunction hush_null(n, unit, no_bold) {\n var s = unit ? n + \" \" + unit + \".\" : n;\n if (n < 3) {\n return [\"quiet\", s];\n } else if (n < 6) {\n return [\"older\", s];\n } else if (n < 10) {\n return [\"old\", s];\n } else if (n < 16) {\n return [\"med\", s];\n } else if (no_bold || n < 21) {\n return [\"recent\", s];\n } else {\n return [\"new\", s];\n }\n}\nfunction get_age(t) {\n var age = Math.abs(+Date.now() - new Date(t)) / 1000;\n var r = Math.floor;\n var m;\n if (age < 5) {\n return \"now\";\n }\n if (age < 60) {\n return r(age) + \"s\";\n }\n age /= 60;\n if (age < 60) {\n return r(age) + \"m\";\n }\n m = r(age % 60);\n age /= 60;\n if (m > 0 && age < 2) {\n return r(age) + \"h\" + m + \"m\";\n }\n if (age < 24) {\n return r(age) + \"h\";\n }\n age /= 24;\n if (age < 7) {\n return r(age) + \"d\";\n }\n age /= 7;\n if (age < 12) {\n return r(age) + \"w\";\n }\n age /= 4;\n if (age < 12) {\n return r(age) + \"m\";\n }\n age /= 12;\n return r(age) + \"y\";\n}\nfunction courtesy_s(n, s) {\n return n == 1 ? \"\" : s || \"s\";\n}","'use strict';\n\n/**\n * HiDPI Canvas Polyfill (1.0.10)\n *\n * Author: Jonathan D. Johnson (http://jondavidjohn.com)\n * Homepage: https://github.com/jondavidjohn/hidpi-canvas-polyfill\n * Issue Tracker: https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues\n * License: Apache-2.0\n*/\n(function (prototype) {\n\n var pixelRatio = function () {\n var canvas = window.document.createElement('canvas'),\n context = canvas.getContext('2d'),\n backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;\n\n return (window.devicePixelRatio || 1) / backingStore;\n }(),\n forEach = function forEach(obj, func) {\n for (var p in obj) {\n if (obj.hasOwnProperty(p)) {\n func(obj[p], p);\n }\n }\n },\n ratioArgs = {\n 'fillRect': 'all',\n 'clearRect': 'all',\n 'strokeRect': 'all',\n 'moveTo': 'all',\n 'lineTo': 'all',\n 'arc': [0, 1, 2],\n 'arcTo': 'all',\n 'bezierCurveTo': 'all',\n 'isPointinPath': 'all',\n 'isPointinStroke': 'all',\n 'quadraticCurveTo': 'all',\n 'rect': 'all',\n 'translate': 'all',\n 'createRadialGradient': 'all',\n 'createLinearGradient': 'all'\n };\n\n if (pixelRatio === 1) return;\n\n forEach(ratioArgs, function (value, key) {\n prototype[key] = function (_super) {\n return function () {\n var i,\n len,\n args = Array.prototype.slice.call(arguments);\n\n if (value === 'all') {\n args = args.map(function (a) {\n return a * pixelRatio;\n });\n } else if (Array.isArray(value)) {\n for (i = 0, len = value.length; i < len; i++) {\n args[value[i]] *= pixelRatio;\n }\n }\n\n return _super.apply(this, args);\n };\n }(prototype[key]);\n });\n\n // Stroke lineWidth adjustment\n prototype.stroke = function (_super) {\n return function () {\n this.lineWidth *= pixelRatio;\n _super.apply(this, arguments);\n this.lineWidth /= pixelRatio;\n };\n }(prototype.stroke);\n\n // Text\n //\n prototype.fillText = function (_super) {\n return function () {\n var args = Array.prototype.slice.call(arguments);\n\n args[1] *= pixelRatio; // x\n args[2] *= pixelRatio; // y\n\n this.font = this.font.replace(/(\\d+)(px|em|rem|pt)/g, function (w, m, u) {\n return m * pixelRatio + u;\n });\n\n _super.apply(this, args);\n\n this.font = this.font.replace(/(\\d+)(px|em|rem|pt)/g, function (w, m, u) {\n return m / pixelRatio + u;\n });\n };\n }(prototype.fillText);\n\n prototype.strokeText = function (_super) {\n return function () {\n var args = Array.prototype.slice.call(arguments);\n\n args[1] *= pixelRatio; // x\n args[2] *= pixelRatio; // y\n\n this.font = this.font.replace(/(\\d+)(px|em|rem|pt)/g, function (w, m, u) {\n return m * pixelRatio + u;\n });\n\n _super.apply(this, args);\n\n this.font = this.font.replace(/(\\d+)(px|em|rem|pt)/g, function (w, m, u) {\n return m / pixelRatio + u;\n });\n };\n }(prototype.strokeText);\n})(window.CanvasRenderingContext2D.prototype);\n;(function (prototype) {\n prototype.getContext = function (_super) {\n return function (type) {\n var backingStore, ratio, context;\n\n if (type == '2d-lodpi') {\n context = _super.call(this, '2d');\n } else if (type === '2d') {\n context = _super.call(this, '2d');\n\n backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;\n\n ratio = (window.devicePixelRatio || 1) / backingStore;\n\n if (ratio > 1) {\n this.style.height = this.height + 'px';\n this.style.width = this.width + 'px';\n this.width *= ratio;\n this.height *= ratio;\n }\n } else {\n context = _super.call(this, type);\n }\n\n return context;\n };\n }(prototype.getContext);\n})(window.HTMLCanvasElement.prototype);","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\nvar _sort = require('./sort');\n\nvar sort = _interopRequireWildcard(_sort);\n\nvar _format = require('./format');\n\nvar format = _interopRequireWildcard(_format);\n\nvar _math = require('./math');\n\nvar maths = _interopRequireWildcard(_math);\n\nrequire('./hidpi-canvas');\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nvar is_iphone = !!(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i));\nvar is_ipad = !!navigator.userAgent.match(/iPad/i);\nvar is_android = !!navigator.userAgent.match(/Android/i);\nvar is_mobile = is_iphone || is_ipad || is_android;\nvar is_desktop = !is_mobile;\n\nvar htmlClassList = document.body.parentNode.classList;\nhtmlClassList.add(is_desktop ? 'desktop' : 'mobile');\nhtmlClassList.remove('loading');\n\n// window.debug = false\n\nvar allProgress = function allProgress(promises, progress_cb) {\n var d = 0;\n progress_cb(0, 0, promises.length);\n promises.forEach(function (p) {\n p.then(function (s) {\n d += 1;\n progress_cb(Math.floor(d * 100 / promises.length), d, promises.length);\n return s;\n });\n });\n return Promise.all(promises);\n};\n\ndocument.body.style.backgroundImage = 'linear-gradient(' + (maths.randint(40) + 40) + 'deg, #fde, #ffe)';\n\nvar fieldSet = function fieldSet(defaultFields) {\n return function (fields) {\n if (fields) {\n if (fields instanceof Set) {\n return fields;\n }\n return new Set(fields.split(' '));\n }\n return defaultFields;\n };\n};\n\nexports.default = _extends({}, maths, format, {\n sort: sort,\n allProgress: allProgress, fieldSet: fieldSet,\n is_iphone: is_iphone, is_ipad: is_ipad, is_android: is_android, is_mobile: is_mobile, is_desktop: is_desktop\n});","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.randrange = randrange;\nexports.randsign = randsign;\nexports.choice = choice;\nexports.angle = angle;\nexports.dist = dist;\nexports.xor = xor;\nexports.quantize = quantize;\nexports.shuffle = shuffle;\nexports.gaussian = gaussian;\nvar mod = exports.mod = function mod(n, m) {\n return n - m * Math.floor(n / m);\n};\nvar clamp = exports.clamp = function clamp(n, a, b) {\n return n < a ? a : n < b ? n : b;\n};\nvar norm = exports.norm = function norm(n, a, b) {\n return (n - a) / (b - a);\n};\nvar lerp = exports.lerp = function lerp(n, a, b) {\n return (b - a) * n + a;\n};\nvar mix = exports.mix = function mix(n, a, b) {\n return a * (1 - n) + b * n;\n};\nvar randint = exports.randint = function randint(n) {\n return Math.floor(Math.random() * n);\n};\nfunction randrange(a, b) {\n return Math.random() * (b - a) + a;\n}\nfunction randsign() {\n return Math.random() >= 0.5 ? -1 : 1;\n}\nfunction choice(a) {\n return a[Math.floor(Math.random() * a.length)];\n}\nfunction angle(x0, y0, x1, y1) {\n return Math.atan2(y1 - y0, x1 - x0);\n}\nfunction dist(x0, y0, x1, y1) {\n return Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2));\n}\nfunction xor(a, b) {\n a = !!a;b = !!b;return (a || b) && !(a && b);\n}\nfunction quantize(a, b) {\n return Math.floor(a / b) * b;\n}\nfunction shuffle(a) {\n for (var i = a.length; i > 0; i--) {\n var r = randint(i);\n var swap = a[i - 1];\n a[i - 1] = a[r];\n a[r] = swap;\n }\n return a;\n}\n// returns a gaussian random function with the given mean and stdev.\nfunction gaussian(mean, stdev) {\n var y2 = void 0;\n var use_last = false;\n return function () {\n var y1 = void 0;\n if (use_last) {\n y1 = y2;\n use_last = false;\n } else {\n var x1 = void 0,\n x2 = void 0,\n w = void 0;\n do {\n x1 = 2.0 * Math.random() - 1.0;\n x2 = 2.0 * Math.random() - 1.0;\n w = x1 * x1 + x2 * x2;\n } while (w >= 1.0);\n w = Math.sqrt(-2.0 * Math.log(w) / w);\n y1 = x1 * w;\n y2 = x2 * w;\n use_last = true;\n }\n\n var retval = mean + stdev * y1;\n if (retval > 0) return retval;\n return -retval;\n };\n}","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar numericSort = exports.numericSort = {\n asc: function asc(a, b) {\n return a[0] - b[0];\n },\n desc: function desc(a, b) {\n return b[0] - a[0];\n }\n};\nvar stringSort = exports.stringSort = {\n asc: function asc(a, b) {\n return a[0].localeCompare(b[0]);\n },\n desc: function desc(a, b) {\n return b[0].localeCompare(a[0]);\n }\n};\nvar orderByFn = exports.orderByFn = function orderByFn() {\n var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'name asc';\n\n var _s$split = s.split(' '),\n _s$split2 = _slicedToArray(_s$split, 2),\n _s$split2$ = _s$split2[0],\n field = _s$split2$ === undefined ? 'name' : _s$split2$,\n _s$split2$2 = _s$split2[1],\n direction = _s$split2$2 === undefined ? 'asc' : _s$split2$2;\n\n var mapFn = void 0,\n sortFn = void 0;\n switch (field) {\n case 'epoch':\n mapFn = function mapFn(a) {\n return [parseInt(a.epoch || a.epochs) || 0, a];\n };\n sortFn = numericSort[direction];\n break;\n case 'size':\n mapFn = function mapFn(a) {\n return [parseInt(a.size) || 0, a];\n };\n sortFn = numericSort[direction];\n break;\n case 'date':\n mapFn = function mapFn(a) {\n return [+new Date(a.date || a.created_at), a];\n };\n sortFn = numericSort[direction];\n break;\n case 'updated_at':\n mapFn = function mapFn(a) {\n return [+new Date(a.updated_at), a];\n };\n sortFn = numericSort[direction];\n break;\n case 'priority':\n mapFn = function mapFn(a) {\n return [parseInt(a.priority) || parseInt(a.id) || 1000, a];\n };\n sortFn = numericSort[direction];\n case 'name':\n default:\n mapFn = function mapFn(a) {\n return [a.name || \"\", a];\n };\n sortFn = stringSort[direction];\n break;\n }\n return { mapFn: mapFn, sortFn: sortFn };\n};","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n for (var i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfunction EventEmitter() {\n this._events = this._events || {};\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nEventEmitter.defaultMaxListeners = 10;\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!isNumber(n) || n < 0 || isNaN(n))\n throw TypeError('n must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nEventEmitter.prototype.emit = function(type) {\n var er, handler, len, args, i, listeners;\n\n if (!this._events)\n this._events = {};\n\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events.error ||\n (isObject(this._events.error) && !this._events.error.length)) {\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n }\n }\n\n handler = this._events[type];\n\n if (isUndefined(handler))\n return false;\n\n if (isFunction(handler)) {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n } else if (isObject(handler)) {\n args = Array.prototype.slice.call(arguments, 1);\n listeners = handler.slice();\n len = listeners.length;\n for (i = 0; i < len; i++)\n listeners[i].apply(this, args);\n }\n\n return true;\n};\n\nEventEmitter.prototype.addListener = function(type, listener) {\n var m;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events)\n this._events = {};\n\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (this._events.newListener)\n this.emit('newListener', type,\n isFunction(listener.listener) ?\n listener.listener : listener);\n\n if (!this._events[type])\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n else if (isObject(this._events[type]))\n // If we've already got an array, just append.\n this._events[type].push(listener);\n else\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n\n // Check for listener leak\n if (isObject(this._events[type]) && !this._events[type].warned) {\n if (!isUndefined(this._maxListeners)) {\n m = this._maxListeners;\n } else {\n m = EventEmitter.defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n if (typeof console.trace === 'function') {\n // not supported in IE 10\n console.trace();\n }\n }\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n var fired = false;\n\n function g() {\n this.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n g.listener = listener;\n this.on(type, g);\n\n return this;\n};\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener = function(type, listener) {\n var list, position, length, i;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events || !this._events[type])\n return this;\n\n list = this._events[type];\n length = list.length;\n position = -1;\n\n if (list === listener ||\n (isFunction(list.listener) && list.listener === listener)) {\n delete this._events[type];\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n\n } else if (isObject(list)) {\n for (i = length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list.length = 0;\n delete this._events[type];\n } else {\n list.splice(position, 1);\n }\n\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n var key, listeners;\n\n if (!this._events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!this._events.removeListener) {\n if (arguments.length === 0)\n this._events = {};\n else if (this._events[type])\n delete this._events[type];\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (key in this._events) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = {};\n return this;\n }\n\n listeners = this._events[type];\n\n if (isFunction(listeners)) {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n while (listeners.length)\n this.removeListener(type, listeners[listeners.length - 1]);\n }\n delete this._events[type];\n\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n var ret;\n if (!this._events || !this._events[type])\n ret = [];\n else if (isFunction(this._events[type]))\n ret = [this._events[type]];\n else\n ret = this._events[type].slice();\n return ret;\n};\n\nEventEmitter.prototype.listenerCount = function(type) {\n if (this._events) {\n var evlistener = this._events[type];\n\n if (isFunction(evlistener))\n return 1;\n else if (evlistener)\n return evlistener.length;\n }\n return 0;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n return emitter.listenerCount(type);\n};\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n","\"use strict\";\n\n/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * \n */\n\nfunction makeEmptyFunction(arg) {\n return function () {\n return arg;\n };\n}\n\n/**\n * This function accepts and discards inputs; it has no side effects. This is\n * primarily useful idiomatically for overridable function endpoints which\n * always need to be callable, since JS lacks a null-call idiom ala Cocoa.\n */\nvar emptyFunction = function emptyFunction() {};\n\nemptyFunction.thatReturns = makeEmptyFunction;\nemptyFunction.thatReturnsFalse = makeEmptyFunction(false);\nemptyFunction.thatReturnsTrue = makeEmptyFunction(true);\nemptyFunction.thatReturnsNull = makeEmptyFunction(null);\nemptyFunction.thatReturnsThis = function () {\n return this;\n};\nemptyFunction.thatReturnsArgument = function (arg) {\n return arg;\n};\n\nmodule.exports = emptyFunction;","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\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 validateFormat = function validateFormat(format) {};\n\nif (process.env.NODE_ENV !== 'production') {\n validateFormat = function validateFormat(format) {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n };\n}\n\nfunction invariant(condition, format, a, b, c, d, e, f) {\n validateFormat(format);\n\n if (!condition) {\n var error;\n if (format === undefined) {\n error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');\n } else {\n var args = [a, b, c, d, e, f];\n var argIndex = 0;\n error = new Error(format.replace(/%s/g, function () {\n 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 * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n'use strict';\n\nvar emptyFunction = require('./emptyFunction');\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 = emptyFunction;\n\nif (process.env.NODE_ENV !== 'production') {\n var printWarning = function printWarning(format) {\n for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n var argIndex = 0;\n var message = 'Warning: ' + format.replace(/%s/g, function () {\n return args[argIndex++];\n });\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\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 warning = function warning(condition, format) {\n if (format === undefined) {\n throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');\n }\n\n if (format.indexOf('Failed Composite propType: ') === 0) {\n return; // Ignore CompositeComponent proptype check.\n }\n\n if (!condition) {\n for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {\n args[_key2 - 2] = arguments[_key2];\n }\n\n printWarning.apply(undefined, [format].concat(args));\n }\n };\n}\n\nmodule.exports = warning;","(function (global, factory) {\n if (typeof define === 'function' && define.amd) {\n define(['exports', 'module'], factory);\n } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {\n factory(exports, module);\n } else {\n var mod = {\n exports: {}\n };\n factory(mod.exports, mod);\n global.fetchJsonp = mod.exports;\n }\n})(this, function (exports, module) {\n 'use strict';\n\n var defaultOptions = {\n timeout: 5000,\n jsonpCallback: 'callback',\n jsonpCallbackFunction: null\n };\n\n function generateCallbackFunction() {\n return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000);\n }\n\n function clearFunction(functionName) {\n // IE8 throws an exception when you try to delete a property on window\n // http://stackoverflow.com/a/1824228/751089\n try {\n delete window[functionName];\n } catch (e) {\n window[functionName] = undefined;\n }\n }\n\n function removeScript(scriptId) {\n var script = document.getElementById(scriptId);\n if (script) {\n document.getElementsByTagName('head')[0].removeChild(script);\n }\n }\n\n function fetchJsonp(_url) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n // to avoid param reassign\n var url = _url;\n var timeout = options.timeout || defaultOptions.timeout;\n var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback;\n\n var timeoutId = undefined;\n\n return new Promise(function (resolve, reject) {\n var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction();\n var scriptId = jsonpCallback + '_' + callbackFunction;\n\n window[callbackFunction] = function (response) {\n resolve({\n ok: true,\n // keep consistent with fetch API\n json: function json() {\n return Promise.resolve(response);\n }\n });\n\n if (timeoutId) clearTimeout(timeoutId);\n\n removeScript(scriptId);\n\n clearFunction(callbackFunction);\n };\n\n // Check if the user set their own params, and if not add a ? to start a list of params\n url += url.indexOf('?') === -1 ? '?' : '&';\n\n var jsonpScript = document.createElement('script');\n jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction);\n if (options.charset) {\n jsonpScript.setAttribute('charset', options.charset);\n }\n jsonpScript.id = scriptId;\n document.getElementsByTagName('head')[0].appendChild(jsonpScript);\n\n timeoutId = setTimeout(function () {\n reject(new Error('JSONP request to ' + _url + ' timed out'));\n\n clearFunction(callbackFunction);\n removeScript(scriptId);\n window[callbackFunction] = function () {\n clearFunction(callbackFunction);\n };\n }, timeout);\n\n // Caught if got 404/500\n jsonpScript.onerror = function () {\n reject(new Error('JSONP request to ' + _url + ' failed'));\n\n clearFunction(callbackFunction);\n removeScript(scriptId);\n if (timeoutId) clearTimeout(timeoutId);\n };\n });\n }\n\n // export as global function\n /*\n let local;\n if (typeof global !== 'undefined') {\n local = global;\n } else if (typeof self !== 'undefined') {\n local = self;\n } else {\n try {\n local = Function('return this')();\n } catch (e) {\n throw new Error('polyfill failed because global object is unavailable in this environment');\n }\n }\n local.fetchJsonp = fetchJsonp;\n */\n\n module.exports = fetchJsonp;\n});","'use strict';\n\nfunction FFT(size) {\n this.size = size | 0;\n if (this.size <= 1 || (this.size & (this.size - 1)) !== 0)\n throw new Error('FFT size must be a power of two and bigger than 1');\n\n this._csize = size << 1;\n\n // NOTE: Use of `var` is intentional for old V8 versions\n var table = new Array(this.size * 2);\n for (var i = 0; i < table.length; i += 2) {\n const angle = Math.PI * i / this.size;\n table[i] = Math.cos(angle);\n table[i + 1] = -Math.sin(angle);\n }\n this.table = table;\n\n // Find size's power of two\n var power = 0;\n for (var t = 1; this.size > t; t <<= 1)\n power++;\n\n // Calculate initial step's width:\n // * If we are full radix-4 - it is 2x smaller to give inital len=8\n // * Otherwise it is the same as `power` to give len=4\n this._width = power % 2 === 0 ? power - 1 : power;\n\n // Pre-compute bit-reversal patterns\n this._bitrev = new Array(1 << this._width);\n for (var j = 0; j < this._bitrev.length; j++) {\n this._bitrev[j] = 0;\n for (var shift = 0; shift < this._width; shift += 2) {\n var revShift = this._width - shift - 2;\n this._bitrev[j] |= ((j >>> shift) & 3) << revShift;\n }\n }\n\n this._out = null;\n this._data = null;\n this._inv = 0;\n}\nmodule.exports = FFT;\n\nFFT.prototype.fromComplexArray = function fromComplexArray(complex, storage) {\n var res = storage || new Array(complex.length >>> 1);\n for (var i = 0; i < complex.length; i += 2)\n res[i >>> 1] = complex[i];\n return res;\n};\n\nFFT.prototype.createComplexArray = function createComplexArray() {\n const res = new Array(this._csize);\n for (var i = 0; i < res.length; i++)\n res[i] = 0;\n return res;\n};\n\nFFT.prototype.toComplexArray = function toComplexArray(input, storage) {\n var res = storage || this.createComplexArray();\n for (var i = 0; i < res.length; i += 2) {\n res[i] = input[i >>> 1];\n res[i + 1] = 0;\n }\n return res;\n};\n\nFFT.prototype.completeSpectrum = function completeSpectrum(spectrum) {\n var size = this._csize;\n var half = size >>> 1;\n for (var i = 2; i < half; i += 2) {\n spectrum[size - i] = spectrum[i];\n spectrum[size - i + 1] = -spectrum[i + 1];\n }\n};\n\nFFT.prototype.transform = function transform(out, data) {\n if (out === data)\n throw new Error('Input and output buffers must be different');\n\n this._out = out;\n this._data = data;\n this._inv = 0;\n this._transform4();\n this._out = null;\n this._data = null;\n};\n\nFFT.prototype.realTransform = function realTransform(out, data) {\n if (out === data)\n throw new Error('Input and output buffers must be different');\n\n this._out = out;\n this._data = data;\n this._inv = 0;\n this._realTransform4();\n this._out = null;\n this._data = null;\n};\n\nFFT.prototype.inverseTransform = function inverseTransform(out, data) {\n if (out === data)\n throw new Error('Input and output buffers must be different');\n\n this._out = out;\n this._data = data;\n this._inv = 1;\n this._transform4();\n for (var i = 0; i < out.length; i++)\n out[i] /= this.size;\n this._out = null;\n this._data = null;\n};\n\n// radix-4 implementation\n//\n// NOTE: Uses of `var` are intentional for older V8 version that do not\n// support both `let compound assignments` and `const phi`\nFFT.prototype._transform4 = function _transform4() {\n var out = this._out;\n var size = this._csize;\n\n // Initial step (permute and transform)\n var width = this._width;\n var step = 1 << width;\n var len = (size / step) << 1;\n\n var outOff;\n var t;\n var bitrev = this._bitrev;\n if (len === 4) {\n for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n const off = bitrev[t];\n this._singleTransform2(outOff, off, step);\n }\n } else {\n // len === 8\n for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n const off = bitrev[t];\n this._singleTransform4(outOff, off, step);\n }\n }\n\n // Loop through steps in decreasing order\n var inv = this._inv ? -1 : 1;\n var table = this.table;\n for (step >>= 2; step >= 2; step >>= 2) {\n len = (size / step) << 1;\n var quarterLen = len >>> 2;\n\n // Loop through offsets in the data\n for (outOff = 0; outOff < size; outOff += len) {\n // Full case\n var limit = outOff + quarterLen;\n for (var i = outOff, k = 0; i < limit; i += 2, k += step) {\n const A = i;\n const B = A + quarterLen;\n const C = B + quarterLen;\n const D = C + quarterLen;\n\n // Original values\n const Ar = out[A];\n const Ai = out[A + 1];\n const Br = out[B];\n const Bi = out[B + 1];\n const Cr = out[C];\n const Ci = out[C + 1];\n const Dr = out[D];\n const Di = out[D + 1];\n\n // Middle values\n const MAr = Ar;\n const MAi = Ai;\n\n const tableBr = table[k];\n const tableBi = inv * table[k + 1];\n const MBr = Br * tableBr - Bi * tableBi;\n const MBi = Br * tableBi + Bi * tableBr;\n\n const tableCr = table[2 * k];\n const tableCi = inv * table[2 * k + 1];\n const MCr = Cr * tableCr - Ci * tableCi;\n const MCi = Cr * tableCi + Ci * tableCr;\n\n const tableDr = table[3 * k];\n const tableDi = inv * table[3 * k + 1];\n const MDr = Dr * tableDr - Di * tableDi;\n const MDi = Dr * tableDi + Di * tableDr;\n\n // Pre-Final values\n const T0r = MAr + MCr;\n const T0i = MAi + MCi;\n const T1r = MAr - MCr;\n const T1i = MAi - MCi;\n const T2r = MBr + MDr;\n const T2i = MBi + MDi;\n const T3r = inv * (MBr - MDr);\n const T3i = inv * (MBi - MDi);\n\n // Final values\n const FAr = T0r + T2r;\n const FAi = T0i + T2i;\n\n const FCr = T0r - T2r;\n const FCi = T0i - T2i;\n\n const FBr = T1r + T3i;\n const FBi = T1i - T3r;\n\n const FDr = T1r - T3i;\n const FDi = T1i + T3r;\n\n out[A] = FAr;\n out[A + 1] = FAi;\n out[B] = FBr;\n out[B + 1] = FBi;\n out[C] = FCr;\n out[C + 1] = FCi;\n out[D] = FDr;\n out[D + 1] = FDi;\n }\n }\n }\n};\n\n// radix-2 implementation\n//\n// NOTE: Only called for len=4\nFFT.prototype._singleTransform2 = function _singleTransform2(outOff, off,\n step) {\n const out = this._out;\n const data = this._data;\n\n const evenR = data[off];\n const evenI = data[off + 1];\n const oddR = data[off + step];\n const oddI = data[off + step + 1];\n\n const leftR = evenR + oddR;\n const leftI = evenI + oddI;\n const rightR = evenR - oddR;\n const rightI = evenI - oddI;\n\n out[outOff] = leftR;\n out[outOff + 1] = leftI;\n out[outOff + 2] = rightR;\n out[outOff + 3] = rightI;\n};\n\n// radix-4\n//\n// NOTE: Only called for len=8\nFFT.prototype._singleTransform4 = function _singleTransform4(outOff, off,\n step) {\n const out = this._out;\n const data = this._data;\n const inv = this._inv ? -1 : 1;\n const step2 = step * 2;\n const step3 = step * 3;\n\n // Original values\n const Ar = data[off];\n const Ai = data[off + 1];\n const Br = data[off + step];\n const Bi = data[off + step + 1];\n const Cr = data[off + step2];\n const Ci = data[off + step2 + 1];\n const Dr = data[off + step3];\n const Di = data[off + step3 + 1];\n\n // Pre-Final values\n const T0r = Ar + Cr;\n const T0i = Ai + Ci;\n const T1r = Ar - Cr;\n const T1i = Ai - Ci;\n const T2r = Br + Dr;\n const T2i = Bi + Di;\n const T3r = inv * (Br - Dr);\n const T3i = inv * (Bi - Di);\n\n // Final values\n const FAr = T0r + T2r;\n const FAi = T0i + T2i;\n\n const FBr = T1r + T3i;\n const FBi = T1i - T3r;\n\n const FCr = T0r - T2r;\n const FCi = T0i - T2i;\n\n const FDr = T1r - T3i;\n const FDi = T1i + T3r;\n\n out[outOff] = FAr;\n out[outOff + 1] = FAi;\n out[outOff + 2] = FBr;\n out[outOff + 3] = FBi;\n out[outOff + 4] = FCr;\n out[outOff + 5] = FCi;\n out[outOff + 6] = FDr;\n out[outOff + 7] = FDi;\n};\n\n// Real input radix-4 implementation\nFFT.prototype._realTransform4 = function _realTransform4() {\n var out = this._out;\n var size = this._csize;\n\n // Initial step (permute and transform)\n var width = this._width;\n var step = 1 << width;\n var len = (size / step) << 1;\n\n var outOff;\n var t;\n var bitrev = this._bitrev;\n if (len === 4) {\n for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n const off = bitrev[t];\n this._singleRealTransform2(outOff, off >>> 1, step >>> 1);\n }\n } else {\n // len === 8\n for (outOff = 0, t = 0; outOff < size; outOff += len, t++) {\n const off = bitrev[t];\n this._singleRealTransform4(outOff, off >>> 1, step >>> 1);\n }\n }\n\n // Loop through steps in decreasing order\n var inv = this._inv ? -1 : 1;\n var table = this.table;\n for (step >>= 2; step >= 2; step >>= 2) {\n len = (size / step) << 1;\n var halfLen = len >>> 1;\n var quarterLen = halfLen >>> 1;\n var hquarterLen = quarterLen >>> 1;\n\n // Loop through offsets in the data\n for (outOff = 0; outOff < size; outOff += len) {\n for (var i = 0, k = 0; i <= hquarterLen; i += 2, k += step) {\n var A = outOff + i;\n var B = A + quarterLen;\n var C = B + quarterLen;\n var D = C + quarterLen;\n\n // Original values\n var Ar = out[A];\n var Ai = out[A + 1];\n var Br = out[B];\n var Bi = out[B + 1];\n var Cr = out[C];\n var Ci = out[C + 1];\n var Dr = out[D];\n var Di = out[D + 1];\n\n // Middle values\n var MAr = Ar;\n var MAi = Ai;\n\n var tableBr = table[k];\n var tableBi = inv * table[k + 1];\n var MBr = Br * tableBr - Bi * tableBi;\n var MBi = Br * tableBi + Bi * tableBr;\n\n var tableCr = table[2 * k];\n var tableCi = inv * table[2 * k + 1];\n var MCr = Cr * tableCr - Ci * tableCi;\n var MCi = Cr * tableCi + Ci * tableCr;\n\n var tableDr = table[3 * k];\n var tableDi = inv * table[3 * k + 1];\n var MDr = Dr * tableDr - Di * tableDi;\n var MDi = Dr * tableDi + Di * tableDr;\n\n // Pre-Final values\n var T0r = MAr + MCr;\n var T0i = MAi + MCi;\n var T1r = MAr - MCr;\n var T1i = MAi - MCi;\n var T2r = MBr + MDr;\n var T2i = MBi + MDi;\n var T3r = inv * (MBr - MDr);\n var T3i = inv * (MBi - MDi);\n\n // Final values\n var FAr = T0r + T2r;\n var FAi = T0i + T2i;\n\n var FBr = T1r + T3i;\n var FBi = T1i - T3r;\n\n out[A] = FAr;\n out[A + 1] = FAi;\n out[B] = FBr;\n out[B + 1] = FBi;\n\n // Output final middle point\n if (i === 0) {\n var FCr = T0r - T2r;\n var FCi = T0i - T2i;\n out[C] = FCr;\n out[C + 1] = FCi;\n continue;\n }\n\n // Do not overwrite ourselves\n if (i === hquarterLen)\n continue;\n\n // In the flipped case:\n // MAi = -MAi\n // MBr=-MBi, MBi=-MBr\n // MCr=-MCr\n // MDr=MDi, MDi=MDr\n var ST0r = T1r;\n var ST0i = -T1i;\n var ST1r = T0r;\n var ST1i = -T0i;\n var ST2r = -inv * T3i;\n var ST2i = -inv * T3r;\n var ST3r = -inv * T2i;\n var ST3i = -inv * T2r;\n\n var SFAr = ST0r + ST2r;\n var SFAi = ST0i + ST2i;\n\n var SFBr = ST1r + ST3i;\n var SFBi = ST1i - ST3r;\n\n var SA = outOff + quarterLen - i;\n var SB = outOff + halfLen - i;\n\n out[SA] = SFAr;\n out[SA + 1] = SFAi;\n out[SB] = SFBr;\n out[SB + 1] = SFBi;\n }\n }\n }\n};\n\n// radix-2 implementation\n//\n// NOTE: Only called for len=4\nFFT.prototype._singleRealTransform2 = function _singleRealTransform2(outOff,\n off,\n step) {\n const out = this._out;\n const data = this._data;\n\n const evenR = data[off];\n const oddR = data[off + step];\n\n const leftR = evenR + oddR;\n const rightR = evenR - oddR;\n\n out[outOff] = leftR;\n out[outOff + 1] = 0;\n out[outOff + 2] = rightR;\n out[outOff + 3] = 0;\n};\n\n// radix-4\n//\n// NOTE: Only called for len=8\nFFT.prototype._singleRealTransform4 = function _singleRealTransform4(outOff,\n off,\n step) {\n const out = this._out;\n const data = this._data;\n const inv = this._inv ? -1 : 1;\n const step2 = step * 2;\n const step3 = step * 3;\n\n // Original values\n const Ar = data[off];\n const Br = data[off + step];\n const Cr = data[off + step2];\n const Dr = data[off + step3];\n\n // Pre-Final values\n const T0r = Ar + Cr;\n const T1r = Ar - Cr;\n const T2r = Br + Dr;\n const T3r = inv * (Br - Dr);\n\n // Final values\n const FAr = T0r + T2r;\n\n const FBr = T1r;\n const FBi = -T3r;\n\n const FCr = T0r - T2r;\n\n const FDr = T1r;\n const FDi = T3r;\n\n out[outOff] = FAr;\n out[outOff + 1] = 0;\n out[outOff + 2] = FBr;\n out[outOff + 3] = FBi;\n out[outOff + 4] = FCr;\n out[outOff + 5] = 0;\n out[outOff + 6] = FDr;\n out[outOff + 7] = FDi;\n};\n","/* FileSaver.js\n * A saveAs() FileSaver implementation.\n * 1.3.2\n * 2016-06-16 18:25:19\n *\n * By Eli Grey, http://eligrey.com\n * License: MIT\n * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md\n */\n\n/*global self */\n/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */\n\n/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */\n\nvar saveAs = saveAs || (function(view) {\n\t\"use strict\";\n\t// IE <10 is explicitly unsupported\n\tif (typeof view === \"undefined\" || typeof navigator !== \"undefined\" && /MSIE [1-9]\\./.test(navigator.userAgent)) {\n\t\treturn;\n\t}\n\tvar\n\t\t doc = view.document\n\t\t // only get URL when necessary in case Blob.js hasn't overridden it yet\n\t\t, get_URL = function() {\n\t\t\treturn view.URL || view.webkitURL || view;\n\t\t}\n\t\t, save_link = doc.createElementNS(\"http://www.w3.org/1999/xhtml\", \"a\")\n\t\t, can_use_save_link = \"download\" in save_link\n\t\t, click = function(node) {\n\t\t\tvar event = new MouseEvent(\"click\");\n\t\t\tnode.dispatchEvent(event);\n\t\t}\n\t\t, is_safari = /constructor/i.test(view.HTMLElement) || view.safari\n\t\t, is_chrome_ios =/CriOS\\/[\\d]+/.test(navigator.userAgent)\n\t\t, throw_outside = function(ex) {\n\t\t\t(view.setImmediate || view.setTimeout)(function() {\n\t\t\t\tthrow ex;\n\t\t\t}, 0);\n\t\t}\n\t\t, force_saveable_type = \"application/octet-stream\"\n\t\t// the Blob API is fundamentally broken as there is no \"downloadfinished\" event to subscribe to\n\t\t, arbitrary_revoke_timeout = 1000 * 40 // in ms\n\t\t, revoke = function(file) {\n\t\t\tvar revoker = function() {\n\t\t\t\tif (typeof file === \"string\") { // file is an object URL\n\t\t\t\t\tget_URL().revokeObjectURL(file);\n\t\t\t\t} else { // file is a File\n\t\t\t\t\tfile.remove();\n\t\t\t\t}\n\t\t\t};\n\t\t\tsetTimeout(revoker, arbitrary_revoke_timeout);\n\t\t}\n\t\t, dispatch = function(filesaver, event_types, event) {\n\t\t\tevent_types = [].concat(event_types);\n\t\t\tvar i = event_types.length;\n\t\t\twhile (i--) {\n\t\t\t\tvar listener = filesaver[\"on\" + event_types[i]];\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlistener.call(filesaver, event || filesaver);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tthrow_outside(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t, auto_bom = function(blob) {\n\t\t\t// prepend BOM for UTF-8 XML and text/* types (including HTML)\n\t\t\t// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF\n\t\t\tif (/^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(blob.type)) {\n\t\t\t\treturn new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});\n\t\t\t}\n\t\t\treturn blob;\n\t\t}\n\t\t, FileSaver = function(blob, name, no_auto_bom) {\n\t\t\tif (!no_auto_bom) {\n\t\t\t\tblob = auto_bom(blob);\n\t\t\t}\n\t\t\t// First try a.download, then web filesystem, then object URLs\n\t\t\tvar\n\t\t\t\t filesaver = this\n\t\t\t\t, type = blob.type\n\t\t\t\t, force = type === force_saveable_type\n\t\t\t\t, object_url\n\t\t\t\t, dispatch_all = function() {\n\t\t\t\t\tdispatch(filesaver, \"writestart progress write writeend\".split(\" \"));\n\t\t\t\t}\n\t\t\t\t// on any filesys errors revert to saving with object URLs\n\t\t\t\t, fs_error = function() {\n\t\t\t\t\tif ((is_chrome_ios || (force && is_safari)) && view.FileReader) {\n\t\t\t\t\t\t// Safari doesn't allow downloading of blob urls\n\t\t\t\t\t\tvar reader = new FileReader();\n\t\t\t\t\t\treader.onloadend = function() {\n\t\t\t\t\t\t\tvar url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');\n\t\t\t\t\t\t\tvar popup = view.open(url, '_blank');\n\t\t\t\t\t\t\tif(!popup) view.location.href = url;\n\t\t\t\t\t\t\turl=undefined; // release reference before dispatching\n\t\t\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\t\t\tdispatch_all();\n\t\t\t\t\t\t};\n\t\t\t\t\t\treader.readAsDataURL(blob);\n\t\t\t\t\t\tfilesaver.readyState = filesaver.INIT;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// don't create more object URLs than needed\n\t\t\t\t\tif (!object_url) {\n\t\t\t\t\t\tobject_url = get_URL().createObjectURL(blob);\n\t\t\t\t\t}\n\t\t\t\t\tif (force) {\n\t\t\t\t\t\tview.location.href = object_url;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar opened = view.open(object_url, \"_blank\");\n\t\t\t\t\t\tif (!opened) {\n\t\t\t\t\t\t\t// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html\n\t\t\t\t\t\t\tview.location.href = object_url;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\tdispatch_all();\n\t\t\t\t\trevoke(object_url);\n\t\t\t\t}\n\t\t\t;\n\t\t\tfilesaver.readyState = filesaver.INIT;\n\n\t\t\tif (can_use_save_link) {\n\t\t\t\tobject_url = get_URL().createObjectURL(blob);\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tsave_link.href = object_url;\n\t\t\t\t\tsave_link.download = name;\n\t\t\t\t\tclick(save_link);\n\t\t\t\t\tdispatch_all();\n\t\t\t\t\trevoke(object_url);\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfs_error();\n\t\t}\n\t\t, FS_proto = FileSaver.prototype\n\t\t, saveAs = function(blob, name, no_auto_bom) {\n\t\t\treturn new FileSaver(blob, name || blob.name || \"download\", no_auto_bom);\n\t\t}\n\t;\n\t// IE 10+ (native saveAs)\n\tif (typeof navigator !== \"undefined\" && navigator.msSaveOrOpenBlob) {\n\t\treturn function(blob, name, no_auto_bom) {\n\t\t\tname = name || blob.name || \"download\";\n\n\t\t\tif (!no_auto_bom) {\n\t\t\t\tblob = auto_bom(blob);\n\t\t\t}\n\t\t\treturn navigator.msSaveOrOpenBlob(blob, name);\n\t\t};\n\t}\n\n\tFS_proto.abort = function(){};\n\tFS_proto.readyState = FS_proto.INIT = 0;\n\tFS_proto.WRITING = 1;\n\tFS_proto.DONE = 2;\n\n\tFS_proto.error =\n\tFS_proto.onwritestart =\n\tFS_proto.onprogress =\n\tFS_proto.onwrite =\n\tFS_proto.onabort =\n\tFS_proto.onerror =\n\tFS_proto.onwriteend =\n\t\tnull;\n\n\treturn saveAs;\n}(\n\t typeof self !== \"undefined\" && self\n\t|| typeof window !== \"undefined\" && window\n\t|| this.content\n));\n// `self` is undefined in Firefox for Android content script context\n// while `this` is nsIContentFrameMessageManager\n// with an attribute `content` that corresponds to the window\n\nif (typeof module !== \"undefined\" && module.exports) {\n module.exports.saveAs = saveAs;\n} else if ((typeof define !== \"undefined\" && define !== null) && (define.amd !== null)) {\n define(\"FileSaver.js\", function() {\n return saveAs;\n });\n}\n","'use strict';\n\nexports.__esModule = true;\nvar canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n\nvar addEventListener = exports.addEventListener = function addEventListener(node, event, listener) {\n return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener);\n};\n\nvar removeEventListener = exports.removeEventListener = function removeEventListener(node, event, listener) {\n return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener);\n};\n\nvar getConfirmation = exports.getConfirmation = function getConfirmation(message, callback) {\n return callback(window.confirm(message));\n}; // eslint-disable-line no-alert\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/reactjs/react-router/issues/586\n */\nvar supportsHistory = exports.supportsHistory = function supportsHistory() {\n var ua = window.navigator.userAgent;\n\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) return false;\n\n return window.history && 'pushState' in window.history;\n};\n\n/**\n * Returns true if browser fires popstate on hash change.\n * IE10 and IE11 do not.\n */\nvar supportsPopStateOnHashChange = exports.supportsPopStateOnHashChange = function supportsPopStateOnHashChange() {\n return window.navigator.userAgent.indexOf('Trident') === -1;\n};\n\n/**\n * Returns false if using go(n) with hash history causes a full page reload.\n */\nvar supportsGoWithoutReloadUsingHash = exports.supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() {\n return window.navigator.userAgent.indexOf('Firefox') === -1;\n};\n\n/**\n * Returns true if a given popstate event is an extraneous WebKit event.\n * Accounts for the fact that Chrome on iOS fires real popstate events\n * containing undefined state when pressing the back button.\n */\nvar isExtraneousPopstateEvent = exports.isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) {\n return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;\n};","'use strict';\n\nexports.__esModule = true;\nexports.locationsAreEqual = exports.createLocation = undefined;\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\nvar _resolvePathname = require('resolve-pathname');\n\nvar _resolvePathname2 = _interopRequireDefault(_resolvePathname);\n\nvar _valueEqual = require('value-equal');\n\nvar _valueEqual2 = _interopRequireDefault(_valueEqual);\n\nvar _PathUtils = require('./PathUtils');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar createLocation = exports.createLocation = function createLocation(path, state, key, currentLocation) {\n var location = void 0;\n if (typeof path === 'string') {\n // Two-arg form: push(path, state)\n location = (0, _PathUtils.parsePath)(path);\n location.state = state;\n } else {\n // One-arg form: push(location)\n location = _extends({}, path);\n\n if (location.pathname === undefined) location.pathname = '';\n\n if (location.search) {\n if (location.search.charAt(0) !== '?') location.search = '?' + location.search;\n } else {\n location.search = '';\n }\n\n if (location.hash) {\n if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;\n } else {\n location.hash = '';\n }\n\n if (state !== undefined && location.state === undefined) location.state = state;\n }\n\n try {\n location.pathname = decodeURI(location.pathname);\n } catch (e) {\n if (e instanceof URIError) {\n throw new URIError('Pathname \"' + location.pathname + '\" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');\n } else {\n throw e;\n }\n }\n\n if (key) location.key = key;\n\n if (currentLocation) {\n // Resolve incomplete/relative pathname relative to current location.\n if (!location.pathname) {\n location.pathname = currentLocation.pathname;\n } else if (location.pathname.charAt(0) !== '/') {\n location.pathname = (0, _resolvePathname2.default)(location.pathname, currentLocation.pathname);\n }\n } else {\n // When there is no prior location and pathname is empty, set it to /\n if (!location.pathname) {\n location.pathname = '/';\n }\n }\n\n return location;\n};\n\nvar locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) {\n return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0, _valueEqual2.default)(a.state, b.state);\n};","'use strict';\n\nexports.__esModule = true;\nvar addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) {\n return path.charAt(0) === '/' ? path : '/' + path;\n};\n\nvar stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) {\n return path.charAt(0) === '/' ? path.substr(1) : path;\n};\n\nvar hasBasename = exports.hasBasename = function hasBasename(path, prefix) {\n return new RegExp('^' + prefix + '(\\\\/|\\\\?|#|$)', 'i').test(path);\n};\n\nvar stripBasename = exports.stripBasename = function stripBasename(path, prefix) {\n return hasBasename(path, prefix) ? path.substr(prefix.length) : path;\n};\n\nvar stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) {\n return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;\n};\n\nvar parsePath = exports.parsePath = function parsePath(path) {\n var pathname = path || '/';\n var search = '';\n var hash = '';\n\n var hashIndex = pathname.indexOf('#');\n if (hashIndex !== -1) {\n hash = pathname.substr(hashIndex);\n pathname = pathname.substr(0, hashIndex);\n }\n\n var searchIndex = pathname.indexOf('?');\n if (searchIndex !== -1) {\n search = pathname.substr(searchIndex);\n pathname = pathname.substr(0, searchIndex);\n }\n\n return {\n pathname: pathname,\n search: search === '?' ? '' : search,\n hash: hash === '#' ? '' : hash\n };\n};\n\nvar createPath = exports.createPath = function createPath(location) {\n var pathname = location.pathname,\n search = location.search,\n hash = location.hash;\n\n\n var path = pathname || '/';\n\n if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;\n\n if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;\n\n return path;\n};","'use strict';\n\nexports.__esModule = true;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\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\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _invariant = require('invariant');\n\nvar _invariant2 = _interopRequireDefault(_invariant);\n\nvar _LocationUtils = require('./LocationUtils');\n\nvar _PathUtils = require('./PathUtils');\n\nvar _createTransitionManager = require('./createTransitionManager');\n\nvar _createTransitionManager2 = _interopRequireDefault(_createTransitionManager);\n\nvar _DOMUtils = require('./DOMUtils');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar PopStateEvent = 'popstate';\nvar HashChangeEvent = 'hashchange';\n\nvar getHistoryState = function getHistoryState() {\n try {\n return window.history.state || {};\n } catch (e) {\n // IE 11 sometimes throws when accessing window.history.state\n // See https://github.com/ReactTraining/history/pull/289\n return {};\n }\n};\n\n/**\n * Creates a history object that uses the HTML5 history API including\n * pushState, replaceState, and the popstate event.\n */\nvar createBrowserHistory = function createBrowserHistory() {\n var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n (0, _invariant2.default)(_DOMUtils.canUseDOM, 'Browser history needs a DOM');\n\n var globalHistory = window.history;\n var canUseHistory = (0, _DOMUtils.supportsHistory)();\n var needsHashChangeListener = !(0, _DOMUtils.supportsPopStateOnHashChange)();\n\n var _props$forceRefresh = props.forceRefresh,\n forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh,\n _props$getUserConfirm = props.getUserConfirmation,\n getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm,\n _props$keyLength = props.keyLength,\n keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;\n\n var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : '';\n\n var getDOMLocation = function getDOMLocation(historyState) {\n var _ref = historyState || {},\n key = _ref.key,\n state = _ref.state;\n\n var _window$location = window.location,\n pathname = _window$location.pathname,\n search = _window$location.search,\n hash = _window$location.hash;\n\n\n var path = pathname + search + hash;\n\n (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path \"' + path + '\" to begin with \"' + basename + '\".');\n\n if (basename) path = (0, _PathUtils.stripBasename)(path, basename);\n\n return (0, _LocationUtils.createLocation)(path, state, key);\n };\n\n var createKey = function createKey() {\n return Math.random().toString(36).substr(2, keyLength);\n };\n\n var transitionManager = (0, _createTransitionManager2.default)();\n\n var setState = function setState(nextState) {\n _extends(history, nextState);\n\n history.length = globalHistory.length;\n\n transitionManager.notifyListeners(history.location, history.action);\n };\n\n var handlePopState = function handlePopState(event) {\n // Ignore extraneous popstate events in WebKit.\n if ((0, _DOMUtils.isExtraneousPopstateEvent)(event)) return;\n\n handlePop(getDOMLocation(event.state));\n };\n\n var handleHashChange = function handleHashChange() {\n handlePop(getDOMLocation(getHistoryState()));\n };\n\n var forceNextPop = false;\n\n var handlePop = function handlePop(location) {\n if (forceNextPop) {\n forceNextPop = false;\n setState();\n } else {\n var action = 'POP';\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({ action: action, location: location });\n } else {\n revertPop(location);\n }\n });\n }\n };\n\n var revertPop = function revertPop(fromLocation) {\n var toLocation = history.location;\n\n // TODO: We could probably make this more reliable by\n // keeping a list of keys we've seen in sessionStorage.\n // Instead, we just default to 0 for keys we don't know.\n\n var toIndex = allKeys.indexOf(toLocation.key);\n\n if (toIndex === -1) toIndex = 0;\n\n var fromIndex = allKeys.indexOf(fromLocation.key);\n\n if (fromIndex === -1) fromIndex = 0;\n\n var delta = toIndex - fromIndex;\n\n if (delta) {\n forceNextPop = true;\n go(delta);\n }\n };\n\n var initialLocation = getDOMLocation(getHistoryState());\n var allKeys = [initialLocation.key];\n\n // Public interface\n\n var createHref = function createHref(location) {\n return basename + (0, _PathUtils.createPath)(location);\n };\n\n var push = function push(path, state) {\n (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'PUSH';\n var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var href = createHref(location);\n var key = location.key,\n state = location.state;\n\n\n if (canUseHistory) {\n globalHistory.pushState({ key: key, state: state }, null, href);\n\n if (forceRefresh) {\n window.location.href = href;\n } else {\n var prevIndex = allKeys.indexOf(history.location.key);\n var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);\n\n nextKeys.push(location.key);\n allKeys = nextKeys;\n\n setState({ action: action, location: location });\n }\n } else {\n (0, _warning2.default)(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history');\n\n window.location.href = href;\n }\n });\n };\n\n var replace = function replace(path, state) {\n (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'REPLACE';\n var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var href = createHref(location);\n var key = location.key,\n state = location.state;\n\n\n if (canUseHistory) {\n globalHistory.replaceState({ key: key, state: state }, null, href);\n\n if (forceRefresh) {\n window.location.replace(href);\n } else {\n var prevIndex = allKeys.indexOf(history.location.key);\n\n if (prevIndex !== -1) allKeys[prevIndex] = location.key;\n\n setState({ action: action, location: location });\n }\n } else {\n (0, _warning2.default)(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history');\n\n window.location.replace(href);\n }\n });\n };\n\n var go = function go(n) {\n globalHistory.go(n);\n };\n\n var goBack = function goBack() {\n return go(-1);\n };\n\n var goForward = function goForward() {\n return go(1);\n };\n\n var listenerCount = 0;\n\n var checkDOMListeners = function checkDOMListeners(delta) {\n listenerCount += delta;\n\n if (listenerCount === 1) {\n (0, _DOMUtils.addEventListener)(window, PopStateEvent, handlePopState);\n\n if (needsHashChangeListener) (0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange);\n } else if (listenerCount === 0) {\n (0, _DOMUtils.removeEventListener)(window, PopStateEvent, handlePopState);\n\n if (needsHashChangeListener) (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange);\n }\n };\n\n var isBlocked = false;\n\n var block = function block() {\n var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n var unblock = transitionManager.setPrompt(prompt);\n\n if (!isBlocked) {\n checkDOMListeners(1);\n isBlocked = true;\n }\n\n return function () {\n if (isBlocked) {\n isBlocked = false;\n checkDOMListeners(-1);\n }\n\n return unblock();\n };\n };\n\n var listen = function listen(listener) {\n var unlisten = transitionManager.appendListener(listener);\n checkDOMListeners(1);\n\n return function () {\n checkDOMListeners(-1);\n unlisten();\n };\n };\n\n var history = {\n length: globalHistory.length,\n action: 'POP',\n location: initialLocation,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n block: block,\n listen: listen\n };\n\n return history;\n};\n\nexports.default = createBrowserHistory;","'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\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _invariant = require('invariant');\n\nvar _invariant2 = _interopRequireDefault(_invariant);\n\nvar _LocationUtils = require('./LocationUtils');\n\nvar _PathUtils = require('./PathUtils');\n\nvar _createTransitionManager = require('./createTransitionManager');\n\nvar _createTransitionManager2 = _interopRequireDefault(_createTransitionManager);\n\nvar _DOMUtils = require('./DOMUtils');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar HashChangeEvent = 'hashchange';\n\nvar HashPathCoders = {\n hashbang: {\n encodePath: function encodePath(path) {\n return path.charAt(0) === '!' ? path : '!/' + (0, _PathUtils.stripLeadingSlash)(path);\n },\n decodePath: function decodePath(path) {\n return path.charAt(0) === '!' ? path.substr(1) : path;\n }\n },\n noslash: {\n encodePath: _PathUtils.stripLeadingSlash,\n decodePath: _PathUtils.addLeadingSlash\n },\n slash: {\n encodePath: _PathUtils.addLeadingSlash,\n decodePath: _PathUtils.addLeadingSlash\n }\n};\n\nvar getHashPath = function getHashPath() {\n // We can't use window.location.hash here because it's not\n // consistent across browsers - Firefox will pre-decode it!\n var href = window.location.href;\n var hashIndex = href.indexOf('#');\n return hashIndex === -1 ? '' : href.substring(hashIndex + 1);\n};\n\nvar pushHashPath = function pushHashPath(path) {\n return window.location.hash = path;\n};\n\nvar replaceHashPath = function replaceHashPath(path) {\n var hashIndex = window.location.href.indexOf('#');\n\n window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);\n};\n\nvar createHashHistory = function createHashHistory() {\n var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n (0, _invariant2.default)(_DOMUtils.canUseDOM, 'Hash history needs a DOM');\n\n var globalHistory = window.history;\n var canGoWithoutReload = (0, _DOMUtils.supportsGoWithoutReloadUsingHash)();\n\n var _props$getUserConfirm = props.getUserConfirmation,\n getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm,\n _props$hashType = props.hashType,\n hashType = _props$hashType === undefined ? 'slash' : _props$hashType;\n\n var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : '';\n\n var _HashPathCoders$hashT = HashPathCoders[hashType],\n encodePath = _HashPathCoders$hashT.encodePath,\n decodePath = _HashPathCoders$hashT.decodePath;\n\n\n var getDOMLocation = function getDOMLocation() {\n var path = decodePath(getHashPath());\n\n (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path \"' + path + '\" to begin with \"' + basename + '\".');\n\n if (basename) path = (0, _PathUtils.stripBasename)(path, basename);\n\n return (0, _LocationUtils.createLocation)(path);\n };\n\n var transitionManager = (0, _createTransitionManager2.default)();\n\n var setState = function setState(nextState) {\n _extends(history, nextState);\n\n history.length = globalHistory.length;\n\n transitionManager.notifyListeners(history.location, history.action);\n };\n\n var forceNextPop = false;\n var ignorePath = null;\n\n var handleHashChange = function handleHashChange() {\n var path = getHashPath();\n var encodedPath = encodePath(path);\n\n if (path !== encodedPath) {\n // Ensure we always have a properly-encoded hash.\n replaceHashPath(encodedPath);\n } else {\n var location = getDOMLocation();\n var prevLocation = history.location;\n\n if (!forceNextPop && (0, _LocationUtils.locationsAreEqual)(prevLocation, location)) return; // A hashchange doesn't always == location change.\n\n if (ignorePath === (0, _PathUtils.createPath)(location)) return; // Ignore this change; we already setState in push/replace.\n\n ignorePath = null;\n\n handlePop(location);\n }\n };\n\n var handlePop = function handlePop(location) {\n if (forceNextPop) {\n forceNextPop = false;\n setState();\n } else {\n var action = 'POP';\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({ action: action, location: location });\n } else {\n revertPop(location);\n }\n });\n }\n };\n\n var revertPop = function revertPop(fromLocation) {\n var toLocation = history.location;\n\n // TODO: We could probably make this more reliable by\n // keeping a list of paths we've seen in sessionStorage.\n // Instead, we just default to 0 for paths we don't know.\n\n var toIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(toLocation));\n\n if (toIndex === -1) toIndex = 0;\n\n var fromIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(fromLocation));\n\n if (fromIndex === -1) fromIndex = 0;\n\n var delta = toIndex - fromIndex;\n\n if (delta) {\n forceNextPop = true;\n go(delta);\n }\n };\n\n // Ensure the hash is encoded properly before doing anything else.\n var path = getHashPath();\n var encodedPath = encodePath(path);\n\n if (path !== encodedPath) replaceHashPath(encodedPath);\n\n var initialLocation = getDOMLocation();\n var allPaths = [(0, _PathUtils.createPath)(initialLocation)];\n\n // Public interface\n\n var createHref = function createHref(location) {\n return '#' + encodePath(basename + (0, _PathUtils.createPath)(location));\n };\n\n var push = function push(path, state) {\n (0, _warning2.default)(state === undefined, 'Hash history cannot push state; it is ignored');\n\n var action = 'PUSH';\n var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var path = (0, _PathUtils.createPath)(location);\n var encodedPath = encodePath(basename + path);\n var hashChanged = getHashPath() !== encodedPath;\n\n if (hashChanged) {\n // We cannot tell if a hashchange was caused by a PUSH, so we'd\n // rather setState here and ignore the hashchange. The caveat here\n // is that other hash histories in the page will consider it a POP.\n ignorePath = path;\n pushHashPath(encodedPath);\n\n var prevIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(history.location));\n var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);\n\n nextPaths.push(path);\n allPaths = nextPaths;\n\n setState({ action: action, location: location });\n } else {\n (0, _warning2.default)(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');\n\n setState();\n }\n });\n };\n\n var replace = function replace(path, state) {\n (0, _warning2.default)(state === undefined, 'Hash history cannot replace state; it is ignored');\n\n var action = 'REPLACE';\n var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var path = (0, _PathUtils.createPath)(location);\n var encodedPath = encodePath(basename + path);\n var hashChanged = getHashPath() !== encodedPath;\n\n if (hashChanged) {\n // We cannot tell if a hashchange was caused by a REPLACE, so we'd\n // rather setState here and ignore the hashchange. The caveat here\n // is that other hash histories in the page will consider it a POP.\n ignorePath = path;\n replaceHashPath(encodedPath);\n }\n\n var prevIndex = allPaths.indexOf((0, _PathUtils.createPath)(history.location));\n\n if (prevIndex !== -1) allPaths[prevIndex] = path;\n\n setState({ action: action, location: location });\n });\n };\n\n var go = function go(n) {\n (0, _warning2.default)(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');\n\n globalHistory.go(n);\n };\n\n var goBack = function goBack() {\n return go(-1);\n };\n\n var goForward = function goForward() {\n return go(1);\n };\n\n var listenerCount = 0;\n\n var checkDOMListeners = function checkDOMListeners(delta) {\n listenerCount += delta;\n\n if (listenerCount === 1) {\n (0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange);\n } else if (listenerCount === 0) {\n (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange);\n }\n };\n\n var isBlocked = false;\n\n var block = function block() {\n var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n var unblock = transitionManager.setPrompt(prompt);\n\n if (!isBlocked) {\n checkDOMListeners(1);\n isBlocked = true;\n }\n\n return function () {\n if (isBlocked) {\n isBlocked = false;\n checkDOMListeners(-1);\n }\n\n return unblock();\n };\n };\n\n var listen = function listen(listener) {\n var unlisten = transitionManager.appendListener(listener);\n checkDOMListeners(1);\n\n return function () {\n checkDOMListeners(-1);\n unlisten();\n };\n };\n\n var history = {\n length: globalHistory.length,\n action: 'POP',\n location: initialLocation,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n block: block,\n listen: listen\n };\n\n return history;\n};\n\nexports.default = createHashHistory;","'use strict';\n\nexports.__esModule = true;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\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\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _PathUtils = require('./PathUtils');\n\nvar _LocationUtils = require('./LocationUtils');\n\nvar _createTransitionManager = require('./createTransitionManager');\n\nvar _createTransitionManager2 = _interopRequireDefault(_createTransitionManager);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar clamp = function clamp(n, lowerBound, upperBound) {\n return Math.min(Math.max(n, lowerBound), upperBound);\n};\n\n/**\n * Creates a history object that stores locations in memory.\n */\nvar createMemoryHistory = function createMemoryHistory() {\n var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var getUserConfirmation = props.getUserConfirmation,\n _props$initialEntries = props.initialEntries,\n initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries,\n _props$initialIndex = props.initialIndex,\n initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex,\n _props$keyLength = props.keyLength,\n keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;\n\n\n var transitionManager = (0, _createTransitionManager2.default)();\n\n var setState = function setState(nextState) {\n _extends(history, nextState);\n\n history.length = history.entries.length;\n\n transitionManager.notifyListeners(history.location, history.action);\n };\n\n var createKey = function createKey() {\n return Math.random().toString(36).substr(2, keyLength);\n };\n\n var index = clamp(initialIndex, 0, initialEntries.length - 1);\n var entries = initialEntries.map(function (entry) {\n return typeof entry === 'string' ? (0, _LocationUtils.createLocation)(entry, undefined, createKey()) : (0, _LocationUtils.createLocation)(entry, undefined, entry.key || createKey());\n });\n\n // Public interface\n\n var createHref = _PathUtils.createPath;\n\n var push = function push(path, state) {\n (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'PUSH';\n var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var prevIndex = history.index;\n var nextIndex = prevIndex + 1;\n\n var nextEntries = history.entries.slice(0);\n if (nextEntries.length > nextIndex) {\n nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);\n } else {\n nextEntries.push(location);\n }\n\n setState({\n action: action,\n location: location,\n index: nextIndex,\n entries: nextEntries\n });\n });\n };\n\n var replace = function replace(path, state) {\n (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'REPLACE';\n var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n history.entries[history.index] = location;\n\n setState({ action: action, location: location });\n });\n };\n\n var go = function go(n) {\n var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);\n\n var action = 'POP';\n var location = history.entries[nextIndex];\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({\n action: action,\n location: location,\n index: nextIndex\n });\n } else {\n // Mimic the behavior of DOM histories by\n // causing a render after a cancelled POP.\n setState();\n }\n });\n };\n\n var goBack = function goBack() {\n return go(-1);\n };\n\n var goForward = function goForward() {\n return go(1);\n };\n\n var canGo = function canGo(n) {\n var nextIndex = history.index + n;\n return nextIndex >= 0 && nextIndex < history.entries.length;\n };\n\n var block = function block() {\n var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n return transitionManager.setPrompt(prompt);\n };\n\n var listen = function listen(listener) {\n return transitionManager.appendListener(listener);\n };\n\n var history = {\n length: entries.length,\n action: 'POP',\n location: entries[index],\n index: index,\n entries: entries,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n canGo: canGo,\n block: block,\n listen: listen\n };\n\n return history;\n};\n\nexports.default = createMemoryHistory;","'use strict';\n\nexports.__esModule = true;\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar createTransitionManager = function createTransitionManager() {\n var prompt = null;\n\n var setPrompt = function setPrompt(nextPrompt) {\n (0, _warning2.default)(prompt == null, 'A history supports only one prompt at a time');\n\n prompt = nextPrompt;\n\n return function () {\n if (prompt === nextPrompt) prompt = null;\n };\n };\n\n var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) {\n // TODO: If another transition starts while we're still confirming\n // the previous one, we may end up in a weird state. Figure out the\n // best way to handle this.\n if (prompt != null) {\n var result = typeof prompt === 'function' ? prompt(location, action) : prompt;\n\n if (typeof result === 'string') {\n if (typeof getUserConfirmation === 'function') {\n getUserConfirmation(result, callback);\n } else {\n (0, _warning2.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message');\n\n callback(true);\n }\n } else {\n // Return false from a transition hook to cancel the transition.\n callback(result !== false);\n }\n } else {\n callback(true);\n }\n };\n\n var listeners = [];\n\n var appendListener = function appendListener(fn) {\n var isActive = true;\n\n var listener = function listener() {\n if (isActive) fn.apply(undefined, arguments);\n };\n\n listeners.push(listener);\n\n return function () {\n isActive = false;\n listeners = listeners.filter(function (item) {\n return item !== listener;\n });\n };\n };\n\n var notifyListeners = function notifyListeners() {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n listeners.forEach(function (listener) {\n return listener.apply(undefined, args);\n });\n };\n\n return {\n setPrompt: setPrompt,\n confirmTransitionTo: confirmTransitionTo,\n appendListener: appendListener,\n notifyListeners: notifyListeners\n };\n};\n\nexports.default = createTransitionManager;","export var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);\n\nexport var addEventListener = function addEventListener(node, event, listener) {\n return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener);\n};\n\nexport var removeEventListener = function removeEventListener(node, event, listener) {\n return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener);\n};\n\nexport var getConfirmation = function getConfirmation(message, callback) {\n return callback(window.confirm(message));\n}; // eslint-disable-line no-alert\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/reactjs/react-router/issues/586\n */\nexport var supportsHistory = function supportsHistory() {\n var ua = window.navigator.userAgent;\n\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) return false;\n\n return window.history && 'pushState' in window.history;\n};\n\n/**\n * Returns true if browser fires popstate on hash change.\n * IE10 and IE11 do not.\n */\nexport var supportsPopStateOnHashChange = function supportsPopStateOnHashChange() {\n return window.navigator.userAgent.indexOf('Trident') === -1;\n};\n\n/**\n * Returns false if using go(n) with hash history causes a full page reload.\n */\nexport var supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() {\n return window.navigator.userAgent.indexOf('Firefox') === -1;\n};\n\n/**\n * Returns true if a given popstate event is an extraneous WebKit event.\n * Accounts for the fact that Chrome on iOS fires real popstate events\n * containing undefined state when pressing the back button.\n */\nexport var isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) {\n return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;\n};","var _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\nimport resolvePathname from 'resolve-pathname';\nimport valueEqual from 'value-equal';\nimport { parsePath } from './PathUtils';\n\nexport var createLocation = function createLocation(path, state, key, currentLocation) {\n var location = void 0;\n if (typeof path === 'string') {\n // Two-arg form: push(path, state)\n location = parsePath(path);\n location.state = state;\n } else {\n // One-arg form: push(location)\n location = _extends({}, path);\n\n if (location.pathname === undefined) location.pathname = '';\n\n if (location.search) {\n if (location.search.charAt(0) !== '?') location.search = '?' + location.search;\n } else {\n location.search = '';\n }\n\n if (location.hash) {\n if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;\n } else {\n location.hash = '';\n }\n\n if (state !== undefined && location.state === undefined) location.state = state;\n }\n\n try {\n location.pathname = decodeURI(location.pathname);\n } catch (e) {\n if (e instanceof URIError) {\n throw new URIError('Pathname \"' + location.pathname + '\" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');\n } else {\n throw e;\n }\n }\n\n if (key) location.key = key;\n\n if (currentLocation) {\n // Resolve incomplete/relative pathname relative to current location.\n if (!location.pathname) {\n location.pathname = currentLocation.pathname;\n } else if (location.pathname.charAt(0) !== '/') {\n location.pathname = resolvePathname(location.pathname, currentLocation.pathname);\n }\n } else {\n // When there is no prior location and pathname is empty, set it to /\n if (!location.pathname) {\n location.pathname = '/';\n }\n }\n\n return location;\n};\n\nexport var locationsAreEqual = function locationsAreEqual(a, b) {\n return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);\n};","export var addLeadingSlash = function addLeadingSlash(path) {\n return path.charAt(0) === '/' ? path : '/' + path;\n};\n\nexport var stripLeadingSlash = function stripLeadingSlash(path) {\n return path.charAt(0) === '/' ? path.substr(1) : path;\n};\n\nexport var hasBasename = function hasBasename(path, prefix) {\n return new RegExp('^' + prefix + '(\\\\/|\\\\?|#|$)', 'i').test(path);\n};\n\nexport var stripBasename = function stripBasename(path, prefix) {\n return hasBasename(path, prefix) ? path.substr(prefix.length) : path;\n};\n\nexport var stripTrailingSlash = function stripTrailingSlash(path) {\n return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;\n};\n\nexport var parsePath = function parsePath(path) {\n var pathname = path || '/';\n var search = '';\n var hash = '';\n\n var hashIndex = pathname.indexOf('#');\n if (hashIndex !== -1) {\n hash = pathname.substr(hashIndex);\n pathname = pathname.substr(0, hashIndex);\n }\n\n var searchIndex = pathname.indexOf('?');\n if (searchIndex !== -1) {\n search = pathname.substr(searchIndex);\n pathname = pathname.substr(0, searchIndex);\n }\n\n return {\n pathname: pathname,\n search: search === '?' ? '' : search,\n hash: hash === '#' ? '' : hash\n };\n};\n\nexport var createPath = function createPath(location) {\n var pathname = location.pathname,\n search = location.search,\n hash = location.hash;\n\n\n var path = pathname || '/';\n\n if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;\n\n if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;\n\n return path;\n};","var _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\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\nimport warning from 'warning';\nimport invariant from 'invariant';\nimport { createLocation } from './LocationUtils';\nimport { addLeadingSlash, stripTrailingSlash, hasBasename, stripBasename, createPath } from './PathUtils';\nimport createTransitionManager from './createTransitionManager';\nimport { canUseDOM, addEventListener, removeEventListener, getConfirmation, supportsHistory, supportsPopStateOnHashChange, isExtraneousPopstateEvent } from './DOMUtils';\n\nvar PopStateEvent = 'popstate';\nvar HashChangeEvent = 'hashchange';\n\nvar getHistoryState = function getHistoryState() {\n try {\n return window.history.state || {};\n } catch (e) {\n // IE 11 sometimes throws when accessing window.history.state\n // See https://github.com/ReactTraining/history/pull/289\n return {};\n }\n};\n\n/**\n * Creates a history object that uses the HTML5 history API including\n * pushState, replaceState, and the popstate event.\n */\nvar createBrowserHistory = function createBrowserHistory() {\n var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n invariant(canUseDOM, 'Browser history needs a DOM');\n\n var globalHistory = window.history;\n var canUseHistory = supportsHistory();\n var needsHashChangeListener = !supportsPopStateOnHashChange();\n\n var _props$forceRefresh = props.forceRefresh,\n forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh,\n _props$getUserConfirm = props.getUserConfirmation,\n getUserConfirmation = _props$getUserConfirm === undefined ? getConfirmation : _props$getUserConfirm,\n _props$keyLength = props.keyLength,\n keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;\n\n var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';\n\n var getDOMLocation = function getDOMLocation(historyState) {\n var _ref = historyState || {},\n key = _ref.key,\n state = _ref.state;\n\n var _window$location = window.location,\n pathname = _window$location.pathname,\n search = _window$location.search,\n hash = _window$location.hash;\n\n\n var path = pathname + search + hash;\n\n warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path \"' + path + '\" to begin with \"' + basename + '\".');\n\n if (basename) path = stripBasename(path, basename);\n\n return createLocation(path, state, key);\n };\n\n var createKey = function createKey() {\n return Math.random().toString(36).substr(2, keyLength);\n };\n\n var transitionManager = createTransitionManager();\n\n var setState = function setState(nextState) {\n _extends(history, nextState);\n\n history.length = globalHistory.length;\n\n transitionManager.notifyListeners(history.location, history.action);\n };\n\n var handlePopState = function handlePopState(event) {\n // Ignore extraneous popstate events in WebKit.\n if (isExtraneousPopstateEvent(event)) return;\n\n handlePop(getDOMLocation(event.state));\n };\n\n var handleHashChange = function handleHashChange() {\n handlePop(getDOMLocation(getHistoryState()));\n };\n\n var forceNextPop = false;\n\n var handlePop = function handlePop(location) {\n if (forceNextPop) {\n forceNextPop = false;\n setState();\n } else {\n var action = 'POP';\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({ action: action, location: location });\n } else {\n revertPop(location);\n }\n });\n }\n };\n\n var revertPop = function revertPop(fromLocation) {\n var toLocation = history.location;\n\n // TODO: We could probably make this more reliable by\n // keeping a list of keys we've seen in sessionStorage.\n // Instead, we just default to 0 for keys we don't know.\n\n var toIndex = allKeys.indexOf(toLocation.key);\n\n if (toIndex === -1) toIndex = 0;\n\n var fromIndex = allKeys.indexOf(fromLocation.key);\n\n if (fromIndex === -1) fromIndex = 0;\n\n var delta = toIndex - fromIndex;\n\n if (delta) {\n forceNextPop = true;\n go(delta);\n }\n };\n\n var initialLocation = getDOMLocation(getHistoryState());\n var allKeys = [initialLocation.key];\n\n // Public interface\n\n var createHref = function createHref(location) {\n return basename + createPath(location);\n };\n\n var push = function push(path, state) {\n warning(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'PUSH';\n var location = createLocation(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var href = createHref(location);\n var key = location.key,\n state = location.state;\n\n\n if (canUseHistory) {\n globalHistory.pushState({ key: key, state: state }, null, href);\n\n if (forceRefresh) {\n window.location.href = href;\n } else {\n var prevIndex = allKeys.indexOf(history.location.key);\n var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);\n\n nextKeys.push(location.key);\n allKeys = nextKeys;\n\n setState({ action: action, location: location });\n }\n } else {\n warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history');\n\n window.location.href = href;\n }\n });\n };\n\n var replace = function replace(path, state) {\n warning(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'REPLACE';\n var location = createLocation(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var href = createHref(location);\n var key = location.key,\n state = location.state;\n\n\n if (canUseHistory) {\n globalHistory.replaceState({ key: key, state: state }, null, href);\n\n if (forceRefresh) {\n window.location.replace(href);\n } else {\n var prevIndex = allKeys.indexOf(history.location.key);\n\n if (prevIndex !== -1) allKeys[prevIndex] = location.key;\n\n setState({ action: action, location: location });\n }\n } else {\n warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history');\n\n window.location.replace(href);\n }\n });\n };\n\n var go = function go(n) {\n globalHistory.go(n);\n };\n\n var goBack = function goBack() {\n return go(-1);\n };\n\n var goForward = function goForward() {\n return go(1);\n };\n\n var listenerCount = 0;\n\n var checkDOMListeners = function checkDOMListeners(delta) {\n listenerCount += delta;\n\n if (listenerCount === 1) {\n addEventListener(window, PopStateEvent, handlePopState);\n\n if (needsHashChangeListener) addEventListener(window, HashChangeEvent, handleHashChange);\n } else if (listenerCount === 0) {\n removeEventListener(window, PopStateEvent, handlePopState);\n\n if (needsHashChangeListener) removeEventListener(window, HashChangeEvent, handleHashChange);\n }\n };\n\n var isBlocked = false;\n\n var block = function block() {\n var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n var unblock = transitionManager.setPrompt(prompt);\n\n if (!isBlocked) {\n checkDOMListeners(1);\n isBlocked = true;\n }\n\n return function () {\n if (isBlocked) {\n isBlocked = false;\n checkDOMListeners(-1);\n }\n\n return unblock();\n };\n };\n\n var listen = function listen(listener) {\n var unlisten = transitionManager.appendListener(listener);\n checkDOMListeners(1);\n\n return function () {\n checkDOMListeners(-1);\n unlisten();\n };\n };\n\n var history = {\n length: globalHistory.length,\n action: 'POP',\n location: initialLocation,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n block: block,\n listen: listen\n };\n\n return history;\n};\n\nexport default createBrowserHistory;","var _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\nimport warning from 'warning';\nimport invariant from 'invariant';\nimport { createLocation, locationsAreEqual } from './LocationUtils';\nimport { addLeadingSlash, stripLeadingSlash, stripTrailingSlash, hasBasename, stripBasename, createPath } from './PathUtils';\nimport createTransitionManager from './createTransitionManager';\nimport { canUseDOM, addEventListener, removeEventListener, getConfirmation, supportsGoWithoutReloadUsingHash } from './DOMUtils';\n\nvar HashChangeEvent = 'hashchange';\n\nvar HashPathCoders = {\n hashbang: {\n encodePath: function encodePath(path) {\n return path.charAt(0) === '!' ? path : '!/' + stripLeadingSlash(path);\n },\n decodePath: function decodePath(path) {\n return path.charAt(0) === '!' ? path.substr(1) : path;\n }\n },\n noslash: {\n encodePath: stripLeadingSlash,\n decodePath: addLeadingSlash\n },\n slash: {\n encodePath: addLeadingSlash,\n decodePath: addLeadingSlash\n }\n};\n\nvar getHashPath = function getHashPath() {\n // We can't use window.location.hash here because it's not\n // consistent across browsers - Firefox will pre-decode it!\n var href = window.location.href;\n var hashIndex = href.indexOf('#');\n return hashIndex === -1 ? '' : href.substring(hashIndex + 1);\n};\n\nvar pushHashPath = function pushHashPath(path) {\n return window.location.hash = path;\n};\n\nvar replaceHashPath = function replaceHashPath(path) {\n var hashIndex = window.location.href.indexOf('#');\n\n window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);\n};\n\nvar createHashHistory = function createHashHistory() {\n var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n invariant(canUseDOM, 'Hash history needs a DOM');\n\n var globalHistory = window.history;\n var canGoWithoutReload = supportsGoWithoutReloadUsingHash();\n\n var _props$getUserConfirm = props.getUserConfirmation,\n getUserConfirmation = _props$getUserConfirm === undefined ? getConfirmation : _props$getUserConfirm,\n _props$hashType = props.hashType,\n hashType = _props$hashType === undefined ? 'slash' : _props$hashType;\n\n var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';\n\n var _HashPathCoders$hashT = HashPathCoders[hashType],\n encodePath = _HashPathCoders$hashT.encodePath,\n decodePath = _HashPathCoders$hashT.decodePath;\n\n\n var getDOMLocation = function getDOMLocation() {\n var path = decodePath(getHashPath());\n\n warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path \"' + path + '\" to begin with \"' + basename + '\".');\n\n if (basename) path = stripBasename(path, basename);\n\n return createLocation(path);\n };\n\n var transitionManager = createTransitionManager();\n\n var setState = function setState(nextState) {\n _extends(history, nextState);\n\n history.length = globalHistory.length;\n\n transitionManager.notifyListeners(history.location, history.action);\n };\n\n var forceNextPop = false;\n var ignorePath = null;\n\n var handleHashChange = function handleHashChange() {\n var path = getHashPath();\n var encodedPath = encodePath(path);\n\n if (path !== encodedPath) {\n // Ensure we always have a properly-encoded hash.\n replaceHashPath(encodedPath);\n } else {\n var location = getDOMLocation();\n var prevLocation = history.location;\n\n if (!forceNextPop && locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.\n\n if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.\n\n ignorePath = null;\n\n handlePop(location);\n }\n };\n\n var handlePop = function handlePop(location) {\n if (forceNextPop) {\n forceNextPop = false;\n setState();\n } else {\n var action = 'POP';\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({ action: action, location: location });\n } else {\n revertPop(location);\n }\n });\n }\n };\n\n var revertPop = function revertPop(fromLocation) {\n var toLocation = history.location;\n\n // TODO: We could probably make this more reliable by\n // keeping a list of paths we've seen in sessionStorage.\n // Instead, we just default to 0 for paths we don't know.\n\n var toIndex = allPaths.lastIndexOf(createPath(toLocation));\n\n if (toIndex === -1) toIndex = 0;\n\n var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));\n\n if (fromIndex === -1) fromIndex = 0;\n\n var delta = toIndex - fromIndex;\n\n if (delta) {\n forceNextPop = true;\n go(delta);\n }\n };\n\n // Ensure the hash is encoded properly before doing anything else.\n var path = getHashPath();\n var encodedPath = encodePath(path);\n\n if (path !== encodedPath) replaceHashPath(encodedPath);\n\n var initialLocation = getDOMLocation();\n var allPaths = [createPath(initialLocation)];\n\n // Public interface\n\n var createHref = function createHref(location) {\n return '#' + encodePath(basename + createPath(location));\n };\n\n var push = function push(path, state) {\n warning(state === undefined, 'Hash history cannot push state; it is ignored');\n\n var action = 'PUSH';\n var location = createLocation(path, undefined, undefined, history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var path = createPath(location);\n var encodedPath = encodePath(basename + path);\n var hashChanged = getHashPath() !== encodedPath;\n\n if (hashChanged) {\n // We cannot tell if a hashchange was caused by a PUSH, so we'd\n // rather setState here and ignore the hashchange. The caveat here\n // is that other hash histories in the page will consider it a POP.\n ignorePath = path;\n pushHashPath(encodedPath);\n\n var prevIndex = allPaths.lastIndexOf(createPath(history.location));\n var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);\n\n nextPaths.push(path);\n allPaths = nextPaths;\n\n setState({ action: action, location: location });\n } else {\n warning(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');\n\n setState();\n }\n });\n };\n\n var replace = function replace(path, state) {\n warning(state === undefined, 'Hash history cannot replace state; it is ignored');\n\n var action = 'REPLACE';\n var location = createLocation(path, undefined, undefined, history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var path = createPath(location);\n var encodedPath = encodePath(basename + path);\n var hashChanged = getHashPath() !== encodedPath;\n\n if (hashChanged) {\n // We cannot tell if a hashchange was caused by a REPLACE, so we'd\n // rather setState here and ignore the hashchange. The caveat here\n // is that other hash histories in the page will consider it a POP.\n ignorePath = path;\n replaceHashPath(encodedPath);\n }\n\n var prevIndex = allPaths.indexOf(createPath(history.location));\n\n if (prevIndex !== -1) allPaths[prevIndex] = path;\n\n setState({ action: action, location: location });\n });\n };\n\n var go = function go(n) {\n warning(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');\n\n globalHistory.go(n);\n };\n\n var goBack = function goBack() {\n return go(-1);\n };\n\n var goForward = function goForward() {\n return go(1);\n };\n\n var listenerCount = 0;\n\n var checkDOMListeners = function checkDOMListeners(delta) {\n listenerCount += delta;\n\n if (listenerCount === 1) {\n addEventListener(window, HashChangeEvent, handleHashChange);\n } else if (listenerCount === 0) {\n removeEventListener(window, HashChangeEvent, handleHashChange);\n }\n };\n\n var isBlocked = false;\n\n var block = function block() {\n var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n var unblock = transitionManager.setPrompt(prompt);\n\n if (!isBlocked) {\n checkDOMListeners(1);\n isBlocked = true;\n }\n\n return function () {\n if (isBlocked) {\n isBlocked = false;\n checkDOMListeners(-1);\n }\n\n return unblock();\n };\n };\n\n var listen = function listen(listener) {\n var unlisten = transitionManager.appendListener(listener);\n checkDOMListeners(1);\n\n return function () {\n checkDOMListeners(-1);\n unlisten();\n };\n };\n\n var history = {\n length: globalHistory.length,\n action: 'POP',\n location: initialLocation,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n block: block,\n listen: listen\n };\n\n return history;\n};\n\nexport default createHashHistory;","var _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\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\nimport warning from 'warning';\nimport { createPath } from './PathUtils';\nimport { createLocation } from './LocationUtils';\nimport createTransitionManager from './createTransitionManager';\n\nvar clamp = function clamp(n, lowerBound, upperBound) {\n return Math.min(Math.max(n, lowerBound), upperBound);\n};\n\n/**\n * Creates a history object that stores locations in memory.\n */\nvar createMemoryHistory = function createMemoryHistory() {\n var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var getUserConfirmation = props.getUserConfirmation,\n _props$initialEntries = props.initialEntries,\n initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries,\n _props$initialIndex = props.initialIndex,\n initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex,\n _props$keyLength = props.keyLength,\n keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;\n\n\n var transitionManager = createTransitionManager();\n\n var setState = function setState(nextState) {\n _extends(history, nextState);\n\n history.length = history.entries.length;\n\n transitionManager.notifyListeners(history.location, history.action);\n };\n\n var createKey = function createKey() {\n return Math.random().toString(36).substr(2, keyLength);\n };\n\n var index = clamp(initialIndex, 0, initialEntries.length - 1);\n var entries = initialEntries.map(function (entry) {\n return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());\n });\n\n // Public interface\n\n var createHref = createPath;\n\n var push = function push(path, state) {\n warning(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'PUSH';\n var location = createLocation(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n var prevIndex = history.index;\n var nextIndex = prevIndex + 1;\n\n var nextEntries = history.entries.slice(0);\n if (nextEntries.length > nextIndex) {\n nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);\n } else {\n nextEntries.push(location);\n }\n\n setState({\n action: action,\n location: location,\n index: nextIndex,\n entries: nextEntries\n });\n });\n };\n\n var replace = function replace(path, state) {\n warning(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored');\n\n var action = 'REPLACE';\n var location = createLocation(path, state, createKey(), history.location);\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (!ok) return;\n\n history.entries[history.index] = location;\n\n setState({ action: action, location: location });\n });\n };\n\n var go = function go(n) {\n var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);\n\n var action = 'POP';\n var location = history.entries[nextIndex];\n\n transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {\n if (ok) {\n setState({\n action: action,\n location: location,\n index: nextIndex\n });\n } else {\n // Mimic the behavior of DOM histories by\n // causing a render after a cancelled POP.\n setState();\n }\n });\n };\n\n var goBack = function goBack() {\n return go(-1);\n };\n\n var goForward = function goForward() {\n return go(1);\n };\n\n var canGo = function canGo(n) {\n var nextIndex = history.index + n;\n return nextIndex >= 0 && nextIndex < history.entries.length;\n };\n\n var block = function block() {\n var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n return transitionManager.setPrompt(prompt);\n };\n\n var listen = function listen(listener) {\n return transitionManager.appendListener(listener);\n };\n\n var history = {\n length: entries.length,\n action: 'POP',\n location: entries[index],\n index: index,\n entries: entries,\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n goBack: goBack,\n goForward: goForward,\n canGo: canGo,\n block: block,\n listen: listen\n };\n\n return history;\n};\n\nexport default createMemoryHistory;","import warning from 'warning';\n\nvar createTransitionManager = function createTransitionManager() {\n var prompt = null;\n\n var setPrompt = function setPrompt(nextPrompt) {\n warning(prompt == null, 'A history supports only one prompt at a time');\n\n prompt = nextPrompt;\n\n return function () {\n if (prompt === nextPrompt) prompt = null;\n };\n };\n\n var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) {\n // TODO: If another transition starts while we're still confirming\n // the previous one, we may end up in a weird state. Figure out the\n // best way to handle this.\n if (prompt != null) {\n var result = typeof prompt === 'function' ? prompt(location, action) : prompt;\n\n if (typeof result === 'string') {\n if (typeof getUserConfirmation === 'function') {\n getUserConfirmation(result, callback);\n } else {\n warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message');\n\n callback(true);\n }\n } else {\n // Return false from a transition hook to cancel the transition.\n callback(result !== false);\n }\n } else {\n callback(true);\n }\n };\n\n var listeners = [];\n\n var appendListener = function appendListener(fn) {\n var isActive = true;\n\n var listener = function listener() {\n if (isActive) fn.apply(undefined, arguments);\n };\n\n listeners.push(listener);\n\n return function () {\n isActive = false;\n listeners = listeners.filter(function (item) {\n return item !== listener;\n });\n };\n };\n\n var notifyListeners = function notifyListeners() {\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n listeners.forEach(function (listener) {\n return listener.apply(undefined, args);\n });\n };\n\n return {\n setPrompt: setPrompt,\n confirmTransitionTo: confirmTransitionTo,\n appendListener: appendListener,\n notifyListeners: notifyListeners\n };\n};\n\nexport default createTransitionManager;","import _createBrowserHistory from './createBrowserHistory';\nexport { _createBrowserHistory as createBrowserHistory };\nimport _createHashHistory from './createHashHistory';\nexport { _createHashHistory as createHashHistory };\nimport _createMemoryHistory from './createMemoryHistory';\nexport { _createMemoryHistory as createMemoryHistory };\n\nexport { createLocation, locationsAreEqual } from './LocationUtils';\nexport { parsePath, createPath } from './PathUtils';","/**\n * Copyright 2015, Yahoo! Inc.\n * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.\n */\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.hoistNonReactStatics = factory());\n}(this, (function () {\n 'use strict';\n \n var REACT_STATICS = {\n childContextTypes: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true\n };\n \n var KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true\n };\n \n var defineProperty = Object.defineProperty;\n var getOwnPropertyNames = Object.getOwnPropertyNames;\n var getOwnPropertySymbols = Object.getOwnPropertySymbols;\n var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\n var getPrototypeOf = Object.getPrototypeOf;\n var objectPrototype = getPrototypeOf && getPrototypeOf(Object);\n \n return function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {\n if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components\n \n if (objectPrototype) {\n var inheritedComponent = getPrototypeOf(sourceComponent);\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);\n }\n }\n \n var keys = getOwnPropertyNames(sourceComponent);\n \n if (getOwnPropertySymbols) {\n keys = keys.concat(getOwnPropertySymbols(sourceComponent));\n }\n \n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) {\n var descriptor = getOwnPropertyDescriptor(sourceComponent, key);\n try { // Avoid failures from read-only properties\n defineProperty(targetComponent, key, descriptor);\n } catch (e) {}\n }\n }\n \n return targetComponent;\n }\n \n return targetComponent;\n };\n})));\n","exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","'use strict';\nvar Mutation = global.MutationObserver || global.WebKitMutationObserver;\n\nvar scheduleDrain;\n\n{\n if (Mutation) {\n var called = 0;\n var observer = new Mutation(nextTick);\n var element = global.document.createTextNode('');\n observer.observe(element, {\n characterData: true\n });\n scheduleDrain = function () {\n element.data = (called = ++called % 2);\n };\n } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {\n var channel = new global.MessageChannel();\n channel.port1.onmessage = nextTick;\n scheduleDrain = function () {\n channel.port2.postMessage(0);\n };\n } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {\n scheduleDrain = function () {\n\n // Create a