From e01771302bbbb53fce6a76a3ad3923934200c914 Mon Sep 17 00:00:00 2001 From: jordangarcia Date: Sun, 1 Nov 2015 19:39:38 -0800 Subject: [PATCH] Build dist for 1.2.0 --- dist/nuclear.js | 2089 ++++++++++++++++++++++++++----------------- dist/nuclear.min.js | 6 +- 2 files changed, 1250 insertions(+), 845 deletions(-) diff --git a/dist/nuclear.js b/dist/nuclear.js index d0d9c35..d8e1839 100644 --- a/dist/nuclear.js +++ b/dist/nuclear.js @@ -54,100 +54,207 @@ return /******/ (function(modules) { // webpackBootstrap /* 0 */ /***/ function(module, exports, __webpack_require__) { - var helpers = __webpack_require__(1) + 'use strict'; - /** - * @return {Reactor} - */ - exports.Reactor = __webpack_require__(4) + Object.defineProperty(exports, '__esModule', { + value: true + }); - /** - * @return {Store} - */ - exports.Store = __webpack_require__(13) + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - // export the immutable library - exports.Immutable = __webpack_require__(2) + __webpack_require__(1); - /** - * @return {boolean} - */ - exports.isKeyPath = __webpack_require__(10).isKeyPath + var _store = __webpack_require__(2); - /** - * @return {boolean} - */ - exports.isGetter = __webpack_require__(9).isGetter + var _store2 = _interopRequireDefault(_store); + + var _reactor = __webpack_require__(6); + + var _reactor2 = _interopRequireDefault(_reactor); + + var _immutable = __webpack_require__(3); + + var _immutable2 = _interopRequireDefault(_immutable); + + var _immutableHelpers = __webpack_require__(5); + + var _keyPath = __webpack_require__(11); - // expose helper functions - exports.toJS = helpers.toJS - exports.toImmutable = helpers.toImmutable - exports.isImmutable = helpers.isImmutable + var _getter = __webpack_require__(10); - exports.createReactMixin = __webpack_require__(12) + var _createReactMixin = __webpack_require__(7); + var _createReactMixin2 = _interopRequireDefault(_createReactMixin); + + exports['default'] = { + Reactor: _reactor2['default'], + Store: _store2['default'], + Immutable: _immutable2['default'], + isKeyPath: _keyPath.isKeyPath, + isGetter: _getter.isGetter, + toJS: _immutableHelpers.toJS, + toImmutable: _immutableHelpers.toImmutable, + isImmutable: _immutableHelpers.isImmutable, + createReactMixin: _createReactMixin2['default'] + }; + module.exports = exports['default']; /***/ }, /* 1 */ +/***/ function(module, exports) { + + "use strict"; + + try { + if (!(window.console && console.log)) { + console = { + log: function log() {}, + debug: function debug() {}, + info: function info() {}, + warn: function warn() {}, + error: function error() {} + }; + } + } catch (e) {} + +/***/ }, +/* 2 */ /***/ function(module, exports, __webpack_require__) { - var Immutable = __webpack_require__(2) - var isObject = __webpack_require__(3).isObject + 'use strict'; - /** - * A collection of helpers for the ImmutableJS library - */ + Object.defineProperty(exports, '__esModule', { + value: true + }); - /** - * @param {*} obj - * @return {boolean} - */ - function isImmutable(obj) { - return Immutable.Iterable.isIterable(obj) - } + var _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; }; })(); - /** - * Returns true if the value is an ImmutableJS data structure - * or a JavaScript primitive that is immutable (string, number, etc) - * @param {*} obj - * @return {boolean} - */ - function isImmutableValue(obj) { - return ( - isImmutable(obj) || - !isObject(obj) - ) - } + exports.isStore = isStore; - /** - * Converts an Immutable Sequence to JS object - * Can be called on any type - */ - function toJS(arg) { - // arg instanceof Immutable.Sequence is unreliable - return (isImmutable(arg)) - ? arg.toJS() - : arg - } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + var _immutable = __webpack_require__(3); + + var _utils = __webpack_require__(4); + + var _immutableHelpers = __webpack_require__(5); /** - * Converts a JS object to an Immutable object, if it's - * already Immutable its a no-op + * Stores define how a certain domain of the application should respond to actions + * taken on the whole system. They manage their own section of the entire app state + * and have no knowledge about the other parts of the application state. */ - function toImmutable(arg) { - return (isImmutable(arg)) - ? arg - : Immutable.fromJS(arg) - } - exports.toJS = toJS - exports.toImmutable = toImmutable - exports.isImmutable = isImmutable - exports.isImmutableValue = isImmutableValue + var Store = (function () { + function Store(config) { + _classCallCheck(this, Store); + + this.__handlers = (0, _immutable.Map)({}); + + if (config) { + // allow `MyStore extends Store` syntax without throwing error + (0, _utils.extend)(this, config); + } + + this.initialize(); + } + + /** + * This method is overridden by extending classes to setup message handlers + * via `this.on` and to set up the initial state + * + * Anything returned from this function will be coerced into an ImmutableJS value + * and set as the initial state for the part of the ReactorCore + */ + + _createClass(Store, [{ + key: 'initialize', + value: function initialize() {} + // extending classes implement to setup action handlers + + /** + * Overridable method to get the initial state for this type of store + */ + + }, { + key: 'getInitialState', + value: function getInitialState() { + return (0, _immutable.Map)(); + } + + /** + * Takes a current reactor state, action type and payload + * does the reaction and returns the new state + */ + }, { + key: 'handle', + value: function handle(state, type, payload) { + var handler = this.__handlers.get(type); + + if (typeof handler === 'function') { + return handler.call(this, state, payload, type); + } + + return state; + } + + /** + * Pure function taking the current state of store and returning + * the new state after a NuclearJS reactor has been reset + * + * Overridable + */ + }, { + key: 'handleReset', + value: function handleReset(state) { + return this.getInitialState(); + } + + /** + * Binds an action type => handler + */ + }, { + key: 'on', + value: function on(actionType, handler) { + this.__handlers = this.__handlers.set(actionType, handler); + } + + /** + * Serializes store state to plain JSON serializable JavaScript + * Overridable + * @param {*} + * @return {*} + */ + }, { + key: 'serialize', + value: function serialize(state) { + return (0, _immutableHelpers.toJS)(state); + } + + /** + * Deserializes plain JavaScript to store state + * Overridable + * @param {*} + * @return {*} + */ + }, { + key: 'deserialize', + value: function deserialize(state) { + return (0, _immutableHelpers.toImmutable)(state); + } + }]); + + return Store; + })(); + + function isStore(toTest) { + return toTest instanceof Store; + } + exports['default'] = (0, _utils.toFactory)(Store); /***/ }, -/* 2 */ +/* 3 */ /***/ function(module, exports, __webpack_require__) { /** @@ -5112,7 +5219,7 @@ return /******/ (function(modules) { // webpackBootstrap })); /***/ }, -/* 3 */ +/* 4 */ /***/ function(module, exports) { /** @@ -5120,18 +5227,21 @@ return /******/ (function(modules) { // webpackBootstrap * @param {*} val * @return {boolean} */ - exports.isString = function(val) { - return typeof val === 'string' || objectToString(val) === '[object String]' - } + 'use strict'; + + var _bind = Function.prototype.bind; + exports.isString = function (val) { + return typeof val === 'string' || objectToString(val) === '[object String]'; + }; /** * Checks if the passed in value is an array * @param {*} val * @return {boolean} */ - exports.isArray = Array.isArray /* istanbul ignore next */|| function(val) { - return objectToString(val) === '[object Array]' - } + exports.isArray = Array.isArray /* istanbul ignore next */ || function (val) { + return objectToString(val) === '[object Array]'; + }; // taken from underscore source to account for browser discrepancy /* istanbul ignore if */ @@ -5141,18 +5251,18 @@ return /******/ (function(modules) { // webpackBootstrap * @param {*} val * @return {boolean} */ - exports.isFunction = function(obj) { - return typeof obj === 'function' || false - } + exports.isFunction = function (obj) { + return typeof obj === 'function' || false; + }; } else { /** * Checks if the passed in value is a function * @param {*} val * @return {boolean} */ - exports.isFunction = function(val) { - return toString.call(val) === '[object Function]' - } + exports.isFunction = function (val) { + return toString.call(val) === '[object Function]'; + }; } /** @@ -5160,10 +5270,10 @@ return /******/ (function(modules) { // webpackBootstrap * @param {*} val * @return {boolean} */ - exports.isObject = function(obj) { - var type = typeof obj - return type === 'function' || type === 'object' && !!obj - } + exports.isObject = function (obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + }; /** * Extends an object with the properties of additional objects @@ -5171,38 +5281,38 @@ return /******/ (function(modules) { // webpackBootstrap * @param {object} objects * @return {object} */ - exports.extend = function(obj) { - var length = arguments.length + exports.extend = function (obj) { + var length = arguments.length; if (!obj || length < 2) { - return obj || {} + return obj || {}; } for (var index = 1; index < length; index++) { - var source = arguments[index] - var keys = Object.keys(source) - var l = keys.length + var source = arguments[index]; + var keys = Object.keys(source); + var l = keys.length; for (var i = 0; i < l; i++) { - var key = keys[i] - obj[key] = source[key] + var key = keys[i]; + obj[key] = source[key]; } } - return obj - } + return obj; + }; /** * Creates a shallow clone of an object * @param {object} obj * @return {object} */ - exports.clone = function(obj) { + exports.clone = function (obj) { if (!exports.isObject(obj)) { - return obj + return obj; } - return exports.isArray(obj) ? obj.slice() : exports.extend({}, obj) - } + return exports.isArray(obj) ? obj.slice() : exports.extend({}, obj); + }; /** * Iterates over a collection of elements yielding each iteration to an @@ -5214,37 +5324,37 @@ return /******/ (function(modules) { // webpackBootstrap * @param {*} context * @return {array|object|string} */ - exports.each = function(collection, iteratee, context) { - var length = collection ? collection.length : 0 - var i = -1 - var keys - var origIteratee + exports.each = function (collection, iteratee, context) { + var length = collection ? collection.length : 0; + var i = -1; + var keys; + var origIteratee; if (context) { - origIteratee = iteratee - iteratee = function(value, index, innerCollection) { - return origIteratee.call(context, value, index, innerCollection) - } + origIteratee = iteratee; + iteratee = function (value, index, innerCollection) { + return origIteratee.call(context, value, index, innerCollection); + }; } if (isLength(length)) { while (++i < length) { if (iteratee(collection[i], i, collection) === false) { - break + break; } } } else { - keys = Object.keys(collection) - length = keys.length + keys = Object.keys(collection); + length = keys.length; while (++i < length) { if (iteratee(collection[keys[i]], keys[i], collection) === false) { - break + break; } } } - return collection - } + return collection; + }; /** * Returns a new function the invokes `func` with `partialArgs` prepended to @@ -5254,14 +5364,31 @@ return /******/ (function(modules) { // webpackBootstrap * @param {*} partialArgs * @return {function} */ - exports.partial = function(func) { - var slice = Array.prototype.slice - var partialArgs = slice.call(arguments, 1) + exports.partial = function (func) { + var slice = Array.prototype.slice; + var partialArgs = slice.call(arguments, 1); - return function() { - return func.apply(this, partialArgs.concat(slice.call(arguments))) - } - } + return function () { + return func.apply(this, partialArgs.concat(slice.call(arguments))); + }; + }; + + /** + * Returns a factory method that allows construction with or without `new` + */ + exports.toFactory = function (Klass) { + var Factory = function Factory() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return new (_bind.apply(Klass, [null].concat(args)))(); + }; + + Factory.__proto__ = Klass; // eslint-disable-line no-proto + Factory.prototype = Klass.prototype; + return Factory; + }; /** * Returns the text value representation of an object @@ -5270,7 +5397,7 @@ return /******/ (function(modules) { // webpackBootstrap * @return {string} */ function objectToString(obj) { - return obj && typeof obj === 'object' && toString.call(obj) + return obj && typeof obj === 'object' && toString.call(obj); } /** @@ -5280,31 +5407,113 @@ return /******/ (function(modules) { // webpackBootstrap * @return {bool} */ function isLength(val) { - return typeof val === 'number' - && val > -1 - && val % 1 === 0 - && val <= Number.MAX_VALUE + return typeof val === 'number' && val > -1 && val % 1 === 0 && val <= Number.MAX_VALUE; + } + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.isImmutable = isImmutable; + exports.isImmutableValue = isImmutableValue; + exports.toJS = toJS; + exports.toImmutable = toImmutable; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _immutable = __webpack_require__(3); + + var _immutable2 = _interopRequireDefault(_immutable); + + var _utils = __webpack_require__(4); + + /** + * A collection of helpers for the ImmutableJS library + */ + + /** + * @param {*} obj + * @return {boolean} + */ + + function isImmutable(obj) { + return _immutable2['default'].Iterable.isIterable(obj); + } + + /** + * Returns true if the value is an ImmutableJS data structure + * or a JavaScript primitive that is immutable (string, number, etc) + * @param {*} obj + * @return {boolean} + */ + + function isImmutableValue(obj) { + return isImmutable(obj) || !(0, _utils.isObject)(obj); + } + + /** + * Converts an Immutable Sequence to JS object + * Can be called on any type + */ + + function toJS(arg) { + // arg instanceof Immutable.Sequence is unreliable + return isImmutable(arg) ? arg.toJS() : arg; } + /** + * Converts a JS object to an Immutable object, if it's + * already Immutable its a no-op + */ + + function toImmutable(arg) { + return isImmutable(arg) ? arg : _immutable2['default'].fromJS(arg); + } /***/ }, -/* 4 */ +/* 6 */ /***/ function(module, exports, __webpack_require__) { - var Immutable = __webpack_require__(2) - var logging = __webpack_require__(5) - var ChangeObserver = __webpack_require__(6) - var Getter = __webpack_require__(9) - var KeyPath = __webpack_require__(10) - var Evaluator = __webpack_require__(11) - var createReactMixin = __webpack_require__(12) + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + var _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; }; })(); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _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; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + + var _immutable = __webpack_require__(3); + + var _immutable2 = _interopRequireDefault(_immutable); - // helper fns - var toJS = __webpack_require__(1).toJS - var toImmutable = __webpack_require__(1).toImmutable - var isImmutableValue = __webpack_require__(1).isImmutableValue - var each = __webpack_require__(3).each + var _createReactMixin = __webpack_require__(7); + var _createReactMixin2 = _interopRequireDefault(_createReactMixin); + + var _reactorFns = __webpack_require__(8); + + var _reactorFns2 = _interopRequireDefault(_reactorFns); + + var _keyPath = __webpack_require__(11); + + var _getter = __webpack_require__(10); + + var _immutableHelpers = __webpack_require__(5); + + var _utils = __webpack_require__(4); + + var _reactorRecords = __webpack_require__(12); /** * State is stored in NuclearJS Reactors. Reactors @@ -5316,38 +5525,27 @@ return /******/ (function(modules) { // webpackBootstrap * state based on the message */ - function Reactor(config) {"use strict"; - if (!(this instanceof Reactor)) { - return new Reactor(config) - } - config = config || {} + var Reactor = (function () { + function Reactor() { + var config = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - this.debug = !!config.debug + _classCallCheck(this, Reactor); - this.ReactMixin = createReactMixin(this) - /** - * The state for the whole cluster - */ - this.state = Immutable.Map({}) - /** - * Holds a map of id => store instance - */ - this.__stores = Immutable.Map({}) + var initialReactorState = new _reactorRecords.ReactorState({ + debug: config.debug + }); - this.__evaluator = new Evaluator() - /** - * Change observer interface to observe certain keypaths - * Created after __initialize so it starts with initialState - */ - this.__changeObserver = new ChangeObserver(this.state, this.__evaluator) + this.prevReactorState = initialReactorState; + this.reactorState = initialReactorState; + this.observerState = new _reactorRecords.ObserverState(); + + this.ReactMixin = (0, _createReactMixin2['default'])(this); // keep track of the depth of batch nesting - this.__batchDepth = 0 - // number of dispatches in the top most batch cycle - this.__batchDispatchCount = 0 + this.__batchDepth = 0; // keep track if we are currently dispatching - this.__isDispatching = false + this.__isDispatching = false; } /** @@ -5355,861 +5553,1068 @@ return /******/ (function(modules) { // webpackBootstrap * @param {KeyPath|Getter} keyPathOrGetter * @return {*} */ - Object.defineProperty(Reactor.prototype,"evaluate",{writable:true,configurable:true,value:function(keyPathOrGetter) {"use strict"; - return this.__evaluator.evaluate(this.state, keyPathOrGetter) - }}); - /** - * Gets the coerced state (to JS object) of the reactor.evaluate - * @param {KeyPath|Getter} keyPathOrGetter - * @return {*} - */ - Object.defineProperty(Reactor.prototype,"evaluateToJS",{writable:true,configurable:true,value:function(keyPathOrGetter) {"use strict"; - return toJS(this.evaluate(keyPathOrGetter)) - }}); - - /** - * Adds a change observer whenever a certain part of the reactor state changes - * - * 1. observe(handlerFn) - 1 argument, called anytime reactor.state changes - * 2. observe(keyPath, handlerFn) same as above - * 3. observe(getter, handlerFn) called whenever any getter dependencies change with - * the value of the getter - * - * Adds a change handler whenever certain deps change - * If only one argument is passed invoked the handler whenever - * the reactor state changes - * - * @param {KeyPath|Getter} getter - * @param {function} handler - * @return {function} unwatch function - */ - Object.defineProperty(Reactor.prototype,"observe",{writable:true,configurable:true,value:function(getter, handler) {"use strict"; - if (arguments.length === 1) { - handler = getter - getter = Getter.fromKeyPath([]) - } else if (KeyPath.isKeyPath(getter)) { - getter = Getter.fromKeyPath(getter) - } - return this.__changeObserver.onChange(getter, handler) - }}); + _createClass(Reactor, [{ + key: 'evaluate', + value: function evaluate(keyPathOrGetter) { + var _fns$evaluate = _reactorFns2['default'].evaluate(this.reactorState, keyPathOrGetter); + var result = _fns$evaluate.result; + var reactorState = _fns$evaluate.reactorState; - /** - * Dispatches a single message - * @param {string} actionType - * @param {object|undefined} payload - */ - Object.defineProperty(Reactor.prototype,"dispatch",{writable:true,configurable:true,value:function(actionType, payload) {"use strict"; - if (this.__batchDepth === 0) { - if (this.__isDispatching) { - this.__isDispatching = false - throw new Error('Dispatch may not be called while a dispatch is in progress') - } - this.__isDispatching = true + this.reactorState = reactorState; + return result; } - var prevState = this.state - - try { - this.state = this.__handleAction(prevState, actionType, payload) - } catch (e) { - this.__isDispatching = false - throw e + /** + * Gets the coerced state (to JS object) of the reactor.evaluate + * @param {KeyPath|Getter} keyPathOrGetter + * @return {*} + */ + }, { + key: 'evaluateToJS', + value: function evaluateToJS(keyPathOrGetter) { + return (0, _immutableHelpers.toJS)(this.evaluate(keyPathOrGetter)); } + /** + * Adds a change observer whenever a certain part of the reactor state changes + * + * 1. observe(handlerFn) - 1 argument, called anytime reactor.state changes + * 2. observe(keyPath, handlerFn) same as above + * 3. observe(getter, handlerFn) called whenever any getter dependencies change with + * the value of the getter + * + * Adds a change handler whenever certain deps change + * If only one argument is passed invoked the handler whenever + * the reactor state changes + * + * @param {KeyPath|Getter} getter + * @param {function} handler + * @return {function} unwatch function + */ + }, { + key: 'observe', + value: function observe(getter, handler) { + var _this = this; - if (this.__batchDepth > 0) { - this.__batchDispatchCount++ - } else { - if (this.state !== prevState) { - try { - this.__notify() - } catch (e) { - this.__isDispatching = false - throw e - } + if (arguments.length === 1) { + handler = getter; + getter = []; } - this.__isDispatching = false - } - }}); - /** - * Allows batching of dispatches before notifying change observers - * @param {Function} fn - */ - Object.defineProperty(Reactor.prototype,"batch",{writable:true,configurable:true,value:function(fn) {"use strict"; - this.__batchStart() - fn() - this.__batchEnd() - }}); + var _fns$addObserver = _reactorFns2['default'].addObserver(this.observerState, getter, handler); - /** - * @deprecated - * @param {String} id - * @param {Store} store - */ - Object.defineProperty(Reactor.prototype,"registerStore",{writable:true,configurable:true,value:function(id, store) {"use strict"; - /* eslint-disable no-console */ - console.warn('Deprecation warning: `registerStore` will no longer be supported in 1.1, use `registerStores` instead') - /* eslint-enable no-console */ - var stores = {} - stores[id] = store - this.registerStores(stores) - }}); + var observerState = _fns$addObserver.observerState; + var entry = _fns$addObserver.entry; - /** - * @param {Store[]} stores - */ - Object.defineProperty(Reactor.prototype,"registerStores",{writable:true,configurable:true,value:function(stores) {"use strict"; - each(stores, function(store, id) { - if (this.__stores.get(id)) { - /* eslint-disable no-console */ - console.warn('Store already defined for id = ' + id) - /* eslint-enable no-console */ + this.observerState = observerState; + return function () { + _this.observerState = _reactorFns2['default'].removeObserverByEntry(_this.observerState, entry); + }; + } + }, { + key: 'unobserve', + value: function unobserve(getter, handler) { + if (arguments.length === 0) { + throw new Error('Must call unobserve with a Getter'); + } + if (!(0, _getter.isGetter)(getter) && !(0, _keyPath.isKeyPath)(getter)) { + throw new Error('Must call unobserve with a Getter'); } - var initialState = store.getInitialState() + this.observerState = _reactorFns2['default'].removeObserver(this.observerState, getter, handler); + } - if (this.debug && !isImmutableValue(initialState)) { - throw new Error('Store getInitialState() must return an immutable value, did you forget to call toImmutable') + /** + * Dispatches a single message + * @param {string} actionType + * @param {object|undefined} payload + */ + }, { + key: 'dispatch', + value: function dispatch(actionType, payload) { + if (this.__batchDepth === 0) { + if (this.__isDispatching) { + this.__isDispatching = false; + throw new Error('Dispatch may not be called while a dispatch is in progress'); + } + this.__isDispatching = true; } - this.__stores = this.__stores.set(id, store) - this.state = this.state.set(id, initialState) - }.bind(this)) - - this.__notify() - }}); + try { + this.reactorState = _reactorFns2['default'].dispatch(this.reactorState, actionType, payload); + } catch (e) { + this.__isDispatching = false; + throw e; + } - /** - * Returns a plain object representing the application state - * @return {Object} - */ - Object.defineProperty(Reactor.prototype,"serialize",{writable:true,configurable:true,value:function() {"use strict"; - var serialized = {} - this.__stores.forEach(function(store, id) { - var storeState = this.state.get(id) - var serializedState = store.serialize(storeState) - if (serializedState !== undefined) { - serialized[id] = serializedState - } - }.bind(this)) - return serialized - }}); + try { + this.__notify(); + } finally { + this.__isDispatching = false; + } + } - /** - * @param {Object} state - */ - Object.defineProperty(Reactor.prototype,"loadState",{writable:true,configurable:true,value:function(state) {"use strict"; - var stateToLoad = toImmutable({}).withMutations(function(stateToLoad) { - each(state, function(serializedStoreState, storeId) { - var store = this.__stores.get(storeId) - if (store) { - var storeState = store.deserialize(serializedStoreState) - if (storeState !== undefined) { - stateToLoad.set(storeId, storeState) - } - } - }.bind(this)) - }.bind(this)) + /** + * Allows batching of dispatches before notifying change observers + * @param {Function} fn + */ + }, { + key: 'batch', + value: function batch(fn) { + this.batchStart(); + fn(); + this.batchEnd(); + } - this.state = this.state.merge(stateToLoad) - this.__notify() - }}); + /** + * @deprecated + * @param {String} id + * @param {Store} store + */ + }, { + key: 'registerStore', + value: function registerStore(id, store) { + /* eslint-disable no-console */ + console.warn('Deprecation warning: `registerStore` will no longer be supported in 1.1, use `registerStores` instead'); + /* eslint-enable no-console */ + this.registerStores(_defineProperty({}, id, store)); + } - /** - * Resets the state of a reactor and returns back to initial state - */ - Object.defineProperty(Reactor.prototype,"reset",{writable:true,configurable:true,value:function() {"use strict"; - var debug = this.debug - var prevState = this.state - - this.state = Immutable.Map().withMutations(function(state) { - this.__stores.forEach(function(store, id) { - var storeState = prevState.get(id) - var resetStoreState = store.handleReset(storeState) - if (debug && resetStoreState === undefined) { - throw new Error('Store handleReset() must return a value, did you forget a return statement') - } - if (debug && !isImmutableValue(resetStoreState)) { - throw new Error('Store reset state must be an immutable value, did you forget to call toImmutable') - } - state.set(id, resetStoreState) - }) - }.bind(this)) + /** + * @param {Store[]} stores + */ + }, { + key: 'registerStores', + value: function registerStores(stores) { + this.reactorState = _reactorFns2['default'].registerStores(this.reactorState, stores); + this.__notify(); + } - this.__evaluator.reset() - this.__changeObserver.reset(this.state) - }}); + /** + * Returns a plain object representing the application state + * @return {Object} + */ + }, { + key: 'serialize', + value: function serialize() { + return _reactorFns2['default'].serialize(this.reactorState); + } - /** - * Notifies all change observers with the current state - * @private - */ - Object.defineProperty(Reactor.prototype,"__notify",{writable:true,configurable:true,value:function() {"use strict"; - this.__changeObserver.notifyObservers(this.state) - }}); + /** + * @param {Object} state + */ + }, { + key: 'loadState', + value: function loadState(state) { + this.reactorState = _reactorFns2['default'].loadState(this.reactorState, state); + this.__notify(); + } - /** - * Reduces the current state to the new state given actionType / message - * @param {string} actionType - * @param {object|undefined} payload - * @return {Immutable.Map} - */ - Object.defineProperty(Reactor.prototype,"__handleAction",{writable:true,configurable:true,value:function(state, actionType, payload) {"use strict"; - return state.withMutations(function(state) { - if (this.debug) { - logging.dispatchStart(actionType, payload) + /** + * Resets the state of a reactor and returns back to initial state + */ + }, { + key: 'reset', + value: function reset() { + var newState = _reactorFns2['default'].reset(this.reactorState); + this.reactorState = newState; + this.prevReactorState = newState; + this.observerState = new _reactorRecords.ObserverState(); + } + + /** + * Notifies all change observers with the current state + * @private + */ + }, { + key: '__notify', + value: function __notify() { + var _this2 = this; + + if (this.__batchDepth > 0) { + // in the middle of batch, dont notify + return; } - // let each store handle the message - this.__stores.forEach(function(store, id) { - var currState = state.get(id) - var newState + var dirtyStores = this.reactorState.get('dirtyStores'); + if (dirtyStores.size === 0) { + return; + } - try { - newState = store.handle(currState, actionType, payload) - } catch(e) { - // ensure console.group is properly closed - logging.dispatchError(e.message) - throw e - } + var observerIdsToNotify = _immutable2['default'].Set().withMutations(function (set) { + // notify all observers + set.union(_this2.observerState.get('any')); + + dirtyStores.forEach(function (id) { + var entries = _this2.observerState.getIn(['stores', id]); + if (!entries) { + return; + } + set.union(entries); + }); + }); - if (this.debug && newState === undefined) { - var errorMsg = 'Store handler must return a value, did you forget a return statement' - logging.dispatchError(errorMsg) - throw new Error(errorMsg) + observerIdsToNotify.forEach(function (observerId) { + var entry = _this2.observerState.getIn(['observersMap', observerId]); + if (!entry) { + // don't notify here in the case a handler called unobserve on another observer + return; } - state.set(id, newState) + var getter = entry.get('getter'); + var handler = entry.get('handler'); + + var prevEvaluateResult = _reactorFns2['default'].evaluate(_this2.prevReactorState, getter); + var currEvaluateResult = _reactorFns2['default'].evaluate(_this2.reactorState, getter); + + _this2.prevReactorState = prevEvaluateResult.reactorState; + _this2.reactorState = currEvaluateResult.reactorState; + + var prevValue = prevEvaluateResult.result; + var currValue = currEvaluateResult.result; - if (this.debug) { - logging.storeHandled(id, currState, newState) + if (!_immutable2['default'].is(prevValue, currValue)) { + handler.call(null, currValue); } - }.bind(this)) + }); - if (this.debug) { - logging.dispatchEnd(state) - } - }.bind(this)) - }}); + var nextReactorState = _reactorFns2['default'].resetDirtyStores(this.reactorState); - Object.defineProperty(Reactor.prototype,"__batchStart",{writable:true,configurable:true,value:function() {"use strict"; - this.__batchDepth++ - }}); + this.prevReactorState = nextReactorState; + this.reactorState = nextReactorState; + } - Object.defineProperty(Reactor.prototype,"__batchEnd",{writable:true,configurable:true,value:function() {"use strict"; - this.__batchDepth-- + /** + * Starts batching, ie pausing notifies and batching up changes + * to be notified when batchEnd() is called + */ + }, { + key: 'batchStart', + value: function batchStart() { + this.__batchDepth++; + } + + /** + * Ends a batch cycle and will notify obsevers of all changes if + * the batch depth is back to 0 (outer most batch completed) + */ + }, { + key: 'batchEnd', + value: function batchEnd() { + this.__batchDepth--; - if (this.__batchDepth <= 0) { - if (this.__batchDispatchCount > 0) { + if (this.__batchDepth <= 0) { // set to true to catch if dispatch called from observer - this.__isDispatching = true + this.__isDispatching = true; try { - this.__notify() + this.__notify(); } catch (e) { - this.__isDispatching = false - throw e + this.__isDispatching = false; + throw e; } - this.__isDispatching = false + this.__isDispatching = false; } - this.__batchDispatchCount = 0 } - }}); + }]); + return Reactor; + })(); - module.exports = Reactor - + exports['default'] = (0, _utils.toFactory)(Reactor); + module.exports = exports['default']; /***/ }, -/* 5 */ -/***/ function(module, exports) { +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + + function _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; } + + var _utils = __webpack_require__(4); - /* eslint-disable no-console */ /** - * Wraps a Reactor.react invocation in a console.group - */ - exports.dispatchStart = function(type, payload) { - if (console.group) { - console.groupCollapsed('Dispatch: %s', type) - console.group('payload') - console.debug(payload) - console.groupEnd() - } + * Returns a mapping of the getDataBinding keys to + * the reactor values + */ + function getState(reactor, data) { + var state = {}; + (0, _utils.each)(data, function (value, key) { + state[key] = reactor.evaluate(value); + }); + return state; } - exports.dispatchError = function(error) { - if (console.group) { - console.debug('Dispatch error: ' + error) - console.groupEnd() - } - } + /** + * @param {Reactor} reactor + */ - exports.storeHandled = function(id, before, after) { - if (console.group) { - if (before !== after) { - console.debug('Store ' + id + ' handled action') - } - } - } + exports['default'] = function (reactor) { + return { + getInitialState: function getInitialState() { + return getState(reactor, this.getDataBindings()); + }, - exports.dispatchEnd = function(state) { - if (console.group) { - console.debug('Dispatch done, new state: ', state.toJS()) - console.groupEnd() - } - } - /* eslint-enable no-console */ + componentDidMount: function componentDidMount() { + var _this = this; + + this.__unwatchFns = []; + (0, _utils.each)(this.getDataBindings(), function (getter, key) { + var unwatchFn = reactor.observe(getter, function (val) { + _this.setState(_defineProperty({}, key, val)); + }); + + _this.__unwatchFns.push(unwatchFn); + }); + }, + componentWillUnmount: function componentWillUnmount() { + while (this.__unwatchFns.length) { + this.__unwatchFns.shift()(); + } + } + }; + }; + + module.exports = exports['default']; /***/ }, -/* 6 */ +/* 8 */ /***/ function(module, exports, __webpack_require__) { - var Immutable = __webpack_require__(2) - var hashCode = __webpack_require__(7) - var isEqual = __webpack_require__(8) + 'use strict'; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _immutable = __webpack_require__(3); + + var _immutable2 = _interopRequireDefault(_immutable); + + var _logging = __webpack_require__(9); + + var _logging2 = _interopRequireDefault(_logging); + + var _immutableHelpers = __webpack_require__(5); + + var _getter = __webpack_require__(10); + + var _keyPath = __webpack_require__(11); + + var _utils = __webpack_require__(4); /** - * ChangeObserver is an object that contains a set of subscriptions - * to changes for keyPaths on a reactor - * - * Packaging the handlers together allows for easier cleanup + * Immutable Types */ + var EvaluateResult = _immutable2['default'].Record({ result: null, reactorState: null }); - /** - * @param {Immutable.Map} initialState - * @param {Evaluator} evaluator - */ - function ChangeObserver(initialState, evaluator) {"use strict"; - this.__prevState = initialState - this.__evaluator = evaluator - this.__prevValues = Immutable.Map() - this.__observers = [] - } + function evaluateResult(result, reactorState) { + return new EvaluateResult({ + result: result, + reactorState: reactorState + }); + } - /** - * @param {Immutable.Map} newState - */ - Object.defineProperty(ChangeObserver.prototype,"notifyObservers",{writable:true,configurable:true,value:function(newState) {"use strict"; - if (this.__observers.length > 0) { - var currentValues = Immutable.Map() - - this.__observers.forEach(function(entry) { - var getter = entry.getter - var code = hashCode(getter) - var prevState = this.__prevState - var prevValue - - if (this.__prevValues.has(code)) { - prevValue = this.__prevValues.get(code) - } else { - prevValue = this.__evaluator.evaluate(prevState, getter) - this.__prevValues = this.__prevValues.set(code, prevValue) - } + /** + * @param {ReactorState} reactorState + * @param {Object} stores + * @return {ReactorState} + */ + exports.registerStores = function (reactorState, stores) { + var debug = reactorState.get('debug'); - var currValue = this.__evaluator.evaluate(newState, getter) + return reactorState.withMutations(function (reactorState) { + (0, _utils.each)(stores, function (store, id) { + if (reactorState.getIn(['stores', id])) { + /* eslint-disable no-console */ + console.warn('Store already defined for id = ' + id); + /* eslint-enable no-console */ + } - if (!isEqual(prevValue, currValue)) { - entry.handler.call(null, currValue) - currentValues = currentValues.set(code, currValue) - } - }.bind(this)) + var initialState = store.getInitialState(); - this.__prevValues = currentValues + if (debug && !(0, _immutableHelpers.isImmutableValue)(initialState)) { + throw new Error('Store getInitialState() must return an immutable value, did you forget to call toImmutable'); + } + + reactorState.update('stores', function (stores) { + return stores.set(id, store); + }).update('state', function (state) { + return state.set(id, initialState); + }).update('dirtyStores', function (state) { + return state.add(id); + }).update('storeStates', function (storeStates) { + return incrementStoreStates(storeStates, [id]); + }); + }); + incrementId(reactorState); + }); + }; + + /** + * @param {ReactorState} reactorState + * @param {String} actionType + * @param {*} payload + * @return {ReactorState} + */ + exports.dispatch = function (reactorState, actionType, payload) { + var currState = reactorState.get('state'); + var debug = reactorState.get('debug'); + var dirtyStores = reactorState.get('dirtyStores'); + + var nextState = currState.withMutations(function (state) { + if (debug) { + _logging2['default'].dispatchStart(actionType, payload); } - this.__prevState = newState - }}); - /** - * Specify a getter and a change handler function - * Handler function is called whenever the value of the getter changes - * @param {Getter} getter - * @param {function} handler - * @return {function} unwatch function - */ - Object.defineProperty(ChangeObserver.prototype,"onChange",{writable:true,configurable:true,value:function(getter, handler) {"use strict"; - // TODO: make observers a map of => { handlers } - var entry = { - getter: getter, - handler: handler, - } - this.__observers.push(entry) - // return unwatch function - return function() { - // TODO: untrack from change emitter - var ind = this.__observers.indexOf(entry) - if (ind > -1) { - this.__observers.splice(ind, 1) - } - }.bind(this) - }}); + // let each store handle the message + reactorState.get('stores').forEach(function (store, id) { + var currState = state.get(id); + var newState = undefined; - /** - * Resets and clears all observers and reinitializes back to the supplied - * previous state - * @param {Immutable.Map} prevState - * - */ - Object.defineProperty(ChangeObserver.prototype,"reset",{writable:true,configurable:true,value:function(prevState) {"use strict"; - this.__prevState = prevState - this.__prevValues = Immutable.Map() - this.__observers = [] - }}); + try { + newState = store.handle(currState, actionType, payload); + } catch (e) { + // ensure console.group is properly closed + _logging2['default'].dispatchError(e.message); + throw e; + } + if (debug && newState === undefined) { + var errorMsg = 'Store handler must return a value, did you forget a return statement'; + _logging2['default'].dispatchError(errorMsg); + throw new Error(errorMsg); + } - module.exports = ChangeObserver + state.set(id, newState); + if (currState !== newState) { + // if the store state changed add store to list of dirty stores + dirtyStores = dirtyStores.add(id); + } -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { + if (debug) { + _logging2['default'].storeHandled(id, currState, newState); + } + }); + + if (debug) { + _logging2['default'].dispatchEnd(state); + } + }); + + var nextReactorState = reactorState.set('state', nextState).set('dirtyStores', dirtyStores).update('storeStates', function (storeStates) { + return incrementStoreStates(storeStates, dirtyStores); + }); + + return incrementId(nextReactorState); + }; + + /** + * @param {ReactorState} reactorState + * @param {Immutable.Map} state + * @return {ReactorState} + */ + exports.loadState = function (reactorState, state) { + var dirtyStores = []; + var stateToLoad = (0, _immutableHelpers.toImmutable)({}).withMutations(function (stateToLoad) { + (0, _utils.each)(state, function (serializedStoreState, storeId) { + var store = reactorState.getIn(['stores', storeId]); + if (store) { + var storeState = store.deserialize(serializedStoreState); + if (storeState !== undefined) { + stateToLoad.set(storeId, storeState); + dirtyStores.push(storeId); + } + } + }); + }); - var Immutable = __webpack_require__(2) + var dirtyStoresSet = _immutable2['default'].Set(dirtyStores); + return reactorState.update('state', function (state) { + return state.merge(stateToLoad); + }).update('dirtyStores', function (stores) { + return stores.union(dirtyStoresSet); + }).update('storeStates', function (storeStates) { + return incrementStoreStates(storeStates, dirtyStores); + }); + }; /** - * Takes a getter and returns the hash code value + * Adds a change observer whenever a certain part of the reactor state changes * - * If cache argument is true it will freeze the getter - * and cache the hashed value + * 1. observe(handlerFn) - 1 argument, called anytime reactor.state changes + * 2. observe(keyPath, handlerFn) same as above + * 3. observe(getter, handlerFn) called whenever any getter dependencies change with + * the value of the getter * - * @param {Getter} getter - * @param {boolean} dontCache - * @return {number} + * Adds a change handler whenever certain deps change + * If only one argument is passed invoked the handler whenever + * the reactor state changes + * + * @param {ObserverState} observerState + * @param {KeyPath|Getter} getter + * @param {function} handler + * @return {ObserveResult} */ - module.exports = function(getter, dontCache) { - if (getter.hasOwnProperty('__hashCode')) { - return getter.__hashCode + exports.addObserver = function (observerState, getter, handler) { + // use the passed in getter as the key so we can rely on a byreference call for unobserve + var getterKey = getter; + if ((0, _keyPath.isKeyPath)(getter)) { + getter = (0, _getter.fromKeyPath)(getter); + } + + var currId = observerState.get('nextId'); + var storeDeps = (0, _getter.getStoreDeps)(getter); + var entry = _immutable2['default'].Map({ + id: currId, + storeDeps: storeDeps, + getterKey: getterKey, + getter: getter, + handler: handler + }); + + var updatedObserverState = undefined; + if (storeDeps.size === 0) { + // no storeDeps means the observer is dependent on any of the state changing + updatedObserverState = observerState.update('any', function (observerIds) { + return observerIds.add(currId); + }); + } else { + updatedObserverState = observerState.withMutations(function (map) { + storeDeps.forEach(function (storeId) { + var path = ['stores', storeId]; + if (!map.hasIn(path)) { + map.setIn(path, _immutable2['default'].Set([])); + } + map.updateIn(['stores', storeId], function (observerIds) { + return observerIds.add(currId); + }); + }); + }); } - var hashCode = Immutable.fromJS(getter).hashCode() + updatedObserverState = updatedObserverState.set('nextId', currId + 1).setIn(['observersMap', currId], entry); - if (!dontCache) { - Object.defineProperty(getter, '__hashCode', { - enumerable: false, - configurable: false, - writable: false, - value: hashCode, - }) + return { + observerState: updatedObserverState, + entry: entry + }; + }; - Object.freeze(getter) - } + /** + * Use cases + * removeObserver(observerState, []) + * removeObserver(observerState, [], handler) + * removeObserver(observerState, ['keyPath']) + * removeObserver(observerState, ['keyPath'], handler) + * removeObserver(observerState, getter) + * removeObserver(observerState, getter, handler) + * @param {ObserverState} observerState + * @param {KeyPath|Getter} getter + * @param {Function} handler + * @return {ObserverState} + */ + exports.removeObserver = function (observerState, getter, handler) { + var entriesToRemove = observerState.get('observersMap').filter(function (entry) { + // use the getterKey in the case of a keyPath is transformed to a getter in addObserver + var entryGetter = entry.get('getterKey'); + var handlersMatch = !handler || entry.get('handler') === handler; + if (!handlersMatch) { + return false; + } + // check for a by-value equality of keypaths + if ((0, _keyPath.isKeyPath)(getter) && (0, _keyPath.isKeyPath)(entryGetter)) { + return (0, _keyPath.isEqual)(getter, entryGetter); + } + // we are comparing two getters do it by reference + return getter === entryGetter; + }); - return hashCode - } + return observerState.withMutations(function (map) { + entriesToRemove.forEach(function (entry) { + return exports.removeObserverByEntry(map, entry); + }); + }); + }; + /** + * Removes an observer entry by id from the observerState + * @param {ObserverState} observerState + * @param {Immutable.Map} entry + * @return {ObserverState} + */ + exports.removeObserverByEntry = function (observerState, entry) { + return observerState.withMutations(function (map) { + var id = entry.get('id'); + var storeDeps = entry.get('storeDeps'); + + if (storeDeps.size === 0) { + map.update('any', function (anyObsevers) { + return anyObsevers.remove(id); + }); + } else { + storeDeps.forEach(function (storeId) { + map.updateIn(['stores', storeId], function (observers) { + if (observers) { + // check for observers being present because reactor.reset() can be called before an unwatch fn + return observers.remove(id); + } + return observers; + }); + }); + } -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { + map.removeIn(['observersMap', id]); + }); + }; - var Immutable = __webpack_require__(2) /** - * Is equal by value check + * @param {ReactorState} reactorState + * @return {ReactorState} */ - module.exports = function(a, b) { - return Immutable.is(a, b) - } + exports.reset = function (reactorState) { + var debug = reactorState.get('debug'); + var prevState = reactorState.get('state'); + + return reactorState.withMutations(function (reactorState) { + var storeMap = reactorState.get('stores'); + var storeIds = storeMap.keySeq().toJS(); + storeMap.forEach(function (store, id) { + var storeState = prevState.get(id); + var resetStoreState = store.handleReset(storeState); + if (debug && resetStoreState === undefined) { + throw new Error('Store handleReset() must return a value, did you forget a return statement'); + } + if (debug && !(0, _immutableHelpers.isImmutableValue)(resetStoreState)) { + throw new Error('Store reset state must be an immutable value, did you forget to call toImmutable'); + } + reactorState.setIn(['state', id], resetStoreState); + }); + + reactorState.update('storeStates', function (storeStates) { + return incrementStoreStates(storeStates, storeIds); + }); + exports.resetDirtyStores(reactorState); + }); + }; + /** + * @param {ReactorState} reactorState + * @param {KeyPath|Gettter} keyPathOrGetter + * @return {EvaluateResult} + */ + exports.evaluate = function evaluate(reactorState, keyPathOrGetter) { + var state = reactorState.get('state'); -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { + if ((0, _keyPath.isKeyPath)(keyPathOrGetter)) { + // if its a keyPath simply return + return evaluateResult(state.getIn(keyPathOrGetter), reactorState); + } else if (!(0, _getter.isGetter)(keyPathOrGetter)) { + throw new Error('evaluate must be passed a keyPath or Getter'); + } + + // Must be a Getter + // if the value is cached for this dispatch cycle, return the cached value + if (isCached(reactorState, keyPathOrGetter)) { + // Cache hit + return evaluateResult(getCachedValue(reactorState, keyPathOrGetter), reactorState); + } - var isFunction = __webpack_require__(3).isFunction - var isArray = __webpack_require__(3).isArray - var isKeyPath = __webpack_require__(10).isKeyPath + // evaluate dependencies + var args = (0, _getter.getDeps)(keyPathOrGetter).map(function (dep) { + return evaluate(reactorState, dep).result; + }); + var evaluatedValue = (0, _getter.getComputeFn)(keyPathOrGetter).apply(null, args); + + return evaluateResult(evaluatedValue, cacheValue(reactorState, keyPathOrGetter, evaluatedValue)); + }; /** - * Getter helper functions - * A getter is an array with the form: - * [, ..., ] + * Returns serialized state for all stores + * @param {ReactorState} reactorState + * @return {Object} */ - var identity = function(x) {return x;} + exports.serialize = function (reactorState) { + var serialized = {}; + reactorState.get('stores').forEach(function (store, id) { + var storeState = reactorState.getIn(['state', id]); + var serializedState = store.serialize(storeState); + if (serializedState !== undefined) { + serialized[id] = serializedState; + } + }); + return serialized; + }; /** - * Checks if something is a getter literal, ex: ['dep1', 'dep2', function(dep1, dep2) {...}] - * @param {*} toTest - * @return {boolean} + * Returns serialized state for all stores + * @param {ReactorState} reactorState + * @return {ReactorState} */ - function isGetter(toTest) { - return (isArray(toTest) && isFunction(toTest[toTest.length - 1])) - } + exports.resetDirtyStores = function (reactorState) { + return reactorState.set('dirtyStores', _immutable2['default'].Set()); + }; /** - * Returns the compute function from a getter + * Currently cache keys are always getters by reference * @param {Getter} getter - * @return {function} + * @return {Getter} */ - function getComputeFn(getter) { - return getter[getter.length - 1] + function getCacheKey(getter) { + return getter; } /** - * Returns an array of deps from a getter - * @param {Getter} getter - * @return {function} + * @param {ReactorState} reactorState + * @param {Getter|KeyPath} keyPathOrGetter + * @return {Immutable.Map} */ - function getDeps(getter) { - return getter.slice(0, getter.length - 1) + function getCacheEntry(reactorState, keyPathOrGetter) { + var key = getCacheKey(keyPathOrGetter); + return reactorState.getIn(['cache', key]); } /** - * @param {KeyPath} - * @return {Getter} + * @param {ReactorState} reactorState + * @param {Getter} getter + * @return {Boolean} */ - function fromKeyPath(keyPath) { - if (!isKeyPath(keyPath)) { - throw new Error('Cannot create Getter from KeyPath: ' + keyPath) + function isCached(reactorState, keyPathOrGetter) { + var entry = getCacheEntry(reactorState, keyPathOrGetter); + if (!entry) { + return false; } - return [keyPath, identity] + return entry.get('storeStates').every(function (stateId, storeId) { + return reactorState.getIn(['storeStates', storeId]) === stateId; + }); } + /** + * Caches the value of a getter given state, getter, args, value + * @param {ReactorState} reactorState + * @param {Getter} getter + * @param {*} value + * @return {ReactorState} + */ + function cacheValue(reactorState, getter, value) { + var cacheKey = getCacheKey(getter); + var dispatchId = reactorState.get('dispatchId'); + var storeDeps = (0, _getter.getStoreDeps)(getter); + var storeStates = (0, _immutableHelpers.toImmutable)({}).withMutations(function (map) { + storeDeps.forEach(function (storeId) { + var stateId = reactorState.getIn(['storeStates', storeId]); + map.set(storeId, stateId); + }); + }); - module.exports = { - isGetter: isGetter, - getComputeFn: getComputeFn, - getDeps: getDeps, - fromKeyPath: fromKeyPath, + return reactorState.setIn(['cache', cacheKey], _immutable2['default'].Map({ + value: value, + storeStates: storeStates, + dispatchId: dispatchId + })); } - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - var isArray = __webpack_require__(3).isArray - var isFunction = __webpack_require__(3).isFunction + /** + * Pulls out the cached value for a getter + */ + function getCachedValue(reactorState, getter) { + var key = getCacheKey(getter); + return reactorState.getIn(['cache', key, 'value']); + } /** - * Checks if something is simply a keyPath and not a getter - * @param {*} toTest - * @return {boolean} + * @param {ReactorState} reactorState + * @return {ReactorState} */ - exports.isKeyPath = function(toTest) { - return ( - isArray(toTest) && - !isFunction(toTest[toTest.length - 1]) - ) + function incrementId(reactorState) { + return reactorState.update('dispatchId', function (id) { + return id + 1; + }); } + /** + * @param {Immutable.Map} storeStates + * @param {Array} storeIds + * @return {Immutable.Map} + */ + function incrementStoreStates(storeStates, storeIds) { + return storeStates.withMutations(function (map) { + storeIds.forEach(function (id) { + var nextId = map.has(id) ? map.get(id) + 1 : 1; + map.set(id, nextId); + }); + }); + } /***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - var Immutable = __webpack_require__(2) - var toImmutable = __webpack_require__(1).toImmutable - var hashCode = __webpack_require__(7) - var isEqual = __webpack_require__(8) - var getComputeFn = __webpack_require__(9).getComputeFn - var getDeps = __webpack_require__(9).getDeps - var isKeyPath = __webpack_require__(10).isKeyPath - var isGetter = __webpack_require__(9).isGetter +/* 9 */ +/***/ function(module, exports) { - // Keep track of whether we are currently executing a Getter's computeFn - var __applyingComputeFn = false + /* eslint-disable no-console */ + /** + * Wraps a Reactor.react invocation in a console.group + */ + 'use strict'; + exports.dispatchStart = function (type, payload) { + if (console.group) { + console.groupCollapsed('Dispatch: %s', type); + console.group('payload'); + console.debug(payload); + console.groupEnd(); + } + }; - function Evaluator() {"use strict"; - /** - * { - * : { - * stateHashCode: number, - * args: Immutable.List, - * value: any, - * } - * } - */ - this.__cachedGetters = Immutable.Map({}) + exports.dispatchError = function (error) { + if (console.group) { + console.debug('Dispatch error: ' + error); + console.groupEnd(); } + }; - /** - * Takes either a KeyPath or Getter and evaluates - * - * KeyPath form: - * ['foo', 'bar'] => state.getIn(['foo', 'bar']) - * - * Getter form: - * [, , ..., ] - * - * @param {Immutable.Map} state - * @param {string|array} getter - * @return {any} - */ - Object.defineProperty(Evaluator.prototype,"evaluate",{writable:true,configurable:true,value:function(state, keyPathOrGetter) {"use strict"; - if (isKeyPath(keyPathOrGetter)) { - // if its a keyPath simply return - return state.getIn(keyPathOrGetter) - } else if (!isGetter(keyPathOrGetter)) { - throw new Error('evaluate must be passed a keyPath or Getter') + exports.storeHandled = function (id, before, after) { + if (console.group) { + if (before !== after) { + console.debug('Store ' + id + ' handled action'); } + } + }; - // Must be a Getter - var code = hashCode(keyPathOrGetter) + exports.dispatchEnd = function (state) { + if (console.group) { + console.debug('Dispatch done, new state: ', state.toJS()); + console.groupEnd(); + } + }; + /* eslint-enable no-console */ - // if the value is cached for this dispatch cycle, return the cached value - if (this.__isCached(state, keyPathOrGetter)) { - // Cache hit - return this.__cachedGetters.getIn([code, 'value']) +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { - } + 'use strict'; - // evaluate dependencies - var args = getDeps(keyPathOrGetter).map(function(dep) {return this.evaluate(state, dep);}.bind(this)) + Object.defineProperty(exports, '__esModule', { + value: true + }); - if (this.__hasStaleValue(state, keyPathOrGetter)) { - // getter deps could still be unchanged since we only looked at the unwrapped (keypath, bottom level) deps - var prevArgs = this.__cachedGetters.getIn([code, 'args']) + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - // since Getter is a pure functions if the args are the same its a cache hit - if (isEqual(prevArgs, toImmutable(args))) { - var prevValue = this.__cachedGetters.getIn([code, 'value']) - this.__cacheValue(state, keyPathOrGetter, prevArgs, prevValue) - return prevValue - } - } + var _immutable = __webpack_require__(3); - // This indicates that we have called evaluate within the body of a computeFn. - // Throw an error as this will lead to inconsistent caching - if (__applyingComputeFn === true) { - __applyingComputeFn = false - throw new Error('Evaluate may not be called within a Getters computeFn') - } + var _immutable2 = _interopRequireDefault(_immutable); - var evaluatedValue - __applyingComputeFn = true - try { - evaluatedValue = getComputeFn(keyPathOrGetter).apply(null, args) - __applyingComputeFn = false - } catch (e) { - __applyingComputeFn = false - throw e - } - - this.__cacheValue(state, keyPathOrGetter, args, evaluatedValue) + var _utils = __webpack_require__(4); - return evaluatedValue - }}); + var _keyPath = __webpack_require__(11); - /** - * @param {Immutable.Map} state - * @param {Getter} getter - */ - Object.defineProperty(Evaluator.prototype,"__hasStaleValue",{writable:true,configurable:true,value:function(state, getter) {"use strict"; - var code = hashCode(getter) - var cache = this.__cachedGetters - return ( - cache.has(code) && - cache.getIn([code, 'stateHashCode']) !== state.hashCode() - ) - }}); - - /** - * Caches the value of a getter given state, getter, args, value - * @param {Immutable.Map} state - * @param {Getter} getter - * @param {Array} args - * @param {any} value - */ - Object.defineProperty(Evaluator.prototype,"__cacheValue",{writable:true,configurable:true,value:function(state, getter, args, value) {"use strict"; - var code = hashCode(getter) - this.__cachedGetters = this.__cachedGetters.set(code, Immutable.Map({ - value: value, - args: toImmutable(args), - stateHashCode: state.hashCode(), - })) - }}); + /** + * Getter helper functions + * A getter is an array with the form: + * [, ..., ] + */ + var identity = function identity(x) { + return x; + }; - /** - * Returns boolean whether the supplied getter is cached for a given state - * @param {Immutable.Map} state - * @param {Getter} getter - * @return {boolean} - */ - Object.defineProperty(Evaluator.prototype,"__isCached",{writable:true,configurable:true,value:function(state, getter) {"use strict"; - var code = hashCode(getter) - return ( - this.__cachedGetters.hasIn([code, 'value']) && - this.__cachedGetters.getIn([code, 'stateHashCode']) === state.hashCode() - ) - }}); + /** + * Checks if something is a getter literal, ex: ['dep1', 'dep2', function(dep1, dep2) {...}] + * @param {*} toTest + * @return {boolean} + */ + function isGetter(toTest) { + return (0, _utils.isArray)(toTest) && (0, _utils.isFunction)(toTest[toTest.length - 1]); + } - /** - * Removes all caching about a getter - * @param {Getter} - */ - Object.defineProperty(Evaluator.prototype,"untrack",{writable:true,configurable:true,value:function(getter) {"use strict"; - // TODO: untrack all dependencies - }}); + /** + * Returns the compute function from a getter + * @param {Getter} getter + * @return {function} + */ + function getComputeFn(getter) { + return getter[getter.length - 1]; + } - Object.defineProperty(Evaluator.prototype,"reset",{writable:true,configurable:true,value:function() {"use strict"; - this.__cachedGetters = Immutable.Map({}) - }}); + /** + * Returns an array of deps from a getter + * @param {Getter} getter + * @return {function} + */ + function getDeps(getter) { + return getter.slice(0, getter.length - 1); + } + /** + * Returns an array of deps from a getter and all its deps + * @param {Getter} getter + * @param {Immutable.Set} existing + * @return {Immutable.Set} + */ + function getFlattenedDeps(getter, existing) { + if (!existing) { + existing = _immutable2['default'].Set(); + } - module.exports = Evaluator + var toAdd = _immutable2['default'].Set().withMutations(function (set) { + if (!isGetter(getter)) { + throw new Error('getFlattenedDeps must be passed a Getter'); + } + getDeps(getter).forEach(function (dep) { + if ((0, _keyPath.isKeyPath)(dep)) { + set.add((0, _immutable.List)(dep)); + } else if (isGetter(dep)) { + set.union(getFlattenedDeps(dep)); + } else { + throw new Error('Invalid getter, each dependency must be a KeyPath or Getter'); + } + }); + }); -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { + return existing.union(toAdd); + } - var each = __webpack_require__(3).each /** - * @param {Reactor} reactor + * @param {KeyPath} + * @return {Getter} */ - module.exports = function(reactor) { - return { - getInitialState: function() { - return getState(reactor, this.getDataBindings()) - }, - - componentDidMount: function() { - var component = this - component.__unwatchFns = [] - each(this.getDataBindings(), function(getter, key) { - var unwatchFn = reactor.observe(getter, function(val) { - var newState = {} - newState[key] = val - component.setState(newState) - }) - - component.__unwatchFns.push(unwatchFn) - }) - }, - - componentWillUnmount: function() { - while (this.__unwatchFns.length) { - this.__unwatchFns.shift()() - } - }, + function fromKeyPath(keyPath) { + if (!(0, _keyPath.isKeyPath)(keyPath)) { + throw new Error('Cannot create Getter from KeyPath: ' + keyPath); } + + return [keyPath, identity]; } /** - * Returns a mapping of the getDataBinding keys to - * the reactor values + * Adds non enumerated __storeDeps property + * @param {Getter} */ - function getState(reactor, data) { - var state = {} - each(data, function(value, key) { - state[key] = reactor.evaluate(value) - }) - return state + function getStoreDeps(getter) { + if (getter.hasOwnProperty('__storeDeps')) { + return getter.__storeDeps; + } + + var storeDeps = getFlattenedDeps(getter).map(function (keyPath) { + return keyPath.first(); + }).filter(function (x) { + return !!x; + }); + + Object.defineProperty(getter, '__storeDeps', { + enumerable: false, + configurable: false, + writable: false, + value: storeDeps + }); + + return storeDeps; } + exports['default'] = { + isGetter: isGetter, + getComputeFn: getComputeFn, + getFlattenedDeps: getFlattenedDeps, + getStoreDeps: getStoreDeps, + getDeps: getDeps, + fromKeyPath: fromKeyPath + }; + module.exports = exports['default']; /***/ }, -/* 13 */ +/* 11 */ /***/ function(module, exports, __webpack_require__) { - var Map = __webpack_require__(2).Map - var extend = __webpack_require__(3).extend - var toJS = __webpack_require__(1).toJS - var toImmutable = __webpack_require__(1).toImmutable + 'use strict'; - /** - * Stores define how a certain domain of the application should respond to actions - * taken on the whole system. They manage their own section of the entire app state - * and have no knowledge about the other parts of the application state. - */ + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.isKeyPath = isKeyPath; + exports.isEqual = isEqual; - function Store(config) {"use strict"; - if (!(this instanceof Store)) { - return new Store(config) - } + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - this.__handlers = Map({}) + var _immutable = __webpack_require__(3); - if (config) { - // allow `MyStore extends Store` syntax without throwing error - extend(this, config) - } + var _immutable2 = _interopRequireDefault(_immutable); - this.initialize() - } + var _utils = __webpack_require__(4); - /** - * This method is overridden by extending classes to setup message handlers - * via `this.on` and to set up the initial state - * - * Anything returned from this function will be coerced into an ImmutableJS value - * and set as the initial state for the part of the ReactorCore - */ - Object.defineProperty(Store.prototype,"initialize",{writable:true,configurable:true,value:function() {"use strict"; - // extending classes implement to setup action handlers - }}); + /** + * Checks if something is simply a keyPath and not a getter + * @param {*} toTest + * @return {boolean} + */ - /** - * Overridable method to get the initial state for this type of store - */ - Object.defineProperty(Store.prototype,"getInitialState",{writable:true,configurable:true,value:function() {"use strict"; - return Map() - }}); + function isKeyPath(toTest) { + return (0, _utils.isArray)(toTest) && !(0, _utils.isFunction)(toTest[toTest.length - 1]); + } - /** - * Takes a current reactor state, action type and payload - * does the reaction and returns the new state - */ - Object.defineProperty(Store.prototype,"handle",{writable:true,configurable:true,value:function(state, type, payload) {"use strict"; - var handler = this.__handlers.get(type) + /** + * Checks if two keypaths are equal by value + * @param {KeyPath} a + * @param {KeyPath} a + * @return {Boolean} + */ - if (typeof handler === 'function') { - return handler.call(this, state, payload, type) - } + function isEqual(a, b) { + var iA = _immutable2['default'].List(a); + var iB = _immutable2['default'].List(b); - return state - }}); + return _immutable2['default'].is(iA, iB); + } - /** - * Pure function taking the current state of store and returning - * the new state after a NuclearJS reactor has been reset - * - * Overridable - */ - Object.defineProperty(Store.prototype,"handleReset",{writable:true,configurable:true,value:function(state) {"use strict"; - return this.getInitialState() - }}); +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { - /** - * Binds an action type => handler - */ - Object.defineProperty(Store.prototype,"on",{writable:true,configurable:true,value:function(actionType, handler) {"use strict"; - this.__handlers = this.__handlers.set(actionType, handler) - }}); + 'use strict'; - /** - * Serializes store state to plain JSON serializable JavaScript - * Overridable - * @param {*} - * @return {*} - */ - Object.defineProperty(Store.prototype,"serialize",{writable:true,configurable:true,value:function(state) {"use strict"; - return toJS(state) - }}); + Object.defineProperty(exports, '__esModule', { + value: true + }); - /** - * Deserializes plain JavaScript to store state - * Overridable - * @param {*} - * @return {*} - */ - Object.defineProperty(Store.prototype,"deserialize",{writable:true,configurable:true,value:function(state) {"use strict"; - return toImmutable(state) - }}); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + var _immutable = __webpack_require__(3); - function isStore(toTest) { - return (toTest instanceof Store) - } + var _immutable2 = _interopRequireDefault(_immutable); + + var ReactorState = _immutable2['default'].Record({ + dispatchId: 0, + state: _immutable2['default'].Map(), + stores: _immutable2['default'].Map(), + cache: _immutable2['default'].Map(), + // maintains a mapping of storeId => state id (monotomically increasing integer whenever store state changes) + storeStates: _immutable2['default'].Map(), + dirtyStores: _immutable2['default'].Set(), + debug: false + }); + + var ObserverState = _immutable2['default'].Record({ + // observers registered to any store change + any: _immutable2['default'].Set([]), + // observers registered to specific store changes + stores: _immutable2['default'].Map({}), - module.exports = Store + observersMap: _immutable2['default'].Map({}), - module.exports.isStore = isStore + nextId: 1 + }); + exports['default'] = { + ReactorState: ReactorState, + ObserverState: ObserverState + }; + module.exports = exports['default']; /***/ } /******/ ]) diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js index 53830b4..48d8bb8 100644 --- a/dist/nuclear.min.js +++ b/dist/nuclear.min.js @@ -1,3 +1,3 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Nuclear=e():t.Nuclear=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){var n=r(1);e.Reactor=r(4),e.Store=r(13),e.Immutable=r(2),e.isKeyPath=r(10).isKeyPath,e.isGetter=r(9).isGetter,e.toJS=n.toJS,e.toImmutable=n.toImmutable,e.isImmutable=n.isImmutable,e.createReactMixin=r(12)},function(t,e,r){function n(t){return s.Iterable.isIterable(t)}function i(t){return n(t)||!a(t)}function o(t){return n(t)?t.toJS():t}function u(t){return n(t)?t:s.fromJS(t)}var s=r(2),a=r(3).isObject;e.toJS=o,e.toImmutable=u,e.isImmutable=n,e.isImmutableValue=i},function(t,e,r){!function(e,r){t.exports=r()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=new Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function o(t){return void 0===t.size&&(t.size=t.__iterate(s)),t.size}function u(t,e){if("number"!=typeof e){var r=+e;if(""+r!==e)return NaN;e=r}return 0>e?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function _(t){return y(t)?t:x(t)}function p(t){return d(t)?t:q(t)}function l(t){return g(t)?t:j(t)}function v(t){return y(t)&&!m(t)?t:A(t)}function y(t){return!(!t||!t[lr])}function d(t){return!(!t||!t[vr])}function g(t){return!(!t||!t[yr])}function m(t){return d(t)||g(t)}function b(t){return!(!t||!t[dr])}function w(t){this.next=t}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!E(t)}function O(t){return t&&"function"==typeof t.next}function D(t){var e=E(t);return e&&e.call(t)}function E(t){var e=t&&(wr&&t[wr]||t[Sr]);return"function"==typeof e?e:void 0}function M(t){return t&&"number"==typeof t.length}function x(t){return null===t||void 0===t?C():y(t)?t.toSeq():B(t)}function q(t){return null===t||void 0===t?C().toKeyedSeq():y(t)?d(t)?t.toSeq():t.fromEntrySeq():L(t)}function j(t){return null===t||void 0===t?C():y(t)?d(t)?t.entrySeq():t.toIndexedSeq():T(t)}function A(t){return(null===t||void 0===t?C():y(t)?d(t)?t.entrySeq():t:T(t)).toSetSeq()}function k(t){this._array=t,this.size=t.length}function P(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function K(t){this._iterable=t,this.size=t.length||t.size}function R(t){this._iterator=t,this._iteratorCache=[]}function U(t){return!(!t||!t[zr])}function C(){return Or||(Or=new k([]))}function L(t){var e=Array.isArray(t)?new k(t).fromEntrySeq():O(t)?new R(t).fromEntrySeq():z(t)?new K(t).fromEntrySeq():"object"==typeof t?new P(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function T(t){var e=J(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function B(t){var e=J(t)||"object"==typeof t&&new P(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function J(t){return M(t)?new k(t):O(t)?new R(t):z(t)?new K(t):void 0}function W(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function V(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new w(function(){var t=i[r?o-u:u];return u++>o?I():S(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function G(){throw TypeError("Abstract")}function H(){}function N(){}function F(){}function X(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function Y(t,e){return e?Q(e,t,"",{"":t}):Z(t)}function Q(t,e,r,n){return Array.isArray(e)?t.call(n,r,j(e).map(function(r,n){return Q(t,r,n,e)})):$(e)?t.call(n,r,q(e).map(function(r,n){return Q(t,r,n,e)})):e}function Z(t){return Array.isArray(t)?j(t).map(Z).toList():$(t)?q(t).map(Z).toMap():t}function $(t){return t&&(t.constructor===Object||void 0===t.constructor)}function tt(t){return t>>>1&1073741824|3221225471&t}function et(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return tt(r)}return"string"===e?t.length>kr?rt(t):nt(t):"function"==typeof t.hashCode?t.hashCode():it(t)}function rt(t){var e=Rr[t];return void 0===e&&(e=nt(t),Kr===Pr&&(Kr=0,Rr={}),Kr++,Rr[t]=e),e}function nt(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ut(t,e){if(!t)throw new Error(e)}function st(t){ut(t!==1/0,"Cannot perform this action with an infinite size.")}function at(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ct(t){this._iter=t,this.size=t.size}function ht(t){this._iter=t,this.size=t.size}function ft(t){this._iter=t,this.size=t.size}function _t(t){var e=kt(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===br){var n=t.__iterator(e,r);return new w(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===mr?gr:mr,r)},e}function pt(t,e,r){var n=kt(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,fr);return o===fr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(br,i);return new w(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function lt(t,e){var r=kt(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=_t(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=Pt,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function vt(t,e,r,n){var i=kt(t);return n&&(i.has=function(n){var i=t.get(n,fr);return i!==fr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,fr);return o!==fr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(br,o),s=0;return new w(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function yt(t,e,r){var n=Ut().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function dt(t,e,r){var n=d(t),i=(b(t)?Ie():Ut()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=At(t);return i.map(function(e){return xt(t,o(e))})}function gt(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return gt(t.toSeq().cacheResult(),e,r,n);var f,_=s-o;_===_&&(f=0>_?0:_);var p=kt(t);return p.size=0===f?f:t.size&&f||void 0,!n&&U(t)&&f>=0&&(p.get=function(e,r){return e=u(this,e),e>=0&&f>e?t.get(e+o,r):r}),p.__iterateUncached=function(e,r){var i=this;if(0===f)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,s=!0,a=0;return t.__iterate(function(t,r){return s&&(s=u++f)return I();var t=i.next();return n||e===mr?t:e===gr?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},p}function mt(t,e,r){var n=kt(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(br,i),s=!0;return new w(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===br?t:S(n,a,c,t):(s=!1,I())})},n}function bt(t,e,r,n){var i=kt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){return s&&(s=e.call(r,t,o,c))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(br,o),a=!0,c=0;return new w(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===mr?t:i===gr?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===br?t:S(i,o,h,t)})},i}function wt(t,e){var r=d(t),n=[t].concat(e).map(function(t){return y(t)?r&&(t=p(t)):t=r?L(t):T(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&d(i)||g(t)&&g(i))return i}var o=new k(n);return r?o=o.toKeyedSeq():g(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function St(t,e,r){var n=kt(t);return n.__iterateUncached=function(n,i){function o(t,a){var c=this;t.__iterate(function(t,i){return(!e||e>a)&&y(t)?o(t,a+1):n(t,r?i:u++,c)===!1&&(s=!0),!s},i)}var u=0,s=!1;return o(t,0),u},n.__iteratorUncached=function(n,i){var o=t.__iterator(n,i),u=[],s=0;return new w(function(){for(;o;){var t=o.next();if(t.done===!1){var a=t.value;if(n===br&&(a=a[1]),e&&!(u.length0}function Mt(t,e,r){var n=kt(t);return n.size=new k(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this.__iterator(mr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=_(t),D(n?t.reverse():t)}),o=0,u=!1;return new w(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?I():S(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function xt(t,e){return U(t)?e:t.constructor(e)}function qt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function jt(t){return st(t.size),o(t)}function At(t){return d(t)?p:g(t)?l:v}function kt(t){return Object.create((d(t)?q:g(t)?j:A).prototype)}function Pt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):x.prototype.cacheResult.call(this)}function Kt(t,e){return t>e?1:e>t?-1:0}function Rt(t){var e=D(t);if(!e){if(!M(t))throw new TypeError("Expected iterable or array-like: "+t);e=D(_(t))}return e}function Ut(t){return null===t||void 0===t?Ft():Ct(t)&&!b(t)?t:Ft().withMutations(function(e){var r=p(t);st(r.size),r.forEach(function(t,r){return e.set(r,t)})})}function Ct(t){return!(!t||!t[Ur])}function Lt(t,e){this.ownerID=t,this.entries=e}function Tt(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function Bt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function Jt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function Wt(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function Vt(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&Ht(t._root)}function Gt(t,e){return S(t,e[0],e[1])}function Ht(t,e){return{node:t,index:0,__prev:e}}function Nt(t,e,r,n){var i=Object.create(Cr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Ft(){return Lr||(Lr=Nt(0))}function Xt(t,r,n){var i,o;if(t._root){var u=e(_r),s=e(pr);if(i=Yt(t._root,t.__ownerID,0,void 0,r,n,u,s),!s.value)return t;o=t.size+(u.value?n===fr?-1:1:0)}else{if(n===fr)return t;o=1,i=new Lt(t.__ownerID,[[r,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Nt(o,i):Ft()}function Yt(t,e,n,i,o,u,s,a){return t?t.update(e,n,i,o,u,s,a):u===fr?t:(r(a),r(s),new Wt(e,i,[o,u]))}function Qt(t){return t.constructor===Wt||t.constructor===Jt}function Zt(t,e,r,n,i){if(t.keyHash===n)return new Jt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&hr,s=(0===r?n:n>>>r)&hr,a=u===s?[Zt(t,e,r+ar,n,i)]:(o=new Wt(e,n,i),s>u?[t,o]:[o,t]);return new Tt(e,1<s;s++,a<<=1){var h=e[s];void 0!==h&&s!==n&&(i|=a,u[o++]=h)}return new Tt(t,i,u)}function ee(t,e,r,n,i){for(var o=0,u=new Array(cr),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Bt(t,o+1,u)}function re(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function se(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function ae(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function ce(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function he(t){var e=ve();if(null===t||void 0===t)return e;if(fe(t))return t;var r=l(t),n=r.size;return 0===n?e:(st(n),n>0&&cr>n?le(0,n,ar,null,new _e(r.toArray())):e.withMutations(function(t){t.setSize(n),r.forEach(function(e,r){return t.set(r,e)})}))}function fe(t){return!(!t||!t[Wr])}function _e(t,e){this.array=t,this.ownerID=e}function pe(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,c=u-r;return c>cr&&(c=cr),function(){if(i===c)return Hr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=(u-i>>n)+1;return h>cr&&(h=cr),function(){for(;;){if(s){var t=s();if(t!==Hr)return t;s=null}if(c===h)return Hr;var o=e?--h:c++;s=r(a&&a[o],n-ar,i+(o<=t.size||0>r)return t.withMutations(function(t){0>r?be(t,r).set(0,n):be(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(pr);return r>=Se(t._capacity)?i=de(i,t.__ownerID,0,r,n,s):o=de(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):le(t._origin,t._capacity,t._level,o,i):t}function de(t,e,n,i,o,u){var s=i>>>n&hr,a=t&&s0){var h=t&&t.array[s],f=de(h,e,n-ar,i,o,u);return f===h?t:(c=ge(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=ge(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function ge(t,e){return e&&t&&e===t.ownerID?t:new _e(t?t.array.slice():[],e)}function me(t,e){if(e>=Se(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&hr],n-=ar;return r}}function be(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:0>r?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;0>s+f;)h=new _e(h&&h.array.length?[void 0,h]:[],i),c+=ar,f+=1<=1<p?me(t,a-1):p>_?new _e([],i):l;if(l&&p>_&&u>s&&l.array.length){h=ge(h,i);for(var y=h,d=c;d>ar;d-=ar){var g=_>>>d&hr;y=y.array[g]=ge(y.array[g],i)}y.array[_>>>ar&hr]=l}if(u>a&&(v=v&&v.removeAfter(i,0,a)),s>=p)s-=p,a-=p,c=ar,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>p){for(f=0;h;){var m=s>>>c&hr;if(m!==p>>>c&hr)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>p&&(h=h.removeAfter(i,c,p-f)),f&&(s-=f,a-=f)}return t.__ownerID?(t.size=a-s,t._origin=s,t._capacity=a,t._level=c,t._root=h,t._tail=v,t.__hash=void 0,t.__altered=!0,t):le(s,a,c,h,v)}function we(t,e,r){for(var n=[],i=0,o=0;oi&&(i=s.size),y(u)||(s=s.map(function(t){return Y(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)),ie(t,e,n)}function Se(t){return cr>t?0:t-1>>>ar<=cr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Oe(n,i)}function Me(t){return null===t||void 0===t?je():xe(t)?t:je().unshiftAll(t)}function xe(t){return!(!t||!t[Fr])}function qe(t,e,r,n){var i=Object.create(Xr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function je(){return Yr||(Yr=qe(0))}function Ae(t){return null===t||void 0===t?Re():ke(t)&&!b(t)?t:Re().withMutations(function(e){var r=v(t);st(r.size),r.forEach(function(t){return e.add(t)})})}function ke(t){return!(!t||!t[Qr])}function Pe(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Ke(t,e){var r=Object.create(Zr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Re(){return $r||($r=Ke(Ft()))}function Ue(t){return null===t||void 0===t?Te():Ce(t)?t:Te().withMutations(function(e){var r=v(t);st(r.size),r.forEach(function(t){return e.add(t)})})}function Ce(t){return ke(t)&&b(t)}function Le(t,e){var r=Object.create(tn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Te(){return en||(en=Le(De()))}function Be(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);Ve(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=Ut(o)},i=n.prototype=Object.create(rn);return i.constructor=n,n}function Je(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function We(t){return t._name||t.constructor.name||"Record"}function Ve(t,e){try{e.forEach(Ge.bind(void 0,t))}catch(r){}}function Ge(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ut(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function He(t,e){if(t===e)return!0;if(!y(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||d(t)!==d(e)||g(t)!==g(e)||b(t)!==b(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!m(t);if(b(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&X(i[1],t)&&(r||X(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){return(r?t.has(e):i?X(e,t.get(n,fr)):X(t.get(n,fr),e))?void 0:(u=!1,!1)});return u&&t.size===s}function Ne(t,e,r){if(!(this instanceof Ne))return new Ne(t,e,r);if(ut(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(nn)return nn;nn=this}}function Fe(t,e){if(!(this instanceof Fe))return new Fe(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(on)return on;on=this}}function Xe(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ye(t,e){return e}function Qe(t,e){return[e,t]}function Ze(t){return function(){return!t.apply(this,arguments)}}function $e(t){return function(){return-t.apply(this,arguments)}}function tr(t){return"string"==typeof t?JSON.stringify(t):t}function er(){return i(arguments)}function rr(t,e){return e>t?1:t>e?-1:0}function nr(t){if(t.size===1/0)return 0;var e=b(t),r=d(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+or(et(t),et(e))|0}:function(t,e){n=n+or(et(t),et(e))|0}:e?function(t){n=31*n+et(t)|0}:function(t){n=n+et(t)|0});return ir(i,n)}function ir(t,e){return e=Er(e,3432918353),e=Er(e<<15|e>>>-15,461845907),e=Er(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Er(e^e>>>16,2246822507),e=Er(e^e>>>13,3266489909),e=tt(e^e>>>16)}function or(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var ur=Array.prototype.slice,sr="delete",ar=5,cr=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},k.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new w(function(){return i>n?I():S(t,i,r[e?n-i++:i++])})},t(P,q),P.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},P.prototype.has=function(t){return this._object.hasOwnProperty(t)},P.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},P.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new w(function(){var u=n[e?i-o:o];return o++>i?I():S(t,u,r[u])})},P.prototype[dr]=!0,t(K,j),K.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=this._iterable,n=D(r),i=0;if(O(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},K.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=D(r);if(!O(n))return new w(I);var i=0;return new w(function(){var e=n.next();return e.done?e:S(t,i++,e.value)})},t(R,j),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})};var Or;t(G,_),t(H,G),t(N,G),t(F,G),G.Keyed=H,G.Indexed=N,G.Set=F;var Dr,Er="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},Mr=Object.isExtensible,xr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),qr="function"==typeof WeakMap;qr&&(Dr=new WeakMap);var jr=0,Ar="__immutablehash__";"function"==typeof Symbol&&(Ar=Symbol(Ar));var kr=16,Pr=255,Kr=0,Rr={};t(at,q),at.prototype.get=function(t,e){return this._iter.get(t,e)},at.prototype.has=function(t){return this._iter.has(t)},at.prototype.valueSeq=function(){return this._iter.valueSeq()},at.prototype.reverse=function(){var t=this,e=lt(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},at.prototype.map=function(t,e){var r=this,n=pt(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},at.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?jt(this):0,function(i){return t(i,e?--r:r++,n)}),e)},at.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(mr,e),n=e?jt(this):0;return new w(function(){var i=r.next();return i.done?i:S(t,e?--n:n++,i.value,i)})},at.prototype[dr]=!0,t(ct,j),ct.prototype.includes=function(t){return this._iter.includes(t)},ct.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ct.prototype.__iterator=function(t,e){var r=this._iter.__iterator(mr,e),n=0;return new w(function(){var e=r.next();return e.done?e:S(t,n++,e.value,e)})},t(ht,A),ht.prototype.has=function(t){return this._iter.includes(t)},ht.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},ht.prototype.__iterator=function(t,e){var r=this._iter.__iterator(mr,e);return new w(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},t(ft,q),ft.prototype.entrySeq=function(){return this._iter.toSeq()},ft.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){qt(e);var n=y(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ft.prototype.__iterator=function(t,e){var r=this._iter.__iterator(mr,e);return new w(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){qt(n);var i=y(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ct.prototype.cacheResult=at.prototype.cacheResult=ht.prototype.cacheResult=ft.prototype.cacheResult=Pt,t(Ut,H),Ut.prototype.toString=function(){return this.__toString("Map {","}")},Ut.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Ut.prototype.set=function(t,e){return Xt(this,t,e)},Ut.prototype.setIn=function(t,e){return this.updateIn(t,fr,function(){return e})},Ut.prototype.remove=function(t){return Xt(this,t,fr)},Ut.prototype.deleteIn=function(t){return this.updateIn(t,function(){return fr})},Ut.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},Ut.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=oe(this,Rt(t),e,r);return n===fr?void 0:n},Ut.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Ft()},Ut.prototype.merge=function(){return re(this,void 0,arguments)},Ut.prototype.mergeWith=function(t){var e=ur.call(arguments,1);return re(this,t,e)},Ut.prototype.mergeIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Ft(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]; -})},Ut.prototype.mergeDeep=function(){return re(this,ne(void 0),arguments)},Ut.prototype.mergeDeepWith=function(t){var e=ur.call(arguments,1);return re(this,ne(t),e)},Ut.prototype.mergeDeepIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Ft(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},Ut.prototype.sort=function(t){return Ie(Ot(this,t))},Ut.prototype.sortBy=function(t,e){return Ie(Ot(this,e,t))},Ut.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Ut.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},Ut.prototype.asImmutable=function(){return this.__ensureOwner()},Ut.prototype.wasAltered=function(){return this.__altered},Ut.prototype.__iterator=function(t,e){return new Vt(this,t,e)},Ut.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},Ut.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Nt(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ut.isMap=Ct;var Ur="@@__IMMUTABLE_MAP__@@",Cr=Ut.prototype;Cr[Ur]=!0,Cr[sr]=Cr.remove,Cr.removeIn=Cr.deleteIn,Lt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Lt.prototype.update=function(t,e,n,o,u,s,a){for(var c=u===fr,h=this.entries,f=0,_=h.length;_>f&&!X(o,h[f][0]);f++);var p=_>f;if(p?h[f][1]===u:c)return this;if(r(a),(c||!p)&&r(s),!c||1!==h.length){if(!p&&!c&&h.length>=Tr)return $t(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return p?c?f===_-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Lt(t,v)}},Tt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=1<<((0===t?e:e>>>t)&hr),o=this.bitmap;return 0===(o&i)?n:this.nodes[ue(o&i-1)].get(t+ar,e,r,n)},Tt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var s=(0===e?r:r>>>e)&hr,a=1<=Br)return ee(t,_,c,s,l);if(h&&!l&&2===_.length&&Qt(_[1^f]))return _[1^f];if(h&&l&&1===_.length&&Qt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?se(_,f,l,v):ce(_,f,v):ae(_,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Tt(t,y,d)},Bt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=(0===t?e:e>>>t)&hr,o=this.nodes[i];return o?o.get(t+ar,e,r,n):n},Bt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var s=(0===e?r:r>>>e)&hr,a=i===fr,c=this.nodes,h=c[s];if(a&&!h)return this;var f=Yt(h,t,e+ar,r,n,i,o,u);if(f===h)return this;var _=this.count;if(h){if(!f&&(_--,Jr>_))return te(t,c,_,s)}else _++;var p=t&&t===this.ownerID,l=se(c,s,f,p);return p?(this.count=_,this.nodes=l,this):new Bt(t,_,l)},Jt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Jt.prototype.update=function(t,e,n,o,u,s,a){void 0===n&&(n=et(o));var c=u===fr;if(n!==this.keyHash)return c?this:(r(a),r(s),Zt(this,t,e,n,[o,u]));for(var h=this.entries,f=0,_=h.length;_>f&&!X(o,h[f][0]);f++);var p=_>f;if(p?h[f][1]===u:c)return this;if(r(a),(c||!p)&&r(s),c&&2===_)return new Wt(t,this.keyHash,h[1^f]);var l=t&&t===this.ownerID,v=l?h:i(h);return p?c?f===_-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Jt(t,this.keyHash,v)},Wt.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},Wt.prototype.update=function(t,e,n,i,o,u,s){var a=o===fr,c=X(i,this.entry[0]);return(c?o===this.entry[1]:a)?this:(r(s),a?void r(u):c?t&&t===this.ownerID?(this.entry[1]=o,this):new Wt(t,this.keyHash,[i,o]):(r(u),Zt(this,t,e,et(i),[i,o])))},Lt.prototype.iterate=Jt.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},Tt.prototype.iterate=Bt.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},Wt.prototype.iterate=function(t,e){return t(this.entry)},t(Vt,w),Vt.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return Gt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return Gt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return Gt(t,o.entry);e=this._stack=Ht(o,e)}continue}e=this._stack=this._stack.__prev}return I()};var Lr,Tr=cr/4,Br=cr/2,Jr=cr/4;t(he,N),he.of=function(){return this(arguments)},he.prototype.toString=function(){return this.__toString("List [","]")},he.prototype.get=function(t,e){if(t=u(this,t),t>=0&&t>>e&hr;if(n>=this.array.length)return new _e([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-ar,r),i===u&&o)return this}if(o&&!i)return this;var s=ge(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},_e.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&hr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-ar,r),i===o&&n===this.array.length-1)return this}var u=ge(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Gr,Hr={};t(Ie,Ut),Ie.of=function(){return this(arguments)},Ie.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Ie.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Ie.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):De()},Ie.prototype.set=function(t,e){return Ee(this,t,e)},Ie.prototype.remove=function(t){return Ee(this,t,fr)},Ie.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Ie.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Ie.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Ie.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Oe(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Ie.isOrderedMap=ze,Ie.prototype[dr]=!0,Ie.prototype[sr]=Ie.prototype.remove;var Nr;t(Me,N),Me.of=function(){return this(arguments)},Me.prototype.toString=function(){return this.__toString("Stack [","]")},Me.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},Me.prototype.peek=function(){return this._head&&this._head.value},Me.prototype.push=function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):qe(t,e)},Me.prototype.pushAll=function(t){if(t=l(t),0===t.size)return this;st(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):qe(e,r)},Me.prototype.pop=function(){return this.slice(1)},Me.prototype.unshift=function(){return this.push.apply(this,arguments)},Me.prototype.unshiftAll=function(t){return this.pushAll(t)},Me.prototype.shift=function(){return this.pop.apply(this,arguments)},Me.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):je()},Me.prototype.slice=function(t,e){if(a(t,e,this.size))return this;var r=c(t,this.size),n=h(e,this.size);if(n!==this.size)return N.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):qe(i,o)},Me.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?qe(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Me.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Me.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new w(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return I()})},Me.isStack=xe;var Fr="@@__IMMUTABLE_STACK__@@",Xr=Me.prototype;Xr[Fr]=!0,Xr.withMutations=Cr.withMutations,Xr.asMutable=Cr.asMutable,Xr.asImmutable=Cr.asImmutable,Xr.wasAltered=Cr.wasAltered;var Yr;t(Ae,F),Ae.of=function(){return this(arguments)},Ae.fromKeys=function(t){return this(p(t).keySeq())},Ae.prototype.toString=function(){return this.__toString("Set {","}")},Ae.prototype.has=function(t){return this._map.has(t)},Ae.prototype.add=function(t){return Pe(this,this._map.set(t,!0))},Ae.prototype.remove=function(t){return Pe(this,this._map.remove(t))},Ae.prototype.clear=function(){return Pe(this,this._map.clear())},Ae.prototype.union=function(){var t=ur.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;r1?" by "+this._step:"")+" ]"},Ne.prototype.get=function(t,e){return this.has(t)?this._start+u(this,t)*this._step:e},Ne.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&e=e?new Ne(0,0):new Ne(this.get(t,this._end),this.get(e,this._end),this._step))},Ne.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&r=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},Ne.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new w(function(){var u=i;return i+=e?-n:n,o>r?I():S(t,o++,u)})},Ne.prototype.equals=function(t){return t instanceof Ne?this._start===t._start&&this._end===t._end&&this._step===t._step:He(this,t)};var nn;t(Fe,j),Fe.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},Fe.prototype.get=function(t,e){return this.has(t)?this._value:e},Fe.prototype.includes=function(t){return X(this._value,t)},Fe.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:new Fe(this._value,h(e,r)-c(t,r))},Fe.prototype.reverse=function(){return this},Fe.prototype.indexOf=function(t){return X(this._value,t)?0:-1},Fe.prototype.lastIndexOf=function(t){return X(this._value,t)?this.size:-1},Fe.prototype.__iterate=function(t,e){for(var r=0;rt?this.count():this.size);var n=this.slice(0,t);return xt(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return xt(this,St(this,t,!1))},get:function(t,e){return t=u(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=u(this,t),t>=0&&(void 0!==this.size?this.size===1/0||t-1&&t%1===0&&t<=Number.MAX_VALUE}e.isString=function(t){return"string"==typeof t||"[object String]"===r(t)},e.isArray=Array.isArray||function(t){return"[object Array]"===r(t)},"function"!=typeof/./&&"object"!=typeof Int8Array?e.isFunction=function(t){return"function"==typeof t||!1}:e.isFunction=function(t){return"[object Function]"===toString.call(t)},e.isObject=function(t){var e=typeof t;return"function"===e||"object"===e&&!!t},e.extend=function(t){var e=arguments.length;if(!t||2>e)return t||{};for(var r=1;e>r;r++)for(var n=arguments[r],i=Object.keys(n),o=i.length,u=0;o>u;u++){var s=i[u];t[s]=n[s]}return t},e.clone=function(t){return e.isObject(t)?e.isArray(t)?t.slice():e.extend({},t):t},e.each=function(t,e,r){var i,o,u=t?t.length:0,s=-1;if(r&&(o=e,e=function(t,e,n){return o.call(r,t,e,n)}),n(u))for(;++s0)this.__batchDispatchCount++;else{if(this.state!==r)try{this.__notify()}catch(n){throw this.__isDispatching=!1,n}this.__isDispatching=!1}}}),Object.defineProperty(n.prototype,"batch",{writable:!0,configurable:!0,value:function(t){"use strict";this.__batchStart(),t(),this.__batchEnd()}}),Object.defineProperty(n.prototype,"registerStore",{writable:!0,configurable:!0,value:function(t,e){"use strict";console.warn("Deprecation warning: `registerStore` will no longer be supported in 1.1, use `registerStores` instead");var r={};r[t]=e,this.registerStores(r)}}),Object.defineProperty(n.prototype,"registerStores",{writable:!0,configurable:!0,value:function(t){"use strict";l(t,function(t,e){this.__stores.get(e)&&console.warn("Store already defined for id = "+e);var r=t.getInitialState();if(this.debug&&!p(r))throw new Error("Store getInitialState() must return an immutable value, did you forget to call toImmutable");this.__stores=this.__stores.set(e,t),this.state=this.state.set(e,r)}.bind(this)),this.__notify()}}),Object.defineProperty(n.prototype,"serialize",{writable:!0,configurable:!0,value:function(){"use strict";var t={};return this.__stores.forEach(function(e,r){var n=this.state.get(r),i=e.serialize(n);void 0!==i&&(t[r]=i)}.bind(this)),t}}),Object.defineProperty(n.prototype,"loadState",{writable:!0,configurable:!0,value:function(t){"use strict";var e=_({}).withMutations(function(e){l(t,function(t,r){var n=this.__stores.get(r);if(n){var i=n.deserialize(t);void 0!==i&&e.set(r,i)}}.bind(this))}.bind(this));this.state=this.state.merge(e),this.__notify()}}),Object.defineProperty(n.prototype,"reset",{writable:!0,configurable:!0,value:function(){"use strict";var t=this.debug,e=this.state;this.state=i.Map().withMutations(function(r){this.__stores.forEach(function(n,i){var o=e.get(i),u=n.handleReset(o);if(t&&void 0===u)throw new Error("Store handleReset() must return a value, did you forget a return statement");if(t&&!p(u))throw new Error("Store reset state must be an immutable value, did you forget to call toImmutable");r.set(i,u)})}.bind(this)),this.__evaluator.reset(),this.__changeObserver.reset(this.state)}}),Object.defineProperty(n.prototype,"__notify",{writable:!0,configurable:!0,value:function(){"use strict";this.__changeObserver.notifyObservers(this.state)}}),Object.defineProperty(n.prototype,"__handleAction",{writable:!0,configurable:!0,value:function(t,e,r){"use strict";return t.withMutations(function(t){this.debug&&o.dispatchStart(e,r),this.__stores.forEach(function(n,i){var u,s=t.get(i);try{u=n.handle(s,e,r)}catch(a){throw o.dispatchError(a.message),a}if(this.debug&&void 0===u){var c="Store handler must return a value, did you forget a return statement";throw o.dispatchError(c),new Error(c)}t.set(i,u),this.debug&&o.storeHandled(i,s,u)}.bind(this)),this.debug&&o.dispatchEnd(t)}.bind(this))}}),Object.defineProperty(n.prototype,"__batchStart",{writable:!0,configurable:!0,value:function(){"use strict";this.__batchDepth++}}),Object.defineProperty(n.prototype,"__batchEnd",{writable:!0,configurable:!0,value:function(){"use strict";if(this.__batchDepth--,this.__batchDepth<=0){if(this.__batchDispatchCount>0){this.__isDispatching=!0;try{this.__notify()}catch(t){throw this.__isDispatching=!1,t}this.__isDispatching=!1}this.__batchDispatchCount=0}}}),t.exports=n},function(t,e){e.dispatchStart=function(t,e){console.group&&(console.groupCollapsed("Dispatch: %s",t),console.group("payload"),console.debug(e),console.groupEnd())},e.dispatchError=function(t){console.group&&(console.debug("Dispatch error: "+t),console.groupEnd())},e.storeHandled=function(t,e,r){console.group&&e!==r&&console.debug("Store "+t+" handled action")},e.dispatchEnd=function(t){console.group&&(console.debug("Dispatch done, new state: ",t.toJS()),console.groupEnd())}},function(t,e,r){function n(t,e){"use strict";this.__prevState=t,this.__evaluator=e,this.__prevValues=i.Map(),this.__observers=[]}var i=r(2),o=r(7),u=r(8);Object.defineProperty(n.prototype,"notifyObservers",{writable:!0,configurable:!0,value:function(t){"use strict";if(this.__observers.length>0){var e=i.Map();this.__observers.forEach(function(r){var n,i=r.getter,s=o(i),a=this.__prevState;this.__prevValues.has(s)?n=this.__prevValues.get(s):(n=this.__evaluator.evaluate(a,i), -this.__prevValues=this.__prevValues.set(s,n));var c=this.__evaluator.evaluate(t,i);u(n,c)||(r.handler.call(null,c),e=e.set(s,c))}.bind(this)),this.__prevValues=e}this.__prevState=t}}),Object.defineProperty(n.prototype,"onChange",{writable:!0,configurable:!0,value:function(t,e){"use strict";var r={getter:t,handler:e};return this.__observers.push(r),function(){var t=this.__observers.indexOf(r);t>-1&&this.__observers.splice(t,1)}.bind(this)}}),Object.defineProperty(n.prototype,"reset",{writable:!0,configurable:!0,value:function(t){"use strict";this.__prevState=t,this.__prevValues=i.Map(),this.__observers=[]}}),t.exports=n},function(t,e,r){var n=r(2);t.exports=function(t,e){if(t.hasOwnProperty("__hashCode"))return t.__hashCode;var r=n.fromJS(t).hashCode();return e||(Object.defineProperty(t,"__hashCode",{enumerable:!1,configurable:!1,writable:!1,value:r}),Object.freeze(t)),r}},function(t,e,r){var n=r(2);t.exports=function(t,e){return n.is(t,e)}},function(t,e,r){function n(t){return a(t)&&s(t[t.length-1])}function i(t){return t[t.length-1]}function o(t){return t.slice(0,t.length-1)}function u(t){if(!c(t))throw new Error("Cannot create Getter from KeyPath: "+t);return[t,h]}var s=r(3).isFunction,a=r(3).isArray,c=r(10).isKeyPath,h=function(t){return t};t.exports={isGetter:n,getComputeFn:i,getDeps:o,fromKeyPath:u}},function(t,e,r){var n=r(3).isArray,i=r(3).isFunction;e.isKeyPath=function(t){return n(t)&&!i(t[t.length-1])}},function(t,e,r){function n(){"use strict";this.__cachedGetters=i.Map({})}var i=r(2),o=r(1).toImmutable,u=r(7),s=r(8),a=r(9).getComputeFn,c=r(9).getDeps,h=r(10).isKeyPath,f=r(9).isGetter,_=!1;Object.defineProperty(n.prototype,"evaluate",{writable:!0,configurable:!0,value:function(t,e){"use strict";if(h(e))return t.getIn(e);if(!f(e))throw new Error("evaluate must be passed a keyPath or Getter");var r=u(e);if(this.__isCached(t,e))return this.__cachedGetters.getIn([r,"value"]);var n=c(e).map(function(e){return this.evaluate(t,e)}.bind(this));if(this.__hasStaleValue(t,e)){var i=this.__cachedGetters.getIn([r,"args"]);if(s(i,o(n))){var p=this.__cachedGetters.getIn([r,"value"]);return this.__cacheValue(t,e,i,p),p}}if(_===!0)throw _=!1,new Error("Evaluate may not be called within a Getters computeFn");var l;_=!0;try{l=a(e).apply(null,n),_=!1}catch(v){throw _=!1,v}return this.__cacheValue(t,e,n,l),l}}),Object.defineProperty(n.prototype,"__hasStaleValue",{writable:!0,configurable:!0,value:function(t,e){"use strict";var r=u(e),n=this.__cachedGetters;return n.has(r)&&n.getIn([r,"stateHashCode"])!==t.hashCode()}}),Object.defineProperty(n.prototype,"__cacheValue",{writable:!0,configurable:!0,value:function(t,e,r,n){"use strict";var s=u(e);this.__cachedGetters=this.__cachedGetters.set(s,i.Map({value:n,args:o(r),stateHashCode:t.hashCode()}))}}),Object.defineProperty(n.prototype,"__isCached",{writable:!0,configurable:!0,value:function(t,e){"use strict";var r=u(e);return this.__cachedGetters.hasIn([r,"value"])&&this.__cachedGetters.getIn([r,"stateHashCode"])===t.hashCode()}}),Object.defineProperty(n.prototype,"untrack",{writable:!0,configurable:!0,value:function(t){"use strict"}}),Object.defineProperty(n.prototype,"reset",{writable:!0,configurable:!0,value:function(){"use strict";this.__cachedGetters=i.Map({})}}),t.exports=n},function(t,e,r){function n(t,e){var r={};return i(e,function(e,n){r[n]=t.evaluate(e)}),r}var i=r(3).each;t.exports=function(t){return{getInitialState:function(){return n(t,this.getDataBindings())},componentDidMount:function(){var e=this;e.__unwatchFns=[],i(this.getDataBindings(),function(r,n){var i=t.observe(r,function(t){var r={};r[n]=t,e.setState(r)});e.__unwatchFns.push(i)})},componentWillUnmount:function(){for(;this.__unwatchFns.length;)this.__unwatchFns.shift()()}}}},function(t,e,r){function n(t){"use strict";return this instanceof n?(this.__handlers=o({}),t&&u(this,t),void this.initialize()):new n(t)}function i(t){return t instanceof n}var o=r(2).Map,u=r(3).extend,s=r(1).toJS,a=r(1).toImmutable;Object.defineProperty(n.prototype,"initialize",{writable:!0,configurable:!0,value:function(){"use strict"}}),Object.defineProperty(n.prototype,"getInitialState",{writable:!0,configurable:!0,value:function(){"use strict";return o()}}),Object.defineProperty(n.prototype,"handle",{writable:!0,configurable:!0,value:function(t,e,r){"use strict";var n=this.__handlers.get(e);return"function"==typeof n?n.call(this,t,r,e):t}}),Object.defineProperty(n.prototype,"handleReset",{writable:!0,configurable:!0,value:function(t){"use strict";return this.getInitialState()}}),Object.defineProperty(n.prototype,"on",{writable:!0,configurable:!0,value:function(t,e){"use strict";this.__handlers=this.__handlers.set(t,e)}}),Object.defineProperty(n.prototype,"serialize",{writable:!0,configurable:!0,value:function(t){"use strict";return s(t)}}),Object.defineProperty(n.prototype,"deserialize",{writable:!0,configurable:!0,value:function(t){"use strict";return a(t)}}),t.exports=n,t.exports.isStore=i}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Nuclear=e():t.Nuclear=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),r(1);var i=r(2),o=n(i),u=r(6),a=n(u),s=r(3),c=n(s),f=r(5),h=r(11),p=r(10),l=r(7),_=n(l);e["default"]={Reactor:a["default"],Store:o["default"],Immutable:c["default"],isKeyPath:h.isKeyPath,isGetter:p.isGetter,toJS:f.toJS,toImmutable:f.toImmutable,isImmutable:f.isImmutable,createReactMixin:_["default"]},t.exports=e["default"]},function(t,e){"use strict";try{window.console&&console.log||(console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){}})}catch(r){}},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return t instanceof c}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var r=0;ri;i++)n[i]=t[i+e];return n}function o(t){return void 0===t.size&&(t.size=t.__iterate(a)),t.size}function u(t,e){if("number"!=typeof e){var r=+e;if(""+r!==e)return NaN;e=r}return 0>e?o(t)+e:e}function a(){return!0}function s(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return h(t,e,0)}function f(t,e){return h(t,e,e)}function h(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function p(t){return d(t)?t:x(t)}function l(t){return y(t)?t:q(t)}function _(t){return g(t)?t:k(t)}function v(t){return d(t)&&!m(t)?t:A(t)}function d(t){return!(!t||!t[_r])}function y(t){return!(!t||!t[vr])}function g(t){return!(!t||!t[dr])}function m(t){return y(t)||g(t)}function w(t){return!(!t||!t[yr])}function S(t){this.next=t}function b(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!E(t)}function M(t){return t&&"function"==typeof t.next}function D(t){var e=E(t);return e&&e.call(t)}function E(t){var e=t&&(Sr&&t[Sr]||t[br]);return"function"==typeof e?e:void 0}function O(t){return t&&"number"==typeof t.length}function x(t){return null===t||void 0===t?L():d(t)?t.toSeq():J(t)}function q(t){return null===t||void 0===t?L().toKeyedSeq():d(t)?y(t)?t.toSeq():t.fromEntrySeq():T(t)}function k(t){return null===t||void 0===t?L():d(t)?y(t)?t.entrySeq():t.toIndexedSeq():B(t)}function A(t){return(null===t||void 0===t?L():d(t)?y(t)?t.entrySeq():t:B(t)).toSetSeq()}function j(t){this._array=t,this.size=t.length}function R(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function K(t){this._iterable=t,this.size=t.length||t.size}function P(t){this._iterator=t,this._iteratorCache=[]}function U(t){return!(!t||!t[zr])}function L(){return Mr||(Mr=new j([]))}function T(t){var e=Array.isArray(t)?new j(t).fromEntrySeq():M(t)?new P(t).fromEntrySeq():z(t)?new K(t).fromEntrySeq():"object"==typeof t?new R(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function B(t){var e=W(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function J(t){var e=W(t)||"object"==typeof t&&new R(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function W(t){return O(t)?new j(t):M(t)?new P(t):z(t)?new K(t):void 0}function C(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var a=i[r?o-u:u];if(e(a[1],n?a[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function F(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new S(function(){var t=i[r?o-u:u];return u++>o?I():b(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function N(){throw TypeError("Abstract")}function G(){}function H(){}function V(){}function X(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function Y(t,e){return e?Q(e,t,"",{"":t}):Z(t)}function Q(t,e,r,n){return Array.isArray(e)?t.call(n,r,k(e).map(function(r,n){return Q(t,r,n,e)})):$(e)?t.call(n,r,q(e).map(function(r,n){return Q(t,r,n,e)})):e}function Z(t){return Array.isArray(t)?k(t).map(Z).toList():$(t)?q(t).map(Z).toMap():t}function $(t){return t&&(t.constructor===Object||void 0===t.constructor)}function tt(t){return t>>>1&1073741824|3221225471&t}function et(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return tt(r)}return"string"===e?t.length>jr?rt(t):nt(t):"function"==typeof t.hashCode?t.hashCode():it(t)}function rt(t){var e=Pr[t];return void 0===e&&(e=nt(t),Kr===Rr&&(Kr=0,Pr={}),Kr++,Pr[t]=e),e}function nt(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ut(t,e){if(!t)throw new Error(e)}function at(t){ut(t!==1/0,"Cannot perform this action with an infinite size.")}function st(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ct(t){this._iter=t,this.size=t.size}function ft(t){this._iter=t,this.size=t.size}function ht(t){this._iter=t,this.size=t.size}function pt(t){var e=jt(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Rt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===wr){var n=t.__iterator(e,r);return new S(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===mr?gr:mr,r)},e}function lt(t,e,r){var n=jt(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,hr);return o===hr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(wr,i);return new S(function(){var i=o.next();if(i.done)return i;var u=i.value,a=u[0];return b(n,a,e.call(r,u[1],a,t),i)})},n}function _t(t,e){var r=jt(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=pt(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=Rt,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function vt(t,e,r,n){var i=jt(t);return n&&(i.has=function(n){var i=t.get(n,hr);return i!==hr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,hr);return o!==hr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,a=0;return t.__iterate(function(t,o,s){return e.call(r,t,o,s)?(a++,i(t,n?o:a-1,u)):void 0},o),a},i.__iteratorUncached=function(i,o){var u=t.__iterator(wr,o),a=0;return new S(function(){for(;;){var o=u.next();if(o.done)return o;var s=o.value,c=s[0],f=s[1];if(e.call(r,f,c,t))return b(i,n?c:a++,f,o)}})},i}function dt(t,e,r){var n=Ut().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function yt(t,e,r){var n=y(t),i=(w(t)?Ie():Ut()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=At(t);return i.map(function(e){return xt(t,o(e))})}function gt(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),s(e,r,i))return t;var o=c(e,i),a=f(r,i);if(o!==o||a!==a)return gt(t.toSeq().cacheResult(),e,r,n);var h,p=a-o;p===p&&(h=0>p?0:p);var l=jt(t);return l.size=0===h?h:t.size&&h||void 0,!n&&U(t)&&h>=0&&(l.get=function(e,r){return e=u(this,e),e>=0&&h>e?t.get(e+o,r):r}),l.__iterateUncached=function(e,r){var i=this;if(0===h)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,a=!0,s=0;return t.__iterate(function(t,r){return a&&(a=u++h)return I();var t=i.next();return n||e===mr?t:e===gr?b(e,a-1,void 0,t):b(e,a-1,t.value[1],t)})},l}function mt(t,e,r){var n=jt(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,a){return e.call(r,t,i,a)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(wr,i),a=!0;return new S(function(){if(!a)return I();var t=u.next();if(t.done)return t;var i=t.value,s=i[0],c=i[1];return e.call(r,c,s,o)?n===wr?t:b(n,s,c,t):(a=!1,I())})},n}function wt(t,e,r,n){var i=jt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var a=!0,s=0;return t.__iterate(function(t,o,c){return a&&(a=e.call(r,t,o,c))?void 0:(s++,i(t,n?o:s-1,u))}),s},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var a=t.__iterator(wr,o),s=!0,c=0;return new S(function(){var t,o,f;do{if(t=a.next(),t.done)return n||i===mr?t:i===gr?b(i,c++,void 0,t):b(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],s&&(s=e.call(r,f,o,u))}while(s);return i===wr?t:b(i,o,f,t)})},i}function St(t,e){var r=y(t),n=[t].concat(e).map(function(t){return d(t)?r&&(t=l(t)):t=r?T(t):B(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&y(i)||g(t)&&g(i))return i}var o=new j(n);return r?o=o.toKeyedSeq():g(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function bt(t,e,r){var n=jt(t);return n.__iterateUncached=function(n,i){function o(t,s){var c=this;t.__iterate(function(t,i){return(!e||e>s)&&d(t)?o(t,s+1):n(t,r?i:u++,c)===!1&&(a=!0),!a},i)}var u=0,a=!1;return o(t,0),u},n.__iteratorUncached=function(n,i){var o=t.__iterator(n,i),u=[],a=0;return new S(function(){for(;o;){var t=o.next();if(t.done===!1){var s=t.value;if(n===wr&&(s=s[1]),e&&!(u.length0}function Ot(t,e,r){var n=jt(t);return n.size=new j(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this.__iterator(mr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=p(t),D(n?t.reverse():t)}),o=0,u=!1;return new S(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?I():b(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function xt(t,e){return U(t)?e:t.constructor(e)}function qt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function kt(t){return at(t.size),o(t)}function At(t){return y(t)?l:g(t)?_:v}function jt(t){return Object.create((y(t)?q:g(t)?k:A).prototype)}function Rt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):x.prototype.cacheResult.call(this)}function Kt(t,e){return t>e?1:e>t?-1:0}function Pt(t){var e=D(t);if(!e){if(!O(t))throw new TypeError("Expected iterable or array-like: "+t);e=D(p(t))}return e}function Ut(t){return null===t||void 0===t?Vt():Lt(t)&&!w(t)?t:Vt().withMutations(function(e){var r=l(t);at(r.size),r.forEach(function(t,r){return e.set(r,t)})})}function Lt(t){return!(!t||!t[Ur])}function Tt(t,e){this.ownerID=t,this.entries=e}function Bt(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function Jt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function Wt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function Ct(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function Ft(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&Gt(t._root)}function Nt(t,e){return b(t,e[0],e[1])}function Gt(t,e){return{node:t,index:0,__prev:e}}function Ht(t,e,r,n){var i=Object.create(Lr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Vt(){return Tr||(Tr=Ht(0))}function Xt(t,r,n){var i,o;if(t._root){var u=e(pr),a=e(lr);if(i=Yt(t._root,t.__ownerID,0,void 0,r,n,u,a),!a.value)return t;o=t.size+(u.value?n===hr?-1:1:0)}else{if(n===hr)return t;o=1,i=new Tt(t.__ownerID,[[r,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Ht(o,i):Vt()}function Yt(t,e,n,i,o,u,a,s){return t?t.update(e,n,i,o,u,a,s):u===hr?t:(r(s),r(a),new Ct(e,i,[o,u]))}function Qt(t){return t.constructor===Ct||t.constructor===Wt}function Zt(t,e,r,n,i){if(t.keyHash===n)return new Wt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&fr,a=(0===r?n:n>>>r)&fr,s=u===a?[Zt(t,e,r+sr,n,i)]:(o=new Ct(e,n,i),a>u?[t,o]:[o,t]);return new Bt(e,1<a;a++,s<<=1){var f=e[a];void 0!==f&&a!==n&&(i|=s,u[o++]=f)}return new Bt(t,i,u)}function ee(t,e,r,n,i){for(var o=0,u=new Array(cr),a=0;0!==r;a++,r>>>=1)u[a]=1&r?e[o++]:void 0;return u[n]=i,new Jt(t,o+1,u)}function re(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function ae(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function se(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,a=0;i>a;a++)a===e?(o[a]=r,u=-1):o[a]=t[a+u];return o}function ce(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function fe(t){var e=ve();if(null===t||void 0===t)return e;if(he(t))return t;var r=_(t),n=r.size;return 0===n?e:(at(n),n>0&&cr>n?_e(0,n,sr,null,new pe(r.toArray())):e.withMutations(function(t){t.setSize(n),r.forEach(function(e,r){return t.set(r,e)})}))}function he(t){return!(!t||!t[Cr])}function pe(t,e){this.array=t,this.ownerID=e}function le(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===a?s&&s.array:t&&t.array,i=r>o?0:o-r,c=u-r;return c>cr&&(c=cr),function(){if(i===c)return Gr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var a,s=t&&t.array,c=i>o?0:o-i>>n,f=(u-i>>n)+1;return f>cr&&(f=cr),function(){for(;;){if(a){var t=a();if(t!==Gr)return t;a=null}if(c===f)return Gr;var o=e?--f:c++;a=r(s&&s[o],n-sr,i+(o<=t.size||0>r)return t.withMutations(function(t){0>r?we(t,r).set(0,n):we(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,a=e(lr);return r>=be(t._capacity)?i=ye(i,t.__ownerID,0,r,n,a):o=ye(o,t.__ownerID,t._level,r,n,a),a.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):_e(t._origin,t._capacity,t._level,o,i):t}function ye(t,e,n,i,o,u){var a=i>>>n&fr,s=t&&a0){var f=t&&t.array[a],h=ye(f,e,n-sr,i,o,u);return h===f?t:(c=ge(t,e),c.array[a]=h,c)}return s&&t.array[a]===o?t:(r(u),c=ge(t,e),void 0===o&&a===c.array.length-1?c.array.pop():c.array[a]=o,c)}function ge(t,e){return e&&t&&e===t.ownerID?t:new pe(t?t.array.slice():[],e)}function me(t,e){if(e>=be(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&fr],n-=sr;return r}}function we(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,a=o+e,s=void 0===r?u:0>r?u+r:o+r;if(a===o&&s===u)return t;if(a>=s)return t.clear();for(var c=t._level,f=t._root,h=0;0>a+h;)f=new pe(f&&f.array.length?[void 0,f]:[],i),c+=sr,h+=1<=1<l?me(t,s-1):l>p?new pe([],i):_;if(_&&l>p&&u>a&&_.array.length){f=ge(f,i);for(var d=f,y=c;y>sr;y-=sr){var g=p>>>y&fr;d=d.array[g]=ge(d.array[g],i)}d.array[p>>>sr&fr]=_}if(u>s&&(v=v&&v.removeAfter(i,0,s)),a>=l)a-=l,s-=l,c=sr,f=null,v=v&&v.removeBefore(i,0,a);else if(a>o||p>l){for(h=0;f;){var m=a>>>c&fr;if(m!==l>>>c&fr)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,a-h)),f&&p>l&&(f=f.removeAfter(i,c,l-h)),h&&(a-=h,s-=h)}return t.__ownerID?(t.size=s-a,t._origin=a,t._capacity=s,t._level=c,t._root=f,t._tail=v,t.__hash=void 0,t.__altered=!0,t):_e(a,s,c,f,v)}function Se(t,e,r){for(var n=[],i=0,o=0;oi&&(i=a.size),d(u)||(a=a.map(function(t){return Y(t)})),n.push(a)}return i>t.size&&(t=t.setSize(i)),ie(t,e,n)}function be(t){return cr>t?0:t-1>>>sr<=cr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&a!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=a===u.size-1?u.pop():u.set(a,void 0))}else if(s){if(r===u.get(a)[1])return t;n=o,i=u.set(a,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Me(n,i)}function Oe(t){return null===t||void 0===t?ke():xe(t)?t:ke().unshiftAll(t)}function xe(t){return!(!t||!t[Vr])}function qe(t,e,r,n){var i=Object.create(Xr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function ke(){return Yr||(Yr=qe(0))}function Ae(t){return null===t||void 0===t?Pe():je(t)&&!w(t)?t:Pe().withMutations(function(e){var r=v(t);at(r.size),r.forEach(function(t){return e.add(t)})})}function je(t){return!(!t||!t[Qr])}function Re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Ke(t,e){var r=Object.create(Zr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Pe(){return $r||($r=Ke(Vt()))}function Ue(t){return null===t||void 0===t?Be():Le(t)?t:Be().withMutations(function(e){var r=v(t);at(r.size),r.forEach(function(t){return e.add(t)})})}function Le(t){return je(t)&&w(t)}function Te(t,e){var r=Object.create(tn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Be(){return en||(en=Te(De()))}function Je(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);Fe(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=Ut(o)},i=n.prototype=Object.create(rn);return i.constructor=n,n}function We(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function Ce(t){return t._name||t.constructor.name||"Record"}function Fe(t,e){try{e.forEach(Ne.bind(void 0,t))}catch(r){}}function Ne(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ut(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Ge(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||y(t)!==y(e)||g(t)!==g(e)||w(t)!==w(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!m(t);if(w(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&X(i[1],t)&&(r||X(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,a=e.__iterate(function(e,n){return(r?t.has(e):i?X(e,t.get(n,hr)):X(t.get(n,hr),e))?void 0:(u=!1,!1)});return u&&t.size===a}function He(t,e,r){if(!(this instanceof He))return new He(t,e,r);if(ut(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(nn)return nn;nn=this}}function Ve(t,e){if(!(this instanceof Ve))return new Ve(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(on)return on;on=this}}function Xe(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ye(t,e){return e}function Qe(t,e){return[e,t]}function Ze(t){return function(){return!t.apply(this,arguments)}}function $e(t){return function(){return-t.apply(this,arguments)}}function tr(t){return"string"==typeof t?JSON.stringify(t):t}function er(){return i(arguments)}function rr(t,e){return e>t?1:t>e?-1:0}function nr(t){if(t.size===1/0)return 0;var e=w(t),r=y(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+or(et(t),et(e))|0}:function(t,e){n=n+or(et(t),et(e))|0}:e?function(t){n=31*n+et(t)|0}:function(t){n=n+et(t)|0});return ir(i,n)}function ir(t,e){return e=Er(e,3432918353),e=Er(e<<15|e>>>-15,461845907),e=Er(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Er(e^e>>>16,2246822507),e=Er(e^e>>>13,3266489909),e=tt(e^e>>>16)}function or(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var ur=Array.prototype.slice,ar="delete",sr=5,cr=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},j.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new S(function(){return i>n?I():b(t,i,r[e?n-i++:i++])})},t(R,q),R.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},R.prototype.has=function(t){return this._object.hasOwnProperty(t)},R.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},R.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new S(function(){var u=n[e?i-o:o];return o++>i?I():b(t,u,r[u])})},R.prototype[yr]=!0,t(K,k),K.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=this._iterable,n=D(r),i=0;if(M(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},K.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=D(r);if(!M(n))return new S(I);var i=0;return new S(function(){var e=n.next();return e.done?e:b(t,i++,e.value)})},t(P,k),P.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return b(t,i,n[i++])})};var Mr;t(N,p),t(G,N),t(H,N),t(V,N),N.Keyed=G,N.Indexed=H,N.Set=V;var Dr,Er="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},Or=Object.isExtensible,xr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),qr="function"==typeof WeakMap;qr&&(Dr=new WeakMap);var kr=0,Ar="__immutablehash__";"function"==typeof Symbol&&(Ar=Symbol(Ar));var jr=16,Rr=255,Kr=0,Pr={};t(st,q),st.prototype.get=function(t,e){return this._iter.get(t,e)},st.prototype.has=function(t){return this._iter.has(t)},st.prototype.valueSeq=function(){return this._iter.valueSeq()},st.prototype.reverse=function(){var t=this,e=_t(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},st.prototype.map=function(t,e){var r=this,n=lt(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},st.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?kt(this):0,function(i){return t(i,e?--r:r++,n)}),e)},st.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(mr,e),n=e?kt(this):0;return new S(function(){var i=r.next();return i.done?i:b(t,e?--n:n++,i.value,i)})},st.prototype[yr]=!0,t(ct,k),ct.prototype.includes=function(t){return this._iter.includes(t)},ct.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ct.prototype.__iterator=function(t,e){var r=this._iter.__iterator(mr,e),n=0;return new S(function(){var e=r.next();return e.done?e:b(t,n++,e.value,e)})},t(ft,A),ft.prototype.has=function(t){return this._iter.includes(t)},ft.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},ft.prototype.__iterator=function(t,e){var r=this._iter.__iterator(mr,e);return new S(function(){var e=r.next();return e.done?e:b(t,e.value,e.value,e)})},t(ht,q),ht.prototype.entrySeq=function(){return this._iter.toSeq()},ht.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){qt(e);var n=d(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ht.prototype.__iterator=function(t,e){var r=this._iter.__iterator(mr,e);return new S(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value; +if(n){qt(n);var i=d(n);return b(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ct.prototype.cacheResult=st.prototype.cacheResult=ft.prototype.cacheResult=ht.prototype.cacheResult=Rt,t(Ut,G),Ut.prototype.toString=function(){return this.__toString("Map {","}")},Ut.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Ut.prototype.set=function(t,e){return Xt(this,t,e)},Ut.prototype.setIn=function(t,e){return this.updateIn(t,hr,function(){return e})},Ut.prototype.remove=function(t){return Xt(this,t,hr)},Ut.prototype.deleteIn=function(t){return this.updateIn(t,function(){return hr})},Ut.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},Ut.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=oe(this,Pt(t),e,r);return n===hr?void 0:n},Ut.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Vt()},Ut.prototype.merge=function(){return re(this,void 0,arguments)},Ut.prototype.mergeWith=function(t){var e=ur.call(arguments,1);return re(this,t,e)},Ut.prototype.mergeIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Vt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},Ut.prototype.mergeDeep=function(){return re(this,ne(void 0),arguments)},Ut.prototype.mergeDeepWith=function(t){var e=ur.call(arguments,1);return re(this,ne(t),e)},Ut.prototype.mergeDeepIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Vt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},Ut.prototype.sort=function(t){return Ie(Mt(this,t))},Ut.prototype.sortBy=function(t,e){return Ie(Mt(this,e,t))},Ut.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Ut.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},Ut.prototype.asImmutable=function(){return this.__ensureOwner()},Ut.prototype.wasAltered=function(){return this.__altered},Ut.prototype.__iterator=function(t,e){return new Ft(this,t,e)},Ut.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},Ut.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ht(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ut.isMap=Lt;var Ur="@@__IMMUTABLE_MAP__@@",Lr=Ut.prototype;Lr[Ur]=!0,Lr[ar]=Lr.remove,Lr.removeIn=Lr.deleteIn,Tt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Tt.prototype.update=function(t,e,n,o,u,a,s){for(var c=u===hr,f=this.entries,h=0,p=f.length;p>h&&!X(o,f[h][0]);h++);var l=p>h;if(l?f[h][1]===u:c)return this;if(r(s),(c||!l)&&r(a),!c||1!==f.length){if(!l&&!c&&f.length>=Br)return $t(t,f,o,u);var _=t&&t===this.ownerID,v=_?f:i(f);return l?c?h===p-1?v.pop():v[h]=v.pop():v[h]=[o,u]:v.push([o,u]),_?(this.entries=v,this):new Tt(t,v)}},Bt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=1<<((0===t?e:e>>>t)&fr),o=this.bitmap;return 0===(o&i)?n:this.nodes[ue(o&i-1)].get(t+sr,e,r,n)},Bt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var a=(0===e?r:r>>>e)&fr,s=1<=Jr)return ee(t,p,c,a,_);if(f&&!_&&2===p.length&&Qt(p[1^h]))return p[1^h];if(f&&_&&1===p.length&&Qt(_))return _;var v=t&&t===this.ownerID,d=f?_?c:c^s:c|s,y=f?_?ae(p,h,_,v):ce(p,h,v):se(p,h,_,v);return v?(this.bitmap=d,this.nodes=y,this):new Bt(t,d,y)},Jt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=(0===t?e:e>>>t)&fr,o=this.nodes[i];return o?o.get(t+sr,e,r,n):n},Jt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var a=(0===e?r:r>>>e)&fr,s=i===hr,c=this.nodes,f=c[a];if(s&&!f)return this;var h=Yt(f,t,e+sr,r,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&(p--,Wr>p))return te(t,c,p,a)}else p++;var l=t&&t===this.ownerID,_=ae(c,a,h,l);return l?(this.count=p,this.nodes=_,this):new Jt(t,p,_)},Wt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Wt.prototype.update=function(t,e,n,o,u,a,s){void 0===n&&(n=et(o));var c=u===hr;if(n!==this.keyHash)return c?this:(r(s),r(a),Zt(this,t,e,n,[o,u]));for(var f=this.entries,h=0,p=f.length;p>h&&!X(o,f[h][0]);h++);var l=p>h;if(l?f[h][1]===u:c)return this;if(r(s),(c||!l)&&r(a),c&&2===p)return new Ct(t,this.keyHash,f[1^h]);var _=t&&t===this.ownerID,v=_?f:i(f);return l?c?h===p-1?v.pop():v[h]=v.pop():v[h]=[o,u]:v.push([o,u]),_?(this.entries=v,this):new Wt(t,this.keyHash,v)},Ct.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},Ct.prototype.update=function(t,e,n,i,o,u,a){var s=o===hr,c=X(i,this.entry[0]);return(c?o===this.entry[1]:s)?this:(r(a),s?void r(u):c?t&&t===this.ownerID?(this.entry[1]=o,this):new Ct(t,this.keyHash,[i,o]):(r(u),Zt(this,t,e,et(i),[i,o])))},Tt.prototype.iterate=Wt.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},Bt.prototype.iterate=Jt.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},Ct.prototype.iterate=function(t,e){return t(this.entry)},t(Ft,S),Ft.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return Nt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return Nt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return Nt(t,o.entry);e=this._stack=Gt(o,e)}continue}e=this._stack=this._stack.__prev}return I()};var Tr,Br=cr/4,Jr=cr/2,Wr=cr/4;t(fe,H),fe.of=function(){return this(arguments)},fe.prototype.toString=function(){return this.__toString("List [","]")},fe.prototype.get=function(t,e){if(t=u(this,t),t>=0&&t>>e&fr;if(n>=this.array.length)return new pe([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-sr,r),i===u&&o)return this}if(o&&!i)return this;var a=ge(this,t);if(!o)for(var s=0;n>s;s++)a.array[s]=void 0;return i&&(a.array[n]=i),a},pe.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&fr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-sr,r),i===o&&n===this.array.length-1)return this}var u=ge(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Nr,Gr={};t(Ie,Ut),Ie.of=function(){return this(arguments)},Ie.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Ie.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Ie.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):De()},Ie.prototype.set=function(t,e){return Ee(this,t,e)},Ie.prototype.remove=function(t){return Ee(this,t,hr)},Ie.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Ie.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Ie.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Ie.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Me(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Ie.isOrderedMap=ze,Ie.prototype[yr]=!0,Ie.prototype[ar]=Ie.prototype.remove;var Hr;t(Oe,H),Oe.of=function(){return this(arguments)},Oe.prototype.toString=function(){return this.__toString("Stack [","]")},Oe.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},Oe.prototype.peek=function(){return this._head&&this._head.value},Oe.prototype.push=function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):qe(t,e)},Oe.prototype.pushAll=function(t){if(t=_(t),0===t.size)return this;at(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):qe(e,r)},Oe.prototype.pop=function(){return this.slice(1)},Oe.prototype.unshift=function(){return this.push.apply(this,arguments)},Oe.prototype.unshiftAll=function(t){return this.pushAll(t)},Oe.prototype.shift=function(){return this.pop.apply(this,arguments)},Oe.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):ke()},Oe.prototype.slice=function(t,e){if(s(t,e,this.size))return this;var r=c(t,this.size),n=f(e,this.size);if(n!==this.size)return H.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):qe(i,o)},Oe.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?qe(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Oe.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Oe.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new S(function(){if(n){var e=n.value;return n=n.next,b(t,r++,e)}return I()})},Oe.isStack=xe;var Vr="@@__IMMUTABLE_STACK__@@",Xr=Oe.prototype;Xr[Vr]=!0,Xr.withMutations=Lr.withMutations,Xr.asMutable=Lr.asMutable,Xr.asImmutable=Lr.asImmutable,Xr.wasAltered=Lr.wasAltered;var Yr;t(Ae,V),Ae.of=function(){return this(arguments)},Ae.fromKeys=function(t){return this(l(t).keySeq())},Ae.prototype.toString=function(){return this.__toString("Set {","}")},Ae.prototype.has=function(t){return this._map.has(t)},Ae.prototype.add=function(t){return Re(this,this._map.set(t,!0))},Ae.prototype.remove=function(t){return Re(this,this._map.remove(t))},Ae.prototype.clear=function(){return Re(this,this._map.clear())},Ae.prototype.union=function(){var t=ur.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;r1?" by "+this._step:"")+" ]"},He.prototype.get=function(t,e){return this.has(t)?this._start+u(this,t)*this._step:e},He.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&e=e?new He(0,0):new He(this.get(t,this._end),this.get(e,this._end),this._step))},He.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&r=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},He.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new S(function(){var u=i;return i+=e?-n:n,o>r?I():b(t,o++,u)})},He.prototype.equals=function(t){return t instanceof He?this._start===t._start&&this._end===t._end&&this._step===t._step:Ge(this,t)};var nn;t(Ve,k),Ve.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},Ve.prototype.get=function(t,e){return this.has(t)?this._value:e},Ve.prototype.includes=function(t){return X(this._value,t)},Ve.prototype.slice=function(t,e){var r=this.size;return s(t,e,r)?this:new Ve(this._value,f(e,r)-c(t,r))},Ve.prototype.reverse=function(){return this},Ve.prototype.indexOf=function(t){return X(this._value,t)?0:-1},Ve.prototype.lastIndexOf=function(t){return X(this._value,t)?this.size:-1},Ve.prototype.__iterate=function(t,e){for(var r=0;rt?this.count():this.size);var n=this.slice(0,t);return xt(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return xt(this,bt(this,t,!1))},get:function(t,e){return t=u(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=u(this,t),t>=0&&(void 0!==this.size?this.size===1/0||t-1&&t%1===0&&t<=Number.MAX_VALUE}var i=Function.prototype.bind;e.isString=function(t){return"string"==typeof t||"[object String]"===r(t)},e.isArray=Array.isArray||function(t){return"[object Array]"===r(t)},"function"!=typeof/./&&"object"!=typeof Int8Array?e.isFunction=function(t){return"function"==typeof t||!1}:e.isFunction=function(t){return"[object Function]"===toString.call(t)},e.isObject=function(t){var e=typeof t;return"function"===e||"object"===e&&!!t},e.extend=function(t){var e=arguments.length;if(!t||2>e)return t||{};for(var r=1;e>r;r++)for(var n=arguments[r],i=Object.keys(n),o=i.length,u=0;o>u;u++){var a=i[u];t[a]=n[a]}return t},e.clone=function(t){return e.isObject(t)?e.isArray(t)?t.slice():e.extend({},t):t},e.each=function(t,e,r){var i,o,u=t?t.length:0,a=-1;if(r&&(o=e,e=function(t,e,n){return o.call(r,t,e,n)}),n(u))for(;++an;n++)r[n]=arguments[n];return new(i.apply(t,[null].concat(r)))};return e.__proto__=t,e.prototype=t.prototype,e}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return c["default"].Iterable.isIterable(t)}function o(t){return i(t)||!f.isObject(t)}function u(t){return i(t)?t.toJS():t}function a(t){return i(t)?t:c["default"].fromJS(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isImmutable=i,e.isImmutableValue=o,e.toJS=u,e.toImmutable=a;var s=r(3),c=n(s),f=r(4)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var u=function(){function t(t,e){for(var r=0;r0)){var e=this.reactorState.get("dirtyStores");if(0!==e.size){var r=s["default"].Set().withMutations(function(r){r.union(t.observerState.get("any")),e.forEach(function(e){var n=t.observerState.getIn(["stores",e]);n&&r.union(n)})});r.forEach(function(e){var r=t.observerState.getIn(["observersMap",e]);if(r){var n=r.get("getter"),i=r.get("handler"),o=p["default"].evaluate(t.prevReactorState,n),u=p["default"].evaluate(t.reactorState,n);t.prevReactorState=o.reactorState,t.reactorState=u.reactorState;var a=o.result,c=u.result;s["default"].is(a,c)||i.call(null,c)}});var n=p["default"].resetDirtyStores(this.reactorState);this.prevReactorState=n,this.reactorState=n}}}},{key:"batchStart",value:function(){this.__batchDepth++; +}},{key:"batchEnd",value:function(){if(this.__batchDepth--,this.__batchDepth<=0){this.__isDispatching=!0;try{this.__notify()}catch(t){throw this.__isDispatching=!1,t}this.__isDispatching=!1}}}]),t}();e["default"]=d.toFactory(g),t.exports=e["default"]},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r={};return o.each(e,function(e,n){r[n]=t.evaluate(e)}),r}Object.defineProperty(e,"__esModule",{value:!0});var o=r(4);e["default"]=function(t){return{getInitialState:function(){return i(t,this.getDataBindings())},componentDidMount:function(){var e=this;this.__unwatchFns=[],o.each(this.getDataBindings(),function(r,i){var o=t.observe(r,function(t){e.setState(n({},i,t))});e.__unwatchFns.push(o)})},componentWillUnmount:function(){for(;this.__unwatchFns.length;)this.__unwatchFns.shift()()}}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return new w({result:t,reactorState:e})}function o(t){return t}function u(t,e){var r=o(e);return t.getIn(["cache",r])}function a(t,e){var r=u(t,e);return r?r.get("storeStates").every(function(e,r){return t.getIn(["storeStates",r])===e}):!1}function s(t,e,r){var n=o(e),i=t.get("dispatchId"),u=y.getStoreDeps(e),a=d.toImmutable({}).withMutations(function(e){u.forEach(function(r){var n=t.getIn(["storeStates",r]);e.set(r,n)})});return t.setIn(["cache",n],l["default"].Map({value:r,storeStates:a,dispatchId:i}))}function c(t,e){var r=o(e);return t.getIn(["cache",r,"value"])}function f(t){return t.update("dispatchId",function(t){return t+1})}function h(t,e){return t.withMutations(function(t){e.forEach(function(e){var r=t.has(e)?t.get(e)+1:1;t.set(e,r)})})}var p=r(3),l=n(p),_=r(9),v=n(_),d=r(5),y=r(10),g=r(11),m=r(4),w=l["default"].Record({result:null,reactorState:null});e.registerStores=function(t,e){var r=t.get("debug");return t.withMutations(function(t){m.each(e,function(e,n){t.getIn(["stores",n])&&console.warn("Store already defined for id = "+n);var i=e.getInitialState();if(r&&!d.isImmutableValue(i))throw new Error("Store getInitialState() must return an immutable value, did you forget to call toImmutable");t.update("stores",function(t){return t.set(n,e)}).update("state",function(t){return t.set(n,i)}).update("dirtyStores",function(t){return t.add(n)}).update("storeStates",function(t){return h(t,[n])})}),f(t)})},e.dispatch=function(t,e,r){var n=t.get("state"),i=t.get("debug"),o=t.get("dirtyStores"),u=n.withMutations(function(n){i&&v["default"].dispatchStart(e,r),t.get("stores").forEach(function(t,u){var a=n.get(u),s=void 0;try{s=t.handle(a,e,r)}catch(c){throw v["default"].dispatchError(c.message),c}if(i&&void 0===s){var f="Store handler must return a value, did you forget a return statement";throw v["default"].dispatchError(f),new Error(f)}n.set(u,s),a!==s&&(o=o.add(u)),i&&v["default"].storeHandled(u,a,s)}),i&&v["default"].dispatchEnd(n)}),a=t.set("state",u).set("dirtyStores",o).update("storeStates",function(t){return h(t,o)});return f(a)},e.loadState=function(t,e){var r=[],n=d.toImmutable({}).withMutations(function(n){m.each(e,function(e,i){var o=t.getIn(["stores",i]);if(o){var u=o.deserialize(e);void 0!==u&&(n.set(i,u),r.push(i))}})}),i=l["default"].Set(r);return t.update("state",function(t){return t.merge(n)}).update("dirtyStores",function(t){return t.union(i)}).update("storeStates",function(t){return h(t,r)})},e.addObserver=function(t,e,r){var n=e;g.isKeyPath(e)&&(e=y.fromKeyPath(e));var i=t.get("nextId"),o=y.getStoreDeps(e),u=l["default"].Map({id:i,storeDeps:o,getterKey:n,getter:e,handler:r}),a=void 0;return a=0===o.size?t.update("any",function(t){return t.add(i)}):t.withMutations(function(t){o.forEach(function(e){var r=["stores",e];t.hasIn(r)||t.setIn(r,l["default"].Set([])),t.updateIn(["stores",e],function(t){return t.add(i)})})}),a=a.set("nextId",i+1).setIn(["observersMap",i],u),{observerState:a,entry:u}},e.removeObserver=function(t,r,n){var i=t.get("observersMap").filter(function(t){var e=t.get("getterKey"),i=!n||t.get("handler")===n;return i?g.isKeyPath(r)&&g.isKeyPath(e)?g.isEqual(r,e):r===e:!1});return t.withMutations(function(t){i.forEach(function(r){return e.removeObserverByEntry(t,r)})})},e.removeObserverByEntry=function(t,e){return t.withMutations(function(t){var r=e.get("id"),n=e.get("storeDeps");0===n.size?t.update("any",function(t){return t.remove(r)}):n.forEach(function(e){t.updateIn(["stores",e],function(t){return t?t.remove(r):t})}),t.removeIn(["observersMap",r])})},e.reset=function(t){var r=t.get("debug"),n=t.get("state");return t.withMutations(function(t){var i=t.get("stores"),o=i.keySeq().toJS();i.forEach(function(e,i){var o=n.get(i),u=e.handleReset(o);if(r&&void 0===u)throw new Error("Store handleReset() must return a value, did you forget a return statement");if(r&&!d.isImmutableValue(u))throw new Error("Store reset state must be an immutable value, did you forget to call toImmutable");t.setIn(["state",i],u)}),t.update("storeStates",function(t){return h(t,o)}),e.resetDirtyStores(t)})},e.evaluate=function S(t,e){var r=t.get("state");if(g.isKeyPath(e))return i(r.getIn(e),t);if(!y.isGetter(e))throw new Error("evaluate must be passed a keyPath or Getter");if(a(t,e))return i(c(t,e),t);var n=y.getDeps(e).map(function(e){return S(t,e).result}),o=y.getComputeFn(e).apply(null,n);return i(o,s(t,e,o))},e.serialize=function(t){var e={};return t.get("stores").forEach(function(r,n){var i=t.getIn(["state",n]),o=r.serialize(i);void 0!==o&&(e[n]=o)}),e},e.resetDirtyStores=function(t){return t.set("dirtyStores",l["default"].Set())}},function(t,e){"use strict";e.dispatchStart=function(t,e){console.group&&(console.groupCollapsed("Dispatch: %s",t),console.group("payload"),console.debug(e),console.groupEnd())},e.dispatchError=function(t){console.group&&(console.debug("Dispatch error: "+t),console.groupEnd())},e.storeHandled=function(t,e,r){console.group&&e!==r&&console.debug("Store "+t+" handled action")},e.dispatchEnd=function(t){console.group&&(console.debug("Dispatch done, new state: ",t.toJS()),console.groupEnd())}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return p.isArray(t)&&p.isFunction(t[t.length-1])}function o(t){return t[t.length-1]}function u(t){return t.slice(0,t.length-1)}function a(t,e){e||(e=h["default"].Set());var r=h["default"].Set().withMutations(function(e){if(!i(t))throw new Error("getFlattenedDeps must be passed a Getter");u(t).forEach(function(t){if(l.isKeyPath(t))e.add(f.List(t));else{if(!i(t))throw new Error("Invalid getter, each dependency must be a KeyPath or Getter");e.union(a(t))}})});return e.union(r)}function s(t){if(!l.isKeyPath(t))throw new Error("Cannot create Getter from KeyPath: "+t);return[t,_]}function c(t){if(t.hasOwnProperty("__storeDeps"))return t.__storeDeps;var e=a(t).map(function(t){return t.first()}).filter(function(t){return!!t});return Object.defineProperty(t,"__storeDeps",{enumerable:!1,configurable:!1,writable:!1,value:e}),e}Object.defineProperty(e,"__esModule",{value:!0});var f=r(3),h=n(f),p=r(4),l=r(11),_=function(t){return t};e["default"]={isGetter:i,getComputeFn:o,getFlattenedDeps:a,getStoreDeps:c,getDeps:u,fromKeyPath:s},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return s.isArray(t)&&!s.isFunction(t[t.length-1])}function o(t,e){var r=a["default"].List(t),n=a["default"].List(e);return a["default"].is(r,n)}Object.defineProperty(e,"__esModule",{value:!0}),e.isKeyPath=i,e.isEqual=o;var u=r(3),a=n(u),s=r(4)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),o=n(i),u=o["default"].Record({dispatchId:0,state:o["default"].Map(),stores:o["default"].Map(),cache:o["default"].Map(),storeStates:o["default"].Map(),dirtyStores:o["default"].Set(),debug:!1}),a=o["default"].Record({any:o["default"].Set([]),stores:o["default"].Map({}),observersMap:o["default"].Map({}),nextId:1});e["default"]={ReactorState:u,ObserverState:a},t.exports=e["default"]}])}); \ No newline at end of file