diff --git a/README.md b/README.md index 36931be..9482849 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,15 @@ Please read the Features section below and issues to make sure your issue is not - [x] File Size - [x] Directory Child Count - [x] Actions on multiple files (selection) -- [ ] Copy/Cut and Paste files -- [ ] File Preview -- [ ] Filter Files -- [ ] Search +- [x] Copy and Paste/Move files +- [x] File Preview +- [x] Filter Files +- [x] Swipe Gestures (Up directory by swiping right) +- [x] Search +- [ ] Intro - [ ] Different views (List, Icons, etc) - [ ] Share Files - [ ] Preferences - [ ] FTP Browser - [ ] File Type Icons -- [ ] Swipe Gestures - [ ] Wi-Fi File Transfer (is this possible?) diff --git a/build/img/Search.png b/build/img/Search.png new file mode 100644 index 0000000..f2dc117 Binary files /dev/null and b/build/img/Search.png differ diff --git a/build/img/Search.svg b/build/img/Search.svg new file mode 100644 index 0000000..6a72cd3 --- /dev/null +++ b/build/img/Search.svg @@ -0,0 +1,14 @@ + + + + Search + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/build/index.html b/build/index.html index cb32db8..24a51e6 100644 --- a/build/index.html +++ b/build/index.html @@ -3,7 +3,7 @@ Hawk - + diff --git a/build/main.js b/build/main.js index 16c3b63..0e24922 100644 --- a/build/main.js +++ b/build/main.js @@ -91,6 +91,7432 @@ process.chdir = function (dir) { process.umask = function() { return 0; }; },{}],2:[function(require,module,exports){ +/*! Hammer.JS - v2.0.4 - 2014-09-28 + * http://hammerjs.github.io/ + * + * Copyright (c) 2014 Jorik Tangelder; + * Licensed under the MIT license */ +(function(window, document, exportName, undefined) { + 'use strict'; + +var VENDOR_PREFIXES = ['', 'webkit', 'moz', 'MS', 'ms', 'o']; +var TEST_ELEMENT = document.createElement('div'); + +var TYPE_FUNCTION = 'function'; + +var round = Math.round; +var abs = Math.abs; +var now = Date.now; + +/** + * set a timeout with a given scope + * @param {Function} fn + * @param {Number} timeout + * @param {Object} context + * @returns {number} + */ +function setTimeoutContext(fn, timeout, context) { + return setTimeout(bindFn(fn, context), timeout); +} + +/** + * if the argument is an array, we want to execute the fn on each entry + * if it aint an array we don't want to do a thing. + * this is used by all the methods that accept a single and array argument. + * @param {*|Array} arg + * @param {String} fn + * @param {Object} [context] + * @returns {Boolean} + */ +function invokeArrayArg(arg, fn, context) { + if (Array.isArray(arg)) { + each(arg, context[fn], context); + return true; + } + return false; +} + +/** + * walk objects and arrays + * @param {Object} obj + * @param {Function} iterator + * @param {Object} context + */ +function each(obj, iterator, context) { + var i; + + if (!obj) { + return; + } + + if (obj.forEach) { + obj.forEach(iterator, context); + } else if (obj.length !== undefined) { + i = 0; + while (i < obj.length) { + iterator.call(context, obj[i], i, obj); + i++; + } + } else { + for (i in obj) { + obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj); + } + } +} + +/** + * extend object. + * means that properties in dest will be overwritten by the ones in src. + * @param {Object} dest + * @param {Object} src + * @param {Boolean} [merge] + * @returns {Object} dest + */ +function extend(dest, src, merge) { + var keys = Object.keys(src); + var i = 0; + while (i < keys.length) { + if (!merge || (merge && dest[keys[i]] === undefined)) { + dest[keys[i]] = src[keys[i]]; + } + i++; + } + return dest; +} + +/** + * merge the values from src in the dest. + * means that properties that exist in dest will not be overwritten by src + * @param {Object} dest + * @param {Object} src + * @returns {Object} dest + */ +function merge(dest, src) { + return extend(dest, src, true); +} + +/** + * simple class inheritance + * @param {Function} child + * @param {Function} base + * @param {Object} [properties] + */ +function inherit(child, base, properties) { + var baseP = base.prototype, + childP; + + childP = child.prototype = Object.create(baseP); + childP.constructor = child; + childP._super = baseP; + + if (properties) { + extend(childP, properties); + } +} + +/** + * simple function bind + * @param {Function} fn + * @param {Object} context + * @returns {Function} + */ +function bindFn(fn, context) { + return function boundFn() { + return fn.apply(context, arguments); + }; +} + +/** + * let a boolean value also be a function that must return a boolean + * this first item in args will be used as the context + * @param {Boolean|Function} val + * @param {Array} [args] + * @returns {Boolean} + */ +function boolOrFn(val, args) { + if (typeof val == TYPE_FUNCTION) { + return val.apply(args ? args[0] || undefined : undefined, args); + } + return val; +} + +/** + * use the val2 when val1 is undefined + * @param {*} val1 + * @param {*} val2 + * @returns {*} + */ +function ifUndefined(val1, val2) { + return (val1 === undefined) ? val2 : val1; +} + +/** + * addEventListener with multiple events at once + * @param {EventTarget} target + * @param {String} types + * @param {Function} handler + */ +function addEventListeners(target, types, handler) { + each(splitStr(types), function(type) { + target.addEventListener(type, handler, false); + }); +} + +/** + * removeEventListener with multiple events at once + * @param {EventTarget} target + * @param {String} types + * @param {Function} handler + */ +function removeEventListeners(target, types, handler) { + each(splitStr(types), function(type) { + target.removeEventListener(type, handler, false); + }); +} + +/** + * find if a node is in the given parent + * @method hasParent + * @param {HTMLElement} node + * @param {HTMLElement} parent + * @return {Boolean} found + */ +function hasParent(node, parent) { + while (node) { + if (node == parent) { + return true; + } + node = node.parentNode; + } + return false; +} + +/** + * small indexOf wrapper + * @param {String} str + * @param {String} find + * @returns {Boolean} found + */ +function inStr(str, find) { + return str.indexOf(find) > -1; +} + +/** + * split string on whitespace + * @param {String} str + * @returns {Array} words + */ +function splitStr(str) { + return str.trim().split(/\s+/g); +} + +/** + * find if a array contains the object using indexOf or a simple polyFill + * @param {Array} src + * @param {String} find + * @param {String} [findByKey] + * @return {Boolean|Number} false when not found, or the index + */ +function inArray(src, find, findByKey) { + if (src.indexOf && !findByKey) { + return src.indexOf(find); + } else { + var i = 0; + while (i < src.length) { + if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) { + return i; + } + i++; + } + return -1; + } +} + +/** + * convert array-like objects to real arrays + * @param {Object} obj + * @returns {Array} + */ +function toArray(obj) { + return Array.prototype.slice.call(obj, 0); +} + +/** + * unique array with objects based on a key (like 'id') or just by the array's value + * @param {Array} src [{id:1},{id:2},{id:1}] + * @param {String} [key] + * @param {Boolean} [sort=False] + * @returns {Array} [{id:1},{id:2}] + */ +function uniqueArray(src, key, sort) { + var results = []; + var values = []; + var i = 0; + + while (i < src.length) { + var val = key ? src[i][key] : src[i]; + if (inArray(values, val) < 0) { + results.push(src[i]); + } + values[i] = val; + i++; + } + + if (sort) { + if (!key) { + results = results.sort(); + } else { + results = results.sort(function sortUniqueArray(a, b) { + return a[key] > b[key]; + }); + } + } + + return results; +} + +/** + * get the prefixed property + * @param {Object} obj + * @param {String} property + * @returns {String|Undefined} prefixed + */ +function prefixed(obj, property) { + var prefix, prop; + var camelProp = property[0].toUpperCase() + property.slice(1); + + var i = 0; + while (i < VENDOR_PREFIXES.length) { + prefix = VENDOR_PREFIXES[i]; + prop = (prefix) ? prefix + camelProp : property; + + if (prop in obj) { + return prop; + } + i++; + } + return undefined; +} + +/** + * get a unique id + * @returns {number} uniqueId + */ +var _uniqueId = 1; +function uniqueId() { + return _uniqueId++; +} + +/** + * get the window object of an element + * @param {HTMLElement} element + * @returns {DocumentView|Window} + */ +function getWindowForElement(element) { + var doc = element.ownerDocument; + return (doc.defaultView || doc.parentWindow); +} + +var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i; + +var SUPPORT_TOUCH = ('ontouchstart' in window); +var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined; +var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent); + +var INPUT_TYPE_TOUCH = 'touch'; +var INPUT_TYPE_PEN = 'pen'; +var INPUT_TYPE_MOUSE = 'mouse'; +var INPUT_TYPE_KINECT = 'kinect'; + +var COMPUTE_INTERVAL = 25; + +var INPUT_START = 1; +var INPUT_MOVE = 2; +var INPUT_END = 4; +var INPUT_CANCEL = 8; + +var DIRECTION_NONE = 1; +var DIRECTION_LEFT = 2; +var DIRECTION_RIGHT = 4; +var DIRECTION_UP = 8; +var DIRECTION_DOWN = 16; + +var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT; +var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN; +var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL; + +var PROPS_XY = ['x', 'y']; +var PROPS_CLIENT_XY = ['clientX', 'clientY']; + +/** + * create new input type manager + * @param {Manager} manager + * @param {Function} callback + * @returns {Input} + * @constructor + */ +function Input(manager, callback) { + var self = this; + this.manager = manager; + this.callback = callback; + this.element = manager.element; + this.target = manager.options.inputTarget; + + // smaller wrapper around the handler, for the scope and the enabled state of the manager, + // so when disabled the input events are completely bypassed. + this.domHandler = function(ev) { + if (boolOrFn(manager.options.enable, [manager])) { + self.handler(ev); + } + }; + + this.init(); + +} + +Input.prototype = { + /** + * should handle the inputEvent data and trigger the callback + * @virtual + */ + handler: function() { }, + + /** + * bind the events + */ + init: function() { + this.evEl && addEventListeners(this.element, this.evEl, this.domHandler); + this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler); + this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler); + }, + + /** + * unbind the events + */ + destroy: function() { + this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler); + this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler); + this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler); + } +}; + +/** + * create new input type manager + * called by the Manager constructor + * @param {Hammer} manager + * @returns {Input} + */ +function createInputInstance(manager) { + var Type; + var inputClass = manager.options.inputClass; + + if (inputClass) { + Type = inputClass; + } else if (SUPPORT_POINTER_EVENTS) { + Type = PointerEventInput; + } else if (SUPPORT_ONLY_TOUCH) { + Type = TouchInput; + } else if (!SUPPORT_TOUCH) { + Type = MouseInput; + } else { + Type = TouchMouseInput; + } + return new (Type)(manager, inputHandler); +} + +/** + * handle input events + * @param {Manager} manager + * @param {String} eventType + * @param {Object} input + */ +function inputHandler(manager, eventType, input) { + var pointersLen = input.pointers.length; + var changedPointersLen = input.changedPointers.length; + var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0)); + var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0)); + + input.isFirst = !!isFirst; + input.isFinal = !!isFinal; + + if (isFirst) { + manager.session = {}; + } + + // source event is the normalized value of the domEvents + // like 'touchstart, mouseup, pointerdown' + input.eventType = eventType; + + // compute scale, rotation etc + computeInputData(manager, input); + + // emit secret event + manager.emit('hammer.input', input); + + manager.recognize(input); + manager.session.prevInput = input; +} + +/** + * extend the data with some usable properties like scale, rotate, velocity etc + * @param {Object} manager + * @param {Object} input + */ +function computeInputData(manager, input) { + var session = manager.session; + var pointers = input.pointers; + var pointersLength = pointers.length; + + // store the first input to calculate the distance and direction + if (!session.firstInput) { + session.firstInput = simpleCloneInputData(input); + } + + // to compute scale and rotation we need to store the multiple touches + if (pointersLength > 1 && !session.firstMultiple) { + session.firstMultiple = simpleCloneInputData(input); + } else if (pointersLength === 1) { + session.firstMultiple = false; + } + + var firstInput = session.firstInput; + var firstMultiple = session.firstMultiple; + var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center; + + var center = input.center = getCenter(pointers); + input.timeStamp = now(); + input.deltaTime = input.timeStamp - firstInput.timeStamp; + + input.angle = getAngle(offsetCenter, center); + input.distance = getDistance(offsetCenter, center); + + computeDeltaXY(session, input); + input.offsetDirection = getDirection(input.deltaX, input.deltaY); + + input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1; + input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0; + + computeIntervalInputData(session, input); + + // find the correct target + var target = manager.element; + if (hasParent(input.srcEvent.target, target)) { + target = input.srcEvent.target; + } + input.target = target; +} + +function computeDeltaXY(session, input) { + var center = input.center; + var offset = session.offsetDelta || {}; + var prevDelta = session.prevDelta || {}; + var prevInput = session.prevInput || {}; + + if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) { + prevDelta = session.prevDelta = { + x: prevInput.deltaX || 0, + y: prevInput.deltaY || 0 + }; + + offset = session.offsetDelta = { + x: center.x, + y: center.y + }; + } + + input.deltaX = prevDelta.x + (center.x - offset.x); + input.deltaY = prevDelta.y + (center.y - offset.y); +} + +/** + * velocity is calculated every x ms + * @param {Object} session + * @param {Object} input + */ +function computeIntervalInputData(session, input) { + var last = session.lastInterval || input, + deltaTime = input.timeStamp - last.timeStamp, + velocity, velocityX, velocityY, direction; + + if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) { + var deltaX = last.deltaX - input.deltaX; + var deltaY = last.deltaY - input.deltaY; + + var v = getVelocity(deltaTime, deltaX, deltaY); + velocityX = v.x; + velocityY = v.y; + velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y; + direction = getDirection(deltaX, deltaY); + + session.lastInterval = input; + } else { + // use latest velocity info if it doesn't overtake a minimum period + velocity = last.velocity; + velocityX = last.velocityX; + velocityY = last.velocityY; + direction = last.direction; + } + + input.velocity = velocity; + input.velocityX = velocityX; + input.velocityY = velocityY; + input.direction = direction; +} + +/** + * create a simple clone from the input used for storage of firstInput and firstMultiple + * @param {Object} input + * @returns {Object} clonedInputData + */ +function simpleCloneInputData(input) { + // make a simple copy of the pointers because we will get a reference if we don't + // we only need clientXY for the calculations + var pointers = []; + var i = 0; + while (i < input.pointers.length) { + pointers[i] = { + clientX: round(input.pointers[i].clientX), + clientY: round(input.pointers[i].clientY) + }; + i++; + } + + return { + timeStamp: now(), + pointers: pointers, + center: getCenter(pointers), + deltaX: input.deltaX, + deltaY: input.deltaY + }; +} + +/** + * get the center of all the pointers + * @param {Array} pointers + * @return {Object} center contains `x` and `y` properties + */ +function getCenter(pointers) { + var pointersLength = pointers.length; + + // no need to loop when only one touch + if (pointersLength === 1) { + return { + x: round(pointers[0].clientX), + y: round(pointers[0].clientY) + }; + } + + var x = 0, y = 0, i = 0; + while (i < pointersLength) { + x += pointers[i].clientX; + y += pointers[i].clientY; + i++; + } + + return { + x: round(x / pointersLength), + y: round(y / pointersLength) + }; +} + +/** + * calculate the velocity between two points. unit is in px per ms. + * @param {Number} deltaTime + * @param {Number} x + * @param {Number} y + * @return {Object} velocity `x` and `y` + */ +function getVelocity(deltaTime, x, y) { + return { + x: x / deltaTime || 0, + y: y / deltaTime || 0 + }; +} + +/** + * get the direction between two points + * @param {Number} x + * @param {Number} y + * @return {Number} direction + */ +function getDirection(x, y) { + if (x === y) { + return DIRECTION_NONE; + } + + if (abs(x) >= abs(y)) { + return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT; + } + return y > 0 ? DIRECTION_UP : DIRECTION_DOWN; +} + +/** + * calculate the absolute distance between two points + * @param {Object} p1 {x, y} + * @param {Object} p2 {x, y} + * @param {Array} [props] containing x and y keys + * @return {Number} distance + */ +function getDistance(p1, p2, props) { + if (!props) { + props = PROPS_XY; + } + var x = p2[props[0]] - p1[props[0]], + y = p2[props[1]] - p1[props[1]]; + + return Math.sqrt((x * x) + (y * y)); +} + +/** + * calculate the angle between two coordinates + * @param {Object} p1 + * @param {Object} p2 + * @param {Array} [props] containing x and y keys + * @return {Number} angle + */ +function getAngle(p1, p2, props) { + if (!props) { + props = PROPS_XY; + } + var x = p2[props[0]] - p1[props[0]], + y = p2[props[1]] - p1[props[1]]; + return Math.atan2(y, x) * 180 / Math.PI; +} + +/** + * calculate the rotation degrees between two pointersets + * @param {Array} start array of pointers + * @param {Array} end array of pointers + * @return {Number} rotation + */ +function getRotation(start, end) { + return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY); +} + +/** + * calculate the scale factor between two pointersets + * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out + * @param {Array} start array of pointers + * @param {Array} end array of pointers + * @return {Number} scale + */ +function getScale(start, end) { + return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY); +} + +var MOUSE_INPUT_MAP = { + mousedown: INPUT_START, + mousemove: INPUT_MOVE, + mouseup: INPUT_END +}; + +var MOUSE_ELEMENT_EVENTS = 'mousedown'; +var MOUSE_WINDOW_EVENTS = 'mousemove mouseup'; + +/** + * Mouse events input + * @constructor + * @extends Input + */ +function MouseInput() { + this.evEl = MOUSE_ELEMENT_EVENTS; + this.evWin = MOUSE_WINDOW_EVENTS; + + this.allow = true; // used by Input.TouchMouse to disable mouse events + this.pressed = false; // mousedown state + + Input.apply(this, arguments); +} + +inherit(MouseInput, Input, { + /** + * handle mouse events + * @param {Object} ev + */ + handler: function MEhandler(ev) { + var eventType = MOUSE_INPUT_MAP[ev.type]; + + // on start we want to have the left mouse button down + if (eventType & INPUT_START && ev.button === 0) { + this.pressed = true; + } + + if (eventType & INPUT_MOVE && ev.which !== 1) { + eventType = INPUT_END; + } + + // mouse must be down, and mouse events are allowed (see the TouchMouse input) + if (!this.pressed || !this.allow) { + return; + } + + if (eventType & INPUT_END) { + this.pressed = false; + } + + this.callback(this.manager, eventType, { + pointers: [ev], + changedPointers: [ev], + pointerType: INPUT_TYPE_MOUSE, + srcEvent: ev + }); + } +}); + +var POINTER_INPUT_MAP = { + pointerdown: INPUT_START, + pointermove: INPUT_MOVE, + pointerup: INPUT_END, + pointercancel: INPUT_CANCEL, + pointerout: INPUT_CANCEL +}; + +// in IE10 the pointer types is defined as an enum +var IE10_POINTER_TYPE_ENUM = { + 2: INPUT_TYPE_TOUCH, + 3: INPUT_TYPE_PEN, + 4: INPUT_TYPE_MOUSE, + 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816 +}; + +var POINTER_ELEMENT_EVENTS = 'pointerdown'; +var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel'; + +// IE10 has prefixed support, and case-sensitive +if (window.MSPointerEvent) { + POINTER_ELEMENT_EVENTS = 'MSPointerDown'; + POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel'; +} + +/** + * Pointer events input + * @constructor + * @extends Input + */ +function PointerEventInput() { + this.evEl = POINTER_ELEMENT_EVENTS; + this.evWin = POINTER_WINDOW_EVENTS; + + Input.apply(this, arguments); + + this.store = (this.manager.session.pointerEvents = []); +} + +inherit(PointerEventInput, Input, { + /** + * handle mouse events + * @param {Object} ev + */ + handler: function PEhandler(ev) { + var store = this.store; + var removePointer = false; + + var eventTypeNormalized = ev.type.toLowerCase().replace('ms', ''); + var eventType = POINTER_INPUT_MAP[eventTypeNormalized]; + var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType; + + var isTouch = (pointerType == INPUT_TYPE_TOUCH); + + // get index of the event in the store + var storeIndex = inArray(store, ev.pointerId, 'pointerId'); + + // start and mouse must be down + if (eventType & INPUT_START && (ev.button === 0 || isTouch)) { + if (storeIndex < 0) { + store.push(ev); + storeIndex = store.length - 1; + } + } else if (eventType & (INPUT_END | INPUT_CANCEL)) { + removePointer = true; + } + + // it not found, so the pointer hasn't been down (so it's probably a hover) + if (storeIndex < 0) { + return; + } + + // update the event in the store + store[storeIndex] = ev; + + this.callback(this.manager, eventType, { + pointers: store, + changedPointers: [ev], + pointerType: pointerType, + srcEvent: ev + }); + + if (removePointer) { + // remove from the store + store.splice(storeIndex, 1); + } + } +}); + +var SINGLE_TOUCH_INPUT_MAP = { + touchstart: INPUT_START, + touchmove: INPUT_MOVE, + touchend: INPUT_END, + touchcancel: INPUT_CANCEL +}; + +var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart'; +var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel'; + +/** + * Touch events input + * @constructor + * @extends Input + */ +function SingleTouchInput() { + this.evTarget = SINGLE_TOUCH_TARGET_EVENTS; + this.evWin = SINGLE_TOUCH_WINDOW_EVENTS; + this.started = false; + + Input.apply(this, arguments); +} + +inherit(SingleTouchInput, Input, { + handler: function TEhandler(ev) { + var type = SINGLE_TOUCH_INPUT_MAP[ev.type]; + + // should we handle the touch events? + if (type === INPUT_START) { + this.started = true; + } + + if (!this.started) { + return; + } + + var touches = normalizeSingleTouches.call(this, ev, type); + + // when done, reset the started state + if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) { + this.started = false; + } + + this.callback(this.manager, type, { + pointers: touches[0], + changedPointers: touches[1], + pointerType: INPUT_TYPE_TOUCH, + srcEvent: ev + }); + } +}); + +/** + * @this {TouchInput} + * @param {Object} ev + * @param {Number} type flag + * @returns {undefined|Array} [all, changed] + */ +function normalizeSingleTouches(ev, type) { + var all = toArray(ev.touches); + var changed = toArray(ev.changedTouches); + + if (type & (INPUT_END | INPUT_CANCEL)) { + all = uniqueArray(all.concat(changed), 'identifier', true); + } + + return [all, changed]; +} + +var TOUCH_INPUT_MAP = { + touchstart: INPUT_START, + touchmove: INPUT_MOVE, + touchend: INPUT_END, + touchcancel: INPUT_CANCEL +}; + +var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel'; + +/** + * Multi-user touch events input + * @constructor + * @extends Input + */ +function TouchInput() { + this.evTarget = TOUCH_TARGET_EVENTS; + this.targetIds = {}; + + Input.apply(this, arguments); +} + +inherit(TouchInput, Input, { + handler: function MTEhandler(ev) { + var type = TOUCH_INPUT_MAP[ev.type]; + var touches = getTouches.call(this, ev, type); + if (!touches) { + return; + } + + this.callback(this.manager, type, { + pointers: touches[0], + changedPointers: touches[1], + pointerType: INPUT_TYPE_TOUCH, + srcEvent: ev + }); + } +}); + +/** + * @this {TouchInput} + * @param {Object} ev + * @param {Number} type flag + * @returns {undefined|Array} [all, changed] + */ +function getTouches(ev, type) { + var allTouches = toArray(ev.touches); + var targetIds = this.targetIds; + + // when there is only one touch, the process can be simplified + if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) { + targetIds[allTouches[0].identifier] = true; + return [allTouches, allTouches]; + } + + var i, + targetTouches, + changedTouches = toArray(ev.changedTouches), + changedTargetTouches = [], + target = this.target; + + // get target touches from touches + targetTouches = allTouches.filter(function(touch) { + return hasParent(touch.target, target); + }); + + // collect touches + if (type === INPUT_START) { + i = 0; + while (i < targetTouches.length) { + targetIds[targetTouches[i].identifier] = true; + i++; + } + } + + // filter changed touches to only contain touches that exist in the collected target ids + i = 0; + while (i < changedTouches.length) { + if (targetIds[changedTouches[i].identifier]) { + changedTargetTouches.push(changedTouches[i]); + } + + // cleanup removed touches + if (type & (INPUT_END | INPUT_CANCEL)) { + delete targetIds[changedTouches[i].identifier]; + } + i++; + } + + if (!changedTargetTouches.length) { + return; + } + + return [ + // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel' + uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), + changedTargetTouches + ]; +} + +/** + * Combined touch and mouse input + * + * Touch has a higher priority then mouse, and while touching no mouse events are allowed. + * This because touch devices also emit mouse events while doing a touch. + * + * @constructor + * @extends Input + */ +function TouchMouseInput() { + Input.apply(this, arguments); + + var handler = bindFn(this.handler, this); + this.touch = new TouchInput(this.manager, handler); + this.mouse = new MouseInput(this.manager, handler); +} + +inherit(TouchMouseInput, Input, { + /** + * handle mouse and touch events + * @param {Hammer} manager + * @param {String} inputEvent + * @param {Object} inputData + */ + handler: function TMEhandler(manager, inputEvent, inputData) { + var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH), + isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE); + + // when we're in a touch event, so block all upcoming mouse events + // most mobile browser also emit mouseevents, right after touchstart + if (isTouch) { + this.mouse.allow = false; + } else if (isMouse && !this.mouse.allow) { + return; + } + + // reset the allowMouse when we're done + if (inputEvent & (INPUT_END | INPUT_CANCEL)) { + this.mouse.allow = true; + } + + this.callback(manager, inputEvent, inputData); + }, + + /** + * remove the event listeners + */ + destroy: function destroy() { + this.touch.destroy(); + this.mouse.destroy(); + } +}); + +var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction'); +var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined; + +// magical touchAction value +var TOUCH_ACTION_COMPUTE = 'compute'; +var TOUCH_ACTION_AUTO = 'auto'; +var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented +var TOUCH_ACTION_NONE = 'none'; +var TOUCH_ACTION_PAN_X = 'pan-x'; +var TOUCH_ACTION_PAN_Y = 'pan-y'; + +/** + * Touch Action + * sets the touchAction property or uses the js alternative + * @param {Manager} manager + * @param {String} value + * @constructor + */ +function TouchAction(manager, value) { + this.manager = manager; + this.set(value); +} + +TouchAction.prototype = { + /** + * set the touchAction value on the element or enable the polyfill + * @param {String} value + */ + set: function(value) { + // find out the touch-action by the event handlers + if (value == TOUCH_ACTION_COMPUTE) { + value = this.compute(); + } + + if (NATIVE_TOUCH_ACTION) { + this.manager.element.style[PREFIXED_TOUCH_ACTION] = value; + } + this.actions = value.toLowerCase().trim(); + }, + + /** + * just re-set the touchAction value + */ + update: function() { + this.set(this.manager.options.touchAction); + }, + + /** + * compute the value for the touchAction property based on the recognizer's settings + * @returns {String} value + */ + compute: function() { + var actions = []; + each(this.manager.recognizers, function(recognizer) { + if (boolOrFn(recognizer.options.enable, [recognizer])) { + actions = actions.concat(recognizer.getTouchAction()); + } + }); + return cleanTouchActions(actions.join(' ')); + }, + + /** + * this method is called on each input cycle and provides the preventing of the browser behavior + * @param {Object} input + */ + preventDefaults: function(input) { + // not needed with native support for the touchAction property + if (NATIVE_TOUCH_ACTION) { + return; + } + + var srcEvent = input.srcEvent; + var direction = input.offsetDirection; + + // if the touch action did prevented once this session + if (this.manager.session.prevented) { + srcEvent.preventDefault(); + return; + } + + var actions = this.actions; + var hasNone = inStr(actions, TOUCH_ACTION_NONE); + var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y); + var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X); + + if (hasNone || + (hasPanY && direction & DIRECTION_HORIZONTAL) || + (hasPanX && direction & DIRECTION_VERTICAL)) { + return this.preventSrc(srcEvent); + } + }, + + /** + * call preventDefault to prevent the browser's default behavior (scrolling in most cases) + * @param {Object} srcEvent + */ + preventSrc: function(srcEvent) { + this.manager.session.prevented = true; + srcEvent.preventDefault(); + } +}; + +/** + * when the touchActions are collected they are not a valid value, so we need to clean things up. * + * @param {String} actions + * @returns {*} + */ +function cleanTouchActions(actions) { + // none + if (inStr(actions, TOUCH_ACTION_NONE)) { + return TOUCH_ACTION_NONE; + } + + var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X); + var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y); + + // pan-x and pan-y can be combined + if (hasPanX && hasPanY) { + return TOUCH_ACTION_PAN_X + ' ' + TOUCH_ACTION_PAN_Y; + } + + // pan-x OR pan-y + if (hasPanX || hasPanY) { + return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y; + } + + // manipulation + if (inStr(actions, TOUCH_ACTION_MANIPULATION)) { + return TOUCH_ACTION_MANIPULATION; + } + + return TOUCH_ACTION_AUTO; +} + +/** + * Recognizer flow explained; * + * All recognizers have the initial state of POSSIBLE when a input session starts. + * The definition of a input session is from the first input until the last input, with all it's movement in it. * + * Example session for mouse-input: mousedown -> mousemove -> mouseup + * + * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed + * which determines with state it should be. + * + * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to + * POSSIBLE to give it another change on the next cycle. + * + * Possible + * | + * +-----+---------------+ + * | | + * +-----+-----+ | + * | | | + * Failed Cancelled | + * +-------+------+ + * | | + * Recognized Began + * | + * Changed + * | + * Ended/Recognized + */ +var STATE_POSSIBLE = 1; +var STATE_BEGAN = 2; +var STATE_CHANGED = 4; +var STATE_ENDED = 8; +var STATE_RECOGNIZED = STATE_ENDED; +var STATE_CANCELLED = 16; +var STATE_FAILED = 32; + +/** + * Recognizer + * Every recognizer needs to extend from this class. + * @constructor + * @param {Object} options + */ +function Recognizer(options) { + this.id = uniqueId(); + + this.manager = null; + this.options = merge(options || {}, this.defaults); + + // default is enable true + this.options.enable = ifUndefined(this.options.enable, true); + + this.state = STATE_POSSIBLE; + + this.simultaneous = {}; + this.requireFail = []; +} + +Recognizer.prototype = { + /** + * @virtual + * @type {Object} + */ + defaults: {}, + + /** + * set options + * @param {Object} options + * @return {Recognizer} + */ + set: function(options) { + extend(this.options, options); + + // also update the touchAction, in case something changed about the directions/enabled state + this.manager && this.manager.touchAction.update(); + return this; + }, + + /** + * recognize simultaneous with an other recognizer. + * @param {Recognizer} otherRecognizer + * @returns {Recognizer} this + */ + recognizeWith: function(otherRecognizer) { + if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) { + return this; + } + + var simultaneous = this.simultaneous; + otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this); + if (!simultaneous[otherRecognizer.id]) { + simultaneous[otherRecognizer.id] = otherRecognizer; + otherRecognizer.recognizeWith(this); + } + return this; + }, + + /** + * drop the simultaneous link. it doesnt remove the link on the other recognizer. + * @param {Recognizer} otherRecognizer + * @returns {Recognizer} this + */ + dropRecognizeWith: function(otherRecognizer) { + if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) { + return this; + } + + otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this); + delete this.simultaneous[otherRecognizer.id]; + return this; + }, + + /** + * recognizer can only run when an other is failing + * @param {Recognizer} otherRecognizer + * @returns {Recognizer} this + */ + requireFailure: function(otherRecognizer) { + if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) { + return this; + } + + var requireFail = this.requireFail; + otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this); + if (inArray(requireFail, otherRecognizer) === -1) { + requireFail.push(otherRecognizer); + otherRecognizer.requireFailure(this); + } + return this; + }, + + /** + * drop the requireFailure link. it does not remove the link on the other recognizer. + * @param {Recognizer} otherRecognizer + * @returns {Recognizer} this + */ + dropRequireFailure: function(otherRecognizer) { + if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) { + return this; + } + + otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this); + var index = inArray(this.requireFail, otherRecognizer); + if (index > -1) { + this.requireFail.splice(index, 1); + } + return this; + }, + + /** + * has require failures boolean + * @returns {boolean} + */ + hasRequireFailures: function() { + return this.requireFail.length > 0; + }, + + /** + * if the recognizer can recognize simultaneous with an other recognizer + * @param {Recognizer} otherRecognizer + * @returns {Boolean} + */ + canRecognizeWith: function(otherRecognizer) { + return !!this.simultaneous[otherRecognizer.id]; + }, + + /** + * You should use `tryEmit` instead of `emit` directly to check + * that all the needed recognizers has failed before emitting. + * @param {Object} input + */ + emit: function(input) { + var self = this; + var state = this.state; + + function emit(withState) { + self.manager.emit(self.options.event + (withState ? stateStr(state) : ''), input); + } + + // 'panstart' and 'panmove' + if (state < STATE_ENDED) { + emit(true); + } + + emit(); // simple 'eventName' events + + // panend and pancancel + if (state >= STATE_ENDED) { + emit(true); + } + }, + + /** + * Check that all the require failure recognizers has failed, + * if true, it emits a gesture event, + * otherwise, setup the state to FAILED. + * @param {Object} input + */ + tryEmit: function(input) { + if (this.canEmit()) { + return this.emit(input); + } + // it's failing anyway + this.state = STATE_FAILED; + }, + + /** + * can we emit? + * @returns {boolean} + */ + canEmit: function() { + var i = 0; + while (i < this.requireFail.length) { + if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) { + return false; + } + i++; + } + return true; + }, + + /** + * update the recognizer + * @param {Object} inputData + */ + recognize: function(inputData) { + // make a new copy of the inputData + // so we can change the inputData without messing up the other recognizers + var inputDataClone = extend({}, inputData); + + // is is enabled and allow recognizing? + if (!boolOrFn(this.options.enable, [this, inputDataClone])) { + this.reset(); + this.state = STATE_FAILED; + return; + } + + // reset when we've reached the end + if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) { + this.state = STATE_POSSIBLE; + } + + this.state = this.process(inputDataClone); + + // the recognizer has recognized a gesture + // so trigger an event + if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) { + this.tryEmit(inputDataClone); + } + }, + + /** + * return the state of the recognizer + * the actual recognizing happens in this method + * @virtual + * @param {Object} inputData + * @returns {Const} STATE + */ + process: function(inputData) { }, // jshint ignore:line + + /** + * return the preferred touch-action + * @virtual + * @returns {Array} + */ + getTouchAction: function() { }, + + /** + * called when the gesture isn't allowed to recognize + * like when another is being recognized or it is disabled + * @virtual + */ + reset: function() { } +}; + +/** + * get a usable string, used as event postfix + * @param {Const} state + * @returns {String} state + */ +function stateStr(state) { + if (state & STATE_CANCELLED) { + return 'cancel'; + } else if (state & STATE_ENDED) { + return 'end'; + } else if (state & STATE_CHANGED) { + return 'move'; + } else if (state & STATE_BEGAN) { + return 'start'; + } + return ''; +} + +/** + * direction cons to string + * @param {Const} direction + * @returns {String} + */ +function directionStr(direction) { + if (direction == DIRECTION_DOWN) { + return 'down'; + } else if (direction == DIRECTION_UP) { + return 'up'; + } else if (direction == DIRECTION_LEFT) { + return 'left'; + } else if (direction == DIRECTION_RIGHT) { + return 'right'; + } + return ''; +} + +/** + * get a recognizer by name if it is bound to a manager + * @param {Recognizer|String} otherRecognizer + * @param {Recognizer} recognizer + * @returns {Recognizer} + */ +function getRecognizerByNameIfManager(otherRecognizer, recognizer) { + var manager = recognizer.manager; + if (manager) { + return manager.get(otherRecognizer); + } + return otherRecognizer; +} + +/** + * This recognizer is just used as a base for the simple attribute recognizers. + * @constructor + * @extends Recognizer + */ +function AttrRecognizer() { + Recognizer.apply(this, arguments); +} + +inherit(AttrRecognizer, Recognizer, { + /** + * @namespace + * @memberof AttrRecognizer + */ + defaults: { + /** + * @type {Number} + * @default 1 + */ + pointers: 1 + }, + + /** + * Used to check if it the recognizer receives valid input, like input.distance > 10. + * @memberof AttrRecognizer + * @param {Object} input + * @returns {Boolean} recognized + */ + attrTest: function(input) { + var optionPointers = this.options.pointers; + return optionPointers === 0 || input.pointers.length === optionPointers; + }, + + /** + * Process the input and return the state for the recognizer + * @memberof AttrRecognizer + * @param {Object} input + * @returns {*} State + */ + process: function(input) { + var state = this.state; + var eventType = input.eventType; + + var isRecognized = state & (STATE_BEGAN | STATE_CHANGED); + var isValid = this.attrTest(input); + + // on cancel input and we've recognized before, return STATE_CANCELLED + if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) { + return state | STATE_CANCELLED; + } else if (isRecognized || isValid) { + if (eventType & INPUT_END) { + return state | STATE_ENDED; + } else if (!(state & STATE_BEGAN)) { + return STATE_BEGAN; + } + return state | STATE_CHANGED; + } + return STATE_FAILED; + } +}); + +/** + * Pan + * Recognized when the pointer is down and moved in the allowed direction. + * @constructor + * @extends AttrRecognizer + */ +function PanRecognizer() { + AttrRecognizer.apply(this, arguments); + + this.pX = null; + this.pY = null; +} + +inherit(PanRecognizer, AttrRecognizer, { + /** + * @namespace + * @memberof PanRecognizer + */ + defaults: { + event: 'pan', + threshold: 10, + pointers: 1, + direction: DIRECTION_ALL + }, + + getTouchAction: function() { + var direction = this.options.direction; + var actions = []; + if (direction & DIRECTION_HORIZONTAL) { + actions.push(TOUCH_ACTION_PAN_Y); + } + if (direction & DIRECTION_VERTICAL) { + actions.push(TOUCH_ACTION_PAN_X); + } + return actions; + }, + + directionTest: function(input) { + var options = this.options; + var hasMoved = true; + var distance = input.distance; + var direction = input.direction; + var x = input.deltaX; + var y = input.deltaY; + + // lock to axis? + if (!(direction & options.direction)) { + if (options.direction & DIRECTION_HORIZONTAL) { + direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT; + hasMoved = x != this.pX; + distance = Math.abs(input.deltaX); + } else { + direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN; + hasMoved = y != this.pY; + distance = Math.abs(input.deltaY); + } + } + input.direction = direction; + return hasMoved && distance > options.threshold && direction & options.direction; + }, + + attrTest: function(input) { + return AttrRecognizer.prototype.attrTest.call(this, input) && + (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input))); + }, + + emit: function(input) { + this.pX = input.deltaX; + this.pY = input.deltaY; + + var direction = directionStr(input.direction); + if (direction) { + this.manager.emit(this.options.event + direction, input); + } + + this._super.emit.call(this, input); + } +}); + +/** + * Pinch + * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out). + * @constructor + * @extends AttrRecognizer + */ +function PinchRecognizer() { + AttrRecognizer.apply(this, arguments); +} + +inherit(PinchRecognizer, AttrRecognizer, { + /** + * @namespace + * @memberof PinchRecognizer + */ + defaults: { + event: 'pinch', + threshold: 0, + pointers: 2 + }, + + getTouchAction: function() { + return [TOUCH_ACTION_NONE]; + }, + + attrTest: function(input) { + return this._super.attrTest.call(this, input) && + (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN); + }, + + emit: function(input) { + this._super.emit.call(this, input); + if (input.scale !== 1) { + var inOut = input.scale < 1 ? 'in' : 'out'; + this.manager.emit(this.options.event + inOut, input); + } + } +}); + +/** + * Press + * Recognized when the pointer is down for x ms without any movement. + * @constructor + * @extends Recognizer + */ +function PressRecognizer() { + Recognizer.apply(this, arguments); + + this._timer = null; + this._input = null; +} + +inherit(PressRecognizer, Recognizer, { + /** + * @namespace + * @memberof PressRecognizer + */ + defaults: { + event: 'press', + pointers: 1, + time: 500, // minimal time of the pointer to be pressed + threshold: 5 // a minimal movement is ok, but keep it low + }, + + getTouchAction: function() { + return [TOUCH_ACTION_AUTO]; + }, + + process: function(input) { + var options = this.options; + var validPointers = input.pointers.length === options.pointers; + var validMovement = input.distance < options.threshold; + var validTime = input.deltaTime > options.time; + + this._input = input; + + // we only allow little movement + // and we've reached an end event, so a tap is possible + if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) { + this.reset(); + } else if (input.eventType & INPUT_START) { + this.reset(); + this._timer = setTimeoutContext(function() { + this.state = STATE_RECOGNIZED; + this.tryEmit(); + }, options.time, this); + } else if (input.eventType & INPUT_END) { + return STATE_RECOGNIZED; + } + return STATE_FAILED; + }, + + reset: function() { + clearTimeout(this._timer); + }, + + emit: function(input) { + if (this.state !== STATE_RECOGNIZED) { + return; + } + + if (input && (input.eventType & INPUT_END)) { + this.manager.emit(this.options.event + 'up', input); + } else { + this._input.timeStamp = now(); + this.manager.emit(this.options.event, this._input); + } + } +}); + +/** + * Rotate + * Recognized when two or more pointer are moving in a circular motion. + * @constructor + * @extends AttrRecognizer + */ +function RotateRecognizer() { + AttrRecognizer.apply(this, arguments); +} + +inherit(RotateRecognizer, AttrRecognizer, { + /** + * @namespace + * @memberof RotateRecognizer + */ + defaults: { + event: 'rotate', + threshold: 0, + pointers: 2 + }, + + getTouchAction: function() { + return [TOUCH_ACTION_NONE]; + }, + + attrTest: function(input) { + return this._super.attrTest.call(this, input) && + (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN); + } +}); + +/** + * Swipe + * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction. + * @constructor + * @extends AttrRecognizer + */ +function SwipeRecognizer() { + AttrRecognizer.apply(this, arguments); +} + +inherit(SwipeRecognizer, AttrRecognizer, { + /** + * @namespace + * @memberof SwipeRecognizer + */ + defaults: { + event: 'swipe', + threshold: 10, + velocity: 0.65, + direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL, + pointers: 1 + }, + + getTouchAction: function() { + return PanRecognizer.prototype.getTouchAction.call(this); + }, + + attrTest: function(input) { + var direction = this.options.direction; + var velocity; + + if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) { + velocity = input.velocity; + } else if (direction & DIRECTION_HORIZONTAL) { + velocity = input.velocityX; + } else if (direction & DIRECTION_VERTICAL) { + velocity = input.velocityY; + } + + return this._super.attrTest.call(this, input) && + direction & input.direction && + input.distance > this.options.threshold && + abs(velocity) > this.options.velocity && input.eventType & INPUT_END; + }, + + emit: function(input) { + var direction = directionStr(input.direction); + if (direction) { + this.manager.emit(this.options.event + direction, input); + } + + this.manager.emit(this.options.event, input); + } +}); + +/** + * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur + * between the given interval and position. The delay option can be used to recognize multi-taps without firing + * a single tap. + * + * The eventData from the emitted event contains the property `tapCount`, which contains the amount of + * multi-taps being recognized. + * @constructor + * @extends Recognizer + */ +function TapRecognizer() { + Recognizer.apply(this, arguments); + + // previous time and center, + // used for tap counting + this.pTime = false; + this.pCenter = false; + + this._timer = null; + this._input = null; + this.count = 0; +} + +inherit(TapRecognizer, Recognizer, { + /** + * @namespace + * @memberof PinchRecognizer + */ + defaults: { + event: 'tap', + pointers: 1, + taps: 1, + interval: 300, // max time between the multi-tap taps + time: 250, // max time of the pointer to be down (like finger on the screen) + threshold: 2, // a minimal movement is ok, but keep it low + posThreshold: 10 // a multi-tap can be a bit off the initial position + }, + + getTouchAction: function() { + return [TOUCH_ACTION_MANIPULATION]; + }, + + process: function(input) { + var options = this.options; + + var validPointers = input.pointers.length === options.pointers; + var validMovement = input.distance < options.threshold; + var validTouchTime = input.deltaTime < options.time; + + this.reset(); + + if ((input.eventType & INPUT_START) && (this.count === 0)) { + return this.failTimeout(); + } + + // we only allow little movement + // and we've reached an end event, so a tap is possible + if (validMovement && validTouchTime && validPointers) { + if (input.eventType != INPUT_END) { + return this.failTimeout(); + } + + var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true; + var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold; + + this.pTime = input.timeStamp; + this.pCenter = input.center; + + if (!validMultiTap || !validInterval) { + this.count = 1; + } else { + this.count += 1; + } + + this._input = input; + + // if tap count matches we have recognized it, + // else it has began recognizing... + var tapCount = this.count % options.taps; + if (tapCount === 0) { + // no failing requirements, immediately trigger the tap event + // or wait as long as the multitap interval to trigger + if (!this.hasRequireFailures()) { + return STATE_RECOGNIZED; + } else { + this._timer = setTimeoutContext(function() { + this.state = STATE_RECOGNIZED; + this.tryEmit(); + }, options.interval, this); + return STATE_BEGAN; + } + } + } + return STATE_FAILED; + }, + + failTimeout: function() { + this._timer = setTimeoutContext(function() { + this.state = STATE_FAILED; + }, this.options.interval, this); + return STATE_FAILED; + }, + + reset: function() { + clearTimeout(this._timer); + }, + + emit: function() { + if (this.state == STATE_RECOGNIZED ) { + this._input.tapCount = this.count; + this.manager.emit(this.options.event, this._input); + } + } +}); + +/** + * Simple way to create an manager with a default set of recognizers. + * @param {HTMLElement} element + * @param {Object} [options] + * @constructor + */ +function Hammer(element, options) { + options = options || {}; + options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset); + return new Manager(element, options); +} + +/** + * @const {string} + */ +Hammer.VERSION = '2.0.4'; + +/** + * default settings + * @namespace + */ +Hammer.defaults = { + /** + * set if DOM events are being triggered. + * But this is slower and unused by simple implementations, so disabled by default. + * @type {Boolean} + * @default false + */ + domEvents: false, + + /** + * The value for the touchAction property/fallback. + * When set to `compute` it will magically set the correct value based on the added recognizers. + * @type {String} + * @default compute + */ + touchAction: TOUCH_ACTION_COMPUTE, + + /** + * @type {Boolean} + * @default true + */ + enable: true, + + /** + * EXPERIMENTAL FEATURE -- can be removed/changed + * Change the parent input target element. + * If Null, then it is being set the to main element. + * @type {Null|EventTarget} + * @default null + */ + inputTarget: null, + + /** + * force an input class + * @type {Null|Function} + * @default null + */ + inputClass: null, + + /** + * Default recognizer setup when calling `Hammer()` + * When creating a new Manager these will be skipped. + * @type {Array} + */ + preset: [ + // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...] + [RotateRecognizer, { enable: false }], + [PinchRecognizer, { enable: false }, ['rotate']], + [SwipeRecognizer,{ direction: DIRECTION_HORIZONTAL }], + [PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ['swipe']], + [TapRecognizer], + [TapRecognizer, { event: 'doubletap', taps: 2 }, ['tap']], + [PressRecognizer] + ], + + /** + * Some CSS properties can be used to improve the working of Hammer. + * Add them to this method and they will be set when creating a new Manager. + * @namespace + */ + cssProps: { + /** + * Disables text selection to improve the dragging gesture. Mainly for desktop browsers. + * @type {String} + * @default 'none' + */ + userSelect: 'none', + + /** + * Disable the Windows Phone grippers when pressing an element. + * @type {String} + * @default 'none' + */ + touchSelect: 'none', + + /** + * Disables the default callout shown when you touch and hold a touch target. + * On iOS, when you touch and hold a touch target such as a link, Safari displays + * a callout containing information about the link. This property allows you to disable that callout. + * @type {String} + * @default 'none' + */ + touchCallout: 'none', + + /** + * Specifies whether zooming is enabled. Used by IE10> + * @type {String} + * @default 'none' + */ + contentZooming: 'none', + + /** + * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers. + * @type {String} + * @default 'none' + */ + userDrag: 'none', + + /** + * Overrides the highlight color shown when the user taps a link or a JavaScript + * clickable element in iOS. This property obeys the alpha value, if specified. + * @type {String} + * @default 'rgba(0,0,0,0)' + */ + tapHighlightColor: 'rgba(0,0,0,0)' + } +}; + +var STOP = 1; +var FORCED_STOP = 2; + +/** + * Manager + * @param {HTMLElement} element + * @param {Object} [options] + * @constructor + */ +function Manager(element, options) { + options = options || {}; + + this.options = merge(options, Hammer.defaults); + this.options.inputTarget = this.options.inputTarget || element; + + this.handlers = {}; + this.session = {}; + this.recognizers = []; + + this.element = element; + this.input = createInputInstance(this); + this.touchAction = new TouchAction(this, this.options.touchAction); + + toggleCssProps(this, true); + + each(options.recognizers, function(item) { + var recognizer = this.add(new (item[0])(item[1])); + item[2] && recognizer.recognizeWith(item[2]); + item[3] && recognizer.requireFailure(item[3]); + }, this); +} + +Manager.prototype = { + /** + * set options + * @param {Object} options + * @returns {Manager} + */ + set: function(options) { + extend(this.options, options); + + // Options that need a little more setup + if (options.touchAction) { + this.touchAction.update(); + } + if (options.inputTarget) { + // Clean up existing event listeners and reinitialize + this.input.destroy(); + this.input.target = options.inputTarget; + this.input.init(); + } + return this; + }, + + /** + * stop recognizing for this session. + * This session will be discarded, when a new [input]start event is fired. + * When forced, the recognizer cycle is stopped immediately. + * @param {Boolean} [force] + */ + stop: function(force) { + this.session.stopped = force ? FORCED_STOP : STOP; + }, + + /** + * run the recognizers! + * called by the inputHandler function on every movement of the pointers (touches) + * it walks through all the recognizers and tries to detect the gesture that is being made + * @param {Object} inputData + */ + recognize: function(inputData) { + var session = this.session; + if (session.stopped) { + return; + } + + // run the touch-action polyfill + this.touchAction.preventDefaults(inputData); + + var recognizer; + var recognizers = this.recognizers; + + // this holds the recognizer that is being recognized. + // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED + // if no recognizer is detecting a thing, it is set to `null` + var curRecognizer = session.curRecognizer; + + // reset when the last recognizer is recognized + // or when we're in a new session + if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) { + curRecognizer = session.curRecognizer = null; + } + + var i = 0; + while (i < recognizers.length) { + recognizer = recognizers[i]; + + // find out if we are allowed try to recognize the input for this one. + // 1. allow if the session is NOT forced stopped (see the .stop() method) + // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one + // that is being recognized. + // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer. + // this can be setup with the `recognizeWith()` method on the recognizer. + if (session.stopped !== FORCED_STOP && ( // 1 + !curRecognizer || recognizer == curRecognizer || // 2 + recognizer.canRecognizeWith(curRecognizer))) { // 3 + recognizer.recognize(inputData); + } else { + recognizer.reset(); + } + + // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the + // current active recognizer. but only if we don't already have an active recognizer + if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) { + curRecognizer = session.curRecognizer = recognizer; + } + i++; + } + }, + + /** + * get a recognizer by its event name. + * @param {Recognizer|String} recognizer + * @returns {Recognizer|Null} + */ + get: function(recognizer) { + if (recognizer instanceof Recognizer) { + return recognizer; + } + + var recognizers = this.recognizers; + for (var i = 0; i < recognizers.length; i++) { + if (recognizers[i].options.event == recognizer) { + return recognizers[i]; + } + } + return null; + }, + + /** + * add a recognizer to the manager + * existing recognizers with the same event name will be removed + * @param {Recognizer} recognizer + * @returns {Recognizer|Manager} + */ + add: function(recognizer) { + if (invokeArrayArg(recognizer, 'add', this)) { + return this; + } + + // remove existing + var existing = this.get(recognizer.options.event); + if (existing) { + this.remove(existing); + } + + this.recognizers.push(recognizer); + recognizer.manager = this; + + this.touchAction.update(); + return recognizer; + }, + + /** + * remove a recognizer by name or instance + * @param {Recognizer|String} recognizer + * @returns {Manager} + */ + remove: function(recognizer) { + if (invokeArrayArg(recognizer, 'remove', this)) { + return this; + } + + var recognizers = this.recognizers; + recognizer = this.get(recognizer); + recognizers.splice(inArray(recognizers, recognizer), 1); + + this.touchAction.update(); + return this; + }, + + /** + * bind event + * @param {String} events + * @param {Function} handler + * @returns {EventEmitter} this + */ + on: function(events, handler) { + var handlers = this.handlers; + each(splitStr(events), function(event) { + handlers[event] = handlers[event] || []; + handlers[event].push(handler); + }); + return this; + }, + + /** + * unbind event, leave emit blank to remove all handlers + * @param {String} events + * @param {Function} [handler] + * @returns {EventEmitter} this + */ + off: function(events, handler) { + var handlers = this.handlers; + each(splitStr(events), function(event) { + if (!handler) { + delete handlers[event]; + } else { + handlers[event].splice(inArray(handlers[event], handler), 1); + } + }); + return this; + }, + + /** + * emit event to the listeners + * @param {String} event + * @param {Object} data + */ + emit: function(event, data) { + // we also want to trigger dom events + if (this.options.domEvents) { + triggerDomEvent(event, data); + } + + // no handlers, so skip it all + var handlers = this.handlers[event] && this.handlers[event].slice(); + if (!handlers || !handlers.length) { + return; + } + + data.type = event; + data.preventDefault = function() { + data.srcEvent.preventDefault(); + }; + + var i = 0; + while (i < handlers.length) { + handlers[i](data); + i++; + } + }, + + /** + * destroy the manager and unbinds all events + * it doesn't unbind dom events, that is the user own responsibility + */ + destroy: function() { + this.element && toggleCssProps(this, false); + + this.handlers = {}; + this.session = {}; + this.input.destroy(); + this.element = null; + } +}; + +/** + * add/remove the css properties as defined in manager.options.cssProps + * @param {Manager} manager + * @param {Boolean} add + */ +function toggleCssProps(manager, add) { + var element = manager.element; + each(manager.options.cssProps, function(value, name) { + element.style[prefixed(element.style, name)] = add ? value : ''; + }); +} + +/** + * trigger dom event + * @param {String} event + * @param {Object} data + */ +function triggerDomEvent(event, data) { + var gestureEvent = document.createEvent('Event'); + gestureEvent.initEvent(event, true, true); + gestureEvent.gesture = data; + data.target.dispatchEvent(gestureEvent); +} + +extend(Hammer, { + INPUT_START: INPUT_START, + INPUT_MOVE: INPUT_MOVE, + INPUT_END: INPUT_END, + INPUT_CANCEL: INPUT_CANCEL, + + STATE_POSSIBLE: STATE_POSSIBLE, + STATE_BEGAN: STATE_BEGAN, + STATE_CHANGED: STATE_CHANGED, + STATE_ENDED: STATE_ENDED, + STATE_RECOGNIZED: STATE_RECOGNIZED, + STATE_CANCELLED: STATE_CANCELLED, + STATE_FAILED: STATE_FAILED, + + DIRECTION_NONE: DIRECTION_NONE, + DIRECTION_LEFT: DIRECTION_LEFT, + DIRECTION_RIGHT: DIRECTION_RIGHT, + DIRECTION_UP: DIRECTION_UP, + DIRECTION_DOWN: DIRECTION_DOWN, + DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL, + DIRECTION_VERTICAL: DIRECTION_VERTICAL, + DIRECTION_ALL: DIRECTION_ALL, + + Manager: Manager, + Input: Input, + TouchAction: TouchAction, + + TouchInput: TouchInput, + MouseInput: MouseInput, + PointerEventInput: PointerEventInput, + TouchMouseInput: TouchMouseInput, + SingleTouchInput: SingleTouchInput, + + Recognizer: Recognizer, + AttrRecognizer: AttrRecognizer, + Tap: TapRecognizer, + Pan: PanRecognizer, + Swipe: SwipeRecognizer, + Pinch: PinchRecognizer, + Rotate: RotateRecognizer, + Press: PressRecognizer, + + on: addEventListeners, + off: removeEventListeners, + each: each, + merge: merge, + extend: extend, + inherit: inherit, + bindFn: bindFn, + prefixed: prefixed +}); + +if (typeof define == TYPE_FUNCTION && define.amd) { + define(function() { + return Hammer; + }); +} else if (typeof module != 'undefined' && module.exports) { + module.exports = Hammer; +} else { + window[exportName] = Hammer; +} + +})(window, document, 'Hammer'); + +},{}],3:[function(require,module,exports){ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + global.Immutable = factory() +}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice; + + function createClass(ctor, superClass) { + if (superClass) { + ctor.prototype = Object.create(superClass.prototype); + } + ctor.prototype.constructor = ctor; + } + + // Used for setting prototype methods that IE8 chokes on. + var DELETE = 'delete'; + + // Constants describing the size of trie nodes. + var SHIFT = 5; // Resulted in best performance after ______? + var SIZE = 1 << SHIFT; + var MASK = SIZE - 1; + + // A consistent shared value representing "not set" which equals nothing other + // than itself, and nothing that could be provided externally. + var NOT_SET = {}; + + // Boolean references, Rough equivalent of `bool &`. + var CHANGE_LENGTH = { value: false }; + var DID_ALTER = { value: false }; + + function MakeRef(ref) { + ref.value = false; + return ref; + } + + function SetRef(ref) { + ref && (ref.value = true); + } + + // A function which returns a value representing an "owner" for transient writes + // to tries. The return value will only ever equal itself, and will not equal + // the return of any subsequent call of this function. + function OwnerID() {} + + // http://jsperf.com/copy-array-inline + function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; + } + + function ensureSize(iter) { + if (iter.size === undefined) { + iter.size = iter.__iterate(returnTrue); + } + return iter.size; + } + + function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // However note that we're currently calling ToNumber() instead of ToUint32() + // which should be improved in the future, as floating point numbers should + // not be accepted as an array index. + if (typeof index !== 'number') { + var numIndex = +index; + if ('' + numIndex !== index) { + return NaN; + } + index = numIndex; + } + return index < 0 ? ensureSize(iter) + index : index; + } + + function returnTrue() { + return true; + } + + function wholeSlice(begin, end, size) { + return (begin === 0 || (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)); + } + + function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); + } + + function resolveEnd(end, size) { + return resolveIndex(end, size, size); + } + + function resolveIndex(index, size, defaultIndex) { + return index === undefined ? + defaultIndex : + index < 0 ? + Math.max(0, size + index) : + size === undefined ? + index : + Math.min(size, index); + } + + function Iterable(value) { + return isIterable(value) ? value : Seq(value); + } + + + createClass(KeyedIterable, Iterable); + function KeyedIterable(value) { + return isKeyed(value) ? value : KeyedSeq(value); + } + + + createClass(IndexedIterable, Iterable); + function IndexedIterable(value) { + return isIndexed(value) ? value : IndexedSeq(value); + } + + + createClass(SetIterable, Iterable); + function SetIterable(value) { + return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); + } + + + + function isIterable(maybeIterable) { + return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); + } + + function isKeyed(maybeKeyed) { + return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); + } + + function isIndexed(maybeIndexed) { + return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); + } + + function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + } + + function isOrdered(maybeOrdered) { + return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); + } + + Iterable.isIterable = isIterable; + Iterable.isKeyed = isKeyed; + Iterable.isIndexed = isIndexed; + Iterable.isAssociative = isAssociative; + Iterable.isOrdered = isOrdered; + + Iterable.Keyed = KeyedIterable; + Iterable.Indexed = IndexedIterable; + Iterable.Set = SetIterable; + + + var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; + var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; + var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; + var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; + + /* global Symbol */ + + var ITERATE_KEYS = 0; + var ITERATE_VALUES = 1; + var ITERATE_ENTRIES = 2; + + var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; + + var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; + + + function src_Iterator__Iterator(next) { + this.next = next; + } + + src_Iterator__Iterator.prototype.toString = function() { + return '[Iterator]'; + }; + + + src_Iterator__Iterator.KEYS = ITERATE_KEYS; + src_Iterator__Iterator.VALUES = ITERATE_VALUES; + src_Iterator__Iterator.ENTRIES = ITERATE_ENTRIES; + + src_Iterator__Iterator.prototype.inspect = + src_Iterator__Iterator.prototype.toSource = function () { return this.toString(); } + src_Iterator__Iterator.prototype[ITERATOR_SYMBOL] = function () { + return this; + }; + + + function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { + value: value, done: false + }); + return iteratorResult; + } + + function iteratorDone() { + return { value: undefined, done: true }; + } + + function hasIterator(maybeIterable) { + return !!getIteratorFn(maybeIterable); + } + + function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; + } + + function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); + } + + function getIteratorFn(iterable) { + var iteratorFn = iterable && ( + (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL] + ); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } + } + + function isArrayLike(value) { + return value && typeof value.length === 'number'; + } + + createClass(Seq, Iterable); + function Seq(value) { + return value === null || value === undefined ? emptySequence() : + isIterable(value) ? value.toSeq() : seqFromValue(value); + } + + Seq.of = function(/*...values*/) { + return Seq(arguments); + }; + + Seq.prototype.toSeq = function() { + return this; + }; + + Seq.prototype.toString = function() { + return this.__toString('Seq {', '}'); + }; + + Seq.prototype.cacheResult = function() { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; + + // abstract __iterateUncached(fn, reverse) + + Seq.prototype.__iterate = function(fn, reverse) { + return seqIterate(this, fn, reverse, true); + }; + + // abstract __iteratorUncached(type, reverse) + + Seq.prototype.__iterator = function(type, reverse) { + return seqIterator(this, type, reverse, true); + }; + + + + createClass(KeyedSeq, Seq); + function KeyedSeq(value) { + return value === null || value === undefined ? + emptySequence().toKeyedSeq() : + isIterable(value) ? + (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) : + keyedSeqFromValue(value); + } + + KeyedSeq.prototype.toKeyedSeq = function() { + return this; + }; + + + + createClass(IndexedSeq, Seq); + function IndexedSeq(value) { + return value === null || value === undefined ? emptySequence() : + !isIterable(value) ? indexedSeqFromValue(value) : + isKeyed(value) ? value.entrySeq() : value.toIndexedSeq(); + } + + IndexedSeq.of = function(/*...values*/) { + return IndexedSeq(arguments); + }; + + IndexedSeq.prototype.toIndexedSeq = function() { + return this; + }; + + IndexedSeq.prototype.toString = function() { + return this.__toString('Seq [', ']'); + }; + + IndexedSeq.prototype.__iterate = function(fn, reverse) { + return seqIterate(this, fn, reverse, false); + }; + + IndexedSeq.prototype.__iterator = function(type, reverse) { + return seqIterator(this, type, reverse, false); + }; + + + + createClass(SetSeq, Seq); + function SetSeq(value) { + return ( + value === null || value === undefined ? emptySequence() : + !isIterable(value) ? indexedSeqFromValue(value) : + isKeyed(value) ? value.entrySeq() : value + ).toSetSeq(); + } + + SetSeq.of = function(/*...values*/) { + return SetSeq(arguments); + }; + + SetSeq.prototype.toSetSeq = function() { + return this; + }; + + + + Seq.isSeq = isSeq; + Seq.Keyed = KeyedSeq; + Seq.Set = SetSeq; + Seq.Indexed = IndexedSeq; + + var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; + + Seq.prototype[IS_SEQ_SENTINEL] = true; + + + + // #pragma Root Sequences + + createClass(ArraySeq, IndexedSeq); + function ArraySeq(array) { + this._array = array; + this.size = array.length; + } + + ArraySeq.prototype.get = function(index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; + + ArraySeq.prototype.__iterate = function(fn, reverse) { + var array = this._array; + var maxIndex = array.length - 1; + for (var ii = 0; ii <= maxIndex; ii++) { + if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) { + return ii + 1; + } + } + return ii; + }; + + ArraySeq.prototype.__iterator = function(type, reverse) { + var array = this._array; + var maxIndex = array.length - 1; + var ii = 0; + return new src_Iterator__Iterator(function() + {return ii > maxIndex ? + iteratorDone() : + iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])} + ); + }; + + + + createClass(ObjectSeq, KeyedSeq); + function ObjectSeq(object) { + var keys = Object.keys(object); + this._object = object; + this._keys = keys; + this.size = keys.length; + } + + ObjectSeq.prototype.get = function(key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; + + ObjectSeq.prototype.has = function(key) { + return this._object.hasOwnProperty(key); + }; + + ObjectSeq.prototype.__iterate = function(fn, reverse) { + var object = this._object; + var keys = this._keys; + var maxIndex = keys.length - 1; + for (var ii = 0; ii <= maxIndex; ii++) { + var key = keys[reverse ? maxIndex - ii : ii]; + if (fn(object[key], key, this) === false) { + return ii + 1; + } + } + return ii; + }; + + ObjectSeq.prototype.__iterator = function(type, reverse) { + var object = this._object; + var keys = this._keys; + var maxIndex = keys.length - 1; + var ii = 0; + return new src_Iterator__Iterator(function() { + var key = keys[reverse ? maxIndex - ii : ii]; + return ii++ > maxIndex ? + iteratorDone() : + iteratorValue(type, key, object[key]); + }); + }; + + ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; + + + createClass(IterableSeq, IndexedSeq); + function IterableSeq(iterable) { + this._iterable = iterable; + this.size = iterable.length || iterable.size; + } + + IterableSeq.prototype.__iterateUncached = function(fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterable = this._iterable; + var iterator = getIterator(iterable); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + } + return iterations; + }; + + IterableSeq.prototype.__iteratorUncached = function(type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterable = this._iterable; + var iterator = getIterator(iterable); + if (!isIterator(iterator)) { + return new src_Iterator__Iterator(iteratorDone); + } + var iterations = 0; + return new src_Iterator__Iterator(function() { + var step = iterator.next(); + return step.done ? step : iteratorValue(type, iterations++, step.value); + }); + }; + + + + createClass(IteratorSeq, IndexedSeq); + function IteratorSeq(iterator) { + this._iterator = iterator; + this._iteratorCache = []; + } + + IteratorSeq.prototype.__iterateUncached = function(fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + while (iterations < cache.length) { + if (fn(cache[iterations], iterations++, this) === false) { + return iterations; + } + } + var step; + while (!(step = iterator.next()).done) { + var val = step.value; + cache[iterations] = val; + if (fn(val, iterations++, this) === false) { + break; + } + } + return iterations; + }; + + IteratorSeq.prototype.__iteratorUncached = function(type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + return new src_Iterator__Iterator(function() { + if (iterations >= cache.length) { + var step = iterator.next(); + if (step.done) { + return step; + } + cache[iterations] = step.value; + } + return iteratorValue(type, iterations, cache[iterations++]); + }); + }; + + + + + // # pragma Helper functions + + function isSeq(maybeSeq) { + return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]); + } + + var EMPTY_SEQ; + + function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); + } + + function keyedSeqFromValue(value) { + var seq = + Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() : + isIterator(value) ? new IteratorSeq(value).fromEntrySeq() : + hasIterator(value) ? new IterableSeq(value).fromEntrySeq() : + typeof value === 'object' ? new ObjectSeq(value) : + undefined; + if (!seq) { + throw new TypeError( + 'Expected Array or iterable object of [k, v] entries, '+ + 'or keyed object: ' + value + ); + } + return seq; + } + + function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (!seq) { + throw new TypeError( + 'Expected Array or iterable object of values: ' + value + ); + } + return seq; + } + + function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value) || + (typeof value === 'object' && new ObjectSeq(value)); + if (!seq) { + throw new TypeError( + 'Expected Array or iterable object of values, or keyed object: ' + value + ); + } + return seq; + } + + function maybeIndexedSeqFromValue(value) { + return ( + isArrayLike(value) ? new ArraySeq(value) : + isIterator(value) ? new IteratorSeq(value) : + hasIterator(value) ? new IterableSeq(value) : + undefined + ); + } + + function seqIterate(seq, fn, reverse, useKeys) { + var cache = seq._cache; + if (cache) { + var maxIndex = cache.length - 1; + for (var ii = 0; ii <= maxIndex; ii++) { + var entry = cache[reverse ? maxIndex - ii : ii]; + if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) { + return ii + 1; + } + } + return ii; + } + return seq.__iterateUncached(fn, reverse); + } + + function seqIterator(seq, type, reverse, useKeys) { + var cache = seq._cache; + if (cache) { + var maxIndex = cache.length - 1; + var ii = 0; + return new src_Iterator__Iterator(function() { + var entry = cache[reverse ? maxIndex - ii : ii]; + return ii++ > maxIndex ? + iteratorDone() : + iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]); + }); + } + return seq.__iteratorUncached(type, reverse); + } + + createClass(Collection, Iterable); + function Collection() { + throw TypeError('Abstract'); + } + + + createClass(KeyedCollection, Collection);function KeyedCollection() {} + + createClass(IndexedCollection, Collection);function IndexedCollection() {} + + createClass(SetCollection, Collection);function SetCollection() {} + + + Collection.Keyed = KeyedCollection; + Collection.Indexed = IndexedCollection; + Collection.Set = SetCollection; + + /** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if the it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections implement `equals` and `hashCode`. + * + */ + function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + if (typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function') { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + if (typeof valueA.equals === 'function' && + typeof valueB.equals === 'function' && + valueA.equals(valueB)) { + return true; + } + return false; + } + + function fromJS(json, converter) { + return converter ? + fromJSWith(converter, json, '', {'': json}) : + fromJSDefault(json); + } + + function fromJSWith(converter, json, key, parentJSON) { + if (Array.isArray(json)) { + return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + } + if (isPlainObj(json)) { + return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + } + return json; + } + + function fromJSDefault(json) { + if (Array.isArray(json)) { + return IndexedSeq(json).map(fromJSDefault).toList(); + } + if (isPlainObj(json)) { + return KeyedSeq(json).map(fromJSDefault).toMap(); + } + return json; + } + + function isPlainObj(value) { + return value && (value.constructor === Object || value.constructor === undefined); + } + + var src_Math__imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? + Math.imul : + function imul(a, b) { + a = a | 0; // int + b = b | 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int + }; + + // v8 has an optimization for storing 31-bit signed numbers. + // Values which have either 00 or 11 as the high order bits qualify. + // This function drops the highest order bit in a signed number, maintaining + // the sign bit. + function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF); + } + + function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; + } + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; + } + } + if (o === true) { + return 1; + } + var type = typeof o; + if (type === 'number') { + var h = o | 0; + if (h !== o) { + h ^= o * 0xFFFFFFFF; + } + while (o > 0xFFFFFFFF) { + o /= 0xFFFFFFFF; + h ^= o; + } + return smi(h); + } + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o); + } + if (typeof o.hashCode === 'function') { + return o.hashCode(); + } + return hashJSObj(o); + } + + function cachedHashString(string) { + var hash = stringHashCache[string]; + if (hash === undefined) { + hash = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hash; + } + return hash; + } + + // http://jsperf.com/hashing-strings + function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hash = 0; + for (var ii = 0; ii < string.length; ii++) { + hash = 31 * hash + string.charCodeAt(ii) | 0; + } + return smi(hash); + } + + function hashJSObj(obj) { + var hash; + if (usingWeakMap) { + hash = weakMap.get(obj); + if (hash !== undefined) { + return hash; + } + } + + hash = obj[UID_HASH_KEY]; + if (hash !== undefined) { + return hash; + } + + if (!canDefineProperty) { + hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hash !== undefined) { + return hash; + } + + hash = getIENodeHash(obj); + if (hash !== undefined) { + return hash; + } + } + + hash = ++objHashUID; + if (objHashUID & 0x40000000) { + objHashUID = 0; + } + + if (usingWeakMap) { + weakMap.set(obj, hash); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + 'enumerable': false, + 'configurable': false, + 'writable': false, + 'value': hash + }); + } else if (obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function() { + return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hash; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hash; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } + + return hash; + } + + // Get references to ES5 object methods. + var isExtensible = Object.isExtensible; + + // True if Object.defineProperty works as expected. IE8 fails this test. + var canDefineProperty = (function() { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; + } + }()); + + // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it + // and avoid memory leaks from the IE cloneNode bug. + function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } + } + + // If possible, use a WeakMap. + var usingWeakMap = typeof WeakMap === 'function'; + var weakMap; + if (usingWeakMap) { + weakMap = new WeakMap(); + } + + var objHashUID = 0; + + var UID_HASH_KEY = '__immutablehash__'; + if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); + } + + var STRING_HASH_CACHE_MIN_STRLEN = 16; + var STRING_HASH_CACHE_MAX_SIZE = 255; + var STRING_HASH_CACHE_SIZE = 0; + var stringHashCache = {}; + + function invariant(condition, error) { + if (!condition) throw new Error(error); + } + + function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); + } + + createClass(ToKeyedSequence, KeyedSeq); + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + ToKeyedSequence.prototype.get = function(key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function(key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function() { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function() {var this$0 = this; + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()}; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this; + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)}; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + var ii; + return this._iter.__iterate( + this._useKeys ? + function(v, k) {return fn(v, k, this$0)} : + ((ii = reverse ? resolveSize(this) : 0), + function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}), + reverse + ); + }; + + ToKeyedSequence.prototype.__iterator = function(type, reverse) { + if (this._useKeys) { + return this._iter.__iterator(type, reverse); + } + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var ii = reverse ? resolveSize(this) : 0; + return new src_Iterator__Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, reverse ? --ii : ii++, step.value, step); + }); + }; + + ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; + + + createClass(ToIndexedSequence, IndexedSeq); + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + ToIndexedSequence.prototype.includes = function(value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + var iterations = 0; + return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse); + }; + + ToIndexedSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + return new src_Iterator__Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, iterations++, step.value, step) + }); + }; + + + + createClass(ToSetSequence, SetSeq); + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + ToSetSequence.prototype.has = function(key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse); + }; + + ToSetSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new src_Iterator__Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, step.value, step.value, step); + }); + }; + + + + createClass(FromEntriesSequence, KeyedSeq); + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + FromEntriesSequence.prototype.entrySeq = function() { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._iter.__iterate(function(entry ) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedIterable = isIterable(entry); + return fn( + indexedIterable ? entry.get(1) : entry[1], + indexedIterable ? entry.get(0) : entry[0], + this$0 + ); + } + }, reverse); + }; + + FromEntriesSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new src_Iterator__Iterator(function() { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedIterable = isIterable(entry); + return iteratorValue( + type, + indexedIterable ? entry.get(0) : entry[0], + indexedIterable ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + + ToIndexedSequence.prototype.cacheResult = + ToKeyedSequence.prototype.cacheResult = + ToSetSequence.prototype.cacheResult = + FromEntriesSequence.prototype.cacheResult = + cacheResultThrough; + + + function flipFactory(iterable) { + var flipSequence = makeSequence(iterable); + flipSequence._iter = iterable; + flipSequence.size = iterable.size; + flipSequence.flip = function() {return iterable}; + flipSequence.reverse = function () { + var reversedSequence = iterable.reverse.apply(this); // super.reverse() + reversedSequence.flip = function() {return iterable.reverse()}; + return reversedSequence; + }; + flipSequence.has = function(key ) {return iterable.includes(key)}; + flipSequence.includes = function(key ) {return iterable.has(key)}; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse); + } + flipSequence.__iteratorUncached = function(type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = iterable.__iterator(type, reverse); + return new src_Iterator__Iterator(function() { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return iterable.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + } + return flipSequence; + } + + + function mapFactory(iterable, mapper, context) { + var mappedSequence = makeSequence(iterable); + mappedSequence.size = iterable.size; + mappedSequence.has = function(key ) {return iterable.has(key)}; + mappedSequence.get = function(key, notSetValue) { + var v = iterable.get(key, NOT_SET); + return v === NOT_SET ? + notSetValue : + mapper.call(context, v, key, iterable); + }; + mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + return iterable.__iterate( + function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false}, + reverse + ); + } + mappedSequence.__iteratorUncached = function (type, reverse) { + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + return new src_Iterator__Iterator(function() { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, iterable), + step + ); + }); + } + return mappedSequence; + } + + + function reverseFactory(iterable, useKeys) { + var reversedSequence = makeSequence(iterable); + reversedSequence._iter = iterable; + reversedSequence.size = iterable.size; + reversedSequence.reverse = function() {return iterable}; + if (iterable.flip) { + reversedSequence.flip = function () { + var flipSequence = flipFactory(iterable); + flipSequence.reverse = function() {return iterable.flip()}; + return flipSequence; + }; + } + reversedSequence.get = function(key, notSetValue) + {return iterable.get(useKeys ? key : -1 - key, notSetValue)}; + reversedSequence.has = function(key ) + {return iterable.has(useKeys ? key : -1 - key)}; + reversedSequence.includes = function(value ) {return iterable.includes(value)}; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function (fn, reverse) {var this$0 = this; + return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse); + }; + reversedSequence.__iterator = + function(type, reverse) {return iterable.__iterator(type, !reverse)}; + return reversedSequence; + } + + + function filterFactory(iterable, predicate, context, useKeys) { + var filterSequence = makeSequence(iterable); + if (useKeys) { + filterSequence.has = function(key ) { + var v = iterable.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, iterable); + }; + filterSequence.get = function(key, notSetValue) { + var v = iterable.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, iterable) ? + v : notSetValue; + }; + } + filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + var iterations = 0; + iterable.__iterate(function(v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0); + } + }, reverse); + return iterations; + }; + filterSequence.__iteratorUncached = function (type, reverse) { + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new src_Iterator__Iterator(function() { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, iterable)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + } + return filterSequence; + } + + + function countByFactory(iterable, grouper, context) { + var groups = src_Map__Map().asMutable(); + iterable.__iterate(function(v, k) { + groups.update( + grouper.call(context, v, k, iterable), + 0, + function(a ) {return a + 1} + ); + }); + return groups.asImmutable(); + } + + + function groupByFactory(iterable, grouper, context) { + var isKeyedIter = isKeyed(iterable); + var groups = (isOrdered(iterable) ? OrderedMap() : src_Map__Map()).asMutable(); + iterable.__iterate(function(v, k) { + groups.update( + grouper.call(context, v, k, iterable), + function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)} + ); + }); + var coerce = iterableClass(iterable); + return groups.map(function(arr ) {return reify(iterable, coerce(arr))}); + } + + + function sliceFactory(iterable, begin, end, useKeys) { + var originalSize = iterable.size; + + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin = begin | 0; + } + if (end !== undefined) { + end = end | 0; + } + + if (wholeSlice(begin, end, originalSize)) { + return iterable; + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // begin or end will be NaN if they were provided as negative numbers and + // this iterable's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys); + } + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(iterable); + + // If iterable.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined; + + if (!useKeys && isSeq(iterable) && sliceSize >= 0) { + sliceSeq.get = function (index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize ? + iterable.get(index + resolvedBegin, notSetValue) : + notSetValue; + } + } + + sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this; + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + iterable.__iterate(function(v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0) !== false && + iterations !== sliceSize; + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function(type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new src_Iterator__Iterator(function() { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES) { + return step; + } else if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } else { + return iteratorValue(type, iterations - 1, step.value[1], step); + } + }); + } + + return sliceSeq; + } + + + function takeWhileFactory(iterable, predicate, context) { + var takeSequence = makeSequence(iterable); + takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + iterable.__iterate(function(v, k, c) + {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)} + ); + return iterations; + }; + takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new src_Iterator__Iterator(function() { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$0)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : + iteratorValue(type, k, v, step); + }); + }; + return takeSequence; + } + + + function skipWhileFactory(iterable, predicate, context, useKeys) { + var skipSequence = makeSequence(iterable); + skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + iterable.__iterate(function(v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new src_Iterator__Iterator(function() { + var step, k, v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } else if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } else { + return iteratorValue(type, iterations++, step.value[1], step); + } + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$0)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : + iteratorValue(type, k, v, step); + }); + }; + return skipSequence; + } + + + function concatFactory(iterable, values) { + var isKeyedIterable = isKeyed(iterable); + var iters = [iterable].concat(values).map(function(v ) { + if (!isIterable(v)) { + v = isKeyedIterable ? + keyedSeqFromValue(v) : + indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedIterable) { + v = KeyedIterable(v); + } + return v; + }).filter(function(v ) {return v.size !== 0}); + + if (iters.length === 0) { + return iterable; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if (singleton === iterable || + isKeyedIterable && isKeyed(singleton) || + isIndexed(iterable) && isIndexed(singleton)) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedIterable) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(iterable)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce( + function(sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, + 0 + ); + return concatSeq; + } + + + function flattenFactory(iterable, depth, useKeys) { + var flatSequence = makeSequence(iterable); + flatSequence.__iterateUncached = function(fn, reverse) { + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) {var this$0 = this; + iter.__iterate(function(v, k) { + if ((!depth || currentDepth < depth) && isIterable(v)) { + flatDeep(v, currentDepth + 1); + } else if (fn(v, useKeys ? k : iterations++, this$0) === false) { + stopped = true; + } + return !stopped; + }, reverse); + } + flatDeep(iterable, 0); + return iterations; + } + flatSequence.__iteratorUncached = function(type, reverse) { + var iterator = iterable.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new src_Iterator__Iterator(function() { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isIterable(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + } + return flatSequence; + } + + + function flatMapFactory(iterable, mapper, context) { + var coerce = iterableClass(iterable); + return iterable.toSeq().map( + function(v, k) {return coerce(mapper.call(context, v, k, iterable))} + ).flatten(true); + } + + + function interposeFactory(iterable, separator) { + var interposedSequence = makeSequence(iterable); + interposedSequence.size = iterable.size && iterable.size * 2 -1; + interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; + var iterations = 0; + iterable.__iterate(function(v, k) + {return (!iterations || fn(separator, iterations++, this$0) !== false) && + fn(v, iterations++, this$0) !== false}, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function(type, reverse) { + var iterator = iterable.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new src_Iterator__Iterator(function() { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 ? + iteratorValue(type, iterations++, separator) : + iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; + } + + + function sortFactory(iterable, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedIterable = isKeyed(iterable); + var index = 0; + var entries = iterable.toSeq().map( + function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]} + ).toArray(); + entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach( + isKeyedIterable ? + function(v, i) { entries[i].length = 2; } : + function(v, i) { entries[i] = v[1]; } + ); + return isKeyedIterable ? KeyedSeq(entries) : + isIndexed(iterable) ? IndexedSeq(entries) : + SetSeq(entries); + } + + + function maxFactory(iterable, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = iterable.toSeq() + .map(function(v, k) {return [v, mapper(v, k, iterable)]}) + .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a}); + return entry && entry[0]; + } else { + return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a}); + } + } + + function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0; + } + + + function zipWithFactory(keyIter, zipper, iters) { + var zipSequence = makeSequence(keyIter); + zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map(function(i ) + {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))} + ); + var iterations = 0; + var isDone = false; + return new src_Iterator__Iterator(function() { + var steps; + if (!isDone) { + steps = iterators.map(function(i ) {return i.next()}); + isDone = steps.some(function(s ) {return s.done}); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function(s ) {return s.value})) + ); + }); + }; + return zipSequence + } + + + // #pragma Helper Functions + + function reify(iter, seq) { + return isSeq(iter) ? seq : iter.constructor(seq); + } + + function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } + } + + function resolveSize(iter) { + assertNotInfinite(iter.size); + return ensureSize(iter); + } + + function iterableClass(iterable) { + return isKeyed(iterable) ? KeyedIterable : + isIndexed(iterable) ? IndexedIterable : + SetIterable; + } + + function makeSequence(iterable) { + return Object.create( + ( + isKeyed(iterable) ? KeyedSeq : + isIndexed(iterable) ? IndexedSeq : + SetSeq + ).prototype + ); + } + + function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } else { + return Seq.prototype.cacheResult.call(this); + } + } + + function defaultComparator(a, b) { + return a > b ? 1 : a < b ? -1 : 0; + } + + function forceIterator(keyPath) { + var iter = getIterator(keyPath); + if (!iter) { + // Array might not be iterable in this environment, so we need a fallback + // to our wrapped type. + if (!isArrayLike(keyPath)) { + throw new TypeError('Expected iterable or array-like: ' + keyPath); + } + iter = getIterator(Iterable(keyPath)); + } + return iter; + } + + createClass(src_Map__Map, KeyedCollection); + + // @pragma Construction + + function src_Map__Map(value) { + return value === null || value === undefined ? emptyMap() : + isMap(value) && !isOrdered(value) ? value : + emptyMap().withMutations(function(map ) { + var iter = KeyedIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v, k) {return map.set(k, v)}); + }); + } + + src_Map__Map.prototype.toString = function() { + return this.__toString('Map {', '}'); + }; + + // @pragma Access + + src_Map__Map.prototype.get = function(k, notSetValue) { + return this._root ? + this._root.get(0, undefined, k, notSetValue) : + notSetValue; + }; + + // @pragma Modification + + src_Map__Map.prototype.set = function(k, v) { + return updateMap(this, k, v); + }; + + src_Map__Map.prototype.setIn = function(keyPath, v) { + return this.updateIn(keyPath, NOT_SET, function() {return v}); + }; + + src_Map__Map.prototype.remove = function(k) { + return updateMap(this, k, NOT_SET); + }; + + src_Map__Map.prototype.deleteIn = function(keyPath) { + return this.updateIn(keyPath, function() {return NOT_SET}); + }; + + src_Map__Map.prototype.update = function(k, notSetValue, updater) { + return arguments.length === 1 ? + k(this) : + this.updateIn([k], notSetValue, updater); + }; + + src_Map__Map.prototype.updateIn = function(keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeepMap( + this, + forceIterator(keyPath), + notSetValue, + updater + ); + return updatedValue === NOT_SET ? undefined : updatedValue; + }; + + src_Map__Map.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + + // @pragma Composition + + src_Map__Map.prototype.merge = function(/*...iters*/) { + return mergeIntoMapWith(this, undefined, arguments); + }; + + src_Map__Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoMapWith(this, merger, iters); + }; + + src_Map__Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); + return this.updateIn( + keyPath, + emptyMap(), + function(m ) {return typeof m.merge === 'function' ? + m.merge.apply(m, iters) : + iters[iters.length - 1]} + ); + }; + + src_Map__Map.prototype.mergeDeep = function(/*...iters*/) { + return mergeIntoMapWith(this, deepMerger(undefined), arguments); + }; + + src_Map__Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoMapWith(this, deepMerger(merger), iters); + }; + + src_Map__Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); + return this.updateIn( + keyPath, + emptyMap(), + function(m ) {return typeof m.mergeDeep === 'function' ? + m.mergeDeep.apply(m, iters) : + iters[iters.length - 1]} + ); + }; + + src_Map__Map.prototype.sort = function(comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + src_Map__Map.prototype.sortBy = function(mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + // @pragma Mutability + + src_Map__Map.prototype.withMutations = function(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; + }; + + src_Map__Map.prototype.asMutable = function() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); + }; + + src_Map__Map.prototype.asImmutable = function() { + return this.__ensureOwner(); + }; + + src_Map__Map.prototype.wasAltered = function() { + return this.__altered; + }; + + src_Map__Map.prototype.__iterator = function(type, reverse) { + return new MapIterator(this, type, reverse); + }; + + src_Map__Map.prototype.__iterate = function(fn, reverse) {var this$0 = this; + var iterations = 0; + this._root && this._root.iterate(function(entry ) { + iterations++; + return fn(entry[1], entry[0], this$0); + }, reverse); + return iterations; + }; + + src_Map__Map.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; + + + function isMap(maybeMap) { + return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); + } + + src_Map__Map.isMap = isMap; + + var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; + + var MapPrototype = src_Map__Map.prototype; + MapPrototype[IS_MAP_SENTINEL] = true; + MapPrototype[DELETE] = MapPrototype.remove; + MapPrototype.removeIn = MapPrototype.deleteIn; + + + // #pragma Trie Nodes + + + + function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; + } + + ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; + }; + + ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + + var entries = this.entries; + var idx = 0; + for (var len = entries.length; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new ArrayMapNode(ownerID, newEntries); + }; + + + + + function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; + } + + BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK)); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 ? notSetValue : + this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue); + }; + + BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; + + if (!exists && value === NOT_SET) { + return this; + } + + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); + + if (newNode === node) { + return this; + } + + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } + + if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) { + return nodes[idx ^ 1]; + } + + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newNodes = exists ? newNode ? + setIn(nodes, idx, newNode, isEditable) : + spliceOut(nodes, idx, isEditable) : + spliceIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } + + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); + }; + + + + + function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; + } + + HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue; + }; + + HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; + + if (removed && !node) { + return this; + } + + var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); + if (newNode === node) { + return this; + } + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; + return this; + } + + return new HashArrayMapNode(ownerID, newCount, newNodes); + }; + + + + + function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; + } + + HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; + }; + + HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + + var removed = value === NOT_SET; + + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + + var entries = this.entries; + var idx = 0; + for (var len = entries.length; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new HashCollisionNode(ownerID, this.keyHash, newEntries); + }; + + + + + function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; + } + + ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; + }; + + ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { + return this; + } + + SetRef(didAlter); + + if (removed) { + SetRef(didChangeSize); + return; // undefined + } + + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; + } + return new ValueNode(ownerID, this.keyHash, [key, value]); + } + + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); + }; + + + + // #pragma Iterators + + ArrayMapNode.prototype.iterate = + HashCollisionNode.prototype.iterate = function (fn, reverse) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } + } + + BitmapIndexedNode.prototype.iterate = + HashArrayMapNode.prototype.iterate = function (fn, reverse) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } + } + + ValueNode.prototype.iterate = function (fn, reverse) { + return fn(this.entry); + } + + createClass(MapIterator, src_Iterator__Iterator); + + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } + + MapIterator.prototype.next = function() { + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex; + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = this._stack = mapIteratorFrame(subNode, stack); + } + continue; + } + } + stack = this._stack = this._stack.__prev; + } + return iteratorDone(); + }; + + + function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); + } + + function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev + }; + } + + function makeMap(size, root, ownerID, hash) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; + } + + var EMPTY_MAP; + function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); + } + + function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(CHANGE_LENGTH); + var didAlter = MakeRef(DID_ALTER); + newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); + } + + function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter); + } + + function isLeafNode(node) { + return node.constructor === ValueNode || node.constructor === HashCollisionNode; + } + + function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } + + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + + var newNode; + var nodes = idx1 === idx2 ? + [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] : + ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]); + + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); + } + + function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; + } + + function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } + } + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); + } + + function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; + } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); + } + + function mergeIntoMapWith(map, merger, iterables) { + var iters = []; + for (var ii = 0; ii < iterables.length; ii++) { + var value = iterables[ii]; + var iter = KeyedIterable(value); + if (!isIterable(value)) { + iter = iter.map(function(v ) {return fromJS(v)}); + } + iters.push(iter); + } + return mergeIntoCollectionWith(map, merger, iters); + } + + function deepMerger(merger) { + return function(existing, value, key) + {return existing && existing.mergeDeepWith && isIterable(value) ? + existing.mergeDeepWith(merger, value) : + merger ? merger(existing, value, key) : value}; + } + + function mergeIntoCollectionWith(collection, merger, iters) { + iters = iters.filter(function(x ) {return x.size !== 0}); + if (iters.length === 0) { + return collection; + } + if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function(collection ) { + var mergeIntoMap = merger ? + function(value, key) { + collection.update(key, NOT_SET, function(existing ) + {return existing === NOT_SET ? value : merger(existing, value, key)} + ); + } : + function(value, key) { + collection.set(key, value); + } + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoMap); + } + }); + } + + function updateInDeepMap(existing, keyPathIter, notSetValue, updater) { + var isNotSet = existing === NOT_SET; + var step = keyPathIter.next(); + if (step.done) { + var existingValue = isNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + invariant( + isNotSet || (existing && existing.set), + 'invalid keyPath' + ); + var key = step.value; + var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET); + var nextUpdated = updateInDeepMap( + nextExisting, + keyPathIter, + notSetValue, + updater + ); + return nextUpdated === nextExisting ? existing : + nextUpdated === NOT_SET ? existing.remove(key) : + (isNotSet ? emptyMap() : existing).set(key, nextUpdated); + } + + function popCount(x) { + x = x - ((x >> 1) & 0x55555555); + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; + x = x + (x >> 8); + x = x + (x >> 16); + return x & 0x7f; + } + + function setIn(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; + } + + function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } + } + return newArray; + } + + function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; + } + + var MAX_ARRAY_MAP_SIZE = SIZE / 4; + var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; + var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; + + createClass(List, IndexedCollection); + + // @pragma Construction + + function List(value) { + var empty = emptyList(); + if (value === null || value === undefined) { + return empty; + } + if (isList(value)) { + return value; + } + var iter = IndexedIterable(value); + var size = iter.size; + if (size === 0) { + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + return empty.withMutations(function(list ) { + list.setSize(size); + iter.forEach(function(v, i) {return list.set(i, v)}); + }); + } + + List.of = function(/*...values*/) { + return this(arguments); + }; + + List.prototype.toString = function() { + return this.__toString('List [', ']'); + }; + + // @pragma Access + + List.prototype.get = function(index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; + } + return notSetValue; + }; + + // @pragma Modification + + List.prototype.set = function(index, value) { + return updateList(this, index, value); + }; + + List.prototype.remove = function(index) { + return !this.has(index) ? this : + index === 0 ? this.shift() : + index === this.size - 1 ? this.pop() : + this.splice(index, 1); + }; + + List.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = this._origin = this._capacity = 0; + this._level = SHIFT; + this._root = this._tail = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; + + List.prototype.push = function(/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function(list ) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; + + List.prototype.pop = function() { + return setListBounds(this, 0, -1); + }; + + List.prototype.unshift = function(/*...values*/) { + var values = arguments; + return this.withMutations(function(list ) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; + + List.prototype.shift = function() { + return setListBounds(this, 1); + }; + + // @pragma Composition + + List.prototype.merge = function(/*...iters*/) { + return mergeIntoListWith(this, undefined, arguments); + }; + + List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoListWith(this, merger, iters); + }; + + List.prototype.mergeDeep = function(/*...iters*/) { + return mergeIntoListWith(this, deepMerger(undefined), arguments); + }; + + List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoListWith(this, deepMerger(merger), iters); + }; + + List.prototype.setSize = function(size) { + return setListBounds(this, 0, size); + }; + + // @pragma Iteration + + List.prototype.slice = function(begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; + } + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; + + List.prototype.__iterator = function(type, reverse) { + var index = 0; + var values = iterateList(this, reverse); + return new src_Iterator__Iterator(function() { + var value = values(); + return value === DONE ? + iteratorDone() : + iteratorValue(type, index++, value); + }); + }; + + List.prototype.__iterate = function(fn, reverse) { + var index = 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, index++, this) === false) { + break; + } + } + return index; + }; + + List.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + this.__ownerID = ownerID; + return this; + } + return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash); + }; + + + function isList(maybeList) { + return !!(maybeList && maybeList[IS_LIST_SENTINEL]); + } + + List.isList = isList; + + var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; + + var ListPrototype = List.prototype; + ListPrototype[IS_LIST_SENTINEL] = true; + ListPrototype[DELETE] = ListPrototype.remove; + ListPrototype.setIn = MapPrototype.setIn; + ListPrototype.deleteIn = + ListPrototype.removeIn = MapPrototype.removeIn; + ListPrototype.update = MapPrototype.update; + ListPrototype.updateIn = MapPrototype.updateIn; + ListPrototype.mergeIn = MapPrototype.mergeIn; + ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; + ListPrototype.withMutations = MapPrototype.withMutations; + ListPrototype.asMutable = MapPrototype.asMutable; + ListPrototype.asImmutable = MapPrototype.asImmutable; + ListPrototype.wasAltered = MapPrototype.wasAltered; + + + + function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; + } + + // TODO: seems like these methods are very similar + + VNode.prototype.removeBefore = function(ownerID, level, index) { + if (index === level ? 1 << level : 0 || this.array.length === 0) { + return this; + } + var originIndex = (index >>> level) & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; + } + } + if (removingFirst && !newChild) { + return this; + } + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; + } + } + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; + }; + + VNode.prototype.removeAfter = function(ownerID, level, index) { + if (index === (level ? 1 << level : 0) || this.array.length === 0) { + return this; + } + var sizeIndex = ((index - 1) >>> level) & MASK; + if (sizeIndex >= this.array.length) { + return this; + } + + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } + + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; + } + return editable; + }; + + + + var DONE = {}; + + function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; + + return iterateNodeOrLeaf(list._root, list._level, 0); + + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 ? + iterateLeaf(node, offset) : + iterateNode(node, level, offset); + } + + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function() { + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + return array && array[idx]; + }; + } + + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; + if (to > SIZE) { + to = SIZE; + } + return function() { + do { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], level - SHIFT, offset + (idx << level) + ); + } while (true); + }; + } + } + + function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; + return list; + } + + var EMPTY_LIST; + function emptyList() { + return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); + } + + function updateList(list, index, value) { + index = wrapIndex(list, index); + + if (index !== index) { + return list; + } + + if (index >= list.size || index < 0) { + return list.withMutations(function(list ) { + index < 0 ? + setListBounds(list, index).set(0, value) : + setListBounds(list, 0, index + 1).set(index, value) + }); + } + + index += list._origin; + + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(DID_ALTER); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter); + } + + if (!didAlter.value) { + return list; + } + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); + } + + function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = (index >>> level) & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } + + var newNode; + + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter); + if (newLowerNode === lowerNode) { + return node; + } + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } + + if (nodeHas && node.array[idx] === value) { + return node; + } + + SetRef(didAlter); + + newNode = editableVNode(node, ownerID); + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } + return newNode; + } + + function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; + } + return new VNode(node ? node.array.slice() : [], ownerID); + } + + function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; + } + if (rawIndex < 1 << (list._level + SHIFT)) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[(rawIndex >>> level) & MASK]; + level -= SHIFT; + } + return node; + } + } + + function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin = begin | 0; + } + if (end !== undefined) { + end = end | 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; + } + + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); + } + + var newLevel = list._level; + var newRoot = list._root; + + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; + } + + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); + + // New size might need creating a higher root. + while (newTailOffset >= 1 << (newLevel + SHIFT)) { + newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner); + newLevel += SHIFT; + } + + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = newTailOffset < oldTailOffset ? + listNodeFor(list, newCapacity - 1) : + newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + + // Merge Tail into tree. + if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); + } + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; + } + + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); + } + + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; + + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if (beginIndex !== (newTailOffset >>> newLevel) & MASK) { + break; + } + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; + } + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } + + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift); + } + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; + } + } + + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); + } + + function mergeIntoListWith(list, merger, iterables) { + var iters = []; + var maxSize = 0; + for (var ii = 0; ii < iterables.length; ii++) { + var value = iterables[ii]; + var iter = IndexedIterable(value); + if (iter.size > maxSize) { + maxSize = iter.size; + } + if (!isIterable(value)) { + iter = iter.map(function(v ) {return fromJS(v)}); + } + iters.push(iter); + } + if (maxSize > list.size) { + list = list.setSize(maxSize); + } + return mergeIntoCollectionWith(list, merger, iters); + } + + function getTailOffset(size) { + return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT); + } + + createClass(OrderedMap, src_Map__Map); + + // @pragma Construction + + function OrderedMap(value) { + return value === null || value === undefined ? emptyOrderedMap() : + isOrderedMap(value) ? value : + emptyOrderedMap().withMutations(function(map ) { + var iter = KeyedIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v, k) {return map.set(k, v)}); + }); + } + + OrderedMap.of = function(/*...values*/) { + return this(arguments); + }; + + OrderedMap.prototype.toString = function() { + return this.__toString('OrderedMap {', '}'); + }; + + // @pragma Access + + OrderedMap.prototype.get = function(k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; + + // @pragma Modification + + OrderedMap.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + return this; + } + return emptyOrderedMap(); + }; + + OrderedMap.prototype.set = function(k, v) { + return updateOrderedMap(this, k, v); + }; + + OrderedMap.prototype.remove = function(k) { + return updateOrderedMap(this, k, NOT_SET); + }; + + OrderedMap.prototype.wasAltered = function() { + return this._map.wasAltered() || this._list.wasAltered(); + }; + + OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._list.__iterate( + function(entry ) {return entry && fn(entry[1], entry[0], this$0)}, + reverse + ); + }; + + OrderedMap.prototype.__iterator = function(type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; + + OrderedMap.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; + + + function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); + } + + OrderedMap.isOrderedMap = isOrderedMap; + + OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; + OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + + + + function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + return omap; + } + + var EMPTY_ORDERED_MAP; + function emptyOrderedMap() { + return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); + } + + function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx}); + newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap(); + if (omap.__ownerID) { + newMap.__ownerID = newList.__ownerID = omap.__ownerID; + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); + } + } else { + if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + return omap; + } + return makeOrderedMap(newMap, newList); + } + + createClass(Stack, IndexedCollection); + + // @pragma Construction + + function Stack(value) { + return value === null || value === undefined ? emptyStack() : + isStack(value) ? value : + emptyStack().unshiftAll(value); + } + + Stack.of = function(/*...values*/) { + return this(arguments); + }; + + Stack.prototype.toString = function() { + return this.__toString('Stack [', ']'); + }; + + // @pragma Access + + Stack.prototype.get = function(index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; + + Stack.prototype.peek = function() { + return this._head && this._head.value; + }; + + // @pragma Modification + + Stack.prototype.push = function(/*...values*/) { + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments[ii], + next: head + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pushAll = function(iter) { + iter = IndexedIterable(iter); + if (iter.size === 0) { + return this; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.reverse().forEach(function(value ) { + newSize++; + head = { + value: value, + next: head + }; + }); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pop = function() { + return this.slice(1); + }; + + Stack.prototype.unshift = function(/*...values*/) { + return this.push.apply(this, arguments); + }; + + Stack.prototype.unshiftAll = function(iter) { + return this.pushAll(iter); + }; + + Stack.prototype.shift = function() { + return this.pop.apply(this, arguments); + }; + + Stack.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; + + Stack.prototype.slice = function(begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + // @pragma Mutability + + Stack.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; + + // @pragma Iteration + + Stack.prototype.__iterate = function(fn, reverse) { + if (reverse) { + return this.reverse().__iterate(fn); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this) === false) { + break; + } + node = node.next; + } + return iterations; + }; + + Stack.prototype.__iterator = function(type, reverse) { + if (reverse) { + return this.reverse().__iterator(type); + } + var iterations = 0; + var node = this._head; + return new src_Iterator__Iterator(function() { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; + + + function isStack(maybeStack) { + return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); + } + + Stack.isStack = isStack; + + var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; + + var StackPrototype = Stack.prototype; + StackPrototype[IS_STACK_SENTINEL] = true; + StackPrototype.withMutations = MapPrototype.withMutations; + StackPrototype.asMutable = MapPrototype.asMutable; + StackPrototype.asImmutable = MapPrototype.asImmutable; + StackPrototype.wasAltered = MapPrototype.wasAltered; + + + function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; + } + + var EMPTY_STACK; + function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); + } + + createClass(src_Set__Set, SetCollection); + + // @pragma Construction + + function src_Set__Set(value) { + return value === null || value === undefined ? emptySet() : + isSet(value) && !isOrdered(value) ? value : + emptySet().withMutations(function(set ) { + var iter = SetIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v ) {return set.add(v)}); + }); + } + + src_Set__Set.of = function(/*...values*/) { + return this(arguments); + }; + + src_Set__Set.fromKeys = function(value) { + return this(KeyedIterable(value).keySeq()); + }; + + src_Set__Set.prototype.toString = function() { + return this.__toString('Set {', '}'); + }; + + // @pragma Access + + src_Set__Set.prototype.has = function(value) { + return this._map.has(value); + }; + + // @pragma Modification + + src_Set__Set.prototype.add = function(value) { + return updateSet(this, this._map.set(value, true)); + }; + + src_Set__Set.prototype.remove = function(value) { + return updateSet(this, this._map.remove(value)); + }; + + src_Set__Set.prototype.clear = function() { + return updateSet(this, this._map.clear()); + }; + + // @pragma Composition + + src_Set__Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0); + iters = iters.filter(function(x ) {return x.size !== 0}); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function(set ) { + for (var ii = 0; ii < iters.length; ii++) { + SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)}); + } + }); + }; + + src_Set__Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0); + if (iters.length === 0) { + return this; + } + iters = iters.map(function(iter ) {return SetIterable(iter)}); + var originalSet = this; + return this.withMutations(function(set ) { + originalSet.forEach(function(value ) { + if (!iters.every(function(iter ) {return iter.includes(value)})) { + set.remove(value); + } + }); + }); + }; + + src_Set__Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0); + if (iters.length === 0) { + return this; + } + iters = iters.map(function(iter ) {return SetIterable(iter)}); + var originalSet = this; + return this.withMutations(function(set ) { + originalSet.forEach(function(value ) { + if (iters.some(function(iter ) {return iter.includes(value)})) { + set.remove(value); + } + }); + }); + }; + + src_Set__Set.prototype.merge = function() { + return this.union.apply(this, arguments); + }; + + src_Set__Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return this.union.apply(this, iters); + }; + + src_Set__Set.prototype.sort = function(comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; + + src_Set__Set.prototype.sortBy = function(mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; + + src_Set__Set.prototype.wasAltered = function() { + return this._map.wasAltered(); + }; + + src_Set__Set.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse); + }; + + src_Set__Set.prototype.__iterator = function(type, reverse) { + return this._map.map(function(_, k) {return k}).__iterator(type, reverse); + }; + + src_Set__Set.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + + function isSet(maybeSet) { + return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); + } + + src_Set__Set.isSet = isSet; + + var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; + + var SetPrototype = src_Set__Set.prototype; + SetPrototype[IS_SET_SENTINEL] = true; + SetPrototype[DELETE] = SetPrototype.remove; + SetPrototype.mergeDeep = SetPrototype.merge; + SetPrototype.mergeDeepWith = SetPrototype.mergeWith; + SetPrototype.withMutations = MapPrototype.withMutations; + SetPrototype.asMutable = MapPrototype.asMutable; + SetPrototype.asImmutable = MapPrototype.asImmutable; + + SetPrototype.__empty = emptySet; + SetPrototype.__make = makeSet; + + function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; + } + return newMap === set._map ? set : + newMap.size === 0 ? set.__empty() : + set.__make(newMap); + } + + function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; + } + + var EMPTY_SET; + function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); + } + + createClass(OrderedSet, src_Set__Set); + + // @pragma Construction + + function OrderedSet(value) { + return value === null || value === undefined ? emptyOrderedSet() : + isOrderedSet(value) ? value : + emptyOrderedSet().withMutations(function(set ) { + var iter = SetIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v ) {return set.add(v)}); + }); + } + + OrderedSet.of = function(/*...values*/) { + return this(arguments); + }; + + OrderedSet.fromKeys = function(value) { + return this(KeyedIterable(value).keySeq()); + }; + + OrderedSet.prototype.toString = function() { + return this.__toString('OrderedSet {', '}'); + }; + + + function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + } + + OrderedSet.isOrderedSet = isOrderedSet; + + var OrderedSetPrototype = OrderedSet.prototype; + OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; + + OrderedSetPrototype.__empty = emptyOrderedSet; + OrderedSetPrototype.__make = makeOrderedSet; + + function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; + } + + var EMPTY_ORDERED_SET; + function emptyOrderedSet() { + return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); + } + + createClass(Record, KeyedCollection); + + function Record(defaultValues, name) { + var hasInitialized; + + var RecordType = function Record(values) { + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + setProps(RecordTypePrototype, keys); + RecordTypePrototype.size = keys.length; + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + } + this._map = src_Map__Map(values); + }; + + var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype); + RecordTypePrototype.constructor = RecordType; + + return RecordType; + } + + Record.prototype.toString = function() { + return this.__toString(recordName(this) + ' {', '}'); + }; + + // @pragma Access + + Record.prototype.has = function(k) { + return this._defaultValues.hasOwnProperty(k); + }; + + Record.prototype.get = function(k, notSetValue) { + if (!this.has(k)) { + return notSetValue; + } + var defaultVal = this._defaultValues[k]; + return this._map ? this._map.get(k, defaultVal) : defaultVal; + }; + + // @pragma Modification + + Record.prototype.clear = function() { + if (this.__ownerID) { + this._map && this._map.clear(); + return this; + } + var RecordType = this.constructor; + return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap())); + }; + + Record.prototype.set = function(k, v) { + if (!this.has(k)) { + throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this)); + } + var newMap = this._map && this._map.set(k, v); + if (this.__ownerID || newMap === this._map) { + return this; + } + return makeRecord(this, newMap); + }; + + Record.prototype.remove = function(k) { + if (!this.has(k)) { + return this; + } + var newMap = this._map && this._map.remove(k); + if (this.__ownerID || newMap === this._map) { + return this; + } + return makeRecord(this, newMap); + }; + + Record.prototype.wasAltered = function() { + return this._map.wasAltered(); + }; + + Record.prototype.__iterator = function(type, reverse) {var this$0 = this; + return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse); + }; + + Record.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse); + }; + + Record.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map && this._map.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return makeRecord(this, newMap, ownerID); + }; + + + var RecordPrototype = Record.prototype; + RecordPrototype[DELETE] = RecordPrototype.remove; + RecordPrototype.deleteIn = + RecordPrototype.removeIn = MapPrototype.removeIn; + RecordPrototype.merge = MapPrototype.merge; + RecordPrototype.mergeWith = MapPrototype.mergeWith; + RecordPrototype.mergeIn = MapPrototype.mergeIn; + RecordPrototype.mergeDeep = MapPrototype.mergeDeep; + RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; + RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; + RecordPrototype.setIn = MapPrototype.setIn; + RecordPrototype.update = MapPrototype.update; + RecordPrototype.updateIn = MapPrototype.updateIn; + RecordPrototype.withMutations = MapPrototype.withMutations; + RecordPrototype.asMutable = MapPrototype.asMutable; + RecordPrototype.asImmutable = MapPrototype.asImmutable; + + + function makeRecord(likeRecord, map, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._map = map; + record.__ownerID = ownerID; + return record; + } + + function recordName(record) { + return record._name || record.constructor.name || 'Record'; + } + + function setProps(prototype, names) { + try { + names.forEach(setProp.bind(undefined, prototype)); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } + } + + function setProp(prototype, name) { + Object.defineProperty(prototype, name, { + get: function() { + return this.get(name); + }, + set: function(value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + } + }); + } + + function deepEqual(a, b) { + if (a === b) { + return true; + } + + if ( + !isIterable(b) || + a.size !== undefined && b.size !== undefined && a.size !== b.size || + a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; + } + + if (a.size === 0 && b.size === 0) { + return true; + } + + var notAssociative = !isAssociative(a); + + if (isOrdered(a)) { + var entries = a.entries(); + return b.every(function(v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done; + } + + var flipped = false; + + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + + var allEqual = true; + var bSize = b.__iterate(function(v, k) { + if (notAssociative ? !a.has(v) : + flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) { + allEqual = false; + return false; + } + }); + + return allEqual && a.size === bSize; + } + + createClass(Range, IndexedSeq); + + function Range(start, end, step) { + if (!(this instanceof Range)) { + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + start = start || 0; + if (end === undefined) { + end = Infinity; + } + step = step === undefined ? 1 : Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + return EMPTY_RANGE; + } + EMPTY_RANGE = this; + } + } + + Range.prototype.toString = function() { + if (this.size === 0) { + return 'Range []'; + } + return 'Range [ ' + + this._start + '...' + this._end + + (this._step > 1 ? ' by ' + this._step : '') + + ' ]'; + }; + + Range.prototype.get = function(index, notSetValue) { + return this.has(index) ? + this._start + wrapIndex(this, index) * this._step : + notSetValue; + }; + + Range.prototype.includes = function(searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex); + }; + + Range.prototype.slice = function(begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range(this.get(begin, this._end), this.get(end, this._end), this._step); + }; + + Range.prototype.indexOf = function(searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index + } + } + return -1; + }; + + Range.prototype.lastIndexOf = function(searchValue) { + return this.indexOf(searchValue); + }; + + Range.prototype.__iterate = function(fn, reverse) { + var maxIndex = this.size - 1; + var step = this._step; + var value = reverse ? this._start + maxIndex * step : this._start; + for (var ii = 0; ii <= maxIndex; ii++) { + if (fn(value, ii, this) === false) { + return ii + 1; + } + value += reverse ? -step : step; + } + return ii; + }; + + Range.prototype.__iterator = function(type, reverse) { + var maxIndex = this.size - 1; + var step = this._step; + var value = reverse ? this._start + maxIndex * step : this._start; + var ii = 0; + return new src_Iterator__Iterator(function() { + var v = value; + value += reverse ? -step : step; + return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v); + }); + }; + + Range.prototype.equals = function(other) { + return other instanceof Range ? + this._start === other._start && + this._end === other._end && + this._step === other._step : + deepEqual(this, other); + }; + + + var EMPTY_RANGE; + + createClass(Repeat, IndexedSeq); + + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + return EMPTY_REPEAT; + } + EMPTY_REPEAT = this; + } + } + + Repeat.prototype.toString = function() { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; + + Repeat.prototype.get = function(index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function(searchValue) { + return is(this._value, searchValue); + }; + + Repeat.prototype.slice = function(begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) ? this : + new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size)); + }; + + Repeat.prototype.reverse = function() { + return this; + }; + + Repeat.prototype.indexOf = function(searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function(searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function(fn, reverse) { + for (var ii = 0; ii < this.size; ii++) { + if (fn(this._value, ii, this) === false) { + return ii + 1; + } + } + return ii; + }; + + Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this; + var ii = 0; + return new src_Iterator__Iterator(function() + {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()} + ); + }; + + Repeat.prototype.equals = function(other) { + return other instanceof Repeat ? + is(this._value, other._value) : + deepEqual(other); + }; + + + var EMPTY_REPEAT; + + /** + * Contributes additional methods to a constructor + */ + function mixin(ctor, methods) { + var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; }; + Object.keys(methods).forEach(keyCopier); + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; + } + + Iterable.Iterator = src_Iterator__Iterator; + + mixin(Iterable, { + + // ### Conversion to other types + + toArray: function() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + this.valueSeq().__iterate(function(v, i) { array[i] = v; }); + return array; + }, + + toIndexedSeq: function() { + return new ToIndexedSequence(this); + }, + + toJS: function() { + return this.toSeq().map( + function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value} + ).__toJS(); + }, + + toJSON: function() { + return this.toSeq().map( + function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value} + ).__toJS(); + }, + + toKeyedSeq: function() { + return new ToKeyedSequence(this, true); + }, + + toMap: function() { + // Use Late Binding here to solve the circular dependency. + return src_Map__Map(this.toKeyedSeq()); + }, + + toObject: function() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function(v, k) { object[k] = v; }); + return object; + }, + + toOrderedMap: function() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function() { + // Use Late Binding here to solve the circular dependency. + return src_Set__Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function() { + return new ToSetSequence(this); + }, + + toSeq: function() { + return isIndexed(this) ? this.toIndexedSeq() : + isKeyed(this) ? this.toKeyedSeq() : + this.toSetSeq(); + }, + + toStack: function() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + + // ### Common JavaScript methods and properties + + toString: function() { + return '[Iterable]'; + }, + + __toString: function(head, tail) { + if (this.size === 0) { + return head + tail; + } + return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail; + }, + + + // ### ES6 Collection methods (ES6 Array and Map) + + concat: function() {var values = SLICE$0.call(arguments, 0); + return reify(this, concatFactory(this, values)); + }, + + includes: function(searchValue) { + return this.some(function(value ) {return is(value, searchValue)}); + }, + + entries: function() { + return this.__iterator(ITERATE_ENTRIES); + }, + + every: function(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function(v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + find: function(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + findEntry: function(predicate, context) { + var found; + this.__iterate(function(v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, + + findLastEntry: function(predicate, context) { + return this.toSeq().reverse().findEntry(predicate, context); + }, + + forEach: function(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function(v ) { + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, + + keys: function() { + return this.__iterator(ITERATE_KEYS); + }, + + map: function(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, + + reduce: function(reducer, initialReduction, context) { + assertNotInfinite(this.size); + var reduction; + var useFirst; + if (arguments.length < 2) { + useFirst = true; + } else { + reduction = initialReduction; + } + this.__iterate(function(v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }); + return reduction; + }, + + reduceRight: function(reducer, initialReduction, context) { + var reversed = this.toKeyedSeq().reverse(); + return reversed.reduce.apply(reversed, arguments); + }, + + reverse: function() { + return reify(this, reverseFactory(this, true)); + }, + + slice: function(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, + + some: function(predicate, context) { + return !this.every(not(predicate), context); + }, + + sort: function(comparator) { + return reify(this, sortFactory(this, comparator)); + }, + + values: function() { + return this.__iterator(ITERATE_VALUES); + }, + + + // ### More sequential methods + + butLast: function() { + return this.slice(0, -1); + }, + + isEmpty: function() { + return this.size !== undefined ? this.size === 0 : !this.some(function() {return true}); + }, + + count: function(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, + + countBy: function(grouper, context) { + return countByFactory(this, grouper, context); + }, + + equals: function(other) { + return deepEqual(this, other); + }, + + entrySeq: function() { + var iterable = this; + if (iterable._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(iterable._cache); + } + var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq(); + entriesSequence.fromEntrySeq = function() {return iterable.toSeq()}; + return entriesSequence; + }, + + filterNot: function(predicate, context) { + return this.filter(not(predicate), context); + }, + + findLast: function(predicate, context, notSetValue) { + return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + }, + + first: function() { + return this.find(returnTrue); + }, + + flatMap: function(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, + + flatten: function(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, + + fromEntrySeq: function() { + return new FromEntriesSequence(this); + }, + + get: function(searchKey, notSetValue) { + return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue); + }, + + getIn: function(searchKeyPath, notSetValue) { + var nested = this; + // Note: in an ES6 environment, we would prefer: + // for (var key of searchKeyPath) { + var iter = forceIterator(searchKeyPath); + var step; + while (!(step = iter.next()).done) { + var key = step.value; + nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET; + if (nested === NOT_SET) { + return notSetValue; + } + } + return nested; + }, + + groupBy: function(grouper, context) { + return groupByFactory(this, grouper, context); + }, + + has: function(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, + + hasIn: function(searchKeyPath) { + return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET; + }, + + isSubset: function(iter) { + iter = typeof iter.includes === 'function' ? iter : Iterable(iter); + return this.every(function(value ) {return iter.includes(value)}); + }, + + isSuperset: function(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter); + return iter.isSubset(this); + }, + + keySeq: function() { + return this.toSeq().map(keyMapper).toIndexedSeq(); + }, + + last: function() { + return this.toSeq().reverse().first(); + }, + + max: function(comparator) { + return maxFactory(this, comparator); + }, + + maxBy: function(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, + + min: function(comparator) { + return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator); + }, + + minBy: function(mapper, comparator) { + return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper); + }, + + rest: function() { + return this.slice(1); + }, + + skip: function(amount) { + return this.slice(Math.max(0, amount)); + }, + + skipLast: function(amount) { + return reify(this, this.toSeq().reverse().skip(amount).reverse()); + }, + + skipWhile: function(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, + + skipUntil: function(predicate, context) { + return this.skipWhile(not(predicate), context); + }, + + sortBy: function(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, + + take: function(amount) { + return this.slice(0, Math.max(0, amount)); + }, + + takeLast: function(amount) { + return reify(this, this.toSeq().reverse().take(amount).reverse()); + }, + + takeWhile: function(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, + + takeUntil: function(predicate, context) { + return this.takeWhile(not(predicate), context); + }, + + valueSeq: function() { + return this.toIndexedSeq(); + }, + + + // ### Hashable Object + + hashCode: function() { + return this.__hash || (this.__hash = hashIterable(this)); + } + + + // ### Internal + + // abstract __iterate(fn, reverse) + + // abstract __iterator(type, reverse) + }); + + // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; + // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; + // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; + // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; + + var IterablePrototype = Iterable.prototype; + IterablePrototype[IS_ITERABLE_SENTINEL] = true; + IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values; + IterablePrototype.__toJS = IterablePrototype.toArray; + IterablePrototype.__toStringMapper = quoteString; + IterablePrototype.inspect = + IterablePrototype.toSource = function() { return this.toString(); }; + IterablePrototype.chain = IterablePrototype.flatMap; + IterablePrototype.contains = IterablePrototype.includes; + + // Temporary warning about using length + (function () { + try { + Object.defineProperty(IterablePrototype, 'length', { + get: function () { + if (!Iterable.noLengthWarning) { + var stack; + try { + throw new Error(); + } catch (error) { + stack = error.stack; + } + if (stack.indexOf('_wrapObject') === -1) { + console && console.warn && console.warn( + 'iterable.length has been deprecated, '+ + 'use iterable.size or iterable.count(). '+ + 'This warning will become a silent error in a future version. ' + + stack + ); + return this.size; + } + } + } + }); + } catch (e) {} + })(); + + + + mixin(KeyedIterable, { + + // ### More sequential methods + + flip: function() { + return reify(this, flipFactory(this)); + }, + + findKey: function(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, + + findLastKey: function(predicate, context) { + return this.toSeq().reverse().findKey(predicate, context); + }, + + keyOf: function(searchValue) { + return this.findKey(function(value ) {return is(value, searchValue)}); + }, + + lastKeyOf: function(searchValue) { + return this.findLastKey(function(value ) {return is(value, searchValue)}); + }, + + mapEntries: function(mapper, context) {var this$0 = this; + var iterations = 0; + return reify(this, + this.toSeq().map( + function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)} + ).fromEntrySeq() + ); + }, + + mapKeys: function(mapper, context) {var this$0 = this; + return reify(this, + this.toSeq().flip().map( + function(k, v) {return mapper.call(context, k, v, this$0)} + ).flip() + ); + } + + }); + + var KeyedIterablePrototype = KeyedIterable.prototype; + KeyedIterablePrototype[IS_KEYED_SENTINEL] = true; + KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries; + KeyedIterablePrototype.__toJS = IterablePrototype.toObject; + KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)}; + + + + mixin(IndexedIterable, { + + // ### Conversion to other types + + toKeyedSeq: function() { + return new ToKeyedSequence(this, false); + }, + + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function(searchValue) { + var key = this.toKeyedSeq().keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function(searchValue) { + return this.toSeq().reverse().indexOf(searchValue); + }, + + reverse: function() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum | 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 ? + spliced : + spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, + + + // ### More collection methods + + findLastIndex: function(predicate, context) { + var key = this.toKeyedSeq().findLastKey(predicate, context); + return key === undefined ? -1 : key; + }, + + first: function() { + return this.get(0); + }, + + flatten: function(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, + + get: function(index, notSetValue) { + index = wrapIndex(this, index); + return (index < 0 || (this.size === Infinity || + (this.size !== undefined && index > this.size))) ? + notSetValue : + this.find(function(_, key) {return key === index}, undefined, notSetValue); + }, + + has: function(index) { + index = wrapIndex(this, index); + return index >= 0 && (this.size !== undefined ? + this.size === Infinity || index < this.size : + this.indexOf(index) !== -1 + ); + }, + + interpose: function(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function(/*...iterables*/) { + var iterables = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * iterables.length; + } + return reify(this, interleaved); + }, + + last: function() { + return this.get(-1); + }, + + skipWhile: function(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function(/*, ...iterables */) { + var iterables = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, iterables)); + }, + + zipWith: function(zipper/*, ...iterables */) { + var iterables = arrCopy(arguments); + iterables[0] = this; + return reify(this, zipWithFactory(this, zipper, iterables)); + } + + }); + + IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true; + IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true; + + + + mixin(SetIterable, { + + // ### ES6 Collection methods (ES6 Array and Map) + + get: function(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, + + includes: function(value) { + return this.has(value); + }, + + + // ### More sequential methods + + keySeq: function() { + return this.valueSeq(); + } + + }); + + SetIterable.prototype.has = IterablePrototype.includes; + + + // Mixin subclasses + + mixin(KeyedSeq, KeyedIterable.prototype); + mixin(IndexedSeq, IndexedIterable.prototype); + mixin(SetSeq, SetIterable.prototype); + + mixin(KeyedCollection, KeyedIterable.prototype); + mixin(IndexedCollection, IndexedIterable.prototype); + mixin(SetCollection, SetIterable.prototype); + + + // #pragma Helper functions + + function keyMapper(v, k) { + return k; + } + + function entryMapper(v, k) { + return [k, v]; + } + + function not(predicate) { + return function() { + return !predicate.apply(this, arguments); + } + } + + function neg(predicate) { + return function() { + return -predicate.apply(this, arguments); + } + } + + function quoteString(value) { + return typeof value === 'string' ? JSON.stringify(value) : value; + } + + function defaultZipper() { + return arrCopy(arguments); + } + + function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; + } + + function hashIterable(iterable) { + if (iterable.size === Infinity) { + return 0; + } + var ordered = isOrdered(iterable); + var keyed = isKeyed(iterable); + var h = ordered ? 1 : 0; + var size = iterable.__iterate( + keyed ? + ordered ? + function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } : + function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } : + ordered ? + function(v ) { h = 31 * h + hash(v) | 0; } : + function(v ) { h = h + hash(v) | 0; } + ); + return murmurHashOfSize(size, h); + } + + function murmurHashOfSize(size, h) { + h = src_Math__imul(h, 0xCC9E2D51); + h = src_Math__imul(h << 15 | h >>> -15, 0x1B873593); + h = src_Math__imul(h << 13 | h >>> -13, 5); + h = (h + 0xE6546B64 | 0) ^ size; + h = src_Math__imul(h ^ h >>> 16, 0x85EBCA6B); + h = src_Math__imul(h ^ h >>> 13, 0xC2B2AE35); + h = smi(h ^ h >>> 16); + return h; + } + + function hashMerge(a, b) { + return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int + } + + var Immutable = { + + Iterable: Iterable, + + Seq: Seq, + Collection: Collection, + Map: src_Map__Map, + OrderedMap: OrderedMap, + List: List, + Stack: Stack, + Set: src_Set__Set, + OrderedSet: OrderedSet, + + Record: Record, + Range: Range, + Repeat: Repeat, + + is: is, + fromJS: fromJS + + }; + + return Immutable; + +})); +},{}],4:[function(require,module,exports){ /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -150,7 +7576,7 @@ function restParam(func, start) { module.exports = restParam; -},{}],3:[function(require,module,exports){ +},{}],5:[function(require,module,exports){ (function (global){ var cachePush = require('./cachePush'), getNative = require('./getNative'); @@ -183,7 +7609,7 @@ SetCache.prototype.push = cachePush; module.exports = SetCache; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./cachePush":15,"./getNative":21}],4:[function(require,module,exports){ +},{"./cachePush":17,"./getNative":23}],6:[function(require,module,exports){ /** * A specialized version of `_.map` for arrays without support for callback * shorthands and `this` binding. @@ -206,7 +7632,7 @@ function arrayMap(array, iteratee) { module.exports = arrayMap; -},{}],5:[function(require,module,exports){ +},{}],7:[function(require,module,exports){ /** * Appends the elements of `values` to `array`. * @@ -228,7 +7654,7 @@ function arrayPush(array, values) { module.exports = arrayPush; -},{}],6:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ var baseIndexOf = require('./baseIndexOf'), cacheIndexOf = require('./cacheIndexOf'), createCache = require('./createCache'); @@ -285,7 +7711,7 @@ function baseDifference(array, values) { module.exports = baseDifference; -},{"./baseIndexOf":10,"./cacheIndexOf":14,"./createCache":17}],7:[function(require,module,exports){ +},{"./baseIndexOf":12,"./cacheIndexOf":16,"./createCache":19}],9:[function(require,module,exports){ var arrayPush = require('./arrayPush'), isArguments = require('../lang/isArguments'), isArray = require('../lang/isArray'), @@ -328,7 +7754,7 @@ function baseFlatten(array, isDeep, isStrict, result) { module.exports = baseFlatten; -},{"../lang/isArguments":31,"../lang/isArray":32,"./arrayPush":5,"./isArrayLike":23,"./isObjectLike":27}],8:[function(require,module,exports){ +},{"../lang/isArguments":33,"../lang/isArray":34,"./arrayPush":7,"./isArrayLike":25,"./isObjectLike":29}],10:[function(require,module,exports){ var createBaseFor = require('./createBaseFor'); /** @@ -347,7 +7773,7 @@ var baseFor = createBaseFor(); module.exports = baseFor; -},{"./createBaseFor":16}],9:[function(require,module,exports){ +},{"./createBaseFor":18}],11:[function(require,module,exports){ var baseFor = require('./baseFor'), keysIn = require('../object/keysIn'); @@ -366,7 +7792,7 @@ function baseForIn(object, iteratee) { module.exports = baseForIn; -},{"../object/keysIn":36,"./baseFor":8}],10:[function(require,module,exports){ +},{"../object/keysIn":38,"./baseFor":10}],12:[function(require,module,exports){ var indexOfNaN = require('./indexOfNaN'); /** @@ -395,7 +7821,7 @@ function baseIndexOf(array, value, fromIndex) { module.exports = baseIndexOf; -},{"./indexOfNaN":22}],11:[function(require,module,exports){ +},{"./indexOfNaN":24}],13:[function(require,module,exports){ /** * The base implementation of `_.property` without support for deep paths. * @@ -411,7 +7837,7 @@ function baseProperty(key) { module.exports = baseProperty; -},{}],12:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ /** * Converts `value` to a string if it's not one. An empty string is returned * for `null` or `undefined` values. @@ -426,7 +7852,7 @@ function baseToString(value) { module.exports = baseToString; -},{}],13:[function(require,module,exports){ +},{}],15:[function(require,module,exports){ var identity = require('../utility/identity'); /** @@ -467,7 +7893,7 @@ function bindCallback(func, thisArg, argCount) { module.exports = bindCallback; -},{"../utility/identity":41}],14:[function(require,module,exports){ +},{"../utility/identity":43}],16:[function(require,module,exports){ var isObject = require('../lang/isObject'); /** @@ -488,7 +7914,7 @@ function cacheIndexOf(cache, value) { module.exports = cacheIndexOf; -},{"../lang/isObject":35}],15:[function(require,module,exports){ +},{"../lang/isObject":37}],17:[function(require,module,exports){ var isObject = require('../lang/isObject'); /** @@ -510,7 +7936,7 @@ function cachePush(value) { module.exports = cachePush; -},{"../lang/isObject":35}],16:[function(require,module,exports){ +},{"../lang/isObject":37}],18:[function(require,module,exports){ var toObject = require('./toObject'); /** @@ -539,7 +7965,7 @@ function createBaseFor(fromRight) { module.exports = createBaseFor; -},{"./toObject":30}],17:[function(require,module,exports){ +},{"./toObject":32}],19:[function(require,module,exports){ (function (global){ var SetCache = require('./SetCache'), getNative = require('./getNative'); @@ -564,7 +7990,7 @@ function createCache(values) { module.exports = createCache; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./SetCache":3,"./getNative":21}],18:[function(require,module,exports){ +},{"./SetCache":5,"./getNative":23}],20:[function(require,module,exports){ var deburr = require('../string/deburr'), words = require('../string/words'); @@ -592,7 +8018,7 @@ function createCompounder(callback) { module.exports = createCompounder; -},{"../string/deburr":39,"../string/words":40}],19:[function(require,module,exports){ +},{"../string/deburr":41,"../string/words":42}],21:[function(require,module,exports){ /** Used to map latin-1 supplementary letters to basic latin letters. */ var deburredLetters = { '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', @@ -627,7 +8053,7 @@ function deburrLetter(letter) { module.exports = deburrLetter; -},{}],20:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ var baseProperty = require('./baseProperty'); /** @@ -644,7 +8070,7 @@ var getLength = baseProperty('length'); module.exports = getLength; -},{"./baseProperty":11}],21:[function(require,module,exports){ +},{"./baseProperty":13}],23:[function(require,module,exports){ var isNative = require('../lang/isNative'); /** @@ -662,7 +8088,7 @@ function getNative(object, key) { module.exports = getNative; -},{"../lang/isNative":34}],22:[function(require,module,exports){ +},{"../lang/isNative":36}],24:[function(require,module,exports){ /** * Gets the index at which the first occurrence of `NaN` is found in `array`. * @@ -687,7 +8113,7 @@ function indexOfNaN(array, fromIndex, fromRight) { module.exports = indexOfNaN; -},{}],23:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ var getLength = require('./getLength'), isLength = require('./isLength'); @@ -704,7 +8130,7 @@ function isArrayLike(value) { module.exports = isArrayLike; -},{"./getLength":20,"./isLength":26}],24:[function(require,module,exports){ +},{"./getLength":22,"./isLength":28}],26:[function(require,module,exports){ /** Used to detect unsigned integer values. */ var reIsUint = /^\d+$/; @@ -730,7 +8156,7 @@ function isIndex(value, length) { module.exports = isIndex; -},{}],25:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ var isArrayLike = require('./isArrayLike'), isIndex = require('./isIndex'), isObject = require('../lang/isObject'); @@ -760,7 +8186,7 @@ function isIterateeCall(value, index, object) { module.exports = isIterateeCall; -},{"../lang/isObject":35,"./isArrayLike":23,"./isIndex":24}],26:[function(require,module,exports){ +},{"../lang/isObject":37,"./isArrayLike":25,"./isIndex":26}],28:[function(require,module,exports){ /** * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) * of an array-like value. @@ -782,7 +8208,7 @@ function isLength(value) { module.exports = isLength; -},{}],27:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ /** * Checks if `value` is object-like. * @@ -796,7 +8222,7 @@ function isObjectLike(value) { module.exports = isObjectLike; -},{}],28:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ var toObject = require('./toObject'); /** @@ -826,7 +8252,7 @@ function pickByArray(object, props) { module.exports = pickByArray; -},{"./toObject":30}],29:[function(require,module,exports){ +},{"./toObject":32}],31:[function(require,module,exports){ var baseForIn = require('./baseForIn'); /** @@ -850,7 +8276,7 @@ function pickByCallback(object, predicate) { module.exports = pickByCallback; -},{"./baseForIn":9}],30:[function(require,module,exports){ +},{"./baseForIn":11}],32:[function(require,module,exports){ var isObject = require('../lang/isObject'); /** @@ -866,7 +8292,7 @@ function toObject(value) { module.exports = toObject; -},{"../lang/isObject":35}],31:[function(require,module,exports){ +},{"../lang/isObject":37}],33:[function(require,module,exports){ var isArrayLike = require('../internal/isArrayLike'), isObjectLike = require('../internal/isObjectLike'); @@ -902,7 +8328,7 @@ function isArguments(value) { module.exports = isArguments; -},{"../internal/isArrayLike":23,"../internal/isObjectLike":27}],32:[function(require,module,exports){ +},{"../internal/isArrayLike":25,"../internal/isObjectLike":29}],34:[function(require,module,exports){ var getNative = require('../internal/getNative'), isLength = require('../internal/isLength'), isObjectLike = require('../internal/isObjectLike'); @@ -944,7 +8370,7 @@ var isArray = nativeIsArray || function(value) { module.exports = isArray; -},{"../internal/getNative":21,"../internal/isLength":26,"../internal/isObjectLike":27}],33:[function(require,module,exports){ +},{"../internal/getNative":23,"../internal/isLength":28,"../internal/isObjectLike":29}],35:[function(require,module,exports){ var isObject = require('./isObject'); /** `Object#toString` result references. */ @@ -984,7 +8410,7 @@ function isFunction(value) { module.exports = isFunction; -},{"./isObject":35}],34:[function(require,module,exports){ +},{"./isObject":37}],36:[function(require,module,exports){ var isFunction = require('./isFunction'), isObjectLike = require('../internal/isObjectLike'); @@ -1034,7 +8460,7 @@ function isNative(value) { module.exports = isNative; -},{"../internal/isObjectLike":27,"./isFunction":33}],35:[function(require,module,exports){ +},{"../internal/isObjectLike":29,"./isFunction":35}],37:[function(require,module,exports){ /** * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) @@ -1064,7 +8490,7 @@ function isObject(value) { module.exports = isObject; -},{}],36:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ var isArguments = require('../lang/isArguments'), isArray = require('../lang/isArray'), isIndex = require('../internal/isIndex'), @@ -1130,7 +8556,7 @@ function keysIn(object) { module.exports = keysIn; -},{"../internal/isIndex":24,"../internal/isLength":26,"../lang/isArguments":31,"../lang/isArray":32,"../lang/isObject":35}],37:[function(require,module,exports){ +},{"../internal/isIndex":26,"../internal/isLength":28,"../lang/isArguments":33,"../lang/isArray":34,"../lang/isObject":37}],39:[function(require,module,exports){ var arrayMap = require('../internal/arrayMap'), baseDifference = require('../internal/baseDifference'), baseFlatten = require('../internal/baseFlatten'), @@ -1179,7 +8605,7 @@ var omit = restParam(function(object, props) { module.exports = omit; -},{"../function/restParam":2,"../internal/arrayMap":4,"../internal/baseDifference":6,"../internal/baseFlatten":7,"../internal/bindCallback":13,"../internal/pickByArray":28,"../internal/pickByCallback":29,"./keysIn":36}],38:[function(require,module,exports){ +},{"../function/restParam":4,"../internal/arrayMap":6,"../internal/baseDifference":8,"../internal/baseFlatten":9,"../internal/bindCallback":15,"../internal/pickByArray":30,"../internal/pickByCallback":31,"./keysIn":38}],40:[function(require,module,exports){ var createCompounder = require('../internal/createCompounder'); /** @@ -1208,7 +8634,7 @@ var camelCase = createCompounder(function(result, word, index) { module.exports = camelCase; -},{"../internal/createCompounder":18}],39:[function(require,module,exports){ +},{"../internal/createCompounder":20}],41:[function(require,module,exports){ var baseToString = require('../internal/baseToString'), deburrLetter = require('../internal/deburrLetter'); @@ -1239,7 +8665,7 @@ function deburr(string) { module.exports = deburr; -},{"../internal/baseToString":12,"../internal/deburrLetter":19}],40:[function(require,module,exports){ +},{"../internal/baseToString":14,"../internal/deburrLetter":21}],42:[function(require,module,exports){ var baseToString = require('../internal/baseToString'), isIterateeCall = require('../internal/isIterateeCall'); @@ -1279,7 +8705,7 @@ function words(string, pattern, guard) { module.exports = words; -},{"../internal/baseToString":12,"../internal/isIterateeCall":25}],41:[function(require,module,exports){ +},{"../internal/baseToString":14,"../internal/isIterateeCall":27}],43:[function(require,module,exports){ /** * This method returns the first argument provided to it. * @@ -1301,7 +8727,7 @@ function identity(value) { module.exports = identity; -},{}],42:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -1325,7 +8751,7 @@ function createAll(React) { } module.exports = exports['default']; -},{"./createConnect":43,"./createProvider":44}],43:[function(require,module,exports){ +},{"./createConnect":45,"./createProvider":46}],45:[function(require,module,exports){ (function (process){ 'use strict'; @@ -1594,7 +9020,7 @@ function createConnect(React) { module.exports = exports['default']; }).call(this,require('_process')) -},{"../utils/createStoreShape":46,"../utils/isPlainObject":47,"../utils/shallowEqual":48,"../utils/wrapActionCreators":49,"_process":1,"invariant":50}],44:[function(require,module,exports){ +},{"../utils/createStoreShape":48,"../utils/isPlainObject":49,"../utils/shallowEqual":50,"../utils/wrapActionCreators":51,"_process":1,"invariant":52}],46:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -1712,7 +9138,7 @@ function createProvider(React) { } module.exports = exports['default']; -},{"../utils/createStoreShape":46}],45:[function(require,module,exports){ +},{"../utils/createStoreShape":48}],47:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -1733,7 +9159,7 @@ var Provider = _createAll.Provider; var connect = _createAll.connect; exports.Provider = Provider; exports.connect = connect; -},{"./components/createAll":42,"react":205}],46:[function(require,module,exports){ +},{"./components/createAll":44,"react":207}],48:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -1748,7 +9174,7 @@ function createStoreShape(PropTypes) { } module.exports = exports["default"]; -},{}],47:[function(require,module,exports){ +},{}],49:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -1779,7 +9205,7 @@ function isPlainObject(obj) { } module.exports = exports['default']; -},{}],48:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -1809,7 +9235,7 @@ function shallowEqual(objA, objB) { } module.exports = exports["default"]; -},{}],49:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -1824,7 +9250,7 @@ function wrapActionCreators(actionCreators) { } module.exports = exports['default']; -},{"redux":207}],50:[function(require,module,exports){ +},{"redux":209}],52:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -1881,7 +9307,7 @@ var invariant = function(condition, format, a, b, c, d, e, f) { module.exports = invariant; }).call(this,require('_process')) -},{"_process":1}],51:[function(require,module,exports){ +},{"_process":1}],53:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -1908,7 +9334,7 @@ var AutoFocusMixin = { module.exports = AutoFocusMixin; -},{"./focusNode":169}],52:[function(require,module,exports){ +},{"./focusNode":171}],54:[function(require,module,exports){ /** * Copyright 2013-2015 Facebook, Inc. * All rights reserved. @@ -2403,7 +9829,7 @@ var BeforeInputEventPlugin = { module.exports = BeforeInputEventPlugin; -},{"./EventConstants":64,"./EventPropagators":69,"./ExecutionEnvironment":70,"./FallbackCompositionState":71,"./SyntheticCompositionEvent":143,"./SyntheticInputEvent":147,"./keyOf":191}],53:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPropagators":71,"./ExecutionEnvironment":72,"./FallbackCompositionState":73,"./SyntheticCompositionEvent":145,"./SyntheticInputEvent":149,"./keyOf":193}],55:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -2528,7 +9954,7 @@ var CSSProperty = { module.exports = CSSProperty; -},{}],54:[function(require,module,exports){ +},{}],56:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -2710,7 +10136,7 @@ var CSSPropertyOperations = { module.exports = CSSPropertyOperations; }).call(this,require('_process')) -},{"./CSSProperty":53,"./ExecutionEnvironment":70,"./camelizeStyleName":158,"./dangerousStyleValue":163,"./hyphenateStyleName":183,"./memoizeStringOnly":193,"./warning":204,"_process":1}],55:[function(require,module,exports){ +},{"./CSSProperty":55,"./ExecutionEnvironment":72,"./camelizeStyleName":160,"./dangerousStyleValue":165,"./hyphenateStyleName":185,"./memoizeStringOnly":195,"./warning":206,"_process":1}],57:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -2810,7 +10236,7 @@ PooledClass.addPoolingTo(CallbackQueue); module.exports = CallbackQueue; }).call(this,require('_process')) -},{"./Object.assign":76,"./PooledClass":77,"./invariant":185,"_process":1}],56:[function(require,module,exports){ +},{"./Object.assign":78,"./PooledClass":79,"./invariant":187,"_process":1}],58:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -3192,7 +10618,7 @@ var ChangeEventPlugin = { module.exports = ChangeEventPlugin; -},{"./EventConstants":64,"./EventPluginHub":66,"./EventPropagators":69,"./ExecutionEnvironment":70,"./ReactUpdates":137,"./SyntheticEvent":145,"./isEventSupported":186,"./isTextInputElement":188,"./keyOf":191}],57:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPluginHub":68,"./EventPropagators":71,"./ExecutionEnvironment":72,"./ReactUpdates":139,"./SyntheticEvent":147,"./isEventSupported":188,"./isTextInputElement":190,"./keyOf":193}],59:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -3217,7 +10643,7 @@ var ClientReactRootIndex = { module.exports = ClientReactRootIndex; -},{}],58:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -3355,7 +10781,7 @@ var DOMChildrenOperations = { module.exports = DOMChildrenOperations; }).call(this,require('_process')) -},{"./Danger":61,"./ReactMultiChildUpdateTypes":122,"./invariant":185,"./setTextContent":199,"_process":1}],59:[function(require,module,exports){ +},{"./Danger":63,"./ReactMultiChildUpdateTypes":124,"./invariant":187,"./setTextContent":201,"_process":1}],61:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -3654,7 +11080,7 @@ var DOMProperty = { module.exports = DOMProperty; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],60:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],62:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -3846,7 +11272,7 @@ var DOMPropertyOperations = { module.exports = DOMPropertyOperations; }).call(this,require('_process')) -},{"./DOMProperty":59,"./quoteAttributeValueForBrowser":197,"./warning":204,"_process":1}],61:[function(require,module,exports){ +},{"./DOMProperty":61,"./quoteAttributeValueForBrowser":199,"./warning":206,"_process":1}],63:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4033,7 +11459,7 @@ var Danger = { module.exports = Danger; }).call(this,require('_process')) -},{"./ExecutionEnvironment":70,"./createNodesFromMarkup":162,"./emptyFunction":164,"./getMarkupWrap":177,"./invariant":185,"_process":1}],62:[function(require,module,exports){ +},{"./ExecutionEnvironment":72,"./createNodesFromMarkup":164,"./emptyFunction":166,"./getMarkupWrap":179,"./invariant":187,"_process":1}],64:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -4072,7 +11498,7 @@ var DefaultEventPluginOrder = [ module.exports = DefaultEventPluginOrder; -},{"./keyOf":191}],63:[function(require,module,exports){ +},{"./keyOf":193}],65:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -4212,7 +11638,7 @@ var EnterLeaveEventPlugin = { module.exports = EnterLeaveEventPlugin; -},{"./EventConstants":64,"./EventPropagators":69,"./ReactMount":120,"./SyntheticMouseEvent":149,"./keyOf":191}],64:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPropagators":71,"./ReactMount":122,"./SyntheticMouseEvent":151,"./keyOf":193}],66:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -4284,7 +11710,7 @@ var EventConstants = { module.exports = EventConstants; -},{"./keyMirror":190}],65:[function(require,module,exports){ +},{"./keyMirror":192}],67:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4374,7 +11800,7 @@ var EventListener = { module.exports = EventListener; }).call(this,require('_process')) -},{"./emptyFunction":164,"_process":1}],66:[function(require,module,exports){ +},{"./emptyFunction":166,"_process":1}],68:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4652,7 +12078,7 @@ var EventPluginHub = { module.exports = EventPluginHub; }).call(this,require('_process')) -},{"./EventPluginRegistry":67,"./EventPluginUtils":68,"./accumulateInto":155,"./forEachAccumulated":170,"./invariant":185,"_process":1}],67:[function(require,module,exports){ +},{"./EventPluginRegistry":69,"./EventPluginUtils":70,"./accumulateInto":157,"./forEachAccumulated":172,"./invariant":187,"_process":1}],69:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4932,7 +12358,7 @@ var EventPluginRegistry = { module.exports = EventPluginRegistry; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],68:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],70:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -5153,7 +12579,7 @@ var EventPluginUtils = { module.exports = EventPluginUtils; }).call(this,require('_process')) -},{"./EventConstants":64,"./invariant":185,"_process":1}],69:[function(require,module,exports){ +},{"./EventConstants":66,"./invariant":187,"_process":1}],71:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -5295,7 +12721,7 @@ var EventPropagators = { module.exports = EventPropagators; }).call(this,require('_process')) -},{"./EventConstants":64,"./EventPluginHub":66,"./accumulateInto":155,"./forEachAccumulated":170,"_process":1}],70:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPluginHub":68,"./accumulateInto":157,"./forEachAccumulated":172,"_process":1}],72:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -5339,7 +12765,7 @@ var ExecutionEnvironment = { module.exports = ExecutionEnvironment; -},{}],71:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -5430,7 +12856,7 @@ PooledClass.addPoolingTo(FallbackCompositionState); module.exports = FallbackCompositionState; -},{"./Object.assign":76,"./PooledClass":77,"./getTextContentAccessor":180}],72:[function(require,module,exports){ +},{"./Object.assign":78,"./PooledClass":79,"./getTextContentAccessor":182}],74:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -5641,7 +13067,7 @@ var HTMLDOMPropertyConfig = { module.exports = HTMLDOMPropertyConfig; -},{"./DOMProperty":59,"./ExecutionEnvironment":70}],73:[function(require,module,exports){ +},{"./DOMProperty":61,"./ExecutionEnvironment":72}],75:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -5797,7 +13223,7 @@ var LinkedValueUtils = { module.exports = LinkedValueUtils; }).call(this,require('_process')) -},{"./ReactPropTypes":128,"./invariant":185,"_process":1}],74:[function(require,module,exports){ +},{"./ReactPropTypes":130,"./invariant":187,"_process":1}],76:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -5854,7 +13280,7 @@ var LocalEventTrapMixin = { module.exports = LocalEventTrapMixin; }).call(this,require('_process')) -},{"./ReactBrowserEventEmitter":80,"./accumulateInto":155,"./forEachAccumulated":170,"./invariant":185,"_process":1}],75:[function(require,module,exports){ +},{"./ReactBrowserEventEmitter":82,"./accumulateInto":157,"./forEachAccumulated":172,"./invariant":187,"_process":1}],77:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -5912,7 +13338,7 @@ var MobileSafariClickEventPlugin = { module.exports = MobileSafariClickEventPlugin; -},{"./EventConstants":64,"./emptyFunction":164}],76:[function(require,module,exports){ +},{"./EventConstants":66,"./emptyFunction":166}],78:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -5961,7 +13387,7 @@ function assign(target, sources) { module.exports = assign; -},{}],77:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -6077,7 +13503,7 @@ var PooledClass = { module.exports = PooledClass; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],78:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],80:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -6229,7 +13655,7 @@ React.version = '0.13.3'; module.exports = React; }).call(this,require('_process')) -},{"./EventPluginUtils":68,"./ExecutionEnvironment":70,"./Object.assign":76,"./ReactChildren":82,"./ReactClass":83,"./ReactComponent":84,"./ReactContext":88,"./ReactCurrentOwner":89,"./ReactDOM":90,"./ReactDOMTextComponent":101,"./ReactDefaultInjection":104,"./ReactElement":107,"./ReactElementValidator":108,"./ReactInstanceHandles":116,"./ReactMount":120,"./ReactPerf":125,"./ReactPropTypes":128,"./ReactReconciler":131,"./ReactServerRendering":134,"./findDOMNode":167,"./onlyChild":194,"_process":1}],79:[function(require,module,exports){ +},{"./EventPluginUtils":70,"./ExecutionEnvironment":72,"./Object.assign":78,"./ReactChildren":84,"./ReactClass":85,"./ReactComponent":86,"./ReactContext":90,"./ReactCurrentOwner":91,"./ReactDOM":92,"./ReactDOMTextComponent":103,"./ReactDefaultInjection":106,"./ReactElement":109,"./ReactElementValidator":110,"./ReactInstanceHandles":118,"./ReactMount":122,"./ReactPerf":127,"./ReactPropTypes":130,"./ReactReconciler":133,"./ReactServerRendering":136,"./findDOMNode":169,"./onlyChild":196,"_process":1}],81:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -6260,7 +13686,7 @@ var ReactBrowserComponentMixin = { module.exports = ReactBrowserComponentMixin; -},{"./findDOMNode":167}],80:[function(require,module,exports){ +},{"./findDOMNode":169}],82:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -6613,7 +14039,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, { module.exports = ReactBrowserEventEmitter; -},{"./EventConstants":64,"./EventPluginHub":66,"./EventPluginRegistry":67,"./Object.assign":76,"./ReactEventEmitterMixin":111,"./ViewportMetrics":154,"./isEventSupported":186}],81:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPluginHub":68,"./EventPluginRegistry":69,"./Object.assign":78,"./ReactEventEmitterMixin":113,"./ViewportMetrics":156,"./isEventSupported":188}],83:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -6740,7 +14166,7 @@ var ReactChildReconciler = { module.exports = ReactChildReconciler; -},{"./ReactReconciler":131,"./flattenChildren":168,"./instantiateReactComponent":184,"./shouldUpdateReactComponent":201}],82:[function(require,module,exports){ +},{"./ReactReconciler":133,"./flattenChildren":170,"./instantiateReactComponent":186,"./shouldUpdateReactComponent":203}],84:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -6893,7 +14319,7 @@ var ReactChildren = { module.exports = ReactChildren; }).call(this,require('_process')) -},{"./PooledClass":77,"./ReactFragment":113,"./traverseAllChildren":203,"./warning":204,"_process":1}],83:[function(require,module,exports){ +},{"./PooledClass":79,"./ReactFragment":115,"./traverseAllChildren":205,"./warning":206,"_process":1}],85:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -7839,7 +15265,7 @@ var ReactClass = { module.exports = ReactClass; }).call(this,require('_process')) -},{"./Object.assign":76,"./ReactComponent":84,"./ReactCurrentOwner":89,"./ReactElement":107,"./ReactErrorUtils":110,"./ReactInstanceMap":117,"./ReactLifeCycle":118,"./ReactPropTypeLocationNames":126,"./ReactPropTypeLocations":127,"./ReactUpdateQueue":136,"./invariant":185,"./keyMirror":190,"./keyOf":191,"./warning":204,"_process":1}],84:[function(require,module,exports){ +},{"./Object.assign":78,"./ReactComponent":86,"./ReactCurrentOwner":91,"./ReactElement":109,"./ReactErrorUtils":112,"./ReactInstanceMap":119,"./ReactLifeCycle":120,"./ReactPropTypeLocationNames":128,"./ReactPropTypeLocations":129,"./ReactUpdateQueue":138,"./invariant":187,"./keyMirror":192,"./keyOf":193,"./warning":206,"_process":1}],86:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -7993,7 +15419,7 @@ if ("production" !== process.env.NODE_ENV) { module.exports = ReactComponent; }).call(this,require('_process')) -},{"./ReactUpdateQueue":136,"./invariant":185,"./warning":204,"_process":1}],85:[function(require,module,exports){ +},{"./ReactUpdateQueue":138,"./invariant":187,"./warning":206,"_process":1}],87:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -8040,7 +15466,7 @@ var ReactComponentBrowserEnvironment = { module.exports = ReactComponentBrowserEnvironment; -},{"./ReactDOMIDOperations":94,"./ReactMount":120}],86:[function(require,module,exports){ +},{"./ReactDOMIDOperations":96,"./ReactMount":122}],88:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -8101,7 +15527,7 @@ var ReactComponentEnvironment = { module.exports = ReactComponentEnvironment; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],87:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],89:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -9014,7 +16440,7 @@ var ReactCompositeComponent = { module.exports = ReactCompositeComponent; }).call(this,require('_process')) -},{"./Object.assign":76,"./ReactComponentEnvironment":86,"./ReactContext":88,"./ReactCurrentOwner":89,"./ReactElement":107,"./ReactElementValidator":108,"./ReactInstanceMap":117,"./ReactLifeCycle":118,"./ReactNativeComponent":123,"./ReactPerf":125,"./ReactPropTypeLocationNames":126,"./ReactPropTypeLocations":127,"./ReactReconciler":131,"./ReactUpdates":137,"./emptyObject":165,"./invariant":185,"./shouldUpdateReactComponent":201,"./warning":204,"_process":1}],88:[function(require,module,exports){ +},{"./Object.assign":78,"./ReactComponentEnvironment":88,"./ReactContext":90,"./ReactCurrentOwner":91,"./ReactElement":109,"./ReactElementValidator":110,"./ReactInstanceMap":119,"./ReactLifeCycle":120,"./ReactNativeComponent":125,"./ReactPerf":127,"./ReactPropTypeLocationNames":128,"./ReactPropTypeLocations":129,"./ReactReconciler":133,"./ReactUpdates":139,"./emptyObject":167,"./invariant":187,"./shouldUpdateReactComponent":203,"./warning":206,"_process":1}],90:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -9092,7 +16518,7 @@ var ReactContext = { module.exports = ReactContext; }).call(this,require('_process')) -},{"./Object.assign":76,"./emptyObject":165,"./warning":204,"_process":1}],89:[function(require,module,exports){ +},{"./Object.assign":78,"./emptyObject":167,"./warning":206,"_process":1}],91:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9126,7 +16552,7 @@ var ReactCurrentOwner = { module.exports = ReactCurrentOwner; -},{}],90:[function(require,module,exports){ +},{}],92:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -9305,7 +16731,7 @@ var ReactDOM = mapObject({ module.exports = ReactDOM; }).call(this,require('_process')) -},{"./ReactElement":107,"./ReactElementValidator":108,"./mapObject":192,"_process":1}],91:[function(require,module,exports){ +},{"./ReactElement":109,"./ReactElementValidator":110,"./mapObject":194,"_process":1}],93:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9369,7 +16795,7 @@ var ReactDOMButton = ReactClass.createClass({ module.exports = ReactDOMButton; -},{"./AutoFocusMixin":51,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107,"./keyMirror":190}],92:[function(require,module,exports){ +},{"./AutoFocusMixin":53,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109,"./keyMirror":192}],94:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -9879,7 +17305,7 @@ ReactDOMComponent.injection = { module.exports = ReactDOMComponent; }).call(this,require('_process')) -},{"./CSSPropertyOperations":54,"./DOMProperty":59,"./DOMPropertyOperations":60,"./Object.assign":76,"./ReactBrowserEventEmitter":80,"./ReactComponentBrowserEnvironment":85,"./ReactMount":120,"./ReactMultiChild":121,"./ReactPerf":125,"./escapeTextContentForBrowser":166,"./invariant":185,"./isEventSupported":186,"./keyOf":191,"./warning":204,"_process":1}],93:[function(require,module,exports){ +},{"./CSSPropertyOperations":56,"./DOMProperty":61,"./DOMPropertyOperations":62,"./Object.assign":78,"./ReactBrowserEventEmitter":82,"./ReactComponentBrowserEnvironment":87,"./ReactMount":122,"./ReactMultiChild":123,"./ReactPerf":127,"./escapeTextContentForBrowser":168,"./invariant":187,"./isEventSupported":188,"./keyOf":193,"./warning":206,"_process":1}],95:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9928,7 +17354,7 @@ var ReactDOMForm = ReactClass.createClass({ module.exports = ReactDOMForm; -},{"./EventConstants":64,"./LocalEventTrapMixin":74,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107}],94:[function(require,module,exports){ +},{"./EventConstants":66,"./LocalEventTrapMixin":76,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109}],96:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -10096,7 +17522,7 @@ ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', { module.exports = ReactDOMIDOperations; }).call(this,require('_process')) -},{"./CSSPropertyOperations":54,"./DOMChildrenOperations":58,"./DOMPropertyOperations":60,"./ReactMount":120,"./ReactPerf":125,"./invariant":185,"./setInnerHTML":198,"_process":1}],95:[function(require,module,exports){ +},{"./CSSPropertyOperations":56,"./DOMChildrenOperations":60,"./DOMPropertyOperations":62,"./ReactMount":122,"./ReactPerf":127,"./invariant":187,"./setInnerHTML":200,"_process":1}],97:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10141,7 +17567,7 @@ var ReactDOMIframe = ReactClass.createClass({ module.exports = ReactDOMIframe; -},{"./EventConstants":64,"./LocalEventTrapMixin":74,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107}],96:[function(require,module,exports){ +},{"./EventConstants":66,"./LocalEventTrapMixin":76,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109}],98:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10187,7 +17613,7 @@ var ReactDOMImg = ReactClass.createClass({ module.exports = ReactDOMImg; -},{"./EventConstants":64,"./LocalEventTrapMixin":74,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107}],97:[function(require,module,exports){ +},{"./EventConstants":66,"./LocalEventTrapMixin":76,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109}],99:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -10364,7 +17790,7 @@ var ReactDOMInput = ReactClass.createClass({ module.exports = ReactDOMInput; }).call(this,require('_process')) -},{"./AutoFocusMixin":51,"./DOMPropertyOperations":60,"./LinkedValueUtils":73,"./Object.assign":76,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107,"./ReactMount":120,"./ReactUpdates":137,"./invariant":185,"_process":1}],98:[function(require,module,exports){ +},{"./AutoFocusMixin":53,"./DOMPropertyOperations":62,"./LinkedValueUtils":75,"./Object.assign":78,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109,"./ReactMount":122,"./ReactUpdates":139,"./invariant":187,"_process":1}],100:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -10416,7 +17842,7 @@ var ReactDOMOption = ReactClass.createClass({ module.exports = ReactDOMOption; }).call(this,require('_process')) -},{"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107,"./warning":204,"_process":1}],99:[function(require,module,exports){ +},{"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109,"./warning":206,"_process":1}],101:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10594,7 +18020,7 @@ var ReactDOMSelect = ReactClass.createClass({ module.exports = ReactDOMSelect; -},{"./AutoFocusMixin":51,"./LinkedValueUtils":73,"./Object.assign":76,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107,"./ReactUpdates":137}],100:[function(require,module,exports){ +},{"./AutoFocusMixin":53,"./LinkedValueUtils":75,"./Object.assign":78,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109,"./ReactUpdates":139}],102:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10807,7 +18233,7 @@ var ReactDOMSelection = { module.exports = ReactDOMSelection; -},{"./ExecutionEnvironment":70,"./getNodeForCharacterOffset":178,"./getTextContentAccessor":180}],101:[function(require,module,exports){ +},{"./ExecutionEnvironment":72,"./getNodeForCharacterOffset":180,"./getTextContentAccessor":182}],103:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10924,7 +18350,7 @@ assign(ReactDOMTextComponent.prototype, { module.exports = ReactDOMTextComponent; -},{"./DOMPropertyOperations":60,"./Object.assign":76,"./ReactComponentBrowserEnvironment":85,"./ReactDOMComponent":92,"./escapeTextContentForBrowser":166}],102:[function(require,module,exports){ +},{"./DOMPropertyOperations":62,"./Object.assign":78,"./ReactComponentBrowserEnvironment":87,"./ReactDOMComponent":94,"./escapeTextContentForBrowser":168}],104:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -11064,7 +18490,7 @@ var ReactDOMTextarea = ReactClass.createClass({ module.exports = ReactDOMTextarea; }).call(this,require('_process')) -},{"./AutoFocusMixin":51,"./DOMPropertyOperations":60,"./LinkedValueUtils":73,"./Object.assign":76,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactElement":107,"./ReactUpdates":137,"./invariant":185,"./warning":204,"_process":1}],103:[function(require,module,exports){ +},{"./AutoFocusMixin":53,"./DOMPropertyOperations":62,"./LinkedValueUtils":75,"./Object.assign":78,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactElement":109,"./ReactUpdates":139,"./invariant":187,"./warning":206,"_process":1}],105:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11137,7 +18563,7 @@ var ReactDefaultBatchingStrategy = { module.exports = ReactDefaultBatchingStrategy; -},{"./Object.assign":76,"./ReactUpdates":137,"./Transaction":153,"./emptyFunction":164}],104:[function(require,module,exports){ +},{"./Object.assign":78,"./ReactUpdates":139,"./Transaction":155,"./emptyFunction":166}],106:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -11296,7 +18722,7 @@ module.exports = { }; }).call(this,require('_process')) -},{"./BeforeInputEventPlugin":52,"./ChangeEventPlugin":56,"./ClientReactRootIndex":57,"./DefaultEventPluginOrder":62,"./EnterLeaveEventPlugin":63,"./ExecutionEnvironment":70,"./HTMLDOMPropertyConfig":72,"./MobileSafariClickEventPlugin":75,"./ReactBrowserComponentMixin":79,"./ReactClass":83,"./ReactComponentBrowserEnvironment":85,"./ReactDOMButton":91,"./ReactDOMComponent":92,"./ReactDOMForm":93,"./ReactDOMIDOperations":94,"./ReactDOMIframe":95,"./ReactDOMImg":96,"./ReactDOMInput":97,"./ReactDOMOption":98,"./ReactDOMSelect":99,"./ReactDOMTextComponent":101,"./ReactDOMTextarea":102,"./ReactDefaultBatchingStrategy":103,"./ReactDefaultPerf":105,"./ReactElement":107,"./ReactEventListener":112,"./ReactInjection":114,"./ReactInstanceHandles":116,"./ReactMount":120,"./ReactReconcileTransaction":130,"./SVGDOMPropertyConfig":138,"./SelectEventPlugin":139,"./ServerReactRootIndex":140,"./SimpleEventPlugin":141,"./createFullPageComponent":161,"_process":1}],105:[function(require,module,exports){ +},{"./BeforeInputEventPlugin":54,"./ChangeEventPlugin":58,"./ClientReactRootIndex":59,"./DefaultEventPluginOrder":64,"./EnterLeaveEventPlugin":65,"./ExecutionEnvironment":72,"./HTMLDOMPropertyConfig":74,"./MobileSafariClickEventPlugin":77,"./ReactBrowserComponentMixin":81,"./ReactClass":85,"./ReactComponentBrowserEnvironment":87,"./ReactDOMButton":93,"./ReactDOMComponent":94,"./ReactDOMForm":95,"./ReactDOMIDOperations":96,"./ReactDOMIframe":97,"./ReactDOMImg":98,"./ReactDOMInput":99,"./ReactDOMOption":100,"./ReactDOMSelect":101,"./ReactDOMTextComponent":103,"./ReactDOMTextarea":104,"./ReactDefaultBatchingStrategy":105,"./ReactDefaultPerf":107,"./ReactElement":109,"./ReactEventListener":114,"./ReactInjection":116,"./ReactInstanceHandles":118,"./ReactMount":122,"./ReactReconcileTransaction":132,"./SVGDOMPropertyConfig":140,"./SelectEventPlugin":141,"./ServerReactRootIndex":142,"./SimpleEventPlugin":143,"./createFullPageComponent":163,"_process":1}],107:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11562,7 +18988,7 @@ var ReactDefaultPerf = { module.exports = ReactDefaultPerf; -},{"./DOMProperty":59,"./ReactDefaultPerfAnalysis":106,"./ReactMount":120,"./ReactPerf":125,"./performanceNow":196}],106:[function(require,module,exports){ +},{"./DOMProperty":61,"./ReactDefaultPerfAnalysis":108,"./ReactMount":122,"./ReactPerf":127,"./performanceNow":198}],108:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11768,7 +19194,7 @@ var ReactDefaultPerfAnalysis = { module.exports = ReactDefaultPerfAnalysis; -},{"./Object.assign":76}],107:[function(require,module,exports){ +},{"./Object.assign":78}],109:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -12076,7 +19502,7 @@ ReactElement.isValidElement = function(object) { module.exports = ReactElement; }).call(this,require('_process')) -},{"./Object.assign":76,"./ReactContext":88,"./ReactCurrentOwner":89,"./warning":204,"_process":1}],108:[function(require,module,exports){ +},{"./Object.assign":78,"./ReactContext":90,"./ReactCurrentOwner":91,"./warning":206,"_process":1}],110:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -12541,7 +19967,7 @@ var ReactElementValidator = { module.exports = ReactElementValidator; }).call(this,require('_process')) -},{"./ReactCurrentOwner":89,"./ReactElement":107,"./ReactFragment":113,"./ReactNativeComponent":123,"./ReactPropTypeLocationNames":126,"./ReactPropTypeLocations":127,"./getIteratorFn":176,"./invariant":185,"./warning":204,"_process":1}],109:[function(require,module,exports){ +},{"./ReactCurrentOwner":91,"./ReactElement":109,"./ReactFragment":115,"./ReactNativeComponent":125,"./ReactPropTypeLocationNames":128,"./ReactPropTypeLocations":129,"./getIteratorFn":178,"./invariant":187,"./warning":206,"_process":1}],111:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -12636,7 +20062,7 @@ var ReactEmptyComponent = { module.exports = ReactEmptyComponent; }).call(this,require('_process')) -},{"./ReactElement":107,"./ReactInstanceMap":117,"./invariant":185,"_process":1}],110:[function(require,module,exports){ +},{"./ReactElement":109,"./ReactInstanceMap":119,"./invariant":187,"_process":1}],112:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -12668,7 +20094,7 @@ var ReactErrorUtils = { module.exports = ReactErrorUtils; -},{}],111:[function(require,module,exports){ +},{}],113:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -12718,7 +20144,7 @@ var ReactEventEmitterMixin = { module.exports = ReactEventEmitterMixin; -},{"./EventPluginHub":66}],112:[function(require,module,exports){ +},{"./EventPluginHub":68}],114:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -12901,7 +20327,7 @@ var ReactEventListener = { module.exports = ReactEventListener; -},{"./EventListener":65,"./ExecutionEnvironment":70,"./Object.assign":76,"./PooledClass":77,"./ReactInstanceHandles":116,"./ReactMount":120,"./ReactUpdates":137,"./getEventTarget":175,"./getUnboundedScrollPosition":181}],113:[function(require,module,exports){ +},{"./EventListener":67,"./ExecutionEnvironment":72,"./Object.assign":78,"./PooledClass":79,"./ReactInstanceHandles":118,"./ReactMount":122,"./ReactUpdates":139,"./getEventTarget":177,"./getUnboundedScrollPosition":183}],115:[function(require,module,exports){ (function (process){ /** * Copyright 2015, Facebook, Inc. @@ -13086,7 +20512,7 @@ var ReactFragment = { module.exports = ReactFragment; }).call(this,require('_process')) -},{"./ReactElement":107,"./warning":204,"_process":1}],114:[function(require,module,exports){ +},{"./ReactElement":109,"./warning":206,"_process":1}],116:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13128,7 +20554,7 @@ var ReactInjection = { module.exports = ReactInjection; -},{"./DOMProperty":59,"./EventPluginHub":66,"./ReactBrowserEventEmitter":80,"./ReactClass":83,"./ReactComponentEnvironment":86,"./ReactDOMComponent":92,"./ReactEmptyComponent":109,"./ReactNativeComponent":123,"./ReactPerf":125,"./ReactRootIndex":133,"./ReactUpdates":137}],115:[function(require,module,exports){ +},{"./DOMProperty":61,"./EventPluginHub":68,"./ReactBrowserEventEmitter":82,"./ReactClass":85,"./ReactComponentEnvironment":88,"./ReactDOMComponent":94,"./ReactEmptyComponent":111,"./ReactNativeComponent":125,"./ReactPerf":127,"./ReactRootIndex":135,"./ReactUpdates":139}],117:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13263,7 +20689,7 @@ var ReactInputSelection = { module.exports = ReactInputSelection; -},{"./ReactDOMSelection":100,"./containsNode":159,"./focusNode":169,"./getActiveElement":171}],116:[function(require,module,exports){ +},{"./ReactDOMSelection":102,"./containsNode":161,"./focusNode":171,"./getActiveElement":173}],118:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -13599,7 +21025,7 @@ var ReactInstanceHandles = { module.exports = ReactInstanceHandles; }).call(this,require('_process')) -},{"./ReactRootIndex":133,"./invariant":185,"_process":1}],117:[function(require,module,exports){ +},{"./ReactRootIndex":135,"./invariant":187,"_process":1}],119:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13648,7 +21074,7 @@ var ReactInstanceMap = { module.exports = ReactInstanceMap; -},{}],118:[function(require,module,exports){ +},{}],120:[function(require,module,exports){ /** * Copyright 2015, Facebook, Inc. * All rights reserved. @@ -13685,7 +21111,7 @@ var ReactLifeCycle = { module.exports = ReactLifeCycle; -},{}],119:[function(require,module,exports){ +},{}],121:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13733,7 +21159,7 @@ var ReactMarkupChecksum = { module.exports = ReactMarkupChecksum; -},{"./adler32":156}],120:[function(require,module,exports){ +},{"./adler32":158}],122:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -14624,7 +22050,7 @@ ReactPerf.measureMethods(ReactMount, 'ReactMount', { module.exports = ReactMount; }).call(this,require('_process')) -},{"./DOMProperty":59,"./ReactBrowserEventEmitter":80,"./ReactCurrentOwner":89,"./ReactElement":107,"./ReactElementValidator":108,"./ReactEmptyComponent":109,"./ReactInstanceHandles":116,"./ReactInstanceMap":117,"./ReactMarkupChecksum":119,"./ReactPerf":125,"./ReactReconciler":131,"./ReactUpdateQueue":136,"./ReactUpdates":137,"./containsNode":159,"./emptyObject":165,"./getReactRootElementInContainer":179,"./instantiateReactComponent":184,"./invariant":185,"./setInnerHTML":198,"./shouldUpdateReactComponent":201,"./warning":204,"_process":1}],121:[function(require,module,exports){ +},{"./DOMProperty":61,"./ReactBrowserEventEmitter":82,"./ReactCurrentOwner":91,"./ReactElement":109,"./ReactElementValidator":110,"./ReactEmptyComponent":111,"./ReactInstanceHandles":118,"./ReactInstanceMap":119,"./ReactMarkupChecksum":121,"./ReactPerf":127,"./ReactReconciler":133,"./ReactUpdateQueue":138,"./ReactUpdates":139,"./containsNode":161,"./emptyObject":167,"./getReactRootElementInContainer":181,"./instantiateReactComponent":186,"./invariant":187,"./setInnerHTML":200,"./shouldUpdateReactComponent":203,"./warning":206,"_process":1}],123:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15054,7 +22480,7 @@ var ReactMultiChild = { module.exports = ReactMultiChild; -},{"./ReactChildReconciler":81,"./ReactComponentEnvironment":86,"./ReactMultiChildUpdateTypes":122,"./ReactReconciler":131}],122:[function(require,module,exports){ +},{"./ReactChildReconciler":83,"./ReactComponentEnvironment":88,"./ReactMultiChildUpdateTypes":124,"./ReactReconciler":133}],124:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15087,7 +22513,7 @@ var ReactMultiChildUpdateTypes = keyMirror({ module.exports = ReactMultiChildUpdateTypes; -},{"./keyMirror":190}],123:[function(require,module,exports){ +},{"./keyMirror":192}],125:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -15194,7 +22620,7 @@ var ReactNativeComponent = { module.exports = ReactNativeComponent; }).call(this,require('_process')) -},{"./Object.assign":76,"./invariant":185,"_process":1}],124:[function(require,module,exports){ +},{"./Object.assign":78,"./invariant":187,"_process":1}],126:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -15306,7 +22732,7 @@ var ReactOwner = { module.exports = ReactOwner; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],125:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],127:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -15410,7 +22836,7 @@ function _noMeasure(objName, fnName, func) { module.exports = ReactPerf; }).call(this,require('_process')) -},{"_process":1}],126:[function(require,module,exports){ +},{"_process":1}],128:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -15438,7 +22864,7 @@ if ("production" !== process.env.NODE_ENV) { module.exports = ReactPropTypeLocationNames; }).call(this,require('_process')) -},{"_process":1}],127:[function(require,module,exports){ +},{"_process":1}],129:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15462,7 +22888,7 @@ var ReactPropTypeLocations = keyMirror({ module.exports = ReactPropTypeLocations; -},{"./keyMirror":190}],128:[function(require,module,exports){ +},{"./keyMirror":192}],130:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15811,7 +23237,7 @@ function getPreciseType(propValue) { module.exports = ReactPropTypes; -},{"./ReactElement":107,"./ReactFragment":113,"./ReactPropTypeLocationNames":126,"./emptyFunction":164}],129:[function(require,module,exports){ +},{"./ReactElement":109,"./ReactFragment":115,"./ReactPropTypeLocationNames":128,"./emptyFunction":166}],131:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15867,7 +23293,7 @@ PooledClass.addPoolingTo(ReactPutListenerQueue); module.exports = ReactPutListenerQueue; -},{"./Object.assign":76,"./PooledClass":77,"./ReactBrowserEventEmitter":80}],130:[function(require,module,exports){ +},{"./Object.assign":78,"./PooledClass":79,"./ReactBrowserEventEmitter":82}],132:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16043,7 +23469,7 @@ PooledClass.addPoolingTo(ReactReconcileTransaction); module.exports = ReactReconcileTransaction; -},{"./CallbackQueue":55,"./Object.assign":76,"./PooledClass":77,"./ReactBrowserEventEmitter":80,"./ReactInputSelection":115,"./ReactPutListenerQueue":129,"./Transaction":153}],131:[function(require,module,exports){ +},{"./CallbackQueue":57,"./Object.assign":78,"./PooledClass":79,"./ReactBrowserEventEmitter":82,"./ReactInputSelection":117,"./ReactPutListenerQueue":131,"./Transaction":155}],133:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -16167,7 +23593,7 @@ var ReactReconciler = { module.exports = ReactReconciler; }).call(this,require('_process')) -},{"./ReactElementValidator":108,"./ReactRef":132,"_process":1}],132:[function(require,module,exports){ +},{"./ReactElementValidator":110,"./ReactRef":134,"_process":1}],134:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16238,7 +23664,7 @@ ReactRef.detachRefs = function(instance, element) { module.exports = ReactRef; -},{"./ReactOwner":124}],133:[function(require,module,exports){ +},{"./ReactOwner":126}],135:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16269,7 +23695,7 @@ var ReactRootIndex = { module.exports = ReactRootIndex; -},{}],134:[function(require,module,exports){ +},{}],136:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -16351,7 +23777,7 @@ module.exports = { }; }).call(this,require('_process')) -},{"./ReactElement":107,"./ReactInstanceHandles":116,"./ReactMarkupChecksum":119,"./ReactServerRenderingTransaction":135,"./emptyObject":165,"./instantiateReactComponent":184,"./invariant":185,"_process":1}],135:[function(require,module,exports){ +},{"./ReactElement":109,"./ReactInstanceHandles":118,"./ReactMarkupChecksum":121,"./ReactServerRenderingTransaction":137,"./emptyObject":167,"./instantiateReactComponent":186,"./invariant":187,"_process":1}],137:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -16464,7 +23890,7 @@ PooledClass.addPoolingTo(ReactServerRenderingTransaction); module.exports = ReactServerRenderingTransaction; -},{"./CallbackQueue":55,"./Object.assign":76,"./PooledClass":77,"./ReactPutListenerQueue":129,"./Transaction":153,"./emptyFunction":164}],136:[function(require,module,exports){ +},{"./CallbackQueue":57,"./Object.assign":78,"./PooledClass":79,"./ReactPutListenerQueue":131,"./Transaction":155,"./emptyFunction":166}],138:[function(require,module,exports){ (function (process){ /** * Copyright 2015, Facebook, Inc. @@ -16763,7 +24189,7 @@ var ReactUpdateQueue = { module.exports = ReactUpdateQueue; }).call(this,require('_process')) -},{"./Object.assign":76,"./ReactCurrentOwner":89,"./ReactElement":107,"./ReactInstanceMap":117,"./ReactLifeCycle":118,"./ReactUpdates":137,"./invariant":185,"./warning":204,"_process":1}],137:[function(require,module,exports){ +},{"./Object.assign":78,"./ReactCurrentOwner":91,"./ReactElement":109,"./ReactInstanceMap":119,"./ReactLifeCycle":120,"./ReactUpdates":139,"./invariant":187,"./warning":206,"_process":1}],139:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17045,7 +24471,7 @@ var ReactUpdates = { module.exports = ReactUpdates; }).call(this,require('_process')) -},{"./CallbackQueue":55,"./Object.assign":76,"./PooledClass":77,"./ReactCurrentOwner":89,"./ReactPerf":125,"./ReactReconciler":131,"./Transaction":153,"./invariant":185,"./warning":204,"_process":1}],138:[function(require,module,exports){ +},{"./CallbackQueue":57,"./Object.assign":78,"./PooledClass":79,"./ReactCurrentOwner":91,"./ReactPerf":127,"./ReactReconciler":133,"./Transaction":155,"./invariant":187,"./warning":206,"_process":1}],140:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17139,7 +24565,7 @@ var SVGDOMPropertyConfig = { module.exports = SVGDOMPropertyConfig; -},{"./DOMProperty":59}],139:[function(require,module,exports){ +},{"./DOMProperty":61}],141:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17334,7 +24760,7 @@ var SelectEventPlugin = { module.exports = SelectEventPlugin; -},{"./EventConstants":64,"./EventPropagators":69,"./ReactInputSelection":115,"./SyntheticEvent":145,"./getActiveElement":171,"./isTextInputElement":188,"./keyOf":191,"./shallowEqual":200}],140:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPropagators":71,"./ReactInputSelection":117,"./SyntheticEvent":147,"./getActiveElement":173,"./isTextInputElement":190,"./keyOf":193,"./shallowEqual":202}],142:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17365,7 +24791,7 @@ var ServerReactRootIndex = { module.exports = ServerReactRootIndex; -},{}],141:[function(require,module,exports){ +},{}],143:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17793,7 +25219,7 @@ var SimpleEventPlugin = { module.exports = SimpleEventPlugin; }).call(this,require('_process')) -},{"./EventConstants":64,"./EventPluginUtils":68,"./EventPropagators":69,"./SyntheticClipboardEvent":142,"./SyntheticDragEvent":144,"./SyntheticEvent":145,"./SyntheticFocusEvent":146,"./SyntheticKeyboardEvent":148,"./SyntheticMouseEvent":149,"./SyntheticTouchEvent":150,"./SyntheticUIEvent":151,"./SyntheticWheelEvent":152,"./getEventCharCode":172,"./invariant":185,"./keyOf":191,"./warning":204,"_process":1}],142:[function(require,module,exports){ +},{"./EventConstants":66,"./EventPluginUtils":70,"./EventPropagators":71,"./SyntheticClipboardEvent":144,"./SyntheticDragEvent":146,"./SyntheticEvent":147,"./SyntheticFocusEvent":148,"./SyntheticKeyboardEvent":150,"./SyntheticMouseEvent":151,"./SyntheticTouchEvent":152,"./SyntheticUIEvent":153,"./SyntheticWheelEvent":154,"./getEventCharCode":174,"./invariant":187,"./keyOf":193,"./warning":206,"_process":1}],144:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17838,7 +25264,7 @@ SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface); module.exports = SyntheticClipboardEvent; -},{"./SyntheticEvent":145}],143:[function(require,module,exports){ +},{"./SyntheticEvent":147}],145:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17883,7 +25309,7 @@ SyntheticEvent.augmentClass( module.exports = SyntheticCompositionEvent; -},{"./SyntheticEvent":145}],144:[function(require,module,exports){ +},{"./SyntheticEvent":147}],146:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17922,7 +25348,7 @@ SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface); module.exports = SyntheticDragEvent; -},{"./SyntheticMouseEvent":149}],145:[function(require,module,exports){ +},{"./SyntheticMouseEvent":151}],147:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18088,7 +25514,7 @@ PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler); module.exports = SyntheticEvent; -},{"./Object.assign":76,"./PooledClass":77,"./emptyFunction":164,"./getEventTarget":175}],146:[function(require,module,exports){ +},{"./Object.assign":78,"./PooledClass":79,"./emptyFunction":166,"./getEventTarget":177}],148:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18127,7 +25553,7 @@ SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface); module.exports = SyntheticFocusEvent; -},{"./SyntheticUIEvent":151}],147:[function(require,module,exports){ +},{"./SyntheticUIEvent":153}],149:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18173,7 +25599,7 @@ SyntheticEvent.augmentClass( module.exports = SyntheticInputEvent; -},{"./SyntheticEvent":145}],148:[function(require,module,exports){ +},{"./SyntheticEvent":147}],150:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18260,7 +25686,7 @@ SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface); module.exports = SyntheticKeyboardEvent; -},{"./SyntheticUIEvent":151,"./getEventCharCode":172,"./getEventKey":173,"./getEventModifierState":174}],149:[function(require,module,exports){ +},{"./SyntheticUIEvent":153,"./getEventCharCode":174,"./getEventKey":175,"./getEventModifierState":176}],151:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18341,7 +25767,7 @@ SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface); module.exports = SyntheticMouseEvent; -},{"./SyntheticUIEvent":151,"./ViewportMetrics":154,"./getEventModifierState":174}],150:[function(require,module,exports){ +},{"./SyntheticUIEvent":153,"./ViewportMetrics":156,"./getEventModifierState":176}],152:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18389,7 +25815,7 @@ SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface); module.exports = SyntheticTouchEvent; -},{"./SyntheticUIEvent":151,"./getEventModifierState":174}],151:[function(require,module,exports){ +},{"./SyntheticUIEvent":153,"./getEventModifierState":176}],153:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18451,7 +25877,7 @@ SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface); module.exports = SyntheticUIEvent; -},{"./SyntheticEvent":145,"./getEventTarget":175}],152:[function(require,module,exports){ +},{"./SyntheticEvent":147,"./getEventTarget":177}],154:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18512,7 +25938,7 @@ SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface); module.exports = SyntheticWheelEvent; -},{"./SyntheticMouseEvent":149}],153:[function(require,module,exports){ +},{"./SyntheticMouseEvent":151}],155:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -18753,7 +26179,7 @@ var Transaction = { module.exports = Transaction; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],154:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],156:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18782,7 +26208,7 @@ var ViewportMetrics = { module.exports = ViewportMetrics; -},{}],155:[function(require,module,exports){ +},{}],157:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -18848,7 +26274,7 @@ function accumulateInto(current, next) { module.exports = accumulateInto; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],156:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],158:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18882,7 +26308,7 @@ function adler32(data) { module.exports = adler32; -},{}],157:[function(require,module,exports){ +},{}],159:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18914,7 +26340,7 @@ function camelize(string) { module.exports = camelize; -},{}],158:[function(require,module,exports){ +},{}],160:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -18956,7 +26382,7 @@ function camelizeStyleName(string) { module.exports = camelizeStyleName; -},{"./camelize":157}],159:[function(require,module,exports){ +},{"./camelize":159}],161:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19000,7 +26426,7 @@ function containsNode(outerNode, innerNode) { module.exports = containsNode; -},{"./isTextNode":189}],160:[function(require,module,exports){ +},{"./isTextNode":191}],162:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19086,7 +26512,7 @@ function createArrayFromMixed(obj) { module.exports = createArrayFromMixed; -},{"./toArray":202}],161:[function(require,module,exports){ +},{"./toArray":204}],163:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19148,7 +26574,7 @@ function createFullPageComponent(tag) { module.exports = createFullPageComponent; }).call(this,require('_process')) -},{"./ReactClass":83,"./ReactElement":107,"./invariant":185,"_process":1}],162:[function(require,module,exports){ +},{"./ReactClass":85,"./ReactElement":109,"./invariant":187,"_process":1}],164:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19238,7 +26664,7 @@ function createNodesFromMarkup(markup, handleScript) { module.exports = createNodesFromMarkup; }).call(this,require('_process')) -},{"./ExecutionEnvironment":70,"./createArrayFromMixed":160,"./getMarkupWrap":177,"./invariant":185,"_process":1}],163:[function(require,module,exports){ +},{"./ExecutionEnvironment":72,"./createArrayFromMixed":162,"./getMarkupWrap":179,"./invariant":187,"_process":1}],165:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19296,7 +26722,7 @@ function dangerousStyleValue(name, value) { module.exports = dangerousStyleValue; -},{"./CSSProperty":53}],164:[function(require,module,exports){ +},{"./CSSProperty":55}],166:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19330,7 +26756,7 @@ emptyFunction.thatReturnsArgument = function(arg) { return arg; }; module.exports = emptyFunction; -},{}],165:[function(require,module,exports){ +},{}],167:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19354,7 +26780,7 @@ if ("production" !== process.env.NODE_ENV) { module.exports = emptyObject; }).call(this,require('_process')) -},{"_process":1}],166:[function(require,module,exports){ +},{"_process":1}],168:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19394,7 +26820,7 @@ function escapeTextContentForBrowser(text) { module.exports = escapeTextContentForBrowser; -},{}],167:[function(require,module,exports){ +},{}],169:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19467,7 +26893,7 @@ function findDOMNode(componentOrElement) { module.exports = findDOMNode; }).call(this,require('_process')) -},{"./ReactCurrentOwner":89,"./ReactInstanceMap":117,"./ReactMount":120,"./invariant":185,"./isNode":187,"./warning":204,"_process":1}],168:[function(require,module,exports){ +},{"./ReactCurrentOwner":91,"./ReactInstanceMap":119,"./ReactMount":122,"./invariant":187,"./isNode":189,"./warning":206,"_process":1}],170:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19525,7 +26951,7 @@ function flattenChildren(children) { module.exports = flattenChildren; }).call(this,require('_process')) -},{"./traverseAllChildren":203,"./warning":204,"_process":1}],169:[function(require,module,exports){ +},{"./traverseAllChildren":205,"./warning":206,"_process":1}],171:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -19554,7 +26980,7 @@ function focusNode(node) { module.exports = focusNode; -},{}],170:[function(require,module,exports){ +},{}],172:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19585,7 +27011,7 @@ var forEachAccumulated = function(arr, cb, scope) { module.exports = forEachAccumulated; -},{}],171:[function(require,module,exports){ +},{}],173:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19614,7 +27040,7 @@ function getActiveElement() /*?DOMElement*/ { module.exports = getActiveElement; -},{}],172:[function(require,module,exports){ +},{}],174:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19666,7 +27092,7 @@ function getEventCharCode(nativeEvent) { module.exports = getEventCharCode; -},{}],173:[function(require,module,exports){ +},{}],175:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19771,7 +27197,7 @@ function getEventKey(nativeEvent) { module.exports = getEventKey; -},{"./getEventCharCode":172}],174:[function(require,module,exports){ +},{"./getEventCharCode":174}],176:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19818,7 +27244,7 @@ function getEventModifierState(nativeEvent) { module.exports = getEventModifierState; -},{}],175:[function(require,module,exports){ +},{}],177:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19849,7 +27275,7 @@ function getEventTarget(nativeEvent) { module.exports = getEventTarget; -},{}],176:[function(require,module,exports){ +},{}],178:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19893,7 +27319,7 @@ function getIteratorFn(maybeIterable) { module.exports = getIteratorFn; -},{}],177:[function(require,module,exports){ +},{}],179:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -20012,7 +27438,7 @@ function getMarkupWrap(nodeName) { module.exports = getMarkupWrap; }).call(this,require('_process')) -},{"./ExecutionEnvironment":70,"./invariant":185,"_process":1}],178:[function(require,module,exports){ +},{"./ExecutionEnvironment":72,"./invariant":187,"_process":1}],180:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20087,7 +27513,7 @@ function getNodeForCharacterOffset(root, offset) { module.exports = getNodeForCharacterOffset; -},{}],179:[function(require,module,exports){ +},{}],181:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20122,7 +27548,7 @@ function getReactRootElementInContainer(container) { module.exports = getReactRootElementInContainer; -},{}],180:[function(require,module,exports){ +},{}],182:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20159,7 +27585,7 @@ function getTextContentAccessor() { module.exports = getTextContentAccessor; -},{"./ExecutionEnvironment":70}],181:[function(require,module,exports){ +},{"./ExecutionEnvironment":72}],183:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20199,7 +27625,7 @@ function getUnboundedScrollPosition(scrollable) { module.exports = getUnboundedScrollPosition; -},{}],182:[function(require,module,exports){ +},{}],184:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20232,7 +27658,7 @@ function hyphenate(string) { module.exports = hyphenate; -},{}],183:[function(require,module,exports){ +},{}],185:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20273,7 +27699,7 @@ function hyphenateStyleName(string) { module.exports = hyphenateStyleName; -},{"./hyphenate":182}],184:[function(require,module,exports){ +},{"./hyphenate":184}],186:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -20411,7 +27837,7 @@ function instantiateReactComponent(node, parentCompositeType) { module.exports = instantiateReactComponent; }).call(this,require('_process')) -},{"./Object.assign":76,"./ReactCompositeComponent":87,"./ReactEmptyComponent":109,"./ReactNativeComponent":123,"./invariant":185,"./warning":204,"_process":1}],185:[function(require,module,exports){ +},{"./Object.assign":78,"./ReactCompositeComponent":89,"./ReactEmptyComponent":111,"./ReactNativeComponent":125,"./invariant":187,"./warning":206,"_process":1}],187:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -20468,7 +27894,7 @@ var invariant = function(condition, format, a, b, c, d, e, f) { module.exports = invariant; }).call(this,require('_process')) -},{"_process":1}],186:[function(require,module,exports){ +},{"_process":1}],188:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20533,7 +27959,7 @@ function isEventSupported(eventNameSuffix, capture) { module.exports = isEventSupported; -},{"./ExecutionEnvironment":70}],187:[function(require,module,exports){ +},{"./ExecutionEnvironment":72}],189:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20560,7 +27986,7 @@ function isNode(object) { module.exports = isNode; -},{}],188:[function(require,module,exports){ +},{}],190:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20603,7 +28029,7 @@ function isTextInputElement(elem) { module.exports = isTextInputElement; -},{}],189:[function(require,module,exports){ +},{}],191:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20628,7 +28054,7 @@ function isTextNode(object) { module.exports = isTextNode; -},{"./isNode":187}],190:[function(require,module,exports){ +},{"./isNode":189}],192:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -20683,7 +28109,7 @@ var keyMirror = function(obj) { module.exports = keyMirror; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],191:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],193:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20719,7 +28145,7 @@ var keyOf = function(oneKeyObj) { module.exports = keyOf; -},{}],192:[function(require,module,exports){ +},{}],194:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20772,7 +28198,7 @@ function mapObject(object, callback, context) { module.exports = mapObject; -},{}],193:[function(require,module,exports){ +},{}],195:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20805,7 +28231,7 @@ function memoizeStringOnly(callback) { module.exports = memoizeStringOnly; -},{}],194:[function(require,module,exports){ +},{}],196:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -20845,7 +28271,7 @@ function onlyChild(children) { module.exports = onlyChild; }).call(this,require('_process')) -},{"./ReactElement":107,"./invariant":185,"_process":1}],195:[function(require,module,exports){ +},{"./ReactElement":109,"./invariant":187,"_process":1}],197:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20873,7 +28299,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = performance || {}; -},{"./ExecutionEnvironment":70}],196:[function(require,module,exports){ +},{"./ExecutionEnvironment":72}],198:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20901,7 +28327,7 @@ var performanceNow = performance.now.bind(performance); module.exports = performanceNow; -},{"./performance":195}],197:[function(require,module,exports){ +},{"./performance":197}],199:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -20929,7 +28355,7 @@ function quoteAttributeValueForBrowser(value) { module.exports = quoteAttributeValueForBrowser; -},{"./escapeTextContentForBrowser":166}],198:[function(require,module,exports){ +},{"./escapeTextContentForBrowser":168}],200:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -21018,7 +28444,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = setInnerHTML; -},{"./ExecutionEnvironment":70}],199:[function(require,module,exports){ +},{"./ExecutionEnvironment":72}],201:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -21060,7 +28486,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = setTextContent; -},{"./ExecutionEnvironment":70,"./escapeTextContentForBrowser":166,"./setInnerHTML":198}],200:[function(require,module,exports){ +},{"./ExecutionEnvironment":72,"./escapeTextContentForBrowser":168,"./setInnerHTML":200}],202:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -21104,7 +28530,7 @@ function shallowEqual(objA, objB) { module.exports = shallowEqual; -},{}],201:[function(require,module,exports){ +},{}],203:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -21208,7 +28634,7 @@ function shouldUpdateReactComponent(prevElement, nextElement) { module.exports = shouldUpdateReactComponent; }).call(this,require('_process')) -},{"./warning":204,"_process":1}],202:[function(require,module,exports){ +},{"./warning":206,"_process":1}],204:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -21280,7 +28706,7 @@ function toArray(obj) { module.exports = toArray; }).call(this,require('_process')) -},{"./invariant":185,"_process":1}],203:[function(require,module,exports){ +},{"./invariant":187,"_process":1}],205:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -21533,7 +28959,7 @@ function traverseAllChildren(children, callback, traverseContext) { module.exports = traverseAllChildren; }).call(this,require('_process')) -},{"./ReactElement":107,"./ReactFragment":113,"./ReactInstanceHandles":116,"./getIteratorFn":176,"./invariant":185,"./warning":204,"_process":1}],204:[function(require,module,exports){ +},{"./ReactElement":109,"./ReactFragment":115,"./ReactInstanceHandles":118,"./getIteratorFn":178,"./invariant":187,"./warning":206,"_process":1}],206:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -21596,10 +29022,10 @@ if ("production" !== process.env.NODE_ENV) { module.exports = warning; }).call(this,require('_process')) -},{"./emptyFunction":164,"_process":1}],205:[function(require,module,exports){ +},{"./emptyFunction":166,"_process":1}],207:[function(require,module,exports){ module.exports = require('./lib/React'); -},{"./lib/React":78}],206:[function(require,module,exports){ +},{"./lib/React":80}],208:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -21764,7 +29190,7 @@ function createStore(reducer, initialState) { replaceReducer: replaceReducer }; } -},{"./utils/isPlainObject":212}],207:[function(require,module,exports){ +},{"./utils/isPlainObject":214}],209:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -21796,7 +29222,7 @@ exports.combineReducers = _utilsCombineReducers2['default']; exports.bindActionCreators = _utilsBindActionCreators2['default']; exports.applyMiddleware = _utilsApplyMiddleware2['default']; exports.compose = _utilsCompose2['default']; -},{"./createStore":206,"./utils/applyMiddleware":208,"./utils/bindActionCreators":209,"./utils/combineReducers":210,"./utils/compose":211}],208:[function(require,module,exports){ +},{"./createStore":208,"./utils/applyMiddleware":210,"./utils/bindActionCreators":211,"./utils/combineReducers":212,"./utils/compose":213}],210:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -21858,7 +29284,7 @@ function applyMiddleware() { } module.exports = exports['default']; -},{"./compose":211}],209:[function(require,module,exports){ +},{"./compose":213}],211:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -21913,7 +29339,7 @@ function bindActionCreators(actionCreators, dispatch) { } module.exports = exports['default']; -},{"../utils/mapValues":213}],210:[function(require,module,exports){ +},{"../utils/mapValues":215}],212:[function(require,module,exports){ (function (process){ 'use strict'; @@ -22033,7 +29459,7 @@ function combineReducers(reducers) { module.exports = exports['default']; }).call(this,require('_process')) -},{"../createStore":206,"../utils/isPlainObject":212,"../utils/mapValues":213,"../utils/pick":214,"_process":1}],211:[function(require,module,exports){ +},{"../createStore":208,"../utils/isPlainObject":214,"../utils/mapValues":215,"../utils/pick":216,"_process":1}],213:[function(require,module,exports){ /** * Composes functions from left to right. * @@ -22058,9 +29484,9 @@ function compose() { } module.exports = exports["default"]; -},{}],212:[function(require,module,exports){ -arguments[4][47][0].apply(exports,arguments) -},{"dup":47}],213:[function(require,module,exports){ +},{}],214:[function(require,module,exports){ +arguments[4][49][0].apply(exports,arguments) +},{"dup":49}],215:[function(require,module,exports){ /** * Applies a function to every key-value pair inside an object. * @@ -22081,7 +29507,7 @@ function mapValues(obj, fn) { } module.exports = exports["default"]; -},{}],214:[function(require,module,exports){ +},{}],216:[function(require,module,exports){ /** * Picks key-value pairs from an object where values satisfy a predicate. * @@ -22104,7 +29530,7 @@ function pick(obj, fn) { } module.exports = exports["default"]; -},{}],215:[function(require,module,exports){ +},{}],217:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22124,7 +29550,7 @@ function changedir(dir) { module.exports = exports['default']; -},{"actions/types":223}],216:[function(require,module,exports){ +},{"actions/types":225}],218:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22176,7 +29602,7 @@ function hideAll() { }, props); } -},{"actions/types":223}],217:[function(require,module,exports){ +},{"actions/types":225}],219:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22185,8 +29611,10 @@ Object.defineProperty(exports, '__esModule', { exports.create = create; exports.share = share; exports.rename = rename; +exports.move = move; +exports.copy = copy; exports.active = active; -exports.deleteFile = deleteFile; +exports.remove = remove; var _actionsTypes = require('actions/types'); @@ -22213,6 +29641,20 @@ function rename(file, name) { }; } +function move(file, newPath) { + return { + type: _actionsTypes.MOVE_FILE, + file: file, newPath: newPath + }; +} + +function copy(file, newPath) { + return { + type: _actionsTypes.COPY_FILE, + file: file, newPath: newPath + }; +} + function active() { var file = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; @@ -22222,25 +29664,26 @@ function active() { }; } -function deleteFile(file) { - console.log('constructing deleteFile action', file); +function remove(file) { return { type: _actionsTypes.DELETE_FILE, file: file }; } -},{"actions/types":223}],218:[function(require,module,exports){ +},{"actions/types":225}],220:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); +exports.listFiles = listFiles; exports.refresh = refresh; exports.toggle = toggle; exports.details = details; exports.list = list; exports.selectView = selectView; +exports.search = search; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -22250,6 +29693,13 @@ var _store = require('store'); var _store2 = _interopRequireDefault(_store); +function listFiles(files) { + return { + type: _actionsTypes.LIST_FILES, + files: files + }; +} + function refresh() { return { type: _actionsTypes.REFRESH @@ -22286,26 +29736,14 @@ function selectView() { }; } -},{"actions/types":223,"store":"store"}],219:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports['default'] = listFiles; - -var _actionsTypes = require('actions/types'); - -function listFiles(files) { +function search(keywords) { return { - type: _actionsTypes.LIST_FILES, - files: files + type: _actionsTypes.SEARCH, + keywords: keywords }; } -module.exports = exports['default']; - -},{"actions/types":223}],220:[function(require,module,exports){ +},{"actions/types":225,"store":"store"}],221:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22357,7 +29795,7 @@ function hideAll() { }, props); } -},{"actions/types":223}],221:[function(require,module,exports){ +},{"actions/types":225}],222:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22390,7 +29828,7 @@ function toggle() { }; } -},{"actions/types":223}],222:[function(require,module,exports){ +},{"actions/types":225}],223:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22409,7 +29847,40 @@ exports['default'] = function (props) { module.exports = exports['default']; -},{"actions/types":223}],223:[function(require,module,exports){ +},{"actions/types":225}],224:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.show = show; +exports.hide = hide; +exports.toggle = toggle; + +var _actionsTypes = require('actions/types'); + +function show() { + return { + type: _actionsTypes.SPINNER, + active: true + }; +} + +function hide() { + return { + type: _actionsTypes.SPINNER, + active: false + }; +} + +function toggle() { + return { + type: _actionsTypes.SPINNER, + active: 'toggle' + }; +} + +},{"actions/types":225}],225:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22433,11 +29904,15 @@ var TYPES = { RENAME_FILE: Symbol('RENAME_FILE'), ACTIVE_FILE: Symbol('ACTIVE_FILE'), DELETE_FILE: Symbol('DELETE_FILE'), + COPY_FILE: Symbol('COPY_FILE'), + MOVE_FILE: Symbol('MOVE_FILE'), MENU: Symbol('MENU'), DIALOG: Symbol('DIALOG'), + SPINNER: Symbol('SPINNER'), + SETTINGS: Symbol('SETTINGS'), SEARCH: Symbol('SEARCH') @@ -22446,7 +29921,7 @@ var TYPES = { exports['default'] = TYPES; module.exports = exports['default']; -},{}],224:[function(require,module,exports){ +},{}],226:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22554,10 +30029,11 @@ var createDirectory = _asyncToGenerator(function* () { exports.createDirectory = createDirectory; -var remove = _asyncToGenerator(function* (file) { +var remove = _asyncToGenerator(function* (file, deep) { var parent = yield root(); - return parent.remove(file); + console.log(deep); + return parent[deep ? 'removeDeep' : 'remove'](file); }); exports.remove = remove; @@ -22566,6 +30042,16 @@ var move = _asyncToGenerator(function* (file, newPath) { var path = (file.path || '').replace(/^\//, ''); // remove starting slash var oldPath = path + file.name; + var process = yield copy(file, newPath); + return remove(oldPath, true); +}); + +exports.move = move; + +var copy = _asyncToGenerator(function* (file, newPath) { + var path = (file.path || '').replace(/^\//, ''); // remove starting slash + var oldPath = path + file.name; + newPath = newPath.replace(/^\//, ''); var target = yield getFile(oldPath); @@ -22604,7 +30090,6 @@ var move = _asyncToGenerator(function* (file, newPath) { } } - yield parent.remove(oldPath); return; } else { var _ret = yield* (function* () { @@ -22618,8 +30103,6 @@ var move = _asyncToGenerator(function* (file, newPath) { request.onsuccess = resolve; request.onerror = reject; request.onabort = reject; - }).then(function () { - return sdcard()['delete'](oldPath); }) }; })(); @@ -22628,7 +30111,7 @@ var move = _asyncToGenerator(function* (file, newPath) { } }); -exports.move = move; +exports.copy = copy; function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { var callNext = step.bind(null, 'next'); var callThrow = step.bind(null, 'throw'); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(callNext, callThrow); } } callNext(); }); }; } @@ -22646,7 +30129,7 @@ function sdcard() { var ROOT_CACHE = undefined; -},{"utils":"utils"}],225:[function(require,module,exports){ +},{"utils":"utils"}],227:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22737,7 +30220,11 @@ var Breadcrumb = (function (_Component) { return _react2['default'].createElement( 'div', { className: 'breadcrumb' }, - els + _react2['default'].createElement( + 'div', + null, + els + ) ); } }]); @@ -22757,7 +30244,7 @@ function props(state) { } module.exports = exports['default']; -},{"actions/changedir":215,"react":205,"react-redux":45,"store":"store"}],226:[function(require,module,exports){ +},{"actions/changedir":217,"react":207,"react-redux":47,"store":"store"}],228:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22842,7 +30329,7 @@ var Dialog = (function (_Component) { exports['default'] = Dialog; module.exports = exports['default']; -},{"react":205,"utils":"utils"}],227:[function(require,module,exports){ +},{"react":207,"utils":"utils"}],229:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -22877,6 +30364,10 @@ var _store = require('store'); var _store2 = _interopRequireDefault(_store); +var _mixinsEntry = require('./mixins/entry'); + +var _mixinsEntry2 = _interopRequireDefault(_mixinsEntry); + var MENU_TOP_SPACE = 20; var Directory = (function (_Component) { @@ -22885,7 +30376,8 @@ var Directory = (function (_Component) { function Directory() { _classCallCheck(this, Directory); - _get(Object.getPrototypeOf(Directory.prototype), 'constructor', this).apply(this, arguments); + _get(Object.getPrototypeOf(Directory.prototype), 'constructor', this).call(this); + Object.assign(this, _mixinsEntry2['default']); } _createClass(Directory, [{ @@ -22930,35 +30422,6 @@ var Directory = (function (_Component) { _store2['default'].dispatch((0, _actionsChangedir2['default'])(file.path.slice(1) + file.name)); } - }, { - key: 'contextMenu', - value: function contextMenu(e) { - e.preventDefault(); - - var rect = _react2['default'].findDOMNode(this.refs.container).getBoundingClientRect(); - var x = rect.x; - var y = rect.y; - var width = rect.width; - var height = rect.height; - - var left = x + width / 2 - _menu.MENU_WIDTH / 2, - top = y + height / 2 + MENU_TOP_SPACE; - _store2['default'].dispatch((0, _actionsMenu.show)('directoryMenu', { style: { left: left, top: top } })); - _store2['default'].dispatch((0, _actionsFile.active)(this.props.index)); - } - }, { - key: 'select', - value: function select() { - var current = (_store2['default'].getState().get('activeFile') || []).slice(0); - var index = this.props.index; - - if (current.indexOf(index) > -1) { - current.splice(current.indexOf(index), 1); - } else { - current.push(index); - } - _store2['default'].dispatch((0, _actionsFile.active)(current)); - } }]); return Directory; @@ -22967,7 +30430,7 @@ var Directory = (function (_Component) { exports['default'] = Directory; module.exports = exports['default']; -},{"./menu":231,"actions/changedir":215,"actions/file":217,"actions/menu":220,"react":205,"store":"store"}],228:[function(require,module,exports){ +},{"./menu":233,"./mixins/entry":234,"actions/changedir":217,"actions/file":219,"actions/menu":221,"react":207,"store":"store"}],230:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23013,6 +30476,14 @@ var _store2 = _interopRequireDefault(_store); var _utils = require('utils'); +var _hammerjs = require('hammerjs'); + +var _hammerjs2 = _interopRequireDefault(_hammerjs); + +var _actionsChangedir = require('actions/changedir'); + +var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir); + var FileList = (function (_Component) { _inherits(FileList, _Component); @@ -23034,7 +30505,7 @@ var FileList = (function (_Component) { var settings = _store2['default'].getState().get('settings'); var els = files.map(function (file, index) { - var selected = activeFile.indexOf(index) > -1; + var selected = activeFile.length && activeFile.indexOf(file) > -1; if ((0, _utils.type)(file) === 'File') { return _react2['default'].createElement(_file2['default'], { selectView: selectView, selected: selected, key: index, index: index, name: file.name, size: file.size }); } else { @@ -23044,10 +30515,25 @@ var FileList = (function (_Component) { return _react2['default'].createElement( 'div', - { className: 'file-list' }, + { className: 'file-list', ref: 'container' }, els ); } + }, { + key: 'componentDidMount', + value: function componentDidMount() { + var container = _react2['default'].findDOMNode(this.refs.container); + var touch = (0, _hammerjs2['default'])(container); + + touch.on('swipe', function (e) { + var current = _store2['default'].getState().get('cwd'); + var up = current.split('/').slice(0, -1).join('/'); + + if (up === current) return; + + _store2['default'].dispatch((0, _actionsChangedir2['default'])(up)); + }).set({ direction: _hammerjs2['default'].DIRECTION_RIGHT }); + } }]); var _FileList = FileList; @@ -23067,7 +30553,7 @@ function props(state) { module.exports = exports['default']; -},{"./directory":227,"./file":229,"react":205,"react-redux":45,"store":"store","utils":"utils"}],229:[function(require,module,exports){ +},{"./directory":229,"./file":231,"actions/changedir":217,"hammerjs":2,"react":207,"react-redux":47,"store":"store","utils":"utils"}],231:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23100,6 +30586,10 @@ var _store2 = _interopRequireDefault(_store); var _utils = require('utils'); +var _mixinsEntry = require('./mixins/entry'); + +var _mixinsEntry2 = _interopRequireDefault(_mixinsEntry); + var MENU_TOP_SPACE = 20; var File = (function (_Component) { @@ -23109,6 +30599,7 @@ var File = (function (_Component) { _classCallCheck(this, File); _get(Object.getPrototypeOf(File.prototype), 'constructor', this).call(this); + Object.assign(this, _mixinsEntry2['default']); } _createClass(File, [{ @@ -23123,7 +30614,7 @@ var File = (function (_Component) { label = _react2['default'].createElement('label', { htmlFor: checkId }); } - var clickHandler = this.props.selectView ? this.select.bind(this) : null; + var clickHandler = this.props.selectView ? this.select.bind(this) : this.open.bind(this); return _react2['default'].createElement( 'div', @@ -23146,33 +30637,18 @@ var File = (function (_Component) { ); } }, { - key: 'contextMenu', - value: function contextMenu(e) { - e.preventDefault(); + key: 'open', + value: function open(e) { + var file = _store2['default'].getState().get('files')[this.props.index]; - var rect = _react2['default'].findDOMNode(this.refs.container).getBoundingClientRect(); - var x = rect.x; - var y = rect.y; - var width = rect.width; - var height = rect.height; - - var left = x + width / 2 - _menu.MENU_WIDTH / 2, - top = y + height / 2 + MENU_TOP_SPACE; - _store2['default'].dispatch((0, _actionsMenu.show)('fileMenu', { style: { left: left, top: top } })); - _store2['default'].dispatch((0, _actionsFile.active)(this.props.index)); - } - }, { - key: 'select', - value: function select() { - var current = (_store2['default'].getState().get('activeFile') || []).slice(0); - var index = this.props.index; - - if (current.indexOf(index) > -1) { - current.splice(current.indexOf(index), 1); - } else { - current.push(index); - } - _store2['default'].dispatch((0, _actionsFile.active)(current)); + var name = file.type === 'application/pdf' ? 'view' : 'open'; + new MozActivity({ + name: name, + data: { + type: file.type, + blob: file + } + }); } }]); @@ -23182,7 +30658,7 @@ var File = (function (_Component) { exports['default'] = File; module.exports = exports['default']; -},{"./menu":231,"actions/file":217,"actions/menu":220,"react":205,"store":"store","utils":"utils"}],230:[function(require,module,exports){ +},{"./menu":233,"./mixins/entry":234,"actions/file":219,"actions/menu":221,"react":207,"store":"store","utils":"utils"}],232:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23205,47 +30681,63 @@ var _react2 = _interopRequireDefault(_react); var _actionsNavigation = require('actions/navigation'); +var _actionsDialog = require('actions/dialog'); + +var _actionsFilesView = require('actions/files-view'); + var _store = require('store'); -var _store2 = _interopRequireDefault(_store); +var _reactRedux = require('react-redux'); var Header = (function (_Component) { _inherits(Header, _Component); function Header() { - _classCallCheck(this, Header); + _classCallCheck(this, _Header); - _get(Object.getPrototypeOf(Header.prototype), 'constructor', this).apply(this, arguments); + _get(Object.getPrototypeOf(_Header.prototype), 'constructor', this).apply(this, arguments); } _createClass(Header, [{ key: 'render', value: function render() { + var i = undefined; + + if (this.props.search) { + i = _react2['default'].createElement('i', { className: 'icon-cross', onClick: (0, _store.bind)((0, _actionsFilesView.search)()) }); + } else { + i = _react2['default'].createElement('i', { className: 'icon-search', onClick: (0, _store.bind)((0, _actionsDialog.show)('searchDialog')) }); + } + return _react2['default'].createElement( 'header', null, - _react2['default'].createElement('button', { className: 'drawer', onClick: this.toggleNavigation.bind(this) }), + _react2['default'].createElement('button', { className: 'drawer', onTouchStart: (0, _store.bind)((0, _actionsNavigation.toggle)()) }), _react2['default'].createElement( 'h1', { className: 'regular-medium' }, 'Hawk' - ) + ), + i ); } - }, { - key: 'toggleNavigation', - value: function toggleNavigation() { - _store2['default'].dispatch((0, _actionsNavigation.toggle)()); - } }]); + var _Header = Header; + Header = (0, _reactRedux.connect)(props)(Header) || Header; return Header; })(_react.Component); exports['default'] = Header; + +function props(state) { + return { + search: state.get('search') + }; +} module.exports = exports['default']; -},{"actions/navigation":221,"react":205,"store":"store"}],231:[function(require,module,exports){ +},{"actions/dialog":218,"actions/files-view":220,"actions/navigation":222,"react":207,"react-redux":47,"store":"store"}],233:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23292,9 +30784,12 @@ var Menu = (function (_Component) { items = items || []; var els = items.map(function (item, index) { + var disabled = !(typeof item.enabled === 'function' ? item.enabled() : true); + var className = disabled ? 'disabled' : ''; + return _react2['default'].createElement( 'li', - { key: index, onClick: item.action.bind(_this) }, + { key: index, className: className, onClick: item.action.bind(_this) }, item.name ); }); @@ -23317,7 +30812,44 @@ var Menu = (function (_Component) { exports['default'] = Menu; -},{"react":205}],232:[function(require,module,exports){ +},{"react":207}],234:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports['default'] = { + contextMenu: function contextMenu(e) { + e.preventDefault(); + + var file = store.getState().get('files')[this.props.index]; + var rect = React.findDOMNode(this.refs.container).getBoundingClientRect(); + var x = rect.x; + var y = rect.y; + var width = rect.width; + var height = rect.height; + + var left = x + width / 2 - MENU_WIDTH / 2, + top = y + height / 2 + MENU_TOP_SPACE; + store.dispatch(show('fileMenu', { style: { left: left, top: top } })); + store.dispatch(active([file])); + }, + + select: function select() { + var current = store.getState().get('activeFile').slice(0); + var file = store.getState().get('files')[this.props.index]; + + if (current.indexOf(file) > -1) { + current.splice(current.indexOf(file), 1); + } else { + current.push(file); + } + store.dispatch(active(current)); + } +}; +module.exports = exports['default']; + +},{}],235:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23372,8 +30904,8 @@ var Navigation = (function (_Component) { return _react2['default'].createElement( 'nav', - { className: this.props.active ? 'active' : '' }, - _react2['default'].createElement('i', { onClick: this.hide.bind(this) }), + { className: this.props.active ? 'active' : '', onChange: this.onChange.bind(this) }, + _react2['default'].createElement('i', { onTouchStart: this.hide }), _react2['default'].createElement( 'p', null, @@ -23385,17 +30917,42 @@ var Navigation = (function (_Component) { _react2['default'].createElement( 'li', null, - 'Picture' + _react2['default'].createElement('input', { id: 'filter-all', name: 'filter', value: '', type: 'radio', defaultChecked: !settings.filter }), + _react2['default'].createElement( + 'label', + { htmlFor: 'filter-all' }, + 'All' + ) ), _react2['default'].createElement( 'li', null, - 'Video' + _react2['default'].createElement('input', { id: 'filter-image', name: 'filter', value: 'image', type: 'radio', defaultChecked: settings.filter === 'image' }), + _react2['default'].createElement( + 'label', + { htmlFor: 'filter-image' }, + 'Image' + ) ), _react2['default'].createElement( 'li', null, - 'Audio' + _react2['default'].createElement('input', { id: 'filter-video', name: 'filter', value: 'video', type: 'radio', defaultChecked: settings.filter === 'video' }), + _react2['default'].createElement( + 'label', + { htmlFor: 'filter-video' }, + 'Video' + ) + ), + _react2['default'].createElement( + 'li', + null, + _react2['default'].createElement('input', { id: 'filter-audio', name: 'filter', value: 'audio', type: 'radio', defaultChecked: settings.filter === 'audio' }), + _react2['default'].createElement( + 'label', + { htmlFor: 'filter-audio' }, + 'Audio' + ) ) ), _react2['default'].createElement( @@ -23408,8 +30965,12 @@ var Navigation = (function (_Component) { null, _react2['default'].createElement( 'li', - null, - 'FTP Browser' + { className: 'coming-soon' }, + _react2['default'].createElement( + 'label', + null, + 'FTP Browser' + ) ) ), _react2['default'].createElement( @@ -23419,7 +30980,7 @@ var Navigation = (function (_Component) { ), _react2['default'].createElement( 'ul', - { onChange: this.onChange.bind(this) }, + null, _react2['default'].createElement( 'li', null, @@ -23440,31 +31001,97 @@ var Navigation = (function (_Component) { 'Show Directories First' ) ), + _react2['default'].createElement( + 'li', + { className: 'coming-soon' }, + _react2['default'].createElement( + 'label', + null, + 'Advanced Preferences' + ) + ) + ), + _react2['default'].createElement( + 'p', + null, + 'External' + ), + _react2['default'].createElement( + 'ul', + null, _react2['default'].createElement( 'li', null, - 'Advanced Preferences' + _react2['default'].createElement( + 'label', + null, + _react2['default'].createElement( + 'a', + { href: 'https://github.com/mdibaiee/Hawk' }, + 'GitHub' + ) + ) + ), + _react2['default'].createElement( + 'li', + null, + _react2['default'].createElement( + 'label', + null, + _react2['default'].createElement( + 'a', + { href: 'https://github.com/mdibaiee/Hawk/issues' }, + 'Report Bugs' + ) + ) + ), + _react2['default'].createElement( + 'li', + null, + _react2['default'].createElement( + 'label', + null, + _react2['default'].createElement( + 'a', + { href: 'http://dibaiee.ir/Hawk' }, + 'Website' + ) + ) + ), + _react2['default'].createElement( + 'li', + null, + _react2['default'].createElement( + 'label', + null, + _react2['default'].createElement( + 'a', + { href: 'http://dibaiee.ir' }, + 'Mahdi Dibaiee' + ) + ) ) ) ); } - }, { - key: 'hide', - value: function hide() { - this.props.dispatch((0, _actionsNavigation.hide)()); - } }, { key: 'onChange', value: function onChange(e) { - if (e.target.nodeName.toLowerCase() !== 'input') return; + var key = e.target.name || e.target.id; + var value = e.target.value === undefined ? e.target.checked : e.target.value; - var key = e.target.id; - var value = this.props.settings[key]; - - var action = (0, _actionsSettings2['default'])(_defineProperty({}, key, e.target.checked)); + var action = (0, _actionsSettings2['default'])(_defineProperty({}, key, value)); _store2['default'].dispatch(action); } + }, { + key: 'hide', + value: function hide(e) { + e.preventDefault(); + e.stopPropagation(); + + _store2['default'].dispatch((0, _actionsNavigation.hide)()); + } }]); var _Navigation = Navigation; @@ -23482,7 +31109,7 @@ function props(store) { } module.exports = exports['default']; -},{"actions/navigation":221,"actions/settings":222,"lodash/string/camelCase":38,"react":205,"react-redux":45,"store":"store"}],233:[function(require,module,exports){ +},{"actions/navigation":222,"actions/settings":223,"lodash/string/camelCase":40,"react":207,"react-redux":47,"store":"store"}],236:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23531,6 +31158,10 @@ var _componentsDialog = require('components/dialog'); var _componentsDialog2 = _interopRequireDefault(_componentsDialog); +var _componentsSpinner = require('components/spinner'); + +var _componentsSpinner2 = _interopRequireDefault(_componentsSpinner); + var _reactRedux = require('react-redux'); var _actionsMenu = require('actions/menu'); @@ -23570,6 +31201,9 @@ var ErrorDialog = (0, _reactRedux.connect)(function (state) { var CreateDialog = (0, _reactRedux.connect)(function (state) { return state.get('createDialog'); })(_componentsDialog2['default']); +var SearchDialog = (0, _reactRedux.connect)(function (state) { + return state.get('searchDialog'); +})(_componentsDialog2['default']); var Root = (function (_Component) { _inherits(Root, _Component); @@ -23585,7 +31219,7 @@ var Root = (function (_Component) { value: function render() { return _react2['default'].createElement( 'div', - { onTouchStart: this.touchStart.bind(this) }, + { onTouchStart: this.touchStart.bind(this), onClick: this.onClick.bind(this) }, _react2['default'].createElement(_componentsHeader2['default'], null), _react2['default'].createElement(_componentsBreadcrumb2['default'], null), _react2['default'].createElement(_componentsNavigation2['default'], null), @@ -23597,21 +31231,48 @@ var Root = (function (_Component) { _react2['default'].createElement(RenameDialog, null), _react2['default'].createElement(DeleteDialog, null), _react2['default'].createElement(ErrorDialog, null), - _react2['default'].createElement(CreateDialog, null) + _react2['default'].createElement(CreateDialog, null), + _react2['default'].createElement(SearchDialog, null), + _react2['default'].createElement(_componentsSpinner2['default'], null) ); } }, { key: 'touchStart', value: function touchStart(e) { var active = document.querySelector('.active'); - var inside = e.target.closest('.menu') || e.target.closest('.dialog'); - if (!inside && active) { + var inside = e.target.closest('.active'); + if (active && !inside) { e.preventDefault(); e.stopPropagation(); _store2['default'].dispatch((0, _actionsMenu.hideAll)()); _store2['default'].dispatch((0, _actionsDialog.hideAll)()); } + + if (document.querySelector('.sk-cube-grid.show')) { + e.preventDefault(); + e.stopPropagation(); + } + } + }, { + key: 'onClick', + value: function onClick(e) { + var tag = e.target.nodeName.toLowerCase(); + if (tag === 'a') { + var url = new URL(e.target.href); + + if (url.origin !== location.origin) { + e.preventDefault(); + new MozActivity({ + name: 'view', + + data: { + type: 'url', + url: e.target.href + } + }); + } + } } }]); @@ -23621,7 +31282,73 @@ var Root = (function (_Component) { exports['default'] = Root; module.exports = exports['default']; -},{"actions/changedir":215,"actions/dialog":216,"actions/menu":220,"components/breadcrumb":225,"components/dialog":226,"components/file-list":228,"components/header":230,"components/menu":231,"components/navigation":232,"components/toolbar":234,"react":205,"react-redux":45,"store":"store"}],234:[function(require,module,exports){ +},{"actions/changedir":217,"actions/dialog":218,"actions/menu":221,"components/breadcrumb":227,"components/dialog":228,"components/file-list":230,"components/header":232,"components/menu":233,"components/navigation":235,"components/spinner":237,"components/toolbar":238,"react":207,"react-redux":47,"store":"store"}],237:[function(require,module,exports){ +'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; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _reactRedux = require('react-redux'); + +var Spinner = (function (_Component) { + _inherits(Spinner, _Component); + + function Spinner() { + _classCallCheck(this, _Spinner); + + _get(Object.getPrototypeOf(_Spinner.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(Spinner, [{ + key: 'render', + value: function render() { + var className = 'sk-cube-grid ' + (this.props.active ? ' show' : ''); + return _react2['default'].createElement( + 'div', + { className: className }, + _react2['default'].createElement('div', { className: 'sk-cube sk-cube1' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube2' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube3' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube4' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube5' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube6' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube7' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube8' }), + _react2['default'].createElement('div', { className: 'sk-cube sk-cube9' }) + ); + } + }]); + + var _Spinner = Spinner; + Spinner = (0, _reactRedux.connect)(props)(Spinner) || Spinner; + return Spinner; +})(_react.Component); + +exports['default'] = Spinner; + +function props(state) { + return { + active: state.get('spinner') + }; +} +module.exports = exports['default']; + +},{"react":207,"react-redux":47}],238:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23670,7 +31397,7 @@ var Toolbar = (function (_Component) { 'div', { className: 'toolbar' }, _react2['default'].createElement('button', { className: 'icon-plus', onClick: this.newFile }), - _react2['default'].createElement('button', { className: 'icon-view', onClick: (0, _store.bind)((0, _actionsFilesView.toggle)()) }), + _react2['default'].createElement('button', { className: 'icon-view coming-soon', onClick: (0, _store.bind)((0, _actionsFilesView.toggle)()) }), _react2['default'].createElement('button', { className: 'icon-refresh', onClick: (0, _store.bind)((0, _actionsFilesView.refresh)()) }), _react2['default'].createElement('button', { className: 'icon-select', onClick: (0, _store.bind)((0, _actionsFilesView.selectView)('toggle')) }), _react2['default'].createElement('button', { className: 'icon-more', onClick: this.showMore.bind(this), ref: 'more' }) @@ -23708,7 +31435,7 @@ var Toolbar = (function (_Component) { exports['default'] = Toolbar; module.exports = exports['default']; -},{"./menu":231,"actions/dialog":216,"actions/files-view":218,"actions/menu":220,"react":205,"store":"store"}],235:[function(require,module,exports){ +},{"./menu":233,"actions/dialog":218,"actions/files-view":220,"actions/menu":221,"react":207,"store":"store"}],239:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23725,6 +31452,8 @@ var _actionsDialog = require('actions/dialog'); var _actionsFile = require('actions/file'); +var _actionsFilesView = require('actions/files-view'); + var _store = require('store'); var _store2 = _interopRequireDefault(_store); @@ -23788,7 +31517,7 @@ exports['default'] = { text: 'Yes', action: function action() { var activeFile = _store2['default'].getState().get('activeFile'); - this.props.dispatch((0, _actionsFile.deleteFile)(activeFile)); + this.props.dispatch((0, _actionsFile.remove)(activeFile)); this.props.dispatch((0, _actionsDialog.hideAll)()); this.props.dispatch((0, _actionsFile.active)()); }, @@ -23801,11 +31530,29 @@ exports['default'] = { text: 'Continue', action: (0, _store.bind)((0, _actionsDialog.hideAll)()) }] + }, + searchDialog: { + title: 'Search', + description: 'Enter keywords to search for', + input: true, + buttons: [{ + text: 'Cancel', + action: (0, _store.bind)((0, _actionsDialog.hideAll)()) + }, { + text: 'Search', + action: function action() { + var input = _react2['default'].findDOMNode(this.refs.input); + + var action = (0, _actionsFilesView.search)(input.value); + this.props.dispatch(action); + this.props.dispatch((0, _actionsDialog.hideAll)()); + } + }] } }; module.exports = exports['default']; -},{"actions/dialog":216,"actions/file":217,"react":205,"store":"store"}],236:[function(require,module,exports){ +},{"actions/dialog":218,"actions/file":219,"actions/files-view":220,"react":207,"store":"store"}],240:[function(require,module,exports){ 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -23833,7 +31580,7 @@ _react2['default'].render(_react2['default'].createElement( } ), wrapper); -},{"components/root":233,"react":205,"react-redux":45,"store":"store"}],237:[function(require,module,exports){ +},{"components/root":236,"react":207,"react-redux":47,"store":"store"}],241:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23846,6 +31593,10 @@ var _actionsMenu = require('actions/menu'); var _actionsDialog = require('actions/dialog'); +var _actionsFilesView = require('actions/files-view'); + +var _actionsFile = require('actions/file'); + var _store = require('store'); var _store2 = _interopRequireDefault(_store); @@ -23856,8 +31607,7 @@ var entryMenu = { action: function action() { var files = _store2['default'].getState().get('files'); var active = _store2['default'].getState().get('activeFile'); - var name = files[active].name; - var description = 'Are you sure you want to remove ' + name + '?'; + var description = 'Enter the new name for ' + active[0].name + '?'; _store2['default'].dispatch((0, _actionsMenu.hideAll)()); _store2['default'].dispatch((0, _actionsDialog.show)('renameDialog', { description: description })); @@ -23867,11 +31617,16 @@ var entryMenu = { action: function action() { var files = _store2['default'].getState().get('files'); var active = _store2['default'].getState().get('activeFile'); - var name = files[active].name; - var description = 'Are you sure you want to remove ' + name + '?'; + var description = 'Are you sure you want to remove ' + active[0].name + '?'; _store2['default'].dispatch((0, _actionsMenu.hideAll)()); _store2['default'].dispatch((0, _actionsDialog.show)('deleteDialog', { description: description })); } + }, { + name: 'Copy', + action: function action() { + _store2['default'].dispatch((0, _actionsFilesView.selectView)(false)); + _store2['default'].dispatch((0, _actionsMenu.hideAll)()); + } }] }; @@ -23883,16 +31638,52 @@ var moreMenu = { var active = _store2['default'].getState().get('activeFile'); var description = undefined; - if (active.length) { + if (active.length > 1) { var count = active.length; description = 'Are you sure you want to remove ' + count + ' files?'; } else { - var _name = files[active].name; + var _name = active[0].name; description = 'Are you sure you want to remove ' + _name + '?'; } _store2['default'].dispatch((0, _actionsMenu.hideAll)()); _store2['default'].dispatch((0, _actionsDialog.show)('deleteDialog', { description: description })); + }, + enabled: function enabled() { + return _store2['default'].getState().get('activeFile'); + } + }, { + name: 'Copy', + action: function action() { + _store2['default'].dispatch((0, _actionsFilesView.selectView)(false)); + _store2['default'].dispatch((0, _actionsMenu.hideAll)()); + }, + enabled: function enabled() { + return _store2['default'].getState().get('activeFile'); + } + }, { + name: 'Paste', + enabled: function enabled() { + return _store2['default'].getState().get('activeFile'); + }, + action: function action() { + var active = _store2['default'].getState().get('activeFile'); + var cwd = _store2['default'].getState().get('cwd'); + + _store2['default'].dispatch((0, _actionsFile.copy)(active, cwd)); + _store2['default'].dispatch((0, _actionsMenu.hideAll)()); + } + }, { + name: 'Move', + enabled: function enabled() { + return _store2['default'].getState().get('activeFile'); + }, + action: function action() { + var active = _store2['default'].getState().get('activeFile'); + var cwd = _store2['default'].getState().get('cwd'); + + _store2['default'].dispatch((0, _actionsFile.move)(active, cwd)); + _store2['default'].dispatch((0, _actionsMenu.hideAll)()); } }] }; @@ -23904,7 +31695,7 @@ exports['default'] = { }; module.exports = exports['default']; -},{"actions/dialog":216,"actions/menu":220,"store":"store"}],238:[function(require,module,exports){ +},{"actions/dialog":218,"actions/file":219,"actions/files-view":220,"actions/menu":221,"store":"store"}],242:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23925,7 +31716,7 @@ exports['default'] = function (state, action) { module.exports = exports['default']; -},{"actions/types":223}],239:[function(require,module,exports){ +},{"actions/types":225}],243:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -23974,6 +31765,14 @@ var _selectView = require('./select-view'); var _selectView2 = _interopRequireDefault(_selectView); +var _spinner = require('./spinner'); + +var _spinner2 = _interopRequireDefault(_spinner); + +var _search = require('./search'); + +var _search2 = _interopRequireDefault(_search); + exports['default'] = function (state, action) { if (state === undefined) state = new _immutable2['default'].Map(); @@ -23982,6 +31781,8 @@ exports['default'] = function (state, action) { lwd: (0, _lwd2['default'])(state, action), // last working directory cwd: (0, _cwd2['default'])(state.get('cwd'), action), files: (0, _files2['default'])(state.get('files'), action), + search: (0, _search2['default'])(state.get('search'), action), + spinner: (0, _spinner2['default'])(state.get('spinner'), action), selectView: (0, _selectView2['default'])(state.get('selectView'), action), activeFile: (0, _activeFile2['default'])(state.get('activeFile'), action), navigation: (0, _navigation2['default'])(state.get('navigation'), action), @@ -23992,13 +31793,14 @@ exports['default'] = function (state, action) { renameDialog: (0, _dialog2['default'])(state, action, 'renameDialog'), deleteDialog: (0, _dialog2['default'])(state, action, 'deleteDialog'), errorDialog: (0, _dialog2['default'])(state, action, 'errorDialog'), - createDialog: (0, _dialog2['default'])(state, action, 'createDialog') + createDialog: (0, _dialog2['default'])(state, action, 'createDialog'), + searchDialog: (0, _dialog2['default'])(state, action, 'searchDialog') }); }; module.exports = exports['default']; -},{"./active-file":238,"./cwd":240,"./dialog":241,"./files":242,"./lwd":243,"./menu":244,"./navigation":245,"./select-view":246,"./settings":247,"immutable":248}],240:[function(require,module,exports){ +},{"./active-file":242,"./cwd":244,"./dialog":245,"./files":246,"./lwd":247,"./menu":248,"./navigation":249,"./search":250,"./select-view":251,"./settings":252,"./spinner":253,"immutable":3}],244:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24009,10 +31811,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd var _actionsTypes = require('actions/types'); -var _actionsListFiles = require('actions/list-files'); - -var _actionsListFiles2 = _interopRequireDefault(_actionsListFiles); - var _apiFiles = require('api/files'); var _store = require('store'); @@ -24021,6 +31819,8 @@ var _store2 = _interopRequireDefault(_store); var _utils = require('utils'); +var _actionsFilesView = require('actions/files-view'); + exports['default'] = function (state, action) { if (state === undefined) state = ''; @@ -24041,12 +31841,12 @@ exports['default'] = function (state, action) { function changeTo(dir) { (0, _apiFiles.children)(dir, true).then(function (files) { - _store2['default'].dispatch((0, _actionsListFiles2['default'])(files)); + _store2['default'].dispatch((0, _actionsFilesView.listFiles)(files)); }, _utils.reportError); } module.exports = exports['default']; -},{"actions/list-files":219,"actions/types":223,"api/files":224,"store":"store","utils":"utils"}],241:[function(require,module,exports){ +},{"actions/files-view":220,"actions/types":225,"api/files":226,"store":"store","utils":"utils"}],245:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24088,7 +31888,7 @@ exports['default'] = function (state, action, id) { module.exports = exports['default']; -},{"actions/types":223,"immutable":248,"lodash/object/omit":37}],242:[function(require,module,exports){ +},{"actions/types":225,"immutable":3,"lodash/object/omit":39}],246:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24117,23 +31917,37 @@ exports['default'] = function (state, action) { if (state === undefined) state = []; if (action.type === _actionsTypes.LIST_FILES) { + var _ret = (function () { + var settings = _store2['default'].getState().get('settings'); - var settings = _store2['default'].getState().get('settings'); + if (settings.showDirectoriesFirst) { + action.files = action.files.sort(function (a, b) { + if ((0, _utils.type)(a) === 'Directory') return -1; + if ((0, _utils.type)(a) === 'File') return 1; + }); + } - if (settings.showDirectoriesFirst) { - action.files = action.files.sort(function (a, b) { - if ((0, _utils.type)(a) === 'Directory') return -1; - if ((0, _utils.type)(a) === 'File') return 1; - }); - } + if (!settings.showHiddenFiles) { + action.files = action.files.filter(function (file) { + return file.name[0] !== '.'; + }); + } - if (!settings.showHiddenFiles) { - action.files = action.files.filter(function (file) { - return file.name[0] !== '.'; - }); - } + if (settings.filter) { + action.files = action.files.filter(function (file) { + if ((0, _utils.type)(file) === 'Directory') return true; - return action.files; + var fileType = file.type.slice(0, file.type.indexOf('/')); + return fileType === settings.filter; + }); + } + + return { + v: action.files + }; + })(); + + if (typeof _ret === 'object') return _ret.v; } if (action.type === _actionsTypes.CREATE_FILE) { @@ -24144,63 +31958,51 @@ exports['default'] = function (state, action) { } if (action.type === _actionsTypes.RENAME_FILE) { - var file = state[action.file]; + var all = Promise.all(action.file.map(function (file) { + return (0, _apiFiles.move)(file, (file.path || '') + action.name); + })); - (0, _apiFiles.move)(file, (file.path || '') + action.name).then(boundRefresh, _utils.reportError); + all.then(boundRefresh, _utils.reportError); + return state; + } + if (action.type === _actionsTypes.MOVE_FILE) { + var all = Promise.all(action.file.map(function (file) { + return (0, _apiFiles.move)(file, action.newPath + '/' + file.name); + })); + + all.then(boundRefresh, _utils.reportError); + return state; + } + + if (action.type === _actionsTypes.COPY_FILE) { + var all = Promise.all(action.file.map(function (file) { + return (0, _apiFiles.copy)(file, action.newPath + '/' + file.name); + })); + + all.then(boundRefresh, _utils.reportError); return state; } if (action.type === _actionsTypes.DELETE_FILE) { - var copy = state.slice(0); + var all = Promise.all(action.file.map(function (file) { + var path = ((file.path || '') + file.name).replace(/^\//, ''); + return (0, _apiFiles.remove)(path, true); + })); - if (action.file.length) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = action.file[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var index = _step.value; - - del(state, index); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator['return']) { - _iterator['return'](); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - copy = copy.filter(function (a, i) { - return action.file.indexOf(i) === -1; - }); - } else { - del(state, action.file); - copy.splice(action.file, 1); - } - - return copy; + all.then(boundRefresh, _utils.reportError); + return state; } return state; }; -function del(state, index) { - var file = state[index]; - return (0, _apiFiles.remove)((file.path || '') + '/' + file.name)['catch'](_utils.reportError); +function mov(file, newPath) { + return; } module.exports = exports['default']; -},{"actions/dialog":216,"actions/files-view":218,"actions/types":223,"api/files":224,"store":"store","utils":"utils"}],243:[function(require,module,exports){ +},{"actions/dialog":218,"actions/files-view":220,"actions/types":225,"api/files":226,"store":"store","utils":"utils"}],247:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24220,7 +32022,7 @@ exports['default'] = function (state, action) { module.exports = exports['default']; -},{"actions/types":223}],244:[function(require,module,exports){ +},{"actions/types":225}],248:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24262,7 +32064,7 @@ exports['default'] = function (state, action, id) { module.exports = exports['default']; -},{"actions/types":223,"immutable":248,"lodash/object/omit":37}],245:[function(require,module,exports){ +},{"actions/types":225,"immutable":3,"lodash/object/omit":39}],249:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24283,7 +32085,75 @@ exports['default'] = function (state, action) { module.exports = exports['default']; -},{"actions/types":223}],246:[function(require,module,exports){ +},{"actions/types":225}],250:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _actionsTypes = require('actions/types'); + +var _store = require('store'); + +var _store2 = _interopRequireDefault(_store); + +var _utils = require('utils'); + +var _actionsFilesView = require('actions/files-view'); + +var _apiFiles = require('api/files'); + +exports['default'] = function (state, action) { + if (state === undefined) state = ''; + + if (action.type === _actionsTypes.SEARCH) { + search(action.keywords); + + return action.keywords; + } + + return state; +}; + +function search(keywords) { + if (!keywords) { + var cwd = _store2['default'].getState().get('cwd'); + console.log(cwd); + (0, _apiFiles.children)(cwd, true).then(function (files) { + _store2['default'].dispatch((0, _actionsFilesView.listFiles)(files)); + }, _utils.reportError); + return ''; + } + var keys = keywords.split(' '); + + // We don't want to show all the currently visible files from the + // first iteration + var once = true; + (0, _apiFiles.children)('/', true).then(function showResults(files) { + if (!_store2['default'].getState().get('search')) return; + + var current = once ? [] : _store2['default'].getState().get('files'); + once = false; + + var filtered = files.filter(function (file) { + if ((0, _utils.type)(file) === 'Directory') { + var path = (file.path + file.name).replace(/^\//, ''); + (0, _apiFiles.children)(path, true).then(showResults, _utils.reportError); + } + return keys.some(function (key) { + return file.name.indexOf(key) > -1; + }); + }); + + _store2['default'].dispatch((0, _actionsFilesView.listFiles)(current.concat(filtered))); + }, _utils.reportError); +} +module.exports = exports['default']; + +},{"actions/files-view":220,"actions/types":225,"api/files":226,"store":"store","utils":"utils"}],251:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24304,7 +32174,7 @@ exports['default'] = function (state, action) { module.exports = exports['default']; -},{"actions/types":223}],247:[function(require,module,exports){ +},{"actions/types":225}],252:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -24336,4935 +32206,40 @@ exports['default'] = function (state, action) { module.exports = exports['default']; -},{"actions/types":223,"lodash/object/omit":37}],248:[function(require,module,exports){ -/** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - global.Immutable = factory() -}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice; +},{"actions/types":225,"lodash/object/omit":39}],253:[function(require,module,exports){ +'use strict'; - function createClass(ctor, superClass) { - if (superClass) { - ctor.prototype = Object.create(superClass.prototype); - } - ctor.prototype.constructor = ctor; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _actionsTypes = require('actions/types'); + +exports['default'] = function (state, action) { + if (state === undefined) state = false; + + if (action.type === _actionsTypes.SPINNER) { + return action.active === 'toggle' ? !state : action.active; } - // Used for setting prototype methods that IE8 chokes on. - var DELETE = 'delete'; - - // Constants describing the size of trie nodes. - var SHIFT = 5; // Resulted in best performance after ______? - var SIZE = 1 << SHIFT; - var MASK = SIZE - 1; - - // A consistent shared value representing "not set" which equals nothing other - // than itself, and nothing that could be provided externally. - var NOT_SET = {}; - - // Boolean references, Rough equivalent of `bool &`. - var CHANGE_LENGTH = { value: false }; - var DID_ALTER = { value: false }; - - function MakeRef(ref) { - ref.value = false; - return ref; - } - - function SetRef(ref) { - ref && (ref.value = true); - } - - // A function which returns a value representing an "owner" for transient writes - // to tries. The return value will only ever equal itself, and will not equal - // the return of any subsequent call of this function. - function OwnerID() {} - - // http://jsperf.com/copy-array-inline - function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; - } - - function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); - } - return iter.size; - } - - function wrapIndex(iter, index) { - return index >= 0 ? (+index) : ensureSize(iter) + (+index); - } - - function returnTrue() { - return true; - } - - function wholeSlice(begin, end, size) { - return (begin === 0 || (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)); - } - - function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); - } - - function resolveEnd(end, size) { - return resolveIndex(end, size, size); - } - - function resolveIndex(index, size, defaultIndex) { - return index === undefined ? - defaultIndex : - index < 0 ? - Math.max(0, size + index) : - size === undefined ? - index : - Math.min(size, index); - } - - function Iterable(value) { - return isIterable(value) ? value : Seq(value); - } - - - createClass(KeyedIterable, Iterable); - function KeyedIterable(value) { - return isKeyed(value) ? value : KeyedSeq(value); - } - - - createClass(IndexedIterable, Iterable); - function IndexedIterable(value) { - return isIndexed(value) ? value : IndexedSeq(value); - } - - - createClass(SetIterable, Iterable); - function SetIterable(value) { - return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); - } - - - - function isIterable(maybeIterable) { - return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); - } - - function isKeyed(maybeKeyed) { - return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); - } - - function isIndexed(maybeIndexed) { - return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); - } - - function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); - } - - function isOrdered(maybeOrdered) { - return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); - } - - Iterable.isIterable = isIterable; - Iterable.isKeyed = isKeyed; - Iterable.isIndexed = isIndexed; - Iterable.isAssociative = isAssociative; - Iterable.isOrdered = isOrdered; - - Iterable.Keyed = KeyedIterable; - Iterable.Indexed = IndexedIterable; - Iterable.Set = SetIterable; - - - var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; - var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; - var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; - var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; - - /* global Symbol */ - - var ITERATE_KEYS = 0; - var ITERATE_VALUES = 1; - var ITERATE_ENTRIES = 2; - - var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - - var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - - - function src_Iterator__Iterator(next) { - this.next = next; - } - - src_Iterator__Iterator.prototype.toString = function() { - return '[Iterator]'; - }; - - - src_Iterator__Iterator.KEYS = ITERATE_KEYS; - src_Iterator__Iterator.VALUES = ITERATE_VALUES; - src_Iterator__Iterator.ENTRIES = ITERATE_ENTRIES; - - src_Iterator__Iterator.prototype.inspect = - src_Iterator__Iterator.prototype.toSource = function () { return this.toString(); } - src_Iterator__Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; - }; - - - function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { - value: value, done: false - }); - return iteratorResult; - } - - function iteratorDone() { - return { value: undefined, done: true }; - } - - function hasIterator(maybeIterable) { - return !!getIteratorFn(maybeIterable); - } - - function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; - } - - function getIterator(iterable) { - var iteratorFn = getIteratorFn(iterable); - return iteratorFn && iteratorFn.call(iterable); - } - - function getIteratorFn(iterable) { - var iteratorFn = iterable && ( - (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || - iterable[FAUX_ITERATOR_SYMBOL] - ); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } - } - - function isArrayLike(value) { - return value && typeof value.length === 'number'; - } - - createClass(Seq, Iterable); - function Seq(value) { - return value === null || value === undefined ? emptySequence() : - isIterable(value) ? value.toSeq() : seqFromValue(value); - } - - Seq.of = function(/*...values*/) { - return Seq(arguments); - }; - - Seq.prototype.toSeq = function() { - return this; - }; - - Seq.prototype.toString = function() { - return this.__toString('Seq {', '}'); - }; - - Seq.prototype.cacheResult = function() { - if (!this._cache && this.__iterateUncached) { - this._cache = this.entrySeq().toArray(); - this.size = this._cache.length; - } - return this; - }; - - // abstract __iterateUncached(fn, reverse) - - Seq.prototype.__iterate = function(fn, reverse) { - return seqIterate(this, fn, reverse, true); - }; - - // abstract __iteratorUncached(type, reverse) - - Seq.prototype.__iterator = function(type, reverse) { - return seqIterator(this, type, reverse, true); - }; - - - - createClass(KeyedSeq, Seq); - function KeyedSeq(value) { - return value === null || value === undefined ? - emptySequence().toKeyedSeq() : - isIterable(value) ? - (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) : - keyedSeqFromValue(value); - } - - KeyedSeq.prototype.toKeyedSeq = function() { - return this; - }; - - - - createClass(IndexedSeq, Seq); - function IndexedSeq(value) { - return value === null || value === undefined ? emptySequence() : - !isIterable(value) ? indexedSeqFromValue(value) : - isKeyed(value) ? value.entrySeq() : value.toIndexedSeq(); - } - - IndexedSeq.of = function(/*...values*/) { - return IndexedSeq(arguments); - }; - - IndexedSeq.prototype.toIndexedSeq = function() { - return this; - }; - - IndexedSeq.prototype.toString = function() { - return this.__toString('Seq [', ']'); - }; - - IndexedSeq.prototype.__iterate = function(fn, reverse) { - return seqIterate(this, fn, reverse, false); - }; - - IndexedSeq.prototype.__iterator = function(type, reverse) { - return seqIterator(this, type, reverse, false); - }; - - - - createClass(SetSeq, Seq); - function SetSeq(value) { - return ( - value === null || value === undefined ? emptySequence() : - !isIterable(value) ? indexedSeqFromValue(value) : - isKeyed(value) ? value.entrySeq() : value - ).toSetSeq(); - } - - SetSeq.of = function(/*...values*/) { - return SetSeq(arguments); - }; - - SetSeq.prototype.toSetSeq = function() { - return this; - }; - - - - Seq.isSeq = isSeq; - Seq.Keyed = KeyedSeq; - Seq.Set = SetSeq; - Seq.Indexed = IndexedSeq; - - var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; - - Seq.prototype[IS_SEQ_SENTINEL] = true; - - - - // #pragma Root Sequences - - createClass(ArraySeq, IndexedSeq); - function ArraySeq(array) { - this._array = array; - this.size = array.length; - } - - ArraySeq.prototype.get = function(index, notSetValue) { - return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; - }; - - ArraySeq.prototype.__iterate = function(fn, reverse) { - var array = this._array; - var maxIndex = array.length - 1; - for (var ii = 0; ii <= maxIndex; ii++) { - if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) { - return ii + 1; - } - } - return ii; - }; - - ArraySeq.prototype.__iterator = function(type, reverse) { - var array = this._array; - var maxIndex = array.length - 1; - var ii = 0; - return new src_Iterator__Iterator(function() - {return ii > maxIndex ? - iteratorDone() : - iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])} - ); - }; - - - - createClass(ObjectSeq, KeyedSeq); - function ObjectSeq(object) { - var keys = Object.keys(object); - this._object = object; - this._keys = keys; - this.size = keys.length; - } - - ObjectSeq.prototype.get = function(key, notSetValue) { - if (notSetValue !== undefined && !this.has(key)) { - return notSetValue; - } - return this._object[key]; - }; - - ObjectSeq.prototype.has = function(key) { - return this._object.hasOwnProperty(key); - }; - - ObjectSeq.prototype.__iterate = function(fn, reverse) { - var object = this._object; - var keys = this._keys; - var maxIndex = keys.length - 1; - for (var ii = 0; ii <= maxIndex; ii++) { - var key = keys[reverse ? maxIndex - ii : ii]; - if (fn(object[key], key, this) === false) { - return ii + 1; - } - } - return ii; - }; - - ObjectSeq.prototype.__iterator = function(type, reverse) { - var object = this._object; - var keys = this._keys; - var maxIndex = keys.length - 1; - var ii = 0; - return new src_Iterator__Iterator(function() { - var key = keys[reverse ? maxIndex - ii : ii]; - return ii++ > maxIndex ? - iteratorDone() : - iteratorValue(type, key, object[key]); - }); - }; - - ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; - - - createClass(IterableSeq, IndexedSeq); - function IterableSeq(iterable) { - this._iterable = iterable; - this.size = iterable.length || iterable.size; - } - - IterableSeq.prototype.__iterateUncached = function(fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterable = this._iterable; - var iterator = getIterator(iterable); - var iterations = 0; - if (isIterator(iterator)) { - var step; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - } - return iterations; - }; - - IterableSeq.prototype.__iteratorUncached = function(type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterable = this._iterable; - var iterator = getIterator(iterable); - if (!isIterator(iterator)) { - return new src_Iterator__Iterator(iteratorDone); - } - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : iteratorValue(type, iterations++, step.value); - }); - }; - - - - createClass(IteratorSeq, IndexedSeq); - function IteratorSeq(iterator) { - this._iterator = iterator; - this._iteratorCache = []; - } - - IteratorSeq.prototype.__iterateUncached = function(fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - while (iterations < cache.length) { - if (fn(cache[iterations], iterations++, this) === false) { - return iterations; - } - } - var step; - while (!(step = iterator.next()).done) { - var val = step.value; - cache[iterations] = val; - if (fn(val, iterations++, this) === false) { - break; - } - } - return iterations; - }; - - IteratorSeq.prototype.__iteratorUncached = function(type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - return new src_Iterator__Iterator(function() { - if (iterations >= cache.length) { - var step = iterator.next(); - if (step.done) { - return step; - } - cache[iterations] = step.value; - } - return iteratorValue(type, iterations, cache[iterations++]); - }); - }; - - - - - // # pragma Helper functions - - function isSeq(maybeSeq) { - return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]); - } - - var EMPTY_SEQ; - - function emptySequence() { - return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); - } - - function keyedSeqFromValue(value) { - var seq = - Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() : - isIterator(value) ? new IteratorSeq(value).fromEntrySeq() : - hasIterator(value) ? new IterableSeq(value).fromEntrySeq() : - typeof value === 'object' ? new ObjectSeq(value) : - undefined; - if (!seq) { - throw new TypeError( - 'Expected Array or iterable object of [k, v] entries, '+ - 'or keyed object: ' + value - ); - } - return seq; - } - - function indexedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (!seq) { - throw new TypeError( - 'Expected Array or iterable object of values: ' + value - ); - } - return seq; - } - - function seqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value) || - (typeof value === 'object' && new ObjectSeq(value)); - if (!seq) { - throw new TypeError( - 'Expected Array or iterable object of values, or keyed object: ' + value - ); - } - return seq; - } - - function maybeIndexedSeqFromValue(value) { - return ( - isArrayLike(value) ? new ArraySeq(value) : - isIterator(value) ? new IteratorSeq(value) : - hasIterator(value) ? new IterableSeq(value) : - undefined - ); - } - - function seqIterate(seq, fn, reverse, useKeys) { - var cache = seq._cache; - if (cache) { - var maxIndex = cache.length - 1; - for (var ii = 0; ii <= maxIndex; ii++) { - var entry = cache[reverse ? maxIndex - ii : ii]; - if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) { - return ii + 1; - } - } - return ii; - } - return seq.__iterateUncached(fn, reverse); - } - - function seqIterator(seq, type, reverse, useKeys) { - var cache = seq._cache; - if (cache) { - var maxIndex = cache.length - 1; - var ii = 0; - return new src_Iterator__Iterator(function() { - var entry = cache[reverse ? maxIndex - ii : ii]; - return ii++ > maxIndex ? - iteratorDone() : - iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]); - }); - } - return seq.__iteratorUncached(type, reverse); - } - - createClass(Collection, Iterable); - function Collection() { - throw TypeError('Abstract'); - } - - - createClass(KeyedCollection, Collection);function KeyedCollection() {} - - createClass(IndexedCollection, Collection);function IndexedCollection() {} - - createClass(SetCollection, Collection);function SetCollection() {} - - - Collection.Keyed = KeyedCollection; - Collection.Indexed = IndexedCollection; - Collection.Set = SetCollection; - - /** - * An extension of the "same-value" algorithm as [described for use by ES6 Map - * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) - * - * NaN is considered the same as NaN, however -0 and 0 are considered the same - * value, which is different from the algorithm described by - * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). - * - * This is extended further to allow Objects to describe the values they - * represent, by way of `valueOf` or `equals` (and `hashCode`). - * - * Note: because of this extension, the key equality of Immutable.Map and the - * value equality of Immutable.Set will differ from ES6 Map and Set. - * - * ### Defining custom values - * - * The easiest way to describe the value an object represents is by implementing - * `valueOf`. For example, `Date` represents a value by returning a unix - * timestamp for `valueOf`: - * - * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... - * var date2 = new Date(1234567890000); - * date1.valueOf(); // 1234567890000 - * assert( date1 !== date2 ); - * assert( Immutable.is( date1, date2 ) ); - * - * Note: overriding `valueOf` may have other implications if you use this object - * where JavaScript expects a primitive, such as implicit string coercion. - * - * For more complex types, especially collections, implementing `valueOf` may - * not be performant. An alternative is to implement `equals` and `hashCode`. - * - * `equals` takes another object, presumably of similar type, and returns true - * if the it is equal. Equality is symmetrical, so the same result should be - * returned if this and the argument are flipped. - * - * assert( a.equals(b) === b.equals(a) ); - * - * `hashCode` returns a 32bit integer number representing the object which will - * be used to determine how to store the value object in a Map or Set. You must - * provide both or neither methods, one must not exist without the other. - * - * Also, an important relationship between these methods must be upheld: if two - * values are equal, they *must* return the same hashCode. If the values are not - * equal, they might have the same hashCode; this is called a hash collision, - * and while undesirable for performance reasons, it is acceptable. - * - * if (a.equals(b)) { - * assert( a.hashCode() === b.hashCode() ); - * } - * - * All Immutable collections implement `equals` and `hashCode`. - * - */ - function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if (typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function') { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - } - if (typeof valueA.equals === 'function' && - typeof valueB.equals === 'function' && - valueA.equals(valueB)) { - return true; - } + if (action.type === _actionsTypes.DIALOG && action.id === 'errorDialog') { return false; } - function fromJS(json, converter) { - return converter ? - fromJSWith(converter, json, '', {'': json}) : - fromJSDefault(json); - } - - function fromJSWith(converter, json, key, parentJSON) { - if (Array.isArray(json)) { - return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); - } - if (isPlainObj(json)) { - return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); - } - return json; - } - - function fromJSDefault(json) { - if (Array.isArray(json)) { - return IndexedSeq(json).map(fromJSDefault).toList(); - } - if (isPlainObj(json)) { - return KeyedSeq(json).map(fromJSDefault).toMap(); - } - return json; - } - - function isPlainObj(value) { - return value && (value.constructor === Object || value.constructor === undefined); - } - - var src_Math__imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? - Math.imul : - function src_Math__imul(a, b) { - a = a | 0; // int - b = b | 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int - }; - - // v8 has an optimization for storing 31-bit signed numbers. - // Values which have either 00 or 11 as the high order bits qualify. - // This function drops the highest order bit in a signed number, maintaining - // the sign bit. - function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF); - } - - function hash(o) { - if (o === false || o === null || o === undefined) { - return 0; - } - if (typeof o.valueOf === 'function') { - o = o.valueOf(); - if (o === false || o === null || o === undefined) { - return 0; - } - } - if (o === true) { - return 1; - } - var type = typeof o; - if (type === 'number') { - var h = o | 0; - if (h !== o) { - h ^= o * 0xFFFFFFFF; - } - while (o > 0xFFFFFFFF) { - o /= 0xFFFFFFFF; - h ^= o; - } - return smi(h); - } - if (type === 'string') { - return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o); - } - if (typeof o.hashCode === 'function') { - return o.hashCode(); - } - return hashJSObj(o); - } - - function cachedHashString(string) { - var hash = stringHashCache[string]; - if (hash === undefined) { - hash = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hash; - } - return hash; - } - - // http://jsperf.com/hashing-strings - function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hash = 0; - for (var ii = 0; ii < string.length; ii++) { - hash = 31 * hash + string.charCodeAt(ii) | 0; - } - return smi(hash); - } - - function hashJSObj(obj) { - var hash; - if (usingWeakMap) { - hash = weakMap.get(obj); - if (hash !== undefined) { - return hash; - } - } - - hash = obj[UID_HASH_KEY]; - if (hash !== undefined) { - return hash; - } - - if (!canDefineProperty) { - hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hash !== undefined) { - return hash; - } - - hash = getIENodeHash(obj); - if (hash !== undefined) { - return hash; - } - } - - hash = ++objHashUID; - if (objHashUID & 0x40000000) { - objHashUID = 0; - } - - if (usingWeakMap) { - weakMap.set(obj, hash); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - 'enumerable': false, - 'configurable': false, - 'writable': false, - 'value': hash - }); - } else if (obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function() { - return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments); - }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hash; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hash; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } - - return hash; - } - - // Get references to ES5 object methods. - var isExtensible = Object.isExtensible; - - // True if Object.defineProperty works as expected. IE8 fails this test. - var canDefineProperty = (function() { - try { - Object.defineProperty({}, '@', {}); + switch (action.type) { + case _actionsTypes.CHANGE_DIRECTORY: + case _actionsTypes.REFRESH: return true; - } catch (e) { + case _actionsTypes.LIST_FILES: return false; - } - }()); - - // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it - // and avoid memory leaks from the IE cloneNode bug. - function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; - } - } - } - - // If possible, use a WeakMap. - var usingWeakMap = typeof WeakMap === 'function'; - var weakMap; - if (usingWeakMap) { - weakMap = new WeakMap(); - } - - var objHashUID = 0; - - var UID_HASH_KEY = '__immutablehash__'; - if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); - } - - var STRING_HASH_CACHE_MIN_STRLEN = 16; - var STRING_HASH_CACHE_MAX_SIZE = 255; - var STRING_HASH_CACHE_SIZE = 0; - var stringHashCache = {}; - - function invariant(condition, error) { - if (!condition) throw new Error(error); - } - - function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); - } - - createClass(ToKeyedSequence, KeyedSeq); - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; - } - - ToKeyedSequence.prototype.get = function(key, notSetValue) { - return this._iter.get(key, notSetValue); - }; - - ToKeyedSequence.prototype.has = function(key) { - return this._iter.has(key); - }; - - ToKeyedSequence.prototype.valueSeq = function() { - return this._iter.valueSeq(); - }; - - ToKeyedSequence.prototype.reverse = function() {var this$0 = this; - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()}; - } - return reversedSequence; - }; - - ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this; - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)}; - } - return mappedSequence; - }; - - ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var ii; - return this._iter.__iterate( - this._useKeys ? - function(v, k) {return fn(v, k, this$0)} : - ((ii = reverse ? resolveSize(this) : 0), - function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}), - reverse - ); - }; - - ToKeyedSequence.prototype.__iterator = function(type, reverse) { - if (this._useKeys) { - return this._iter.__iterator(type, reverse); - } - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var ii = reverse ? resolveSize(this) : 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, reverse ? --ii : ii++, step.value, step); - }); - }; - - ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; - - - createClass(ToIndexedSequence, IndexedSeq); - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - ToIndexedSequence.prototype.includes = function(value) { - return this._iter.includes(value); - }; - - ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var iterations = 0; - return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse); - }; - - ToIndexedSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, iterations++, step.value, step) - }); - }; - - - - createClass(ToSetSequence, SetSeq); - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - ToSetSequence.prototype.has = function(key) { - return this._iter.includes(key); - }; - - ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse); - }; - - ToSetSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, step.value, step.value, step); - }); - }; - - - - createClass(FromEntriesSequence, KeyedSeq); - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; - } - - FromEntriesSequence.prototype.entrySeq = function() { - return this._iter.toSeq(); - }; - - FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._iter.__iterate(function(entry ) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedIterable = isIterable(entry); - return fn( - indexedIterable ? entry.get(1) : entry[1], - indexedIterable ? entry.get(0) : entry[0], - this$0 - ); - } - }, reverse); - }; - - FromEntriesSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new src_Iterator__Iterator(function() { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedIterable = isIterable(entry); - return iteratorValue( - type, - indexedIterable ? entry.get(0) : entry[0], - indexedIterable ? entry.get(1) : entry[1], - step - ); - } - } - }); - }; - - - ToIndexedSequence.prototype.cacheResult = - ToKeyedSequence.prototype.cacheResult = - ToSetSequence.prototype.cacheResult = - FromEntriesSequence.prototype.cacheResult = - cacheResultThrough; - - - function flipFactory(iterable) { - var flipSequence = makeSequence(iterable); - flipSequence._iter = iterable; - flipSequence.size = iterable.size; - flipSequence.flip = function() {return iterable}; - flipSequence.reverse = function () { - var reversedSequence = iterable.reverse.apply(this); // super.reverse() - reversedSequence.flip = function() {return iterable.reverse()}; - return reversedSequence; - }; - flipSequence.has = function(key ) {return iterable.includes(key)}; - flipSequence.includes = function(key ) {return iterable.has(key)}; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse); - } - flipSequence.__iteratorUncached = function(type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = iterable.__iterator(type, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; - } - return step; - }); - } - return iterable.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); - } - return flipSequence; - } - - - function mapFactory(iterable, mapper, context) { - var mappedSequence = makeSequence(iterable); - mappedSequence.size = iterable.size; - mappedSequence.has = function(key ) {return iterable.has(key)}; - mappedSequence.get = function(key, notSetValue) { - var v = iterable.get(key, NOT_SET); - return v === NOT_SET ? - notSetValue : - mapper.call(context, v, key, iterable); - }; - mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - return iterable.__iterate( - function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false}, - reverse - ); - } - mappedSequence.__iteratorUncached = function (type, reverse) { - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, iterable), - step - ); - }); - } - return mappedSequence; - } - - - function reverseFactory(iterable, useKeys) { - var reversedSequence = makeSequence(iterable); - reversedSequence._iter = iterable; - reversedSequence.size = iterable.size; - reversedSequence.reverse = function() {return iterable}; - if (iterable.flip) { - reversedSequence.flip = function () { - var flipSequence = flipFactory(iterable); - flipSequence.reverse = function() {return iterable.flip()}; - return flipSequence; - }; - } - reversedSequence.get = function(key, notSetValue) - {return iterable.get(useKeys ? key : -1 - key, notSetValue)}; - reversedSequence.has = function(key ) - {return iterable.has(useKeys ? key : -1 - key)}; - reversedSequence.includes = function(value ) {return iterable.includes(value)}; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function (fn, reverse) {var this$0 = this; - return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse); - }; - reversedSequence.__iterator = - function(type, reverse) {return iterable.__iterator(type, !reverse)}; - return reversedSequence; - } - - - function filterFactory(iterable, predicate, context, useKeys) { - var filterSequence = makeSequence(iterable); - if (useKeys) { - filterSequence.has = function(key ) { - var v = iterable.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, iterable); - }; - filterSequence.get = function(key, notSetValue) { - var v = iterable.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, iterable) ? - v : notSetValue; - }; - } - filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - var iterations = 0; - iterable.__iterate(function(v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0); - } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function (type, reverse) { - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, iterable)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); - } - } - }); - } - return filterSequence; - } - - - function countByFactory(iterable, grouper, context) { - var groups = src_Map__Map().asMutable(); - iterable.__iterate(function(v, k) { - groups.update( - grouper.call(context, v, k, iterable), - 0, - function(a ) {return a + 1} - ); - }); - return groups.asImmutable(); - } - - - function groupByFactory(iterable, grouper, context) { - var isKeyedIter = isKeyed(iterable); - var groups = (isOrdered(iterable) ? OrderedMap() : src_Map__Map()).asMutable(); - iterable.__iterate(function(v, k) { - groups.update( - grouper.call(context, v, k, iterable), - function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)} - ); - }); - var coerce = iterableClass(iterable); - return groups.map(function(arr ) {return reify(iterable, coerce(arr))}); - } - - - function sliceFactory(iterable, begin, end, useKeys) { - var originalSize = iterable.size; - - if (wholeSlice(begin, end, originalSize)) { - return iterable; - } - - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); - - // begin or end will be NaN if they were provided as negative numbers and - // this iterable's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { - return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys); - } - - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; - } - - var sliceSeq = makeSequence(iterable); - - sliceSeq.size = sliceSize; - - if (!useKeys && isSeq(iterable) && sliceSize >= 0) { - sliceSeq.get = function (index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize ? - iterable.get(index + resolvedBegin, notSetValue) : - notSetValue; - } - } - - sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this; - if (sliceSize === 0) { - return 0; - } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - iterable.__iterate(function(v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0) !== false && - iterations !== sliceSize; - } - }); - return iterations; - }; - - sliceSeq.__iteratorUncached = function(type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); - } - // Don't bother instantiating parent iterator if taking 0. - var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { - return step; - } else if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); - } else { - return iteratorValue(type, iterations - 1, step.value[1], step); - } - }); - } - - return sliceSeq; - } - - - function takeWhileFactory(iterable, predicate, context) { - var takeSequence = makeSequence(iterable); - takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - iterable.__iterate(function(v, k, c) - {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)} - ); - return iterations; - }; - takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new src_Iterator__Iterator(function() { - if (!iterating) { - return iteratorDone(); - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$0)) { - iterating = false; - return iteratorDone(); - } - return type === ITERATE_ENTRIES ? step : - iteratorValue(type, k, v, step); - }); - }; - return takeSequence; - } - - - function skipWhileFactory(iterable, predicate, context, useKeys) { - var skipSequence = makeSequence(iterable); - skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var isSkipping = true; - var iterations = 0; - iterable.__iterate(function(v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0); - } - }); - return iterations; - }; - skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step, k, v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } else if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } else { - return iteratorValue(type, iterations++, step.value[1], step); - } - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$0)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : - iteratorValue(type, k, v, step); - }); - }; - return skipSequence; - } - - - function concatFactory(iterable, values) { - var isKeyedIterable = isKeyed(iterable); - var iters = [iterable].concat(values).map(function(v ) { - if (!isIterable(v)) { - v = isKeyedIterable ? - keyedSeqFromValue(v) : - indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedIterable) { - v = KeyedIterable(v); - } - return v; - }).filter(function(v ) {return v.size !== 0}); - - if (iters.length === 0) { - return iterable; - } - - if (iters.length === 1) { - var singleton = iters[0]; - if (singleton === iterable || - isKeyedIterable && isKeyed(singleton) || - isIndexed(iterable) && isIndexed(singleton)) { - return singleton; - } - } - - var concatSeq = new ArraySeq(iters); - if (isKeyedIterable) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(iterable)) { - concatSeq = concatSeq.toSetSeq(); - } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce( - function(sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } - } - }, - 0 - ); - return concatSeq; - } - - - function flattenFactory(iterable, depth, useKeys) { - var flatSequence = makeSequence(iterable); - flatSequence.__iterateUncached = function(fn, reverse) { - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) {var this$0 = this; - iter.__iterate(function(v, k) { - if ((!depth || currentDepth < depth) && isIterable(v)) { - flatDeep(v, currentDepth + 1); - } else if (fn(v, useKeys ? k : iterations++, this$0) === false) { - stopped = true; - } - return !stopped; - }, reverse); - } - flatDeep(iterable, 0); - return iterations; - } - flatSequence.__iteratorUncached = function(type, reverse) { - var iterator = iterable.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isIterable(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } - } - return iteratorDone(); - }); - } - return flatSequence; - } - - - function flatMapFactory(iterable, mapper, context) { - var coerce = iterableClass(iterable); - return iterable.toSeq().map( - function(v, k) {return coerce(mapper.call(context, v, k, iterable))} - ).flatten(true); - } - - - function interposeFactory(iterable, separator) { - var interposedSequence = makeSequence(iterable); - interposedSequence.size = iterable.size && iterable.size * 2 -1; - interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; - var iterations = 0; - iterable.__iterate(function(v, k) - {return (!iterations || fn(separator, iterations++, this$0) !== false) && - fn(v, iterations++, this$0) !== false}, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function(type, reverse) { - var iterator = iterable.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new src_Iterator__Iterator(function() { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } - } - return iterations % 2 ? - iteratorValue(type, iterations++, separator) : - iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; - } - - - function sortFactory(iterable, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedIterable = isKeyed(iterable); - var index = 0; - var entries = iterable.toSeq().map( - function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]} - ).toArray(); - entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach( - isKeyedIterable ? - function(v, i) { entries[i].length = 2; } : - function(v, i) { entries[i] = v[1]; } - ); - return isKeyedIterable ? KeyedSeq(entries) : - isIndexed(iterable) ? IndexedSeq(entries) : - SetSeq(entries); - } - - - function maxFactory(iterable, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = iterable.toSeq() - .map(function(v, k) {return [v, mapper(v, k, iterable)]}) - .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a}); - return entry && entry[0]; - } else { - return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a}); - } - } - - function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0; - } - - - function zipWithFactory(keyIter, zipper, iters) { - var zipSequence = makeSequence(keyIter); - zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function(fn, reverse) { - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - return iterations; - }; - zipSequence.__iteratorUncached = function(type, reverse) { - var iterators = iters.map(function(i ) - {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))} - ); - var iterations = 0; - var isDone = false; - return new src_Iterator__Iterator(function() { - var steps; - if (!isDone) { - steps = iterators.map(function(i ) {return i.next()}); - isDone = steps.some(function(s ) {return s.done}); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply(null, steps.map(function(s ) {return s.value})) - ); - }); - }; - return zipSequence - } - - - // #pragma Helper Functions - - function reify(iter, seq) { - return isSeq(iter) ? seq : iter.constructor(seq); - } - - function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } - } - - function resolveSize(iter) { - assertNotInfinite(iter.size); - return ensureSize(iter); - } - - function iterableClass(iterable) { - return isKeyed(iterable) ? KeyedIterable : - isIndexed(iterable) ? IndexedIterable : - SetIterable; - } - - function makeSequence(iterable) { - return Object.create( - ( - isKeyed(iterable) ? KeyedSeq : - isIndexed(iterable) ? IndexedSeq : - SetSeq - ).prototype - ); - } - - function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } else { - return Seq.prototype.cacheResult.call(this); - } - } - - function defaultComparator(a, b) { - return a > b ? 1 : a < b ? -1 : 0; - } - - function forceIterator(keyPath) { - var iter = getIterator(keyPath); - if (!iter) { - // Array might not be iterable in this environment, so we need a fallback - // to our wrapped type. - if (!isArrayLike(keyPath)) { - throw new TypeError('Expected iterable or array-like: ' + keyPath); - } - iter = getIterator(Iterable(keyPath)); - } - return iter; - } - - createClass(src_Map__Map, KeyedCollection); - - // @pragma Construction - - function src_Map__Map(value) { - return value === null || value === undefined ? emptyMap() : - isMap(value) ? value : - emptyMap().withMutations(function(map ) { - var iter = KeyedIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v, k) {return map.set(k, v)}); - }); - } - - src_Map__Map.prototype.toString = function() { - return this.__toString('Map {', '}'); - }; - - // @pragma Access - - src_Map__Map.prototype.get = function(k, notSetValue) { - return this._root ? - this._root.get(0, undefined, k, notSetValue) : - notSetValue; - }; - - // @pragma Modification - - src_Map__Map.prototype.set = function(k, v) { - return updateMap(this, k, v); - }; - - src_Map__Map.prototype.setIn = function(keyPath, v) { - return this.updateIn(keyPath, NOT_SET, function() {return v}); - }; - - src_Map__Map.prototype.remove = function(k) { - return updateMap(this, k, NOT_SET); - }; - - src_Map__Map.prototype.deleteIn = function(keyPath) { - return this.updateIn(keyPath, function() {return NOT_SET}); - }; - - src_Map__Map.prototype.update = function(k, notSetValue, updater) { - return arguments.length === 1 ? - k(this) : - this.updateIn([k], notSetValue, updater); - }; - - src_Map__Map.prototype.updateIn = function(keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeepMap( - this, - forceIterator(keyPath), - notSetValue, - updater - ); - return updatedValue === NOT_SET ? undefined : updatedValue; - }; - - src_Map__Map.prototype.clear = function() { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyMap(); - }; - - // @pragma Composition - - src_Map__Map.prototype.merge = function(/*...iters*/) { - return mergeIntoMapWith(this, undefined, arguments); - }; - - src_Map__Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoMapWith(this, merger, iters); - }; - - src_Map__Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); - return this.updateIn( - keyPath, - emptyMap(), - function(m ) {return typeof m.merge === 'function' ? - m.merge.apply(m, iters) : - iters[iters.length - 1]} - ); - }; - - src_Map__Map.prototype.mergeDeep = function(/*...iters*/) { - return mergeIntoMapWith(this, deepMerger(undefined), arguments); - }; - - src_Map__Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoMapWith(this, deepMerger(merger), iters); - }; - - src_Map__Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); - return this.updateIn( - keyPath, - emptyMap(), - function(m ) {return typeof m.mergeDeep === 'function' ? - m.mergeDeep.apply(m, iters) : - iters[iters.length - 1]} - ); - }; - - src_Map__Map.prototype.sort = function(comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); - }; - - src_Map__Map.prototype.sortBy = function(mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); - }; - - // @pragma Mutability - - src_Map__Map.prototype.withMutations = function(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; - }; - - src_Map__Map.prototype.asMutable = function() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); - }; - - src_Map__Map.prototype.asImmutable = function() { - return this.__ensureOwner(); - }; - - src_Map__Map.prototype.wasAltered = function() { - return this.__altered; - }; - - src_Map__Map.prototype.__iterator = function(type, reverse) { - return new MapIterator(this, type, reverse); - }; - - src_Map__Map.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var iterations = 0; - this._root && this._root.iterate(function(entry ) { - iterations++; - return fn(entry[1], entry[0], this$0); - }, reverse); - return iterations; - }; - - src_Map__Map.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeMap(this.size, this._root, ownerID, this.__hash); - }; - - - function isMap(maybeMap) { - return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); - } - - src_Map__Map.isMap = isMap; - - var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - - var MapPrototype = src_Map__Map.prototype; - MapPrototype[IS_MAP_SENTINEL] = true; - MapPrototype[DELETE] = MapPrototype.remove; - MapPrototype.removeIn = MapPrototype.deleteIn; - - - // #pragma Trie Nodes - - - - function ArrayMapNode(ownerID, entries) { - this.ownerID = ownerID; - this.entries = entries; - } - - ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; - }; - - ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - - var entries = this.entries; - var idx = 0; - for (var len = entries.length; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && entries.length === 1) { - return; // undefined - } - - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new ArrayMapNode(ownerID, newEntries); - }; - - - - - function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; - } - - BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK)); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 ? notSetValue : - this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue); - }; - - BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; - - if (!exists && value === NOT_SET) { - return this; - } - - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - - if (newNode === node) { - return this; - } - - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } - - if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) { - return nodes[idx ^ 1]; - } - - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; - var newNodes = exists ? newNode ? - setIn(nodes, idx, newNode, isEditable) : - spliceOut(nodes, idx, isEditable) : - spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; - } - - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); - }; - - - - - function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; - } - - HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue; - }; - - HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - - if (removed && !node) { - return this; - } - - var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - if (newNode === node) { - return this; - } - - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); - } - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; - } - - return new HashArrayMapNode(ownerID, newCount, newNodes); - }; - - - - - function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; - } - - HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; - }; - - HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - - var removed = value === NOT_SET; - - if (keyHash !== this.keyHash) { - if (removed) { - return this; - } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); - } - - var entries = this.entries; - var idx = 0; - for (var len = entries.length; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new HashCollisionNode(ownerID, this.keyHash, newEntries); - }; - - - - - function ValueNode(ownerID, keyHash, entry) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entry = entry; - } - - ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) { - return is(key, this.entry[0]) ? this.entry[1] : notSetValue; - }; - - ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - var keyMatch = is(key, this.entry[0]); - if (keyMatch ? value === this.entry[1] : removed) { - return this; - } - - SetRef(didAlter); - - if (removed) { - SetRef(didChangeSize); - return; // undefined - } - - if (keyMatch) { - if (ownerID && ownerID === this.ownerID) { - this.entry[1] = value; - return this; - } - return new ValueNode(ownerID, this.keyHash, [key, value]); - } - - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); - }; - - - - // #pragma Iterators - - ArrayMapNode.prototype.iterate = - HashCollisionNode.prototype.iterate = function (fn, reverse) { - var entries = this.entries; - for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { - if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { - return false; - } - } - } - - BitmapIndexedNode.prototype.iterate = - HashArrayMapNode.prototype.iterate = function (fn, reverse) { - var nodes = this.nodes; - for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { - var node = nodes[reverse ? maxIndex - ii : ii]; - if (node && node.iterate(fn, reverse) === false) { - return false; - } - } - } - - ValueNode.prototype.iterate = function (fn, reverse) { - return fn(this.entry); - } - - createClass(MapIterator, src_Iterator__Iterator); - - function MapIterator(map, type, reverse) { - this._type = type; - this._reverse = reverse; - this._stack = map._root && mapIteratorFrame(map._root); - } - - MapIterator.prototype.next = function() { - var type = this._type; - var stack = this._stack; - while (stack) { - var node = stack.node; - var index = stack.index++; - var maxIndex; - if (node.entry) { - if (index === 0) { - return mapIteratorValue(type, node.entry); - } - } else if (node.entries) { - maxIndex = node.entries.length - 1; - if (index <= maxIndex) { - return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]); - } - } else { - maxIndex = node.nodes.length - 1; - if (index <= maxIndex) { - var subNode = node.nodes[this._reverse ? maxIndex - index : index]; - if (subNode) { - if (subNode.entry) { - return mapIteratorValue(type, subNode.entry); - } - stack = this._stack = mapIteratorFrame(subNode, stack); - } - continue; - } - } - stack = this._stack = this._stack.__prev; - } - return iteratorDone(); - }; - - - function mapIteratorValue(type, entry) { - return iteratorValue(type, entry[0], entry[1]); - } - - function mapIteratorFrame(node, prev) { - return { - node: node, - index: 0, - __prev: prev - }; - } - - function makeMap(size, root, ownerID, hash) { - var map = Object.create(MapPrototype); - map.size = size; - map._root = root; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; - } - - var EMPTY_MAP; - function emptyMap() { - return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); - } - - function updateMap(map, k, v) { - var newRoot; - var newSize; - if (!map._root) { - if (v === NOT_SET) { - return map; - } - newSize = 1; - newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); - } else { - var didChangeSize = MakeRef(CHANGE_LENGTH); - var didAlter = MakeRef(DID_ALTER); - newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter); - if (!didAlter.value) { - return map; - } - newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0); - } - if (map.__ownerID) { - map.size = newSize; - map._root = newRoot; - map.__hash = undefined; - map.__altered = true; - return map; - } - return newRoot ? makeMap(newSize, newRoot) : emptyMap(); - } - - function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (!node) { - if (value === NOT_SET) { - return node; - } - SetRef(didAlter); - SetRef(didChangeSize); - return new ValueNode(ownerID, keyHash, [key, value]); - } - return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter); - } - - function isLeafNode(node) { - return node.constructor === ValueNode || node.constructor === HashCollisionNode; - } - - function mergeIntoNode(node, ownerID, shift, keyHash, entry) { - if (node.keyHash === keyHash) { - return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); - } - - var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; - var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - - var newNode; - var nodes = idx1 === idx2 ? - [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] : - ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]); - - return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); - } - - function createNodes(ownerID, entries, key, value) { - if (!ownerID) { - ownerID = new OwnerID(); - } - var node = new ValueNode(ownerID, hash(key), [key, value]); - for (var ii = 0; ii < entries.length; ii++) { - var entry = entries[ii]; - node = node.update(ownerID, 0, undefined, entry[0], entry[1]); - } - return node; - } - - function packNodes(ownerID, nodes, count, excluding) { - var bitmap = 0; - var packedII = 0; - var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { - var node = nodes[ii]; - if (node !== undefined && ii !== excluding) { - bitmap |= bit; - packedNodes[packedII++] = node; - } - } - return new BitmapIndexedNode(ownerID, bitmap, packedNodes); - } - - function expandNodes(ownerID, nodes, bitmap, including, node) { - var count = 0; - var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { - expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; - } - expandedNodes[including] = node; - return new HashArrayMapNode(ownerID, count + 1, expandedNodes); - } - - function mergeIntoMapWith(map, merger, iterables) { - var iters = []; - for (var ii = 0; ii < iterables.length; ii++) { - var value = iterables[ii]; - var iter = KeyedIterable(value); - if (!isIterable(value)) { - iter = iter.map(function(v ) {return fromJS(v)}); - } - iters.push(iter); - } - return mergeIntoCollectionWith(map, merger, iters); - } - - function deepMerger(merger) { - return function(existing, value, key) - {return existing && existing.mergeDeepWith && isIterable(value) ? - existing.mergeDeepWith(merger, value) : - merger ? merger(existing, value, key) : value}; - } - - function mergeIntoCollectionWith(collection, merger, iters) { - iters = iters.filter(function(x ) {return x.size !== 0}); - if (iters.length === 0) { - return collection; - } - if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function(collection ) { - var mergeIntoMap = merger ? - function(value, key) { - collection.update(key, NOT_SET, function(existing ) - {return existing === NOT_SET ? value : merger(existing, value, key)} - ); - } : - function(value, key) { - collection.set(key, value); - } - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoMap); - } - }); - } - - function updateInDeepMap(existing, keyPathIter, notSetValue, updater) { - var isNotSet = existing === NOT_SET; - var step = keyPathIter.next(); - if (step.done) { - var existingValue = isNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - invariant( - isNotSet || (existing && existing.set), - 'invalid keyPath' - ); - var key = step.value; - var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET); - var nextUpdated = updateInDeepMap( - nextExisting, - keyPathIter, - notSetValue, - updater - ); - return nextUpdated === nextExisting ? existing : - nextUpdated === NOT_SET ? existing.remove(key) : - (isNotSet ? emptyMap() : existing).set(key, nextUpdated); - } - - function popCount(x) { - x = x - ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0f0f0f0f; - x = x + (x >> 8); - x = x + (x >> 16); - return x & 0x7f; - } - - function setIn(array, idx, val, canEdit) { - var newArray = canEdit ? array : arrCopy(array); - newArray[idx] = val; - return newArray; - } - - function spliceIn(array, idx, val, canEdit) { - var newLen = array.length + 1; - if (canEdit && idx + 1 === newLen) { - array[idx] = val; - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - newArray[ii] = val; - after = -1; - } else { - newArray[ii] = array[ii + after]; - } - } - return newArray; - } - - function spliceOut(array, idx, canEdit) { - var newLen = array.length - 1; - if (canEdit && idx === newLen) { - array.pop(); - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - after = 1; - } - newArray[ii] = array[ii + after]; - } - return newArray; - } - - var MAX_ARRAY_MAP_SIZE = SIZE / 4; - var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; - var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; - - createClass(List, IndexedCollection); - - // @pragma Construction - - function List(value) { - var empty = emptyList(); - if (value === null || value === undefined) { - return empty; - } - if (isList(value)) { - return value; - } - var iter = IndexedIterable(value); - var size = iter.size; - if (size === 0) { - return empty; - } - assertNotInfinite(size); - if (size > 0 && size < SIZE) { - return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); - } - return empty.withMutations(function(list ) { - list.setSize(size); - iter.forEach(function(v, i) {return list.set(i, v)}); - }); - } - - List.of = function(/*...values*/) { - return this(arguments); - }; - - List.prototype.toString = function() { - return this.__toString('List [', ']'); - }; - - // @pragma Access - - List.prototype.get = function(index, notSetValue) { - index = wrapIndex(this, index); - if (index < 0 || index >= this.size) { - return notSetValue; - } - index += this._origin; - var node = listNodeFor(this, index); - return node && node.array[index & MASK]; - }; - - // @pragma Modification - - List.prototype.set = function(index, value) { - return updateList(this, index, value); - }; - - List.prototype.remove = function(index) { - return !this.has(index) ? this : - index === 0 ? this.shift() : - index === this.size - 1 ? this.pop() : - this.splice(index, 1); - }; - - List.prototype.clear = function() { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = this._origin = this._capacity = 0; - this._level = SHIFT; - this._root = this._tail = null; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyList(); - }; - - List.prototype.push = function(/*...values*/) { - var values = arguments; - var oldSize = this.size; - return this.withMutations(function(list ) { - setListBounds(list, 0, oldSize + values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(oldSize + ii, values[ii]); - } - }); - }; - - List.prototype.pop = function() { - return setListBounds(this, 0, -1); - }; - - List.prototype.unshift = function(/*...values*/) { - var values = arguments; - return this.withMutations(function(list ) { - setListBounds(list, -values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(ii, values[ii]); - } - }); - }; - - List.prototype.shift = function() { - return setListBounds(this, 1); - }; - - // @pragma Composition - - List.prototype.merge = function(/*...iters*/) { - return mergeIntoListWith(this, undefined, arguments); - }; - - List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoListWith(this, merger, iters); - }; - - List.prototype.mergeDeep = function(/*...iters*/) { - return mergeIntoListWith(this, deepMerger(undefined), arguments); - }; - - List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoListWith(this, deepMerger(merger), iters); - }; - - List.prototype.setSize = function(size) { - return setListBounds(this, 0, size); - }; - - // @pragma Iteration - - List.prototype.slice = function(begin, end) { - var size = this.size; - if (wholeSlice(begin, end, size)) { - return this; - } - return setListBounds( - this, - resolveBegin(begin, size), - resolveEnd(end, size) - ); - }; - - List.prototype.__iterator = function(type, reverse) { - var index = 0; - var values = iterateList(this, reverse); - return new src_Iterator__Iterator(function() { - var value = values(); - return value === DONE ? - iteratorDone() : - iteratorValue(type, index++, value); - }); - }; - - List.prototype.__iterate = function(fn, reverse) { - var index = 0; - var values = iterateList(this, reverse); - var value; - while ((value = values()) !== DONE) { - if (fn(value, index++, this) === false) { - break; - } - } - return index; - }; - - List.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - this.__ownerID = ownerID; - return this; - } - return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash); - }; - - - function isList(maybeList) { - return !!(maybeList && maybeList[IS_LIST_SENTINEL]); - } - - List.isList = isList; - - var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; - - var ListPrototype = List.prototype; - ListPrototype[IS_LIST_SENTINEL] = true; - ListPrototype[DELETE] = ListPrototype.remove; - ListPrototype.setIn = MapPrototype.setIn; - ListPrototype.deleteIn = - ListPrototype.removeIn = MapPrototype.removeIn; - ListPrototype.update = MapPrototype.update; - ListPrototype.updateIn = MapPrototype.updateIn; - ListPrototype.mergeIn = MapPrototype.mergeIn; - ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; - ListPrototype.withMutations = MapPrototype.withMutations; - ListPrototype.asMutable = MapPrototype.asMutable; - ListPrototype.asImmutable = MapPrototype.asImmutable; - ListPrototype.wasAltered = MapPrototype.wasAltered; - - - - function VNode(array, ownerID) { - this.array = array; - this.ownerID = ownerID; - } - - // TODO: seems like these methods are very similar - - VNode.prototype.removeBefore = function(ownerID, level, index) { - if (index === level ? 1 << level : 0 || this.array.length === 0) { - return this; - } - var originIndex = (index >>> level) & MASK; - if (originIndex >= this.array.length) { - return new VNode([], ownerID); - } - var removingFirst = originIndex === 0; - var newChild; - if (level > 0) { - var oldChild = this.array[originIndex]; - newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); - if (newChild === oldChild && removingFirst) { - return this; - } - } - if (removingFirst && !newChild) { - return this; - } - var editable = editableVNode(this, ownerID); - if (!removingFirst) { - for (var ii = 0; ii < originIndex; ii++) { - editable.array[ii] = undefined; - } - } - if (newChild) { - editable.array[originIndex] = newChild; - } - return editable; - }; - - VNode.prototype.removeAfter = function(ownerID, level, index) { - if (index === level ? 1 << level : 0 || this.array.length === 0) { - return this; - } - var sizeIndex = ((index - 1) >>> level) & MASK; - if (sizeIndex >= this.array.length) { - return this; - } - var removingLast = sizeIndex === this.array.length - 1; - var newChild; - if (level > 0) { - var oldChild = this.array[sizeIndex]; - newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); - if (newChild === oldChild && removingLast) { - return this; - } - } - if (removingLast && !newChild) { - return this; - } - var editable = editableVNode(this, ownerID); - if (!removingLast) { - editable.array.pop(); - } - if (newChild) { - editable.array[sizeIndex] = newChild; - } - return editable; - }; - - - - var DONE = {}; - - function iterateList(list, reverse) { - var left = list._origin; - var right = list._capacity; - var tailPos = getTailOffset(right); - var tail = list._tail; - - return iterateNodeOrLeaf(list._root, list._level, 0); - - function iterateNodeOrLeaf(node, level, offset) { - return level === 0 ? - iterateLeaf(node, offset) : - iterateNode(node, level, offset); - } - - function iterateLeaf(node, offset) { - var array = offset === tailPos ? tail && tail.array : node && node.array; - var from = offset > left ? 0 : left - offset; - var to = right - offset; - if (to > SIZE) { - to = SIZE; - } - return function() { - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - return array && array[idx]; - }; - } - - function iterateNode(node, level, offset) { - var values; - var array = node && node.array; - var from = offset > left ? 0 : (left - offset) >> level; - var to = ((right - offset) >> level) + 1; - if (to > SIZE) { - to = SIZE; - } - return function() { - do { - if (values) { - var value = values(); - if (value !== DONE) { - return value; - } - values = null; - } - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - values = iterateNodeOrLeaf( - array && array[idx], level - SHIFT, offset + (idx << level) - ); - } while (true); - }; - } - } - - function makeList(origin, capacity, level, root, tail, ownerID, hash) { - var list = Object.create(ListPrototype); - list.size = capacity - origin; - list._origin = origin; - list._capacity = capacity; - list._level = level; - list._root = root; - list._tail = tail; - list.__ownerID = ownerID; - list.__hash = hash; - list.__altered = false; - return list; - } - - var EMPTY_LIST; - function emptyList() { - return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); - } - - function updateList(list, index, value) { - index = wrapIndex(list, index); - - if (index >= list.size || index < 0) { - return list.withMutations(function(list ) { - index < 0 ? - setListBounds(list, index).set(0, value) : - setListBounds(list, 0, index + 1).set(index, value) - }); - } - - index += list._origin; - - var newTail = list._tail; - var newRoot = list._root; - var didAlter = MakeRef(DID_ALTER); - if (index >= getTailOffset(list._capacity)) { - newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); - } else { - newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter); - } - - if (!didAlter.value) { - return list; - } - - if (list.__ownerID) { - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(list._origin, list._capacity, list._level, newRoot, newTail); - } - - function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = (index >>> level) & MASK; - var nodeHas = node && idx < node.array.length; - if (!nodeHas && value === undefined) { - return node; - } - - var newNode; - - if (level > 0) { - var lowerNode = node && node.array[idx]; - var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter); - if (newLowerNode === lowerNode) { - return node; - } - newNode = editableVNode(node, ownerID); - newNode.array[idx] = newLowerNode; - return newNode; - } - - if (nodeHas && node.array[idx] === value) { - return node; - } - - SetRef(didAlter); - - newNode = editableVNode(node, ownerID); - if (value === undefined && idx === newNode.array.length - 1) { - newNode.array.pop(); - } else { - newNode.array[idx] = value; - } - return newNode; - } - - function editableVNode(node, ownerID) { - if (ownerID && node && ownerID === node.ownerID) { - return node; - } - return new VNode(node ? node.array.slice() : [], ownerID); - } - - function listNodeFor(list, rawIndex) { - if (rawIndex >= getTailOffset(list._capacity)) { - return list._tail; - } - if (rawIndex < 1 << (list._level + SHIFT)) { - var node = list._root; - var level = list._level; - while (node && level > 0) { - node = node.array[(rawIndex >>> level) & MASK]; - level -= SHIFT; - } - return node; - } - } - - function setListBounds(list, begin, end) { - var owner = list.__ownerID || new OwnerID(); - var oldOrigin = list._origin; - var oldCapacity = list._capacity; - var newOrigin = oldOrigin + begin; - var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end; - if (newOrigin === oldOrigin && newCapacity === oldCapacity) { - return list; - } - - // If it's going to end after it starts, it's empty. - if (newOrigin >= newCapacity) { - return list.clear(); - } - - var newLevel = list._level; - var newRoot = list._root; - - // New origin might need creating a higher root. - var offsetShift = 0; - while (newOrigin + offsetShift < 0) { - newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner); - newLevel += SHIFT; - offsetShift += 1 << newLevel; - } - if (offsetShift) { - newOrigin += offsetShift; - oldOrigin += offsetShift; - newCapacity += offsetShift; - oldCapacity += offsetShift; - } - - var oldTailOffset = getTailOffset(oldCapacity); - var newTailOffset = getTailOffset(newCapacity); - - // New size might need creating a higher root. - while (newTailOffset >= 1 << (newLevel + SHIFT)) { - newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner); - newLevel += SHIFT; - } - - // Locate or create the new tail. - var oldTail = list._tail; - var newTail = newTailOffset < oldTailOffset ? - listNodeFor(list, newCapacity - 1) : - newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; - - // Merge Tail into tree. - if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) { - newRoot = editableVNode(newRoot, owner); - var node = newRoot; - for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = (oldTailOffset >>> level) & MASK; - node = node.array[idx] = editableVNode(node.array[idx], owner); - } - node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; - } - - // If the size has been reduced, there's a chance the tail needs to be trimmed. - if (newCapacity < oldCapacity) { - newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); - } - - // If the new origin is within the tail, then we do not need a root. - if (newOrigin >= newTailOffset) { - newOrigin -= newTailOffset; - newCapacity -= newTailOffset; - newLevel = SHIFT; - newRoot = null; - newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); - - // Otherwise, if the root has been trimmed, garbage collect. - } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { - offsetShift = 0; - - // Identify the new top root node of the subtree of the old root. - while (newRoot) { - var beginIndex = (newOrigin >>> newLevel) & MASK; - if (beginIndex !== (newTailOffset >>> newLevel) & MASK) { - break; - } - if (beginIndex) { - offsetShift += (1 << newLevel) * beginIndex; - } - newLevel -= SHIFT; - newRoot = newRoot.array[beginIndex]; - } - - // Trim the new sides of the new root. - if (newRoot && newOrigin > oldOrigin) { - newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); - } - if (newRoot && newTailOffset < oldTailOffset) { - newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift); - } - if (offsetShift) { - newOrigin -= offsetShift; - newCapacity -= offsetShift; - } - } - - if (list.__ownerID) { - list.size = newCapacity - newOrigin; - list._origin = newOrigin; - list._capacity = newCapacity; - list._level = newLevel; - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); - } - - function mergeIntoListWith(list, merger, iterables) { - var iters = []; - var maxSize = 0; - for (var ii = 0; ii < iterables.length; ii++) { - var value = iterables[ii]; - var iter = IndexedIterable(value); - if (iter.size > maxSize) { - maxSize = iter.size; - } - if (!isIterable(value)) { - iter = iter.map(function(v ) {return fromJS(v)}); - } - iters.push(iter); - } - if (maxSize > list.size) { - list = list.setSize(maxSize); - } - return mergeIntoCollectionWith(list, merger, iters); - } - - function getTailOffset(size) { - return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT); - } - - createClass(OrderedMap, src_Map__Map); - - // @pragma Construction - - function OrderedMap(value) { - return value === null || value === undefined ? emptyOrderedMap() : - isOrderedMap(value) ? value : - emptyOrderedMap().withMutations(function(map ) { - var iter = KeyedIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v, k) {return map.set(k, v)}); - }); - } - - OrderedMap.of = function(/*...values*/) { - return this(arguments); - }; - - OrderedMap.prototype.toString = function() { - return this.__toString('OrderedMap {', '}'); - }; - - // @pragma Access - - OrderedMap.prototype.get = function(k, notSetValue) { - var index = this._map.get(k); - return index !== undefined ? this._list.get(index)[1] : notSetValue; - }; - - // @pragma Modification - - OrderedMap.prototype.clear = function() { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._map.clear(); - this._list.clear(); - return this; - } - return emptyOrderedMap(); - }; - - OrderedMap.prototype.set = function(k, v) { - return updateOrderedMap(this, k, v); - }; - - OrderedMap.prototype.remove = function(k) { - return updateOrderedMap(this, k, NOT_SET); - }; - - OrderedMap.prototype.wasAltered = function() { - return this._map.wasAltered() || this._list.wasAltered(); - }; - - OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._list.__iterate( - function(entry ) {return entry && fn(entry[1], entry[0], this$0)}, - reverse - ); - }; - - OrderedMap.prototype.__iterator = function(type, reverse) { - return this._list.fromEntrySeq().__iterator(type, reverse); - }; - - OrderedMap.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - var newList = this._list.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._map = newMap; - this._list = newList; - return this; - } - return makeOrderedMap(newMap, newList, ownerID, this.__hash); - }; - - - function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); - } - - OrderedMap.isOrderedMap = isOrderedMap; - - OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; - OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; - - - - function makeOrderedMap(map, list, ownerID, hash) { - var omap = Object.create(OrderedMap.prototype); - omap.size = map ? map.size : 0; - omap._map = map; - omap._list = list; - omap.__ownerID = ownerID; - omap.__hash = hash; - return omap; - } - - var EMPTY_ORDERED_MAP; - function emptyOrderedMap() { - return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); - } - - function updateOrderedMap(omap, k, v) { - var map = omap._map; - var list = omap._list; - var i = map.get(k); - var has = i !== undefined; - var newMap; - var newList; - if (v === NOT_SET) { // removed - if (!has) { - return omap; - } - if (list.size >= SIZE && list.size >= map.size * 2) { - newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx}); - newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap(); - if (omap.__ownerID) { - newMap.__ownerID = newList.__ownerID = omap.__ownerID; - } - } else { - newMap = map.remove(k); - newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); - } - } else { - if (has) { - if (v === list.get(i)[1]) { - return omap; - } - newMap = map; - newList = list.set(i, [k, v]); - } else { - newMap = map.set(k, list.size); - newList = list.set(list.size, [k, v]); - } - } - if (omap.__ownerID) { - omap.size = newMap.size; - omap._map = newMap; - omap._list = newList; - omap.__hash = undefined; - return omap; - } - return makeOrderedMap(newMap, newList); - } - - createClass(Stack, IndexedCollection); - - // @pragma Construction - - function Stack(value) { - return value === null || value === undefined ? emptyStack() : - isStack(value) ? value : - emptyStack().unshiftAll(value); - } - - Stack.of = function(/*...values*/) { - return this(arguments); - }; - - Stack.prototype.toString = function() { - return this.__toString('Stack [', ']'); - }; - - // @pragma Access - - Stack.prototype.get = function(index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; - } - return head ? head.value : notSetValue; - }; - - Stack.prototype.peek = function() { - return this._head && this._head.value; - }; - - // @pragma Modification - - Stack.prototype.push = function(/*...values*/) { - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments[ii], - next: head - }; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pushAll = function(iter) { - iter = IndexedIterable(iter); - if (iter.size === 0) { - return this; - } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.reverse().forEach(function(value ) { - newSize++; - head = { - value: value, - next: head - }; - }); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pop = function() { - return this.slice(1); - }; - - Stack.prototype.unshift = function(/*...values*/) { - return this.push.apply(this, arguments); - }; - - Stack.prototype.unshiftAll = function(iter) { - return this.pushAll(iter); - }; - - Stack.prototype.shift = function() { - return this.pop.apply(this, arguments); - }; - - Stack.prototype.clear = function() { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyStack(); - }; - - Stack.prototype.slice = function(begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - // @pragma Mutability - - Stack.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeStack(this.size, this._head, ownerID, this.__hash); - }; - - // @pragma Iteration - - Stack.prototype.__iterate = function(fn, reverse) { - if (reverse) { - return this.reverse().__iterate(fn); - } - var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this) === false) { - break; - } - node = node.next; - } - return iterations; - }; - - Stack.prototype.__iterator = function(type, reverse) { - if (reverse) { - return this.reverse().__iterator(type); - } - var iterations = 0; - var node = this._head; - return new src_Iterator__Iterator(function() { - if (node) { - var value = node.value; - node = node.next; - return iteratorValue(type, iterations++, value); - } - return iteratorDone(); - }); - }; - - - function isStack(maybeStack) { - return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); - } - - Stack.isStack = isStack; - - var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; - - var StackPrototype = Stack.prototype; - StackPrototype[IS_STACK_SENTINEL] = true; - StackPrototype.withMutations = MapPrototype.withMutations; - StackPrototype.asMutable = MapPrototype.asMutable; - StackPrototype.asImmutable = MapPrototype.asImmutable; - StackPrototype.wasAltered = MapPrototype.wasAltered; - - - function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; - } - - var EMPTY_STACK; - function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); - } - - createClass(src_Set__Set, SetCollection); - - // @pragma Construction - - function src_Set__Set(value) { - return value === null || value === undefined ? emptySet() : - isSet(value) ? value : - emptySet().withMutations(function(set ) { - var iter = SetIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v ) {return set.add(v)}); - }); - } - - src_Set__Set.of = function(/*...values*/) { - return this(arguments); - }; - - src_Set__Set.fromKeys = function(value) { - return this(KeyedIterable(value).keySeq()); - }; - - src_Set__Set.prototype.toString = function() { - return this.__toString('Set {', '}'); - }; - - // @pragma Access - - src_Set__Set.prototype.has = function(value) { - return this._map.has(value); - }; - - // @pragma Modification - - src_Set__Set.prototype.add = function(value) { - return updateSet(this, this._map.set(value, true)); - }; - - src_Set__Set.prototype.remove = function(value) { - return updateSet(this, this._map.remove(value)); - }; - - src_Set__Set.prototype.clear = function() { - return updateSet(this, this._map.clear()); - }; - - // @pragma Composition - - src_Set__Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0); - iters = iters.filter(function(x ) {return x.size !== 0}); - if (iters.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && iters.length === 1) { - return this.constructor(iters[0]); - } - return this.withMutations(function(set ) { - for (var ii = 0; ii < iters.length; ii++) { - SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)}); - } - }); - }; - - src_Set__Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0); - if (iters.length === 0) { - return this; - } - iters = iters.map(function(iter ) {return SetIterable(iter)}); - var originalSet = this; - return this.withMutations(function(set ) { - originalSet.forEach(function(value ) { - if (!iters.every(function(iter ) {return iter.includes(value)})) { - set.remove(value); - } - }); - }); - }; - - src_Set__Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0); - if (iters.length === 0) { - return this; - } - iters = iters.map(function(iter ) {return SetIterable(iter)}); - var originalSet = this; - return this.withMutations(function(set ) { - originalSet.forEach(function(value ) { - if (iters.some(function(iter ) {return iter.includes(value)})) { - set.remove(value); - } - }); - }); - }; - - src_Set__Set.prototype.merge = function() { - return this.union.apply(this, arguments); - }; - - src_Set__Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return this.union.apply(this, iters); - }; - - src_Set__Set.prototype.sort = function(comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator)); - }; - - src_Set__Set.prototype.sortBy = function(mapper, comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator, mapper)); - }; - - src_Set__Set.prototype.wasAltered = function() { - return this._map.wasAltered(); - }; - - src_Set__Set.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse); - }; - - src_Set__Set.prototype.__iterator = function(type, reverse) { - return this._map.map(function(_, k) {return k}).__iterator(type, reverse); - }; - - src_Set__Set.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return this.__make(newMap, ownerID); - }; - - - function isSet(maybeSet) { - return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); - } - - src_Set__Set.isSet = isSet; - - var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; - - var SetPrototype = src_Set__Set.prototype; - SetPrototype[IS_SET_SENTINEL] = true; - SetPrototype[DELETE] = SetPrototype.remove; - SetPrototype.mergeDeep = SetPrototype.merge; - SetPrototype.mergeDeepWith = SetPrototype.mergeWith; - SetPrototype.withMutations = MapPrototype.withMutations; - SetPrototype.asMutable = MapPrototype.asMutable; - SetPrototype.asImmutable = MapPrototype.asImmutable; - - SetPrototype.__empty = emptySet; - SetPrototype.__make = makeSet; - - function updateSet(set, newMap) { - if (set.__ownerID) { - set.size = newMap.size; - set._map = newMap; - return set; - } - return newMap === set._map ? set : - newMap.size === 0 ? set.__empty() : - set.__make(newMap); - } - - function makeSet(map, ownerID) { - var set = Object.create(SetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; - } - - var EMPTY_SET; - function emptySet() { - return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); - } - - createClass(OrderedSet, src_Set__Set); - - // @pragma Construction - - function OrderedSet(value) { - return value === null || value === undefined ? emptyOrderedSet() : - isOrderedSet(value) ? value : - emptyOrderedSet().withMutations(function(set ) { - var iter = SetIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v ) {return set.add(v)}); - }); - } - - OrderedSet.of = function(/*...values*/) { - return this(arguments); - }; - - OrderedSet.fromKeys = function(value) { - return this(KeyedIterable(value).keySeq()); - }; - - OrderedSet.prototype.toString = function() { - return this.__toString('OrderedSet {', '}'); - }; - - - function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); - } - - OrderedSet.isOrderedSet = isOrderedSet; - - var OrderedSetPrototype = OrderedSet.prototype; - OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; - - OrderedSetPrototype.__empty = emptyOrderedSet; - OrderedSetPrototype.__make = makeOrderedSet; - - function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; - } - - var EMPTY_ORDERED_SET; - function emptyOrderedSet() { - return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); - } - - createClass(Record, KeyedCollection); - - function Record(defaultValues, name) { - var hasInitialized; - - var RecordType = function Record(values) { - if (values instanceof RecordType) { - return values; - } - if (!(this instanceof RecordType)) { - return new RecordType(values); - } - if (!hasInitialized) { - hasInitialized = true; - var keys = Object.keys(defaultValues); - setProps(RecordTypePrototype, keys); - RecordTypePrototype.size = keys.length; - RecordTypePrototype._name = name; - RecordTypePrototype._keys = keys; - RecordTypePrototype._defaultValues = defaultValues; - } - this._map = src_Map__Map(values); - }; - - var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype); - RecordTypePrototype.constructor = RecordType; - - return RecordType; - } - - Record.prototype.toString = function() { - return this.__toString(recordName(this) + ' {', '}'); - }; - - // @pragma Access - - Record.prototype.has = function(k) { - return this._defaultValues.hasOwnProperty(k); - }; - - Record.prototype.get = function(k, notSetValue) { - if (!this.has(k)) { - return notSetValue; - } - var defaultVal = this._defaultValues[k]; - return this._map ? this._map.get(k, defaultVal) : defaultVal; - }; - - // @pragma Modification - - Record.prototype.clear = function() { - if (this.__ownerID) { - this._map && this._map.clear(); - return this; - } - var RecordType = this.constructor; - return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap())); - }; - - Record.prototype.set = function(k, v) { - if (!this.has(k)) { - throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this)); - } - var newMap = this._map && this._map.set(k, v); - if (this.__ownerID || newMap === this._map) { - return this; - } - return makeRecord(this, newMap); - }; - - Record.prototype.remove = function(k) { - if (!this.has(k)) { - return this; - } - var newMap = this._map && this._map.remove(k); - if (this.__ownerID || newMap === this._map) { - return this; - } - return makeRecord(this, newMap); - }; - - Record.prototype.wasAltered = function() { - return this._map.wasAltered(); - }; - - Record.prototype.__iterator = function(type, reverse) {var this$0 = this; - return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse); - }; - - Record.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse); - }; - - Record.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map && this._map.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return makeRecord(this, newMap, ownerID); - }; - - - var RecordPrototype = Record.prototype; - RecordPrototype[DELETE] = RecordPrototype.remove; - RecordPrototype.deleteIn = - RecordPrototype.removeIn = MapPrototype.removeIn; - RecordPrototype.merge = MapPrototype.merge; - RecordPrototype.mergeWith = MapPrototype.mergeWith; - RecordPrototype.mergeIn = MapPrototype.mergeIn; - RecordPrototype.mergeDeep = MapPrototype.mergeDeep; - RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; - RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; - RecordPrototype.setIn = MapPrototype.setIn; - RecordPrototype.update = MapPrototype.update; - RecordPrototype.updateIn = MapPrototype.updateIn; - RecordPrototype.withMutations = MapPrototype.withMutations; - RecordPrototype.asMutable = MapPrototype.asMutable; - RecordPrototype.asImmutable = MapPrototype.asImmutable; - - - function makeRecord(likeRecord, map, ownerID) { - var record = Object.create(Object.getPrototypeOf(likeRecord)); - record._map = map; - record.__ownerID = ownerID; - return record; - } - - function recordName(record) { - return record._name || record.constructor.name || 'Record'; - } - - function setProps(prototype, names) { - try { - names.forEach(setProp.bind(undefined, prototype)); - } catch (error) { - // Object.defineProperty failed. Probably IE8. - } - } - - function setProp(prototype, name) { - Object.defineProperty(prototype, name, { - get: function() { - return this.get(name); - }, - set: function(value) { - invariant(this.__ownerID, 'Cannot set on an immutable record.'); - this.set(name, value); - } - }); - } - - function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isIterable(b) || - a.size !== undefined && b.size !== undefined && a.size !== b.size || - a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; - } - - if (a.size === 0 && b.size === 0) { - return true; - } - - var notAssociative = !isAssociative(a); - - if (isOrdered(a)) { - var entries = a.entries(); - return b.every(function(v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done; - } - - var flipped = false; - - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } - } - - var allEqual = true; - var bSize = b.__iterate(function(v, k) { - if (notAssociative ? !a.has(v) : - flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) { - allEqual = false; - return false; - } - }); - - return allEqual && a.size === bSize; - } - - createClass(Range, IndexedSeq); - - function Range(start, end, step) { - if (!(this instanceof Range)) { - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - start = start || 0; - if (end === undefined) { - end = Infinity; - } - step = step === undefined ? 1 : Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { - return EMPTY_RANGE; - } - EMPTY_RANGE = this; - } - } - - Range.prototype.toString = function() { - if (this.size === 0) { - return 'Range []'; - } - return 'Range [ ' + - this._start + '...' + this._end + - (this._step > 1 ? ' by ' + this._step : '') + - ' ]'; - }; - - Range.prototype.get = function(index, notSetValue) { - return this.has(index) ? - this._start + wrapIndex(this, index) * this._step : - notSetValue; - }; - - Range.prototype.includes = function(searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex); - }; - - Range.prototype.slice = function(begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); - } - return new Range(this.get(begin, this._end), this.get(end, this._end), this._step); - }; - - Range.prototype.indexOf = function(searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index - } - } - return -1; - }; - - Range.prototype.lastIndexOf = function(searchValue) { - return this.indexOf(searchValue); - }; - - Range.prototype.__iterate = function(fn, reverse) { - var maxIndex = this.size - 1; - var step = this._step; - var value = reverse ? this._start + maxIndex * step : this._start; - for (var ii = 0; ii <= maxIndex; ii++) { - if (fn(value, ii, this) === false) { - return ii + 1; - } - value += reverse ? -step : step; - } - return ii; - }; - - Range.prototype.__iterator = function(type, reverse) { - var maxIndex = this.size - 1; - var step = this._step; - var value = reverse ? this._start + maxIndex * step : this._start; - var ii = 0; - return new src_Iterator__Iterator(function() { - var v = value; - value += reverse ? -step : step; - return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v); - }); - }; - - Range.prototype.equals = function(other) { - return other instanceof Range ? - this._start === other._start && - this._end === other._end && - this._step === other._step : - deepEqual(this, other); - }; - - - var EMPTY_RANGE; - - createClass(Repeat, IndexedSeq); - - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - return new Repeat(value, times); - } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); - if (this.size === 0) { - if (EMPTY_REPEAT) { - return EMPTY_REPEAT; - } - EMPTY_REPEAT = this; - } - } - - Repeat.prototype.toString = function() { - if (this.size === 0) { - return 'Repeat []'; - } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; - }; - - Repeat.prototype.get = function(index, notSetValue) { - return this.has(index) ? this._value : notSetValue; - }; - - Repeat.prototype.includes = function(searchValue) { - return is(this._value, searchValue); - }; - - Repeat.prototype.slice = function(begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) ? this : - new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size)); - }; - - Repeat.prototype.reverse = function() { - return this; - }; - - Repeat.prototype.indexOf = function(searchValue) { - if (is(this._value, searchValue)) { - return 0; - } - return -1; - }; - - Repeat.prototype.lastIndexOf = function(searchValue) { - if (is(this._value, searchValue)) { - return this.size; - } - return -1; - }; - - Repeat.prototype.__iterate = function(fn, reverse) { - for (var ii = 0; ii < this.size; ii++) { - if (fn(this._value, ii, this) === false) { - return ii + 1; - } - } - return ii; - }; - - Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this; - var ii = 0; - return new src_Iterator__Iterator(function() - {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()} - ); - }; - - Repeat.prototype.equals = function(other) { - return other instanceof Repeat ? - is(this._value, other._value) : - deepEqual(other); - }; - - - var EMPTY_REPEAT; - - /** - * Contributes additional methods to a constructor - */ - function mixin(ctor, methods) { - var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; }; - Object.keys(methods).forEach(keyCopier); - Object.getOwnPropertySymbols && - Object.getOwnPropertySymbols(methods).forEach(keyCopier); - return ctor; - } - - Iterable.Iterator = src_Iterator__Iterator; - - mixin(Iterable, { - - // ### Conversion to other types - - toArray: function() { - assertNotInfinite(this.size); - var array = new Array(this.size || 0); - this.valueSeq().__iterate(function(v, i) { array[i] = v; }); - return array; - }, - - toIndexedSeq: function() { - return new ToIndexedSequence(this); - }, - - toJS: function() { - return this.toSeq().map( - function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value} - ).__toJS(); - }, - - toJSON: function() { - return this.toSeq().map( - function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value} - ).__toJS(); - }, - - toKeyedSeq: function() { - return new ToKeyedSequence(this, true); - }, - - toMap: function() { - // Use Late Binding here to solve the circular dependency. - return src_Map__Map(this.toKeyedSeq()); - }, - - toObject: function() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function(v, k) { object[k] = v; }); - return object; - }, - - toOrderedMap: function() { - // Use Late Binding here to solve the circular dependency. - return OrderedMap(this.toKeyedSeq()); - }, - - toOrderedSet: function() { - // Use Late Binding here to solve the circular dependency. - return OrderedSet(isKeyed(this) ? this.valueSeq() : this); - }, - - toSet: function() { - // Use Late Binding here to solve the circular dependency. - return src_Set__Set(isKeyed(this) ? this.valueSeq() : this); - }, - - toSetSeq: function() { - return new ToSetSequence(this); - }, - - toSeq: function() { - return isIndexed(this) ? this.toIndexedSeq() : - isKeyed(this) ? this.toKeyedSeq() : - this.toSetSeq(); - }, - - toStack: function() { - // Use Late Binding here to solve the circular dependency. - return Stack(isKeyed(this) ? this.valueSeq() : this); - }, - - toList: function() { - // Use Late Binding here to solve the circular dependency. - return List(isKeyed(this) ? this.valueSeq() : this); - }, - - - // ### Common JavaScript methods and properties - - toString: function() { - return '[Iterable]'; - }, - - __toString: function(head, tail) { - if (this.size === 0) { - return head + tail; - } - return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail; - }, - - - // ### ES6 Collection methods (ES6 Array and Map) - - concat: function() {var values = SLICE$0.call(arguments, 0); - return reify(this, concatFactory(this, values)); - }, - - contains: function(searchValue) { - return this.includes(searchValue); - }, - - includes: function(searchValue) { - return this.some(function(value ) {return is(value, searchValue)}); - }, - - entries: function() { - return this.__iterator(ITERATE_ENTRIES); - }, - - every: function(predicate, context) { - assertNotInfinite(this.size); - var returnValue = true; - this.__iterate(function(v, k, c) { - if (!predicate.call(context, v, k, c)) { - returnValue = false; - return false; - } - }); - return returnValue; - }, - - filter: function(predicate, context) { - return reify(this, filterFactory(this, predicate, context, true)); - }, - - find: function(predicate, context, notSetValue) { - var entry = this.findEntry(predicate, context); - return entry ? entry[1] : notSetValue; - }, - - findEntry: function(predicate, context) { - var found; - this.__iterate(function(v, k, c) { - if (predicate.call(context, v, k, c)) { - found = [k, v]; - return false; - } - }); - return found; - }, - - findLastEntry: function(predicate, context) { - return this.toSeq().reverse().findEntry(predicate, context); - }, - - forEach: function(sideEffect, context) { - assertNotInfinite(this.size); - return this.__iterate(context ? sideEffect.bind(context) : sideEffect); - }, - - join: function(separator) { - assertNotInfinite(this.size); - separator = separator !== undefined ? '' + separator : ','; - var joined = ''; - var isFirst = true; - this.__iterate(function(v ) { - isFirst ? (isFirst = false) : (joined += separator); - joined += v !== null && v !== undefined ? v.toString() : ''; - }); - return joined; - }, - - keys: function() { - return this.__iterator(ITERATE_KEYS); - }, - - map: function(mapper, context) { - return reify(this, mapFactory(this, mapper, context)); - }, - - reduce: function(reducer, initialReduction, context) { - assertNotInfinite(this.size); - var reduction; - var useFirst; - if (arguments.length < 2) { - useFirst = true; - } else { - reduction = initialReduction; - } - this.__iterate(function(v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }); - return reduction; - }, - - reduceRight: function(reducer, initialReduction, context) { - var reversed = this.toKeyedSeq().reverse(); - return reversed.reduce.apply(reversed, arguments); - }, - - reverse: function() { - return reify(this, reverseFactory(this, true)); - }, - - slice: function(begin, end) { - return reify(this, sliceFactory(this, begin, end, true)); - }, - - some: function(predicate, context) { - return !this.every(not(predicate), context); - }, - - sort: function(comparator) { - return reify(this, sortFactory(this, comparator)); - }, - - values: function() { - return this.__iterator(ITERATE_VALUES); - }, - - - // ### More sequential methods - - butLast: function() { - return this.slice(0, -1); - }, - - isEmpty: function() { - return this.size !== undefined ? this.size === 0 : !this.some(function() {return true}); - }, - - count: function(predicate, context) { - return ensureSize( - predicate ? this.toSeq().filter(predicate, context) : this - ); - }, - - countBy: function(grouper, context) { - return countByFactory(this, grouper, context); - }, - - equals: function(other) { - return deepEqual(this, other); - }, - - entrySeq: function() { - var iterable = this; - if (iterable._cache) { - // We cache as an entries array, so we can just return the cache! - return new ArraySeq(iterable._cache); - } - var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq(); - entriesSequence.fromEntrySeq = function() {return iterable.toSeq()}; - return entriesSequence; - }, - - filterNot: function(predicate, context) { - return this.filter(not(predicate), context); - }, - - findLast: function(predicate, context, notSetValue) { - return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); - }, - - first: function() { - return this.find(returnTrue); - }, - - flatMap: function(mapper, context) { - return reify(this, flatMapFactory(this, mapper, context)); - }, - - flatten: function(depth) { - return reify(this, flattenFactory(this, depth, true)); - }, - - fromEntrySeq: function() { - return new FromEntriesSequence(this); - }, - - get: function(searchKey, notSetValue) { - return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue); - }, - - getIn: function(searchKeyPath, notSetValue) { - var nested = this; - // Note: in an ES6 environment, we would prefer: - // for (var key of searchKeyPath) { - var iter = forceIterator(searchKeyPath); - var step; - while (!(step = iter.next()).done) { - var key = step.value; - nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET; - if (nested === NOT_SET) { - return notSetValue; - } - } - return nested; - }, - - groupBy: function(grouper, context) { - return groupByFactory(this, grouper, context); - }, - - has: function(searchKey) { - return this.get(searchKey, NOT_SET) !== NOT_SET; - }, - - hasIn: function(searchKeyPath) { - return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET; - }, - - isSubset: function(iter) { - iter = typeof iter.includes === 'function' ? iter : Iterable(iter); - return this.every(function(value ) {return iter.includes(value)}); - }, - - isSuperset: function(iter) { - iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter); - return iter.isSubset(this); - }, - - keySeq: function() { - return this.toSeq().map(keyMapper).toIndexedSeq(); - }, - - last: function() { - return this.toSeq().reverse().first(); - }, - - max: function(comparator) { - return maxFactory(this, comparator); - }, - - maxBy: function(mapper, comparator) { - return maxFactory(this, comparator, mapper); - }, - - min: function(comparator) { - return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator); - }, - - minBy: function(mapper, comparator) { - return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper); - }, - - rest: function() { - return this.slice(1); - }, - - skip: function(amount) { - return this.slice(Math.max(0, amount)); - }, - - skipLast: function(amount) { - return reify(this, this.toSeq().reverse().skip(amount).reverse()); - }, - - skipWhile: function(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, true)); - }, - - skipUntil: function(predicate, context) { - return this.skipWhile(not(predicate), context); - }, - - sortBy: function(mapper, comparator) { - return reify(this, sortFactory(this, comparator, mapper)); - }, - - take: function(amount) { - return this.slice(0, Math.max(0, amount)); - }, - - takeLast: function(amount) { - return reify(this, this.toSeq().reverse().take(amount).reverse()); - }, - - takeWhile: function(predicate, context) { - return reify(this, takeWhileFactory(this, predicate, context)); - }, - - takeUntil: function(predicate, context) { - return this.takeWhile(not(predicate), context); - }, - - valueSeq: function() { - return this.toIndexedSeq(); - }, - - - // ### Hashable Object - - hashCode: function() { - return this.__hash || (this.__hash = hashIterable(this)); - }, - - - // ### Internal - - // abstract __iterate(fn, reverse) - - // abstract __iterator(type, reverse) - }); - - // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; - // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; - // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; - // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; - - var IterablePrototype = Iterable.prototype; - IterablePrototype[IS_ITERABLE_SENTINEL] = true; - IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values; - IterablePrototype.__toJS = IterablePrototype.toArray; - IterablePrototype.__toStringMapper = quoteString; - IterablePrototype.inspect = - IterablePrototype.toSource = function() { return this.toString(); }; - IterablePrototype.chain = IterablePrototype.flatMap; - - // Temporary warning about using length - (function () { - try { - Object.defineProperty(IterablePrototype, 'length', { - get: function () { - if (!Iterable.noLengthWarning) { - var stack; - try { - throw new Error(); - } catch (error) { - stack = error.stack; - } - if (stack.indexOf('_wrapObject') === -1) { - console && console.warn && console.warn( - 'iterable.length has been deprecated, '+ - 'use iterable.size or iterable.count(). '+ - 'This warning will become a silent error in a future version. ' + - stack - ); - return this.size; - } - } - } - }); - } catch (e) {} - })(); - - - - mixin(KeyedIterable, { - - // ### More sequential methods - - flip: function() { - return reify(this, flipFactory(this)); - }, - - findKey: function(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry && entry[0]; - }, - - findLastKey: function(predicate, context) { - return this.toSeq().reverse().findKey(predicate, context); - }, - - keyOf: function(searchValue) { - return this.findKey(function(value ) {return is(value, searchValue)}); - }, - - lastKeyOf: function(searchValue) { - return this.findLastKey(function(value ) {return is(value, searchValue)}); - }, - - mapEntries: function(mapper, context) {var this$0 = this; - var iterations = 0; - return reify(this, - this.toSeq().map( - function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)} - ).fromEntrySeq() - ); - }, - - mapKeys: function(mapper, context) {var this$0 = this; - return reify(this, - this.toSeq().flip().map( - function(k, v) {return mapper.call(context, k, v, this$0)} - ).flip() - ); - }, - - }); - - var KeyedIterablePrototype = KeyedIterable.prototype; - KeyedIterablePrototype[IS_KEYED_SENTINEL] = true; - KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries; - KeyedIterablePrototype.__toJS = IterablePrototype.toObject; - KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)}; - - - - mixin(IndexedIterable, { - - // ### Conversion to other types - - toKeyedSeq: function() { - return new ToKeyedSequence(this, false); - }, - - - // ### ES6 Collection methods (ES6 Array and Map) - - filter: function(predicate, context) { - return reify(this, filterFactory(this, predicate, context, false)); - }, - - findIndex: function(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - indexOf: function(searchValue) { - var key = this.toKeyedSeq().keyOf(searchValue); - return key === undefined ? -1 : key; - }, - - lastIndexOf: function(searchValue) { - return this.toSeq().reverse().indexOf(searchValue); - }, - - reverse: function() { - return reify(this, reverseFactory(this, false)); - }, - - slice: function(begin, end) { - return reify(this, sliceFactory(this, begin, end, false)); - }, - - splice: function(index, removeNum /*, ...values*/) { - var numArgs = arguments.length; - removeNum = Math.max(removeNum | 0, 0); - if (numArgs === 0 || (numArgs === 2 && !removeNum)) { - return this; - } - index = resolveBegin(index, this.size); - var spliced = this.slice(0, index); - return reify( - this, - numArgs === 1 ? - spliced : - spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) - ); - }, - - - // ### More collection methods - - findLastIndex: function(predicate, context) { - var key = this.toKeyedSeq().findLastKey(predicate, context); - return key === undefined ? -1 : key; - }, - - first: function() { - return this.get(0); - }, - - flatten: function(depth) { - return reify(this, flattenFactory(this, depth, false)); - }, - - get: function(index, notSetValue) { - index = wrapIndex(this, index); - return (index < 0 || (this.size === Infinity || - (this.size !== undefined && index > this.size))) ? - notSetValue : - this.find(function(_, key) {return key === index}, undefined, notSetValue); - }, - - has: function(index) { - index = wrapIndex(this, index); - return index >= 0 && (this.size !== undefined ? - this.size === Infinity || index < this.size : - this.indexOf(index) !== -1 - ); - }, - - interpose: function(separator) { - return reify(this, interposeFactory(this, separator)); - }, - - interleave: function(/*...iterables*/) { - var iterables = [this].concat(arrCopy(arguments)); - var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables); - var interleaved = zipped.flatten(true); - if (zipped.size) { - interleaved.size = zipped.size * iterables.length; - } - return reify(this, interleaved); - }, - - last: function() { - return this.get(-1); - }, - - skipWhile: function(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, false)); - }, - - zip: function(/*, ...iterables */) { - var iterables = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, iterables)); - }, - - zipWith: function(zipper/*, ...iterables */) { - var iterables = arrCopy(arguments); - iterables[0] = this; - return reify(this, zipWithFactory(this, zipper, iterables)); - }, - - }); - - IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true; - IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true; - - - - mixin(SetIterable, { - - // ### ES6 Collection methods (ES6 Array and Map) - - get: function(value, notSetValue) { - return this.has(value) ? value : notSetValue; - }, - - includes: function(value) { - return this.has(value); - }, - - - // ### More sequential methods - - keySeq: function() { - return this.valueSeq(); - }, - - }); - - SetIterable.prototype.has = IterablePrototype.includes; - - - // Mixin subclasses - - mixin(KeyedSeq, KeyedIterable.prototype); - mixin(IndexedSeq, IndexedIterable.prototype); - mixin(SetSeq, SetIterable.prototype); - - mixin(KeyedCollection, KeyedIterable.prototype); - mixin(IndexedCollection, IndexedIterable.prototype); - mixin(SetCollection, SetIterable.prototype); - - - // #pragma Helper functions - - function keyMapper(v, k) { - return k; - } - - function entryMapper(v, k) { - return [k, v]; - } - - function not(predicate) { - return function() { - return !predicate.apply(this, arguments); - } - } - - function neg(predicate) { - return function() { - return -predicate.apply(this, arguments); - } - } - - function quoteString(value) { - return typeof value === 'string' ? JSON.stringify(value) : value; - } - - function defaultZipper() { - return arrCopy(arguments); - } - - function defaultNegComparator(a, b) { - return a < b ? 1 : a > b ? -1 : 0; - } - - function hashIterable(iterable) { - if (iterable.size === Infinity) { - return 0; - } - var ordered = isOrdered(iterable); - var keyed = isKeyed(iterable); - var h = ordered ? 1 : 0; - var size = iterable.__iterate( - keyed ? - ordered ? - function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } : - function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } : - ordered ? - function(v ) { h = 31 * h + hash(v) | 0; } : - function(v ) { h = h + hash(v) | 0; } - ); - return murmurHashOfSize(size, h); - } - - function murmurHashOfSize(size, h) { - h = src_Math__imul(h, 0xCC9E2D51); - h = src_Math__imul(h << 15 | h >>> -15, 0x1B873593); - h = src_Math__imul(h << 13 | h >>> -13, 5); - h = (h + 0xE6546B64 | 0) ^ size; - h = src_Math__imul(h ^ h >>> 16, 0x85EBCA6B); - h = src_Math__imul(h ^ h >>> 13, 0xC2B2AE35); - h = smi(h ^ h >>> 16); - return h; - } - - function hashMerge(a, b) { - return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int } - var Immutable = { - - Iterable: Iterable, - - Seq: Seq, - Collection: Collection, - Map: src_Map__Map, - OrderedMap: OrderedMap, - List: List, - Stack: Stack, - Set: src_Set__Set, - OrderedSet: OrderedSet, - - Record: Record, - Range: Range, - Repeat: Repeat, - - is: is, - fromJS: fromJS, - - }; + return state; +}; - return Immutable; +module.exports = exports['default']; -})); -},{}],"store":[function(require,module,exports){ +},{"actions/types":225}],"store":[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -29301,7 +32276,6 @@ var DEFAULT = new _immutable2['default'].Map(Object.assign({ }, _dialogs2['default'], _menus2['default'])); var store = (0, _redux.createStore)(_reducersAll2['default'], DEFAULT); -store.dispatch((0, _actionsChangedir2['default'])(DEFAULT.get('dir'))); function bind(action) { return function () { @@ -29311,7 +32285,9 @@ function bind(action) { exports['default'] = store; -},{"./dialogs":235,"./menus":237,"actions/changedir":215,"immutable":248,"reducers/all":239,"redux":207}],"utils":[function(require,module,exports){ +store.dispatch((0, _actionsChangedir2['default'])(DEFAULT.get('dir'))); + +},{"./dialogs":239,"./menus":241,"actions/changedir":217,"immutable":3,"reducers/all":243,"redux":209}],"utils":[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -29379,4 +32355,4 @@ function humanSize(size) { } } -},{"actions/dialog":216,"store":"store"}]},{},[215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,"store","utils"]); +},{"actions/dialog":218,"store":"store"}]},{},[217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,"store","utils"]); diff --git a/build/style.css b/build/style.css index 768499f..cd73cef 100644 --- a/build/style.css +++ b/build/style.css @@ -43,6 +43,22 @@ width: 6px; height: 24px; } +.icon-search { + display: block; + background: url(/img/Search.svg) no-repeat; + width: 19px; + height: 27px; +} +.icon-cross { + display: block; + background: url(/img/Plus.svg) no-repeat; + width: 24px; + height: 24px; + transform: rotate(45deg); +} +.icon-cross svg * { + fill: white; +} .regular-medium { font-weight: normal; } @@ -104,10 +120,8 @@ input { font-weight: 200; font-size: 1.6rem; } -label { - clear: left; -} -label::after { +input[type='checkbox'] + label::after, +input[type='radio'] + label::after { content: ''; display: block; float: right; @@ -118,14 +132,36 @@ label::after { background: transparent; border: 1px solid #9b9b93; } -input[type='checkbox'] { - clear: right; - float: right; +input[type='checkbox'], +input[type='radio'] { display: none; } input:checked + label::after { background: #63b0cd; } +.coming-soon::after { + content: 'soon...'; + background: #f7c59f; + color: #39393a; + padding: 2px 8px; + border-radius: 12px; + font-size: 11px; + font-weight: normal; +} +li.coming-soon::after { + margin-right: 13px; + float: right; +} +button.coming-soon { + position: relative; +} +button.coming-soon::after { + position: absolute; + left: 50%; + top: 50%; + opacity: 0.8; + transform: translate(-50%, -50%) rotate(-45deg); +} .file, .directory { display: flex; @@ -141,11 +177,13 @@ input:checked + label::after { .file p, .directory p { flex: 1 1; + text-overflow: ellipsis; } .file > span, .directory > span { font-weight: 100; font-size: 1.5rem; + margin-left: 1rem; } .file i, .directory i { @@ -176,6 +214,10 @@ header { } header h1 { margin-left: -3rem; + flex: 1; +} +header i { + margin-right: 16px; } header button { background: none; @@ -202,7 +244,7 @@ header button::before { border-radius: 4px; pointer-events: none; opacity: 0; - transition: opacity 0.5s ease; + transition: opacity 0.3s ease; box-shadow: 0 8px 16px 3px rgba(0, 0, 0, 0.2); } .menu.active { @@ -221,6 +263,10 @@ header button::before { .menu li:last-of-type { border-bottom: none; } +.menu li.disabled { + color: #9b9b93; + pointer-events: none; +} nav { display: flex; flex-flow: column; @@ -229,18 +275,22 @@ nav { top: 0; width: 70vw; height: 100vh; + overflow-y: auto; background: #39393a; color: white; - box-shadow: 3px 0 16px 5px rgba(0, 0, 0, 0.2); + box-shadow: 3px 0 16px 5px transparent, 0 0 0 1000px rgba(0, 0, 0, 0); z-index: 6; - transition: left 0.5s ease; + transition: left 0.3s ease, box-shadow 0.3s ease; +} +nav ul:last-of-type li:last-of-type { + margin-bottom: 13px; } nav.active { left: 0; + box-shadow: 3px 0 16px 5px rgba(0, 0, 0, 0.2), 0 0 0 1000px rgba(0, 0, 0, 0.55); } nav.active i { pointer-events: all; - opacity: 0.99; } nav p { margin-left: 1.6rem; @@ -252,6 +302,7 @@ nav ul { padding-left: 0; } nav li { + display: flex; font-weight: 200; font-size: 1.6rem; padding: 1rem 0 1rem 3rem; @@ -264,18 +315,21 @@ nav li:last-of-type { padding-bottom: 0; border-bottom: none; } +nav li label { + flex: 1; + order: 0; +} +nav li input { + order: 1; +} nav i { display: block; position: fixed; - left: 0; + left: 70vw; top: 0; - pointer-events: none; - width: 100vw; + width: 30vw; height: 100vh; - background: rgba(0, 0, 0, 0.55); - opacity: 0; - z-index: -1; - transition: opacity 0.5s ease; + pointer-events: none; } .toolbar { display: flex; @@ -293,13 +347,20 @@ nav i { flex: 1; align-items: center; width: 100vw; - height: 3.5rem; + height: 4.5rem; + overflow-x: auto; padding: 8px; box-sizing: border-box; font-weight: 200; font-size: 1.6rem; background: #f8f8f8; border-bottom: 1px solid rgba(0, 0, 0, 0.2); + overflow-x: scroll; + overflow-y: hidden; + white-space: nowrap; +} +.breadcrumb span { + white-space: nowrap; } .breadcrumb i { margin: 0 2px; @@ -308,7 +369,7 @@ nav i { color: #9b9b93; } .file-list { - height: calc(100vh - 13.5rem); + height: calc(100vh - 14.5rem); overflow-x: hidden; overflow-y: auto; } @@ -319,13 +380,13 @@ nav i { top: 50%; left: 50%; transform: translate(-50%, -50%); - width: 335px; + width: 90vw; height: auto; padding: 1.5rem 1.7rem; background: white; box-shadow: 0 15px 24px 6px rgba(0, 0, 0, 0.2); - z-index: 3; - transition: opacity 0.5s ease; + z-index: 5; + transition: opacity 0.3s ease; opacity: 0; pointer-events: none; } @@ -356,6 +417,66 @@ nav i { .dialog .foot button:last-of-type { margin-right: 0; } +.sk-cube-grid { + opacity: 0; + pointer-events: none; + width: 4rem; + height: 4rem; + position: fixed; + left: 50%; + top: 50%; + margin-top: -2rem; + margin-left: -2rem; + z-index: 5; + transition: opacity 0.3s ease; +} +.sk-cube-grid.show { + opacity: 1; +} +.sk-cube-grid .sk-cube { + width: 33.33%; + height: 33.33%; + background-color: #333; + float: left; + animation: sk-cubeGridScaleDelay 1.3s infinite ease-in-out; +} +.sk-cube-grid .sk-cube1 { + animation-delay: 0.2s; +} +.sk-cube-grid .sk-cube2 { + animation-delay: 0.3s; +} +.sk-cube-grid .sk-cube3 { + animation-delay: 0.4s; +} +.sk-cube-grid .sk-cube4 { + animation-delay: 0.1s; +} +.sk-cube-grid .sk-cube5 { + animation-delay: 0.2s; +} +.sk-cube-grid .sk-cube6 { + animation-delay: 0.3s; +} +.sk-cube-grid .sk-cube7 { + animation-delay: 0s; +} +.sk-cube-grid .sk-cube8 { + animation-delay: 0.1s; +} +.sk-cube-grid .sk-cube9 { + animation-delay: 0.2s; +} +@keyframes sk-cubeGridScaleDelay { + 0%, + 70%, + 100% { + transform: scale3D(1, 1, 1); + } + 35% { + transform: scale3D(0, 0, 1); + } +} html, body { margin: 0; @@ -372,3 +493,7 @@ body { display: flex; flex-flow: column; } +a { + color: currentColor; + text-decoration: none; +} diff --git a/design/userinterface.sketch b/design/userinterface.sketch index 325b44a..eb576bb 100644 Binary files a/design/userinterface.sketch and b/design/userinterface.sketch differ diff --git a/package.json b/package.json index 38e8cbd..b57f880 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,8 @@ "grunt-contrib-watch": "^0.6.1", "grunt-fxos": "^0.1.2", "grunt-task-loader": "^0.6.0", + "hammerjs": "^2.0.4", + "immutable": "^3.7.5", "less-plugin-clean-css": "^1.5.1", "lodash": "^3.10.1", "react": "^0.13.3", diff --git a/src/img/Search.png b/src/img/Search.png new file mode 100644 index 0000000..f2dc117 Binary files /dev/null and b/src/img/Search.png differ diff --git a/src/img/Search.svg b/src/img/Search.svg new file mode 100644 index 0000000..6a72cd3 --- /dev/null +++ b/src/img/Search.svg @@ -0,0 +1,14 @@ + + + + Search + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/src/index.html b/src/index.html index cb32db8..24a51e6 100644 --- a/src/index.html +++ b/src/index.html @@ -3,7 +3,7 @@ Hawk - + diff --git a/src/js/actions/file.js b/src/js/actions/file.js index 4214aa8..77fb4ff 100644 --- a/src/js/actions/file.js +++ b/src/js/actions/file.js @@ -1,4 +1,4 @@ -import { CREATE_FILE, SHARE_FILE, RENAME_FILE, ACTIVE_FILE, DELETE_FILE } from 'actions/types'; +import { CREATE_FILE, SHARE_FILE, RENAME_FILE, ACTIVE_FILE, DELETE_FILE, MOVE_FILE, COPY_FILE } from 'actions/types'; export function create(path, directory = false) { return { @@ -21,6 +21,20 @@ export function rename(file, name) { } } +export function move(file, newPath) { + return { + type: MOVE_FILE, + file, newPath + } +} + +export function copy(file, newPath) { + return { + type: COPY_FILE, + file, newPath + } +} + export function active(file = null) { return { type: ACTIVE_FILE, @@ -28,8 +42,7 @@ export function active(file = null) { } } -export function deleteFile(file) { - console.log('constructing deleteFile action', file); +export function remove(file) { return { type: DELETE_FILE, file diff --git a/src/js/actions/files-view.js b/src/js/actions/files-view.js index a9fd852..b3e6af9 100644 --- a/src/js/actions/files-view.js +++ b/src/js/actions/files-view.js @@ -1,6 +1,13 @@ -import { LIST_FILES, FILES_VIEW, SELECT_VIEW, REFRESH } from 'actions/types'; +import { LIST_FILES, FILES_VIEW, SELECT_VIEW, REFRESH, SEARCH } from 'actions/types'; import store from 'store'; +export function listFiles(files) { + return { + type: LIST_FILES, + files + }; +} + export function refresh() { return { type: REFRESH @@ -34,3 +41,10 @@ export function selectView(active = true) { active } } + +export function search(keywords) { + return { + type: SEARCH, + keywords + } +} diff --git a/src/js/actions/list-files.js b/src/js/actions/list-files.js deleted file mode 100644 index aa8aa9e..0000000 --- a/src/js/actions/list-files.js +++ /dev/null @@ -1,8 +0,0 @@ -import { LIST_FILES } from 'actions/types'; - -export default function listFiles(files) { - return { - type: LIST_FILES, - files - }; -} diff --git a/src/js/actions/spinner.js b/src/js/actions/spinner.js new file mode 100644 index 0000000..b9e105a --- /dev/null +++ b/src/js/actions/spinner.js @@ -0,0 +1,22 @@ +import { SPINNER } from 'actions/types'; + +export function show() { + return { + type: SPINNER, + active: true + } +} + +export function hide() { + return { + type: SPINNER, + active: false + } +} + +export function toggle() { + return { + type: SPINNER, + active: 'toggle' + } +} diff --git a/src/js/actions/types.js b/src/js/actions/types.js index ebca1c2..4cdc10e 100644 --- a/src/js/actions/types.js +++ b/src/js/actions/types.js @@ -16,11 +16,15 @@ const TYPES = { RENAME_FILE: Symbol('RENAME_FILE'), ACTIVE_FILE: Symbol('ACTIVE_FILE'), DELETE_FILE: Symbol('DELETE_FILE'), + COPY_FILE: Symbol('COPY_FILE'), + MOVE_FILE: Symbol('MOVE_FILE'), MENU: Symbol('MENU'), DIALOG: Symbol('DIALOG'), + SPINNER: Symbol('SPINNER'), + SETTINGS: Symbol('SETTINGS'), SEARCH: Symbol('SEARCH') diff --git a/src/js/api/files.js b/src/js/api/files.js index 121f27a..ae5bc8c 100644 --- a/src/js/api/files.js +++ b/src/js/api/files.js @@ -75,16 +75,25 @@ export async function createDirectory(...args) { return parent.createDirectory(...args); } -export async function remove(file) { +export async function remove(file, deep) { let parent = await root(); - return parent.remove(file); + console.log(deep); + return parent[deep ? 'removeDeep' : 'remove'](file); } export async function move(file, newPath) { let path = (file.path || '').replace(/^\//, ''); // remove starting slash let oldPath = path + file.name; + let process = await copy(file, newPath); + return remove(oldPath, true); +} + +export async function copy(file, newPath) { + let path = (file.path || '').replace(/^\//, ''); // remove starting slash + let oldPath = path + file.name; + newPath = newPath.replace(/^\//, ''); let target = await getFile(oldPath); @@ -102,7 +111,6 @@ export async function move(file, newPath) { await move(child, newPath + '/' + child.name); } - await parent.remove(oldPath); return; } else { let content = await readFile(oldPath); @@ -114,6 +122,6 @@ export async function move(file, newPath) { request.onsuccess = resolve; request.onerror = reject; request.onabort = reject; - }).then(() => sdcard().delete(oldPath)); + }); } } diff --git a/src/js/components/breadcrumb.js b/src/js/components/breadcrumb.js index 4bf5701..d96dd49 100644 --- a/src/js/components/breadcrumb.js +++ b/src/js/components/breadcrumb.js @@ -40,7 +40,9 @@ export default class Breadcrumb extends Component { return (
- {els} +
+ {els} +
); } diff --git a/src/js/components/directory.js b/src/js/components/directory.js index f1e02fc..c2fe9c0 100644 --- a/src/js/components/directory.js +++ b/src/js/components/directory.js @@ -4,10 +4,16 @@ import { show } from 'actions/menu'; import { active } from 'actions/file'; import { MENU_WIDTH } from './menu'; import store from 'store'; +import entry from './mixins/entry'; const MENU_TOP_SPACE = 20; export default class Directory extends Component { + constructor() { + super(); + Object.assign(this, entry); + } + render() { let checkId = `file-${this.props.index}`; @@ -40,28 +46,4 @@ export default class Directory extends Component { store.dispatch(changedir(file.path.slice(1) + file.name)); } - - contextMenu(e) { - e.preventDefault(); - - let rect = React.findDOMNode(this.refs.container).getBoundingClientRect(); - let {x, y, width, height} = rect; - - let left = x + width / 2 - MENU_WIDTH / 2, - top = y + height / 2 + MENU_TOP_SPACE; - store.dispatch(show('directoryMenu', {style: {left, top}})); - store.dispatch(active(this.props.index)); - } - - select() { - let current = (store.getState().get('activeFile') || []).slice(0); - let index = this.props.index; - - if (current.indexOf(index) > -1) { - current.splice(current.indexOf(index), 1); - } else { - current.push(index) - } - store.dispatch(active(current)); - } } diff --git a/src/js/components/file-list.js b/src/js/components/file-list.js index c774fdc..0519b34 100644 --- a/src/js/components/file-list.js +++ b/src/js/components/file-list.js @@ -4,6 +4,8 @@ import File from './file'; import Directory from './directory'; import store from 'store'; import { type } from 'utils'; +import Hammer from 'hammerjs'; +import changedir from 'actions/changedir'; @connect(props) export default class FileList extends Component { @@ -17,7 +19,7 @@ export default class FileList extends Component { let settings = store.getState().get('settings'); let els = files.map((file, index) => { - let selected = activeFile.indexOf(index) > -1; + let selected = activeFile.length && activeFile.indexOf(file) > -1; if (type(file) === 'File') { return ; } else { @@ -26,11 +28,25 @@ export default class FileList extends Component { }); return ( -
+
{els}
); } + + componentDidMount() { + let container = React.findDOMNode(this.refs.container); + let touch = Hammer(container); + + touch.on('swipe', e => { + let current = store.getState().get('cwd'); + let up = current.split('/').slice(0, -1).join('/'); + + if (up === current) return; + + store.dispatch(changedir(up)); + }).set({direction: Hammer.DIRECTION_RIGHT}); + } } function props(state) { diff --git a/src/js/components/file.js b/src/js/components/file.js index cb160e1..a0a7316 100644 --- a/src/js/components/file.js +++ b/src/js/components/file.js @@ -4,12 +4,14 @@ import { active } from 'actions/file'; import { MENU_WIDTH } from './menu'; import store from 'store'; import { humanSize } from 'utils'; +import entry from './mixins/entry'; const MENU_TOP_SPACE = 20; export default class File extends Component { constructor() { super(); + Object.assign(this, entry); } render() { @@ -22,7 +24,7 @@ export default class File extends Component { } let clickHandler = this.props.selectView ? this.select.bind(this) - : null; + : this.open.bind(this); return (
-1) { - current.splice(current.indexOf(index), 1); - } else { - current.push(index) - } - store.dispatch(active(current)); + let name = file.type === 'application/pdf' ? 'view' : 'open'; + new MozActivity({ + name, + data: { + type: file.type, + blob: file + } + }) } } diff --git a/src/js/components/header.js b/src/js/components/header.js index bdc5442..8382d9b 100644 --- a/src/js/components/header.js +++ b/src/js/components/header.js @@ -1,18 +1,34 @@ import React, { Component } from 'react'; import { toggle } from 'actions/navigation'; -import store from 'store'; +import { show } from 'actions/dialog'; +import { search } from 'actions/files-view'; +import { bind } from 'store'; +import { connect } from 'react-redux'; +@connect(props) export default class Header extends Component { render() { + let i; + + if (this.props.search) { + i = + } else { + i = + } + return (
- +
); } +} - toggleNavigation() { - store.dispatch(toggle()); +function props(state) { + return { + search: state.get('search') } } diff --git a/src/js/components/menu.js b/src/js/components/menu.js index f5a379b..88ba53e 100644 --- a/src/js/components/menu.js +++ b/src/js/components/menu.js @@ -8,7 +8,10 @@ export default class Menu extends Component { items = items || []; let els = items.map((item, index) => { - return
  • {item.name}
  • + let disabled = !(typeof item.enabled === 'function' ? item.enabled() : true) + let className = disabled ? 'disabled' : ''; + + return
  • {item.name}
  • }); let className = 'menu ' + (active ? 'active' : ''); diff --git a/src/js/components/mixins/entry.js b/src/js/components/mixins/entry.js new file mode 100644 index 0000000..b87c1bb --- /dev/null +++ b/src/js/components/mixins/entry.js @@ -0,0 +1,26 @@ +export default { + contextMenu(e) { + e.preventDefault(); + + let file = store.getState().get('files')[this.props.index]; + let rect = React.findDOMNode(this.refs.container).getBoundingClientRect(); + let {x, y, width, height} = rect; + + let left = x + width / 2 - MENU_WIDTH / 2, + top = y + height / 2 + MENU_TOP_SPACE; + store.dispatch(show('fileMenu', {style: {left, top}})); + store.dispatch(active([file])); + }, + + select() { + let current = store.getState().get('activeFile').slice(0); + let file = store.getState().get('files')[this.props.index]; + + if (current.indexOf(file) > -1) { + current.splice(current.indexOf(file), 1); + } else { + current.push(file) + } + store.dispatch(active(current)); + } +} diff --git a/src/js/components/navigation.js b/src/js/components/navigation.js index 3bf00d8..a6aac97 100644 --- a/src/js/components/navigation.js +++ b/src/js/components/navigation.js @@ -1,9 +1,9 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; -import { hide } from 'actions/navigation'; +import { hide as hideNavigation } from 'actions/navigation'; import camelCase from 'lodash/string/camelCase'; import updateSettings from 'actions/settings'; -import store from 'store'; +import store, { bind } from 'store'; @connect(props) export default class Navigation extends Component { @@ -11,23 +11,38 @@ export default class Navigation extends Component { let { settings } = this.props; return ( -