diff --git a/Gruntfile.js b/Gruntfile.js index 07ce51b..87d26a3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,10 +5,17 @@ module.exports = function(grunt) { browserify: { dev: { files: { - 'build/main.js': 'src/js/**/*' + 'build/main.js': ['src/js/**/*', '!src/js/libs/**'] }, options: { - transform: ['babelify'], + alias: { + store: './src/js/store.js' + }, + transform: [['babelify', { + optional: ['es7.asyncFunctions', 'asyncToGenerator', + 'es7.decorators'], + blacklist: [] + }]], plugin: [ [ 'remapify', [ @@ -16,6 +23,21 @@ module.exports = function(grunt) { src: '**/*.js', expose: 'components', cwd: __dirname + '/src/js/components/' + }, + { + src: '**/*.js', + expose: 'actions', + cwd: __dirname + '/src/js/actions' + }, + { + src: '**/*.js', + expose: 'reducers', + cwd: __dirname + '/src/js/reducers' + }, + { + src: '**/*.js', + expose: 'api', + cwd: __dirname + '/src/js/api' } ] ] @@ -48,14 +70,34 @@ module.exports = function(grunt) { }] } }, + copy: { + assets: { + files: [{ + expand: true, + cwd: 'src', + dest: 'build', + src: ['index.html', 'manifest.webapp', + 'fonts/**', 'img/**', 'js/libs/**'] + }] + } + }, watch: { styles: { - files: ['less/**/*.less'], - tasks: ['less'] + files: ['src/less/**/*.less'], + tasks: ['less:dev'] + }, + scripts: { + files: ['src/js/**/*'], + tasks: ['browserify:dev'] + }, + assets: { + files: ['src/index.html', 'src/manifest.webapp', + 'src/fonts/**', 'src/img/**', 'src/data/**'], + tasks: ['copy'] } } }); - grunt.registerTask('default', ['browserify:dev', 'less:dev']); - grunt.registerTask('production', ['browserify:prod', 'less:prod']); + grunt.registerTask('default', ['browserify:dev', 'less:dev', 'copy']); + grunt.registerTask('production', ['browserify:prod', 'less:prod', 'copy']); }; diff --git a/build/img/icons/icon.svg b/build/img/icons/icon.svg new file mode 100644 index 0000000..834968c --- /dev/null +++ b/build/img/icons/icon.svg @@ -0,0 +1,106 @@ + + + + + + image/svg+xml + + + + + + + empty + Created with Sketch. + + + + + + + + + + + + diff --git a/build/img/icons/icon128x128.png b/build/img/icons/icon128x128.png new file mode 100644 index 0000000..7c672c5 Binary files /dev/null and b/build/img/icons/icon128x128.png differ diff --git a/build/img/icons/icon16x16.png b/build/img/icons/icon16x16.png new file mode 100644 index 0000000..abf254e Binary files /dev/null and b/build/img/icons/icon16x16.png differ diff --git a/build/img/icons/icon48x48.png b/build/img/icons/icon48x48.png new file mode 100644 index 0000000..451655b Binary files /dev/null and b/build/img/icons/icon48x48.png differ diff --git a/build/img/icons/icon60x60.png b/build/img/icons/icon60x60.png new file mode 100644 index 0000000..c7d4115 Binary files /dev/null and b/build/img/icons/icon60x60.png differ diff --git a/build/index.html b/build/index.html new file mode 100644 index 0000000..f0d774e --- /dev/null +++ b/build/index.html @@ -0,0 +1,13 @@ + + + + + Hawk + + + +
+ + + + diff --git a/build/js/libs/l10n.js b/build/js/libs/l10n.js new file mode 100644 index 0000000..cfc5c51 --- /dev/null +++ b/build/js/libs/l10n.js @@ -0,0 +1,1571 @@ +// This is the Gaia version of l20n: https://github.com/l20n/l20n.js +// l20n is Apache 2.0 licensed: https://github.com/l20n/l20n.js/blob/master/LICENSE +// You can find the latest build for Gaia here: https://github.com/mozilla-b2g/gaia/blob/master/shared/js/l10n.js +(function(window, undefined) { + 'use strict'; + + /* jshint validthis:true */ + function L10nError(message, id, loc) { + this.name = 'L10nError'; + this.message = message; + this.id = id; + this.loc = loc; + } + L10nError.prototype = Object.create(Error.prototype); + L10nError.prototype.constructor = L10nError; + + + /* jshint browser:true */ + + var io = { + load: function load(url, callback, sync) { + var xhr = new XMLHttpRequest(); + + if (xhr.overrideMimeType) { + xhr.overrideMimeType('text/plain'); + } + + xhr.open('GET', url, !sync); + + xhr.addEventListener('load', function io_load(e) { + if (e.target.status === 200 || e.target.status === 0) { + callback(null, e.target.responseText); + } else { + callback(new L10nError('Not found: ' + url)); + } + }); + xhr.addEventListener('error', callback); + xhr.addEventListener('timeout', callback); + + // the app: protocol throws on 404, see https://bugzil.la/827243 + try { + xhr.send(null); + } catch (e) { + callback(new L10nError('Not found: ' + url)); + } + }, + + loadJSON: function loadJSON(url, callback) { + var xhr = new XMLHttpRequest(); + + if (xhr.overrideMimeType) { + xhr.overrideMimeType('application/json'); + } + + xhr.open('GET', url); + + xhr.responseType = 'json'; + xhr.addEventListener('load', function io_loadjson(e) { + if (e.target.status === 200 || e.target.status === 0) { + callback(null, e.target.response); + } else { + callback(new L10nError('Not found: ' + url)); + } + }); + xhr.addEventListener('error', callback); + xhr.addEventListener('timeout', callback); + + // the app: protocol throws on 404, see https://bugzil.la/827243 + try { + xhr.send(null); + } catch (e) { + callback(new L10nError('Not found: ' + url)); + } + } + }; + + function EventEmitter() {} + + EventEmitter.prototype.emit = function ee_emit() { + if (!this._listeners) { + return; + } + + var args = Array.prototype.slice.call(arguments); + var type = args.shift(); + if (!this._listeners[type]) { + return; + } + + var typeListeners = this._listeners[type].slice(); + for (var i = 0; i < typeListeners.length; i++) { + typeListeners[i].apply(this, args); + } + }; + + EventEmitter.prototype.addEventListener = function ee_add(type, listener) { + if (!this._listeners) { + this._listeners = {}; + } + if (!(type in this._listeners)) { + this._listeners[type] = []; + } + this._listeners[type].push(listener); + }; + + EventEmitter.prototype.removeEventListener = function ee_rm(type, listener) { + if (!this._listeners) { + return; + } + + var typeListeners = this._listeners[type]; + var pos = typeListeners.indexOf(listener); + if (pos === -1) { + return; + } + + typeListeners.splice(pos, 1); + }; + + + function getPluralRule(lang) { + var locales2rules = { + 'af': 3, + 'ak': 4, + 'am': 4, + 'ar': 1, + 'asa': 3, + 'az': 0, + 'be': 11, + 'bem': 3, + 'bez': 3, + 'bg': 3, + 'bh': 4, + 'bm': 0, + 'bn': 3, + 'bo': 0, + 'br': 20, + 'brx': 3, + 'bs': 11, + 'ca': 3, + 'cgg': 3, + 'chr': 3, + 'cs': 12, + 'cy': 17, + 'da': 3, + 'de': 3, + 'dv': 3, + 'dz': 0, + 'ee': 3, + 'el': 3, + 'en': 3, + 'eo': 3, + 'es': 3, + 'et': 3, + 'eu': 3, + 'fa': 0, + 'ff': 5, + 'fi': 3, + 'fil': 4, + 'fo': 3, + 'fr': 5, + 'fur': 3, + 'fy': 3, + 'ga': 8, + 'gd': 24, + 'gl': 3, + 'gsw': 3, + 'gu': 3, + 'guw': 4, + 'gv': 23, + 'ha': 3, + 'haw': 3, + 'he': 2, + 'hi': 4, + 'hr': 11, + 'hu': 0, + 'id': 0, + 'ig': 0, + 'ii': 0, + 'is': 3, + 'it': 3, + 'iu': 7, + 'ja': 0, + 'jmc': 3, + 'jv': 0, + 'ka': 0, + 'kab': 5, + 'kaj': 3, + 'kcg': 3, + 'kde': 0, + 'kea': 0, + 'kk': 3, + 'kl': 3, + 'km': 0, + 'kn': 0, + 'ko': 0, + 'ksb': 3, + 'ksh': 21, + 'ku': 3, + 'kw': 7, + 'lag': 18, + 'lb': 3, + 'lg': 3, + 'ln': 4, + 'lo': 0, + 'lt': 10, + 'lv': 6, + 'mas': 3, + 'mg': 4, + 'mk': 16, + 'ml': 3, + 'mn': 3, + 'mo': 9, + 'mr': 3, + 'ms': 0, + 'mt': 15, + 'my': 0, + 'nah': 3, + 'naq': 7, + 'nb': 3, + 'nd': 3, + 'ne': 3, + 'nl': 3, + 'nn': 3, + 'no': 3, + 'nr': 3, + 'nso': 4, + 'ny': 3, + 'nyn': 3, + 'om': 3, + 'or': 3, + 'pa': 3, + 'pap': 3, + 'pl': 13, + 'ps': 3, + 'pt': 3, + 'rm': 3, + 'ro': 9, + 'rof': 3, + 'ru': 11, + 'rwk': 3, + 'sah': 0, + 'saq': 3, + 'se': 7, + 'seh': 3, + 'ses': 0, + 'sg': 0, + 'sh': 11, + 'shi': 19, + 'sk': 12, + 'sl': 14, + 'sma': 7, + 'smi': 7, + 'smj': 7, + 'smn': 7, + 'sms': 7, + 'sn': 3, + 'so': 3, + 'sq': 3, + 'sr': 11, + 'ss': 3, + 'ssy': 3, + 'st': 3, + 'sv': 3, + 'sw': 3, + 'syr': 3, + 'ta': 3, + 'te': 3, + 'teo': 3, + 'th': 0, + 'ti': 4, + 'tig': 3, + 'tk': 3, + 'tl': 4, + 'tn': 3, + 'to': 0, + 'tr': 0, + 'ts': 3, + 'tzm': 22, + 'uk': 11, + 'ur': 3, + 've': 3, + 'vi': 0, + 'vun': 3, + 'wa': 4, + 'wae': 3, + 'wo': 0, + 'xh': 3, + 'xog': 3, + 'yo': 0, + 'zh': 0, + 'zu': 3 + }; + + // utility functions for plural rules methods + function isIn(n, list) { + return list.indexOf(n) !== -1; + } + function isBetween(n, start, end) { + return start <= n && n <= end; + } + + // list of all plural rules methods: + // map an integer to the plural form name to use + var pluralRules = { + '0': function() { + return 'other'; + }, + '1': function(n) { + if ((isBetween((n % 100), 3, 10))) { + return 'few'; + } + if (n === 0) { + return 'zero'; + } + if ((isBetween((n % 100), 11, 99))) { + return 'many'; + } + if (n === 2) { + return 'two'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '2': function(n) { + if (n !== 0 && (n % 10) === 0) { + return 'many'; + } + if (n === 2) { + return 'two'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '3': function(n) { + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '4': function(n) { + if ((isBetween(n, 0, 1))) { + return 'one'; + } + return 'other'; + }, + '5': function(n) { + if ((isBetween(n, 0, 2)) && n !== 2) { + return 'one'; + } + return 'other'; + }, + '6': function(n) { + if (n === 0) { + return 'zero'; + } + if ((n % 10) === 1 && (n % 100) !== 11) { + return 'one'; + } + return 'other'; + }, + '7': function(n) { + if (n === 2) { + return 'two'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '8': function(n) { + if ((isBetween(n, 3, 6))) { + return 'few'; + } + if ((isBetween(n, 7, 10))) { + return 'many'; + } + if (n === 2) { + return 'two'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '9': function(n) { + if (n === 0 || n !== 1 && (isBetween((n % 100), 1, 19))) { + return 'few'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '10': function(n) { + if ((isBetween((n % 10), 2, 9)) && !(isBetween((n % 100), 11, 19))) { + return 'few'; + } + if ((n % 10) === 1 && !(isBetween((n % 100), 11, 19))) { + return 'one'; + } + return 'other'; + }, + '11': function(n) { + if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14))) { + return 'few'; + } + if ((n % 10) === 0 || + (isBetween((n % 10), 5, 9)) || + (isBetween((n % 100), 11, 14))) { + return 'many'; + } + if ((n % 10) === 1 && (n % 100) !== 11) { + return 'one'; + } + return 'other'; + }, + '12': function(n) { + if ((isBetween(n, 2, 4))) { + return 'few'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '13': function(n) { + if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14))) { + return 'few'; + } + if (n !== 1 && (isBetween((n % 10), 0, 1)) || + (isBetween((n % 10), 5, 9)) || + (isBetween((n % 100), 12, 14))) { + return 'many'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '14': function(n) { + if ((isBetween((n % 100), 3, 4))) { + return 'few'; + } + if ((n % 100) === 2) { + return 'two'; + } + if ((n % 100) === 1) { + return 'one'; + } + return 'other'; + }, + '15': function(n) { + if (n === 0 || (isBetween((n % 100), 2, 10))) { + return 'few'; + } + if ((isBetween((n % 100), 11, 19))) { + return 'many'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '16': function(n) { + if ((n % 10) === 1 && n !== 11) { + return 'one'; + } + return 'other'; + }, + '17': function(n) { + if (n === 3) { + return 'few'; + } + if (n === 0) { + return 'zero'; + } + if (n === 6) { + return 'many'; + } + if (n === 2) { + return 'two'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '18': function(n) { + if (n === 0) { + return 'zero'; + } + if ((isBetween(n, 0, 2)) && n !== 0 && n !== 2) { + return 'one'; + } + return 'other'; + }, + '19': function(n) { + if ((isBetween(n, 2, 10))) { + return 'few'; + } + if ((isBetween(n, 0, 1))) { + return 'one'; + } + return 'other'; + }, + '20': function(n) { + if ((isBetween((n % 10), 3, 4) || ((n % 10) === 9)) && !( + isBetween((n % 100), 10, 19) || + isBetween((n % 100), 70, 79) || + isBetween((n % 100), 90, 99) + )) { + return 'few'; + } + if ((n % 1000000) === 0 && n !== 0) { + return 'many'; + } + if ((n % 10) === 2 && !isIn((n % 100), [12, 72, 92])) { + return 'two'; + } + if ((n % 10) === 1 && !isIn((n % 100), [11, 71, 91])) { + return 'one'; + } + return 'other'; + }, + '21': function(n) { + if (n === 0) { + return 'zero'; + } + if (n === 1) { + return 'one'; + } + return 'other'; + }, + '22': function(n) { + if ((isBetween(n, 0, 1)) || (isBetween(n, 11, 99))) { + return 'one'; + } + return 'other'; + }, + '23': function(n) { + if ((isBetween((n % 10), 1, 2)) || (n % 20) === 0) { + return 'one'; + } + return 'other'; + }, + '24': function(n) { + if ((isBetween(n, 3, 10) || isBetween(n, 13, 19))) { + return 'few'; + } + if (isIn(n, [2, 12])) { + return 'two'; + } + if (isIn(n, [1, 11])) { + return 'one'; + } + return 'other'; + } + }; + + // return a function that gives the plural form name for a given integer + var index = locales2rules[lang.replace(/-.*$/, '')]; + if (!(index in pluralRules)) { + return function() { return 'other'; }; + } + return pluralRules[index]; + } + + + + + var nestedProps = ['style', 'dataset']; + + var parsePatterns; + + function parse(ctx, source) { + var ast = {}; + + if (!parsePatterns) { + parsePatterns = { + comment: /^\s*#|^\s*$/, + entity: /^([^=\s]+)\s*=\s*(.+)$/, + multiline: /[^\\]\\$/, + macro: /\{\[\s*(\w+)\(([^\)]*)\)\s*\]\}/i, + unicode: /\\u([0-9a-fA-F]{1,4})/g, + entries: /[\r\n]+/, + controlChars: /\\([\\\n\r\t\b\f\{\}\"\'])/g + }; + } + + var entries = source.split(parsePatterns.entries); + for (var i = 0; i < entries.length; i++) { + var line = entries[i]; + + if (parsePatterns.comment.test(line)) { + continue; + } + + while (parsePatterns.multiline.test(line) && i < entries.length) { + line = line.slice(0, -1) + entries[++i].trim(); + } + + var entityMatch = line.match(parsePatterns.entity); + if (entityMatch) { + try { + parseEntity(entityMatch[1], entityMatch[2], ast); + } catch (e) { + if (ctx) { + ctx._emitter.emit('error', e); + } else { + throw e; + } + } + } + } + return ast; + } + + function setEntityValue(id, attr, key, value, ast) { + var obj = ast; + var prop = id; + + if (attr) { + if (!(id in obj)) { + obj[id] = {}; + } + if (typeof(obj[id]) === 'string') { + obj[id] = {'_': obj[id]}; + } + obj = obj[id]; + prop = attr; + } + + if (!key) { + obj[prop] = value; + return; + } + + if (!(prop in obj)) { + obj[prop] = {'_': {}}; + } else if (typeof(obj[prop]) === 'string') { + obj[prop] = {'_index': parseMacro(obj[prop]), '_': {}}; + } + obj[prop]._[key] = value; + } + + function parseEntity(id, value, ast) { + var name, key; + + var pos = id.indexOf('['); + if (pos !== -1) { + name = id.substr(0, pos); + key = id.substring(pos + 1, id.length - 1); + } else { + name = id; + key = null; + } + + var nameElements = name.split('.'); + + var attr; + if (nameElements.length > 1) { + var attrElements = []; + attrElements.push(nameElements.pop()); + if (nameElements.length > 1) { + // Usually the last dot separates an attribute from an id + // + // In case when there are more than one dot in the id + // and the second to last item is "style" or "dataset" then the last two + // items are becoming the attribute. + // + // ex. + // id.style.color = foo => + // + // id: + // style.color: foo + // + // id.other.color = foo => + // + // id.other: + // color: foo + if (nestedProps.indexOf(nameElements[nameElements.length - 1]) !== -1) { + attrElements.push(nameElements.pop()); + } + } + name = nameElements.join('.'); + attr = attrElements.reverse().join('.'); + } else { + attr = null; + } + + setEntityValue(name, attr, key, unescapeString(value), ast); + } + + function unescapeControlCharacters(str) { + return str.replace(parsePatterns.controlChars, '$1'); + } + + function unescapeUnicode(str) { + return str.replace(parsePatterns.unicode, function(match, token) { + return unescape('%u' + '0000'.slice(token.length) + token); + }); + } + + function unescapeString(str) { + if (str.lastIndexOf('\\') !== -1) { + str = unescapeControlCharacters(str); + } + return unescapeUnicode(str); + } + + function parseMacro(str) { + var match = str.match(parsePatterns.macro); + if (!match) { + throw new L10nError('Malformed macro'); + } + return [match[1], match[2]]; + } + + + + var MAX_PLACEABLE_LENGTH = 2500; + var MAX_PLACEABLES = 100; + var rePlaceables = /\{\{\s*(.+?)\s*\}\}/g; + + function Entity(id, node, env) { + this.id = id; + this.env = env; + // the dirty guard prevents cyclic or recursive references from other + // Entities; see Entity.prototype.resolve + this.dirty = false; + if (typeof node === 'string') { + this.value = node; + } else { + // it's either a hash or it has attrs, or both + for (var key in node) { + if (node.hasOwnProperty(key) && key[0] !== '_') { + if (!this.attributes) { + this.attributes = {}; + } + this.attributes[key] = new Entity(this.id + '.' + key, node[key], + env); + } + } + this.value = node._ || null; + this.index = node._index; + } + } + + Entity.prototype.resolve = function E_resolve(ctxdata) { + if (this.dirty) { + return undefined; + } + + this.dirty = true; + var val; + // if resolve fails, we want the exception to bubble up and stop the whole + // resolving process; however, we still need to clean up the dirty flag + try { + val = resolve(ctxdata, this.env, this.value, this.index); + } finally { + this.dirty = false; + } + return val; + }; + + Entity.prototype.toString = function E_toString(ctxdata) { + try { + return this.resolve(ctxdata); + } catch (e) { + return undefined; + } + }; + + Entity.prototype.valueOf = function E_valueOf(ctxdata) { + if (!this.attributes) { + return this.toString(ctxdata); + } + + var entity = { + value: this.toString(ctxdata), + attributes: {} + }; + + for (var key in this.attributes) { + if (this.attributes.hasOwnProperty(key)) { + entity.attributes[key] = this.attributes[key].toString(ctxdata); + } + } + + return entity; + }; + + function subPlaceable(ctxdata, env, match, id) { + if (ctxdata && ctxdata.hasOwnProperty(id) && + (typeof ctxdata[id] === 'string' || + (typeof ctxdata[id] === 'number' && !isNaN(ctxdata[id])))) { + return ctxdata[id]; + } + + if (env.hasOwnProperty(id)) { + if (!(env[id] instanceof Entity)) { + env[id] = new Entity(id, env[id], env); + } + var value = env[id].resolve(ctxdata); + if (typeof value === 'string') { + // prevent Billion Laughs attacks + if (value.length >= MAX_PLACEABLE_LENGTH) { + throw new L10nError('Too many characters in placeable (' + + value.length + ', max allowed is ' + + MAX_PLACEABLE_LENGTH + ')'); + } + return value; + } + } + return match; + } + + function interpolate(ctxdata, env, str) { + var placeablesCount = 0; + var value = str.replace(rePlaceables, function(match, id) { + // prevent Quadratic Blowup attacks + if (placeablesCount++ >= MAX_PLACEABLES) { + throw new L10nError('Too many placeables (' + placeablesCount + + ', max allowed is ' + MAX_PLACEABLES + ')'); + } + return subPlaceable(ctxdata, env, match, id); + }); + placeablesCount = 0; + return value; + } + + function resolve(ctxdata, env, expr, index) { + if (typeof expr === 'string') { + return interpolate(ctxdata, env, expr); + } + + if (typeof expr === 'boolean' || + typeof expr === 'number' || + !expr) { + return expr; + } + + // otherwise, it's a dict + + if (index && ctxdata && ctxdata.hasOwnProperty(index[1])) { + var argValue = ctxdata[index[1]]; + + // special cases for zero, one, two if they are defined on the hash + if (argValue === 0 && 'zero' in expr) { + return resolve(ctxdata, env, expr.zero); + } + if (argValue === 1 && 'one' in expr) { + return resolve(ctxdata, env, expr.one); + } + if (argValue === 2 && 'two' in expr) { + return resolve(ctxdata, env, expr.two); + } + + var selector = env.__plural(argValue); + if (expr.hasOwnProperty(selector)) { + return resolve(ctxdata, env, expr[selector]); + } + } + + // if there was no index or no selector was found, try 'other' + if ('other' in expr) { + return resolve(ctxdata, env, expr.other); + } + + return undefined; + } + + function compile(env, ast) { + env = env || {}; + for (var id in ast) { + if (ast.hasOwnProperty(id)) { + env[id] = new Entity(id, ast[id], env); + } + } + return env; + } + + + + function Locale(id, ctx) { + this.id = id; + this.ctx = ctx; + this.isReady = false; + this.entries = { + __plural: getPluralRule(id) + }; + } + + Locale.prototype.getEntry = function L_getEntry(id) { + /* jshint -W093 */ + + var entries = this.entries; + + if (!entries.hasOwnProperty(id)) { + return undefined; + } + + if (entries[id] instanceof Entity) { + return entries[id]; + } + + return entries[id] = new Entity(id, entries[id], entries); + }; + + Locale.prototype.build = function L_build(callback) { + var sync = !callback; + var ctx = this.ctx; + var self = this; + + var l10nLoads = ctx.resLinks.length; + + function onL10nLoaded(err) { + if (err) { + ctx._emitter.emit('error', err); + } + if (--l10nLoads <= 0) { + self.isReady = true; + if (callback) { + callback(); + } + } + } + + if (l10nLoads === 0) { + onL10nLoaded(); + return; + } + + function onJSONLoaded(err, json) { + if (!err && json) { + self.addAST(json); + } + onL10nLoaded(err); + } + + function onPropLoaded(err, source) { + if (!err && source) { + var ast = parse(ctx, source); + self.addAST(ast); + } + onL10nLoaded(err); + } + + + for (var i = 0; i < ctx.resLinks.length; i++) { + var path = ctx.resLinks[i].replace('{{locale}}', this.id); + var type = path.substr(path.lastIndexOf('.') + 1); + + switch (type) { + case 'json': + io.loadJSON(path, onJSONLoaded, sync); + break; + case 'properties': + io.load(path, onPropLoaded, sync); + break; + } + } + }; + + Locale.prototype.addAST = function(ast) { + for (var id in ast) { + if (ast.hasOwnProperty(id)) { + this.entries[id] = ast[id]; + } + } + }; + + Locale.prototype.getEntity = function(id, ctxdata) { + var entry = this.getEntry(id); + + if (!entry) { + return null; + } + return entry.valueOf(ctxdata); + }; + + + + function Context(id) { + + this.id = id; + this.isReady = false; + this.isLoading = false; + + this.supportedLocales = []; + this.resLinks = []; + this.locales = {}; + + this._emitter = new EventEmitter(); + + + // Getting translations + + function getWithFallback(id) { + /* jshint -W084 */ + + if (!this.isReady) { + throw new L10nError('Context not ready'); + } + + var cur = 0; + var loc; + var locale; + while (loc = this.supportedLocales[cur]) { + locale = this.getLocale(loc); + if (!locale.isReady) { + // build without callback, synchronously + locale.build(null); + } + var entry = locale.getEntry(id); + if (entry === undefined) { + cur++; + warning.call(this, new L10nError(id + ' not found in ' + loc, id, + loc)); + continue; + } + return entry; + } + + error.call(this, new L10nError(id + ' not found', id)); + return null; + } + + this.get = function get(id, ctxdata) { + var entry = getWithFallback.call(this, id); + if (entry === null) { + return ''; + } + + return entry.toString(ctxdata) || ''; + }; + + this.getEntity = function getEntity(id, ctxdata) { + var entry = getWithFallback.call(this, id); + if (entry === null) { + return null; + } + + return entry.valueOf(ctxdata); + }; + + + // Helpers + + this.getLocale = function getLocale(code) { + /* jshint -W093 */ + + var locales = this.locales; + if (locales[code]) { + return locales[code]; + } + + return locales[code] = new Locale(code, this); + }; + + + // Getting ready + + function negotiate(available, requested, defaultLocale) { + if (available.indexOf(requested[0]) === -1 || + requested[0] === defaultLocale) { + return [defaultLocale]; + } else { + return [requested[0], defaultLocale]; + } + } + + function freeze(supported) { + var locale = this.getLocale(supported[0]); + if (locale.isReady) { + setReady.call(this, supported); + } else { + locale.build(setReady.bind(this, supported)); + } + } + + function setReady(supported) { + this.supportedLocales = supported; + this.isReady = true; + this._emitter.emit('ready'); + } + + this.requestLocales = function requestLocales() { + if (this.isLoading && !this.isReady) { + throw new L10nError('Context not ready'); + } + + this.isLoading = true; + var requested = Array.prototype.slice.call(arguments); + + var supported = negotiate(requested.concat('en-US'), requested, 'en-US'); + freeze.call(this, supported); + }; + + + // Events + + this.addEventListener = function addEventListener(type, listener) { + this._emitter.addEventListener(type, listener); + }; + + this.removeEventListener = function removeEventListener(type, listener) { + this._emitter.removeEventListener(type, listener); + }; + + this.ready = function ready(callback) { + if (this.isReady) { + setTimeout(callback); + } + this.addEventListener('ready', callback); + }; + + this.once = function once(callback) { + /* jshint -W068 */ + if (this.isReady) { + setTimeout(callback); + return; + } + + var callAndRemove = (function() { + this.removeEventListener('ready', callAndRemove); + callback(); + }).bind(this); + this.addEventListener('ready', callAndRemove); + }; + + + // Errors + + function warning(e) { + this._emitter.emit('warning', e); + return e; + } + + function error(e) { + this._emitter.emit('error', e); + return e; + } + } + + + /* jshint -W104 */ + + var DEBUG = false; + var isPretranslated = false; + var rtlList = ['ar', 'he', 'fa', 'ps', 'qps-plocm', 'ur']; + + // Public API + + navigator.mozL10n = { + ctx: new Context(), + get: function get(id, ctxdata) { + return navigator.mozL10n.ctx.get(id, ctxdata); + }, + localize: function localize(element, id, args) { + return localizeElement.call(navigator.mozL10n, element, id, args); + }, + translate: function translate(element) { + return translateFragment.call(navigator.mozL10n, element); + }, + ready: function ready(callback) { + return navigator.mozL10n.ctx.ready(callback); + }, + once: function once(callback) { + return navigator.mozL10n.ctx.once(callback); + }, + get readyState() { + return navigator.mozL10n.ctx.isReady ? 'complete' : 'loading'; + }, + language: { + set code(lang) { + navigator.mozL10n.ctx.requestLocales(lang); + }, + get code() { + return navigator.mozL10n.ctx.supportedLocales[0]; + }, + get direction() { + return getDirection(navigator.mozL10n.ctx.supportedLocales[0]); + } + }, + _getInternalAPI: function() { + return { + Error: L10nError, + Context: Context, + Locale: Locale, + Entity: Entity, + getPluralRule: getPluralRule, + rePlaceables: rePlaceables, + getTranslatableChildren: getTranslatableChildren, + getL10nAttributes: getL10nAttributes, + loadINI: loadINI, + fireLocalizedEvent: fireLocalizedEvent, + parse: parse, + compile: compile + }; + } + }; + + navigator.mozL10n.ctx.ready(onReady.bind(navigator.mozL10n)); + + if (DEBUG) { + navigator.mozL10n.ctx.addEventListener('error', console.error); + navigator.mozL10n.ctx.addEventListener('warning', console.warn); + } + + function getDirection(lang) { + return (rtlList.indexOf(lang) >= 0) ? 'rtl' : 'ltr'; + } + + var readyStates = { + 'loading': 0, + 'interactive': 1, + 'complete': 2 + }; + + function waitFor(state, callback) { + state = readyStates[state]; + if (readyStates[document.readyState] >= state) { + callback(); + return; + } + + document.addEventListener('readystatechange', function l10n_onrsc() { + if (readyStates[document.readyState] >= state) { + document.removeEventListener('readystatechange', l10n_onrsc); + callback(); + } + }); + } + + if (window.document) { + isPretranslated = (document.documentElement.lang === navigator.language); + + // this is a special case for netError bug; see https://bugzil.la/444165 + if (document.documentElement.dataset.noCompleteBug) { + pretranslate.call(navigator.mozL10n); + return; + } + + + if (isPretranslated) { + waitFor('interactive', function() { + window.setTimeout(initResources.bind(navigator.mozL10n)); + }); + } else { + if (document.readyState === 'complete') { + window.setTimeout(initResources.bind(navigator.mozL10n)); + } else { + waitFor('interactive', pretranslate.bind(navigator.mozL10n)); + } + } + + } + + function pretranslate() { + /* jshint -W068 */ + if (inlineLocalization.call(this)) { + waitFor('interactive', (function() { + window.setTimeout(initResources.bind(this)); + }).bind(this)); + } else { + initResources.call(this); + } + } + + function inlineLocalization() { + var script = document.documentElement + .querySelector('script[type="application/l10n"]' + + '[lang="' + navigator.language + '"]'); + if (!script) { + return false; + } + + var locale = this.ctx.getLocale(navigator.language); + // the inline localization is happenning very early, when the ctx is not + // yet ready and when the resources haven't been downloaded yet; add the + // inlined JSON directly to the current locale + locale.addAST(JSON.parse(script.innerHTML)); + // localize the visible DOM + var l10n = { + ctx: locale, + language: { + code: locale.id, + direction: getDirection(locale.id) + } + }; + translateFragment.call(l10n); + // the visible DOM is now pretranslated + isPretranslated = true; + return true; + } + + function initResources() { + var resLinks = document.head + .querySelectorAll('link[type="application/l10n"]'); + var iniLinks = []; + var i; + + for (i = 0; i < resLinks.length; i++) { + var link = resLinks[i]; + var url = link.getAttribute('href'); + var type = url.substr(url.lastIndexOf('.') + 1); + if (type === 'ini') { + iniLinks.push(url); + } + this.ctx.resLinks.push(url); + } + + var iniLoads = iniLinks.length; + if (iniLoads === 0) { + initLocale.call(this); + return; + } + + function onIniLoaded(err) { + if (err) { + this.ctx._emitter.emit('error', err); + } + if (--iniLoads === 0) { + initLocale.call(this); + } + } + + for (i = 0; i < iniLinks.length; i++) { + loadINI.call(this, iniLinks[i], onIniLoaded.bind(this)); + } + } + + function initLocale() { + this.ctx.requestLocales(navigator.language); + window.addEventListener('languagechange', function l10n_langchange() { + navigator.mozL10n.language.code = navigator.language; + }); + } + + function onReady() { + if (!isPretranslated) { + this.translate(); + } + isPretranslated = false; + + fireLocalizedEvent.call(this); + } + + function fireLocalizedEvent() { + var event = new CustomEvent('localized', { + 'bubbles': false, + 'cancelable': false, + 'detail': { + 'language': this.ctx.supportedLocales[0] + } + }); + window.dispatchEvent(event); + } + + /* jshint -W104 */ + + function loadINI(url, callback) { + var ctx = this.ctx; + io.load(url, function(err, source) { + var pos = ctx.resLinks.indexOf(url); + + if (err) { + // remove the ini link from resLinks + ctx.resLinks.splice(pos, 1); + return callback(err); + } + + if (!source) { + ctx.resLinks.splice(pos, 1); + return callback(new Error('Empty file: ' + url)); + } + + var patterns = parseINI(source, url).resources.map(function(x) { + return x.replace('en-US', '{{locale}}'); + }); + ctx.resLinks.splice.apply(ctx.resLinks, [pos, 1].concat(patterns)); + callback(); + }); + } + + function relativePath(baseUrl, url) { + if (url[0] === '/') { + return url; + } + + var dirs = baseUrl.split('/') + .slice(0, -1) + .concat(url.split('/')) + .filter(function(path) { + return path !== '.'; + }); + + return dirs.join('/'); + } + + var iniPatterns = { + 'section': /^\s*\[(.*)\]\s*$/, + 'import': /^\s*@import\s+url\((.*)\)\s*$/i, + 'entry': /[\r\n]+/ + }; + + function parseINI(source, iniPath) { + var entries = source.split(iniPatterns.entry); + var locales = ['en-US']; + var genericSection = true; + var uris = []; + var match; + + for (var i = 0; i < entries.length; i++) { + var line = entries[i]; + // we only care about en-US resources + if (genericSection && iniPatterns['import'].test(line)) { + match = iniPatterns['import'].exec(line); + var uri = relativePath(iniPath, match[1]); + uris.push(uri); + continue; + } + + // but we need the list of all locales in the ini, too + if (iniPatterns.section.test(line)) { + genericSection = false; + match = iniPatterns.section.exec(line); + locales.push(match[1]); + } + } + return { + locales: locales, + resources: uris + }; + } + + /* jshint -W104 */ + + function translateFragment(element) { + if (!element) { + element = document.documentElement; + document.documentElement.lang = this.language.code; + document.documentElement.dir = this.language.direction; + } + translateElement.call(this, element); + + var nodes = getTranslatableChildren(element); + for (var i = 0; i < nodes.length; i++ ) { + translateElement.call(this, nodes[i]); + } + } + + function getTranslatableChildren(element) { + return element ? element.querySelectorAll('*[data-l10n-id]') : []; + } + + function localizeElement(element, id, args) { + if (!element) { + return; + } + + if (!id) { + element.removeAttribute('data-l10n-id'); + element.removeAttribute('data-l10n-args'); + setTextContent(element, ''); + return; + } + + element.setAttribute('data-l10n-id', id); + if (args && typeof args === 'object') { + element.setAttribute('data-l10n-args', JSON.stringify(args)); + } else { + element.removeAttribute('data-l10n-args'); + } + + if (this.ctx.isReady) { + translateElement.call(this, element); + } + } + + function getL10nAttributes(element) { + if (!element) { + return {}; + } + + var l10nId = element.getAttribute('data-l10n-id'); + var l10nArgs = element.getAttribute('data-l10n-args'); + + var args = l10nArgs ? JSON.parse(l10nArgs) : null; + + return {id: l10nId, args: args}; + } + + + + function translateElement(element) { + var l10n = getL10nAttributes(element); + + if (!l10n.id) { + return; + } + + var entity = this.ctx.getEntity(l10n.id, l10n.args); + + if (!entity) { + return; + } + + if (typeof entity === 'string') { + setTextContent(element, entity); + return true; + } + + if (entity.value) { + setTextContent(element, entity.value); + } + + for (var key in entity.attributes) { + if (entity.attributes.hasOwnProperty(key)) { + var attr = entity.attributes[key]; + var pos = key.indexOf('.'); + if (pos !== -1) { + element[key.substr(0, pos)][key.substr(pos + 1)] = attr; + } else if (key === 'ariaLabel') { + element.setAttribute('aria-label', attr); + } else { + element[key] = attr; + } + } + } + + return true; + } + + function setTextContent(element, text) { + // standard case: no element children + if (!element.firstElementChild) { + element.textContent = text; + return; + } + + // this element has element children: replace the content of the first + // (non-blank) child textNode and clear other child textNodes + var found = false; + var reNotBlank = /\S/; + for (var child = element.firstChild; child; child = child.nextSibling) { + if (child.nodeType === Node.TEXT_NODE && + reNotBlank.test(child.nodeValue)) { + if (found) { + child.nodeValue = ''; + } else { + child.nodeValue = text; + found = true; + } + } + } + // if no (non-empty) textNode is found, insert a textNode before the + // element's first child. + if (!found) { + element.insertBefore(document.createTextNode(text), element.firstChild); + } + } + +})(this); + diff --git a/src/data/en-US.properties b/build/locales/en-US.properties similarity index 74% rename from src/data/en-US.properties rename to build/locales/en-US.properties index fbf3788..26f9a84 100644 --- a/src/data/en-US.properties +++ b/build/locales/en-US.properties @@ -1,3 +1,3 @@ -app_title = Privileged empty app +appname = Hawk app_description.innerHTML = This app is empty. Fill it with your own stuff! message = Hello world diff --git a/build/locales/locales.ini b/build/locales/locales.ini new file mode 100644 index 0000000..173dfb0 --- /dev/null +++ b/build/locales/locales.ini @@ -0,0 +1 @@ +@import url(en-US.properties) diff --git a/build/main.js b/build/main.js index 5e2dba8..4360500 100644 --- a/build/main.js +++ b/build/main.js @@ -1,4 +1,4 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1; + var shouldUpdateDispatchProps = finalMapDispatchToProps.length > 1; + + // Helps track hot reloading. + var version = nextVersion++; + + function computeStateProps(store, props) { + var state = store.getState(); + var stateProps = shouldUpdateStateProps ? finalMapStateToProps(state, props) : finalMapStateToProps(state); + + _invariant2['default'](_utilsIsPlainObject2['default'](stateProps), '`mapStateToProps` must return an object. Instead received %s.', stateProps); + return stateProps; + } + + function computeDispatchProps(store, props) { + var dispatch = store.dispatch; + + var dispatchProps = shouldUpdateDispatchProps ? finalMapDispatchToProps(dispatch, props) : finalMapDispatchToProps(dispatch); + + _invariant2['default'](_utilsIsPlainObject2['default'](dispatchProps), '`mapDispatchToProps` must return an object. Instead received %s.', dispatchProps); + return dispatchProps; + } + + function _computeNextState(stateProps, dispatchProps, parentProps) { + var mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps); + _invariant2['default'](_utilsIsPlainObject2['default'](mergedProps), '`mergeProps` must return an object. Instead received %s.', mergedProps); + return mergedProps; + } + + return function wrapWithConnect(WrappedComponent) { + var Connect = (function (_Component) { + _inherits(Connect, _Component); + + Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { + return !_utilsShallowEqual2['default'](this.state.props, nextState.props); + }; + + _createClass(Connect, null, [{ + key: 'displayName', + value: 'Connect(' + getDisplayName(WrappedComponent) + ')', + enumerable: true + }, { + key: 'WrappedComponent', + value: WrappedComponent, + enumerable: true + }, { + key: 'contextTypes', + value: { + store: storeShape + }, + enumerable: true + }, { + key: 'propTypes', + value: { + store: storeShape + }, + enumerable: true + }]); + + function Connect(props, context) { + _classCallCheck(this, Connect); + + _Component.call(this, props, context); + this.version = version; + this.store = props.store || context.store; + + _invariant2['default'](this.store, 'Could not find "store" in either the context or ' + ('props of "' + this.constructor.displayName + '". ') + 'Either wrap the root component in a , ' + ('or explicitly pass "store" as a prop to "' + this.constructor.displayName + '".')); + + this.stateProps = computeStateProps(this.store, props); + this.dispatchProps = computeDispatchProps(this.store, props); + this.state = { + props: this.computeNextState() + }; + } + + Connect.prototype.computeNextState = function computeNextState() { + var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0]; + + return _computeNextState(this.stateProps, this.dispatchProps, props); + }; + + Connect.prototype.updateStateProps = function updateStateProps() { + var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0]; + + var nextStateProps = computeStateProps(this.store, props); + if (_utilsShallowEqual2['default'](nextStateProps, this.stateProps)) { + return false; + } + + this.stateProps = nextStateProps; + return true; + }; + + Connect.prototype.updateDispatchProps = function updateDispatchProps() { + var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0]; + + var nextDispatchProps = computeDispatchProps(this.store, props); + if (_utilsShallowEqual2['default'](nextDispatchProps, this.dispatchProps)) { + return false; + } + + this.dispatchProps = nextDispatchProps; + return true; + }; + + Connect.prototype.updateState = function updateState() { + var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0]; + + var nextState = this.computeNextState(props); + if (!_utilsShallowEqual2['default'](nextState, this.state.props)) { + this.setState({ + props: nextState + }); + } + }; + + Connect.prototype.isSubscribed = function isSubscribed() { + return typeof this.unsubscribe === 'function'; + }; + + Connect.prototype.trySubscribe = function trySubscribe() { + if (shouldSubscribe && !this.unsubscribe) { + this.unsubscribe = this.store.subscribe(this.handleChange.bind(this)); + this.handleChange(); + } + }; + + Connect.prototype.tryUnsubscribe = function tryUnsubscribe() { + if (this.unsubscribe) { + this.unsubscribe(); + this.unsubscribe = null; + } + }; + + Connect.prototype.componentDidMount = function componentDidMount() { + this.trySubscribe(); + }; + + Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { + if (!_utilsShallowEqual2['default'](nextProps, this.props)) { + if (shouldUpdateStateProps) { + this.updateStateProps(nextProps); + } + + if (shouldUpdateDispatchProps) { + this.updateDispatchProps(nextProps); + } + + this.updateState(nextProps); + } + }; + + Connect.prototype.componentWillUnmount = function componentWillUnmount() { + this.tryUnsubscribe(); + }; + + Connect.prototype.handleChange = function handleChange() { + if (this.updateStateProps()) { + this.updateState(); + } + }; + + Connect.prototype.getWrappedInstance = function getWrappedInstance() { + return this.refs.wrappedInstance; + }; + + Connect.prototype.render = function render() { + return React.createElement(WrappedComponent, _extends({ ref: 'wrappedInstance' + }, this.state.props)); + }; + + return Connect; + })(Component); + + if ( + // Node-like CommonJS environments (Browserify, Webpack) + typeof process !== 'undefined' && typeof process.env !== 'undefined' && process.env.NODE_ENV !== 'production' || + // React Native + typeof __DEV__ !== 'undefined' && __DEV__ //eslint-disable-line no-undef + ) { + Connect.prototype.componentWillUpdate = function componentWillUpdate() { + if (this.version === version) { + return; + } + + // We are hot reloading! + this.version = version; + + // Update the state and bindings. + this.trySubscribe(); + this.updateStateProps(); + this.updateDispatchProps(); + this.updateState(); + }; + } + + return Connect; + }; + }; +} + +module.exports = exports['default']; +}).call(this,require('_process')) +},{"../utils/createStoreShape":6,"../utils/isPlainObject":7,"../utils/shallowEqual":8,"../utils/wrapActionCreators":9,"_process":1,"invariant":10}],4:[function(require,module,exports){ +'use strict'; + +exports.__esModule = 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; }; })(); + +exports['default'] = createProvider; + +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 _utilsCreateStoreShape = require('../utils/createStoreShape'); + +var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape); + +function isUsingOwnerContext(React) { + var version = React.version; + + if (typeof version !== 'string') { + return true; + } + + var sections = version.split('.'); + var major = parseInt(sections[0], 10); + var minor = parseInt(sections[1], 10); + + return major === 0 && minor === 13; +} + +function createProvider(React) { + var Component = React.Component; + var PropTypes = React.PropTypes; + var Children = React.Children; + + var storeShape = _utilsCreateStoreShape2['default'](PropTypes); + var requireFunctionChild = isUsingOwnerContext(React); + + var didWarn = false; + function warnAboutFunction() { + if (didWarn || requireFunctionChild) { + return; + } + + didWarn = true; + console.error( // eslint-disable-line no-console + 'With React 0.14 and later versions, you no longer need to ' + 'wrap child into a function.'); + } + function warnAboutElement() { + if (didWarn || !requireFunctionChild) { + return; + } + + didWarn = true; + console.error( // eslint-disable-line no-console + 'With React 0.13, you need to ' + 'wrap child into a function. ' + 'This restriction will be removed with React 0.14.'); + } + + return (function (_Component) { + _inherits(Provider, _Component); + + Provider.prototype.getChildContext = function getChildContext() { + return { store: this.state.store }; + }; + + _createClass(Provider, null, [{ + key: 'childContextTypes', + value: { + store: storeShape.isRequired + }, + enumerable: true + }, { + key: 'propTypes', + value: { + store: storeShape.isRequired, + children: (requireFunctionChild ? PropTypes.func : PropTypes.element).isRequired + }, + enumerable: true + }]); + + function Provider(props, context) { + _classCallCheck(this, Provider); + + _Component.call(this, props, context); + this.state = { store: props.store }; + } + + Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { + var store = this.state.store; + var nextStore = nextProps.store; + + if (store !== nextStore) { + var nextReducer = nextStore.getReducer(); + store.replaceReducer(nextReducer); + } + }; + + Provider.prototype.render = function render() { + var children = this.props.children; + + if (typeof children === 'function') { + warnAboutFunction(); + children = children(); + } else { + warnAboutElement(); + } + + return Children.only(children); + }; + + return Provider; + })(Component); +} + +module.exports = exports['default']; +},{"../utils/createStoreShape":6}],5:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _componentsCreateAll = require('./components/createAll'); + +var _componentsCreateAll2 = _interopRequireDefault(_componentsCreateAll); + +var _createAll = _componentsCreateAll2['default'](_react2['default']); + +var Provider = _createAll.Provider; +var connect = _createAll.connect; +exports.Provider = Provider; +exports.connect = connect; +},{"./components/createAll":2,"react":165}],6:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; +exports["default"] = createStoreShape; + +function createStoreShape(PropTypes) { + return PropTypes.shape({ + subscribe: PropTypes.func.isRequired, + dispatch: PropTypes.func.isRequired, + getState: PropTypes.func.isRequired + }); +} + +module.exports = exports["default"]; +},{}],7:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports['default'] = isPlainObject; +var fnToString = function fnToString(fn) { + return Function.prototype.toString.call(fn); +}; + +/** + * @param {any} obj The object to inspect. + * @returns {boolean} True if the argument appears to be a plain object. + */ + +function isPlainObject(obj) { + if (!obj || typeof obj !== 'object') { + return false; + } + + var proto = typeof obj.constructor === 'function' ? Object.getPrototypeOf(obj) : Object.prototype; + + if (proto === null) { + return true; + } + + var constructor = proto.constructor; + + return typeof constructor === 'function' && constructor instanceof constructor && fnToString(constructor) === fnToString(Object); +} + +module.exports = exports['default']; +},{}],8:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; +exports["default"] = shallowEqual; + +function shallowEqual(objA, objB) { + if (objA === objB) { + return true; + } + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + var hasOwn = Object.prototype.hasOwnProperty; + for (var i = 0; i < keysA.length; i++) { + if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { + return false; + } + } + + return true; +} + +module.exports = exports["default"]; +},{}],9:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports['default'] = wrapActionCreators; + +var _redux = require('redux'); + +function wrapActionCreators(actionCreators) { + return function (dispatch) { + return _redux.bindActionCreators(actionCreators, dispatch); + }; +} + +module.exports = exports['default']; +},{"redux":167}],10:[function(require,module,exports){ +(function (process){ +/** + * Copyright 2013-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. + * + * @providesModule invariant + */ + +'use strict'; + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var invariant = function(condition, format, a, b, c, d, e, f) { + if (process.env.NODE_ENV !== 'production') { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + } + + if (!condition) { + var error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.' + ); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error( + 'Invariant Violation: ' + + format.replace(/%s/g, function() { return args[argIndex++]; }) + ); + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +}; + +module.exports = invariant; + +}).call(this,require('_process')) +},{"_process":1}],11:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -117,7 +697,7 @@ var AutoFocusMixin = { module.exports = AutoFocusMixin; -},{"./focusNode":120}],3:[function(require,module,exports){ +},{"./focusNode":129}],12:[function(require,module,exports){ /** * Copyright 2013-2015 Facebook, Inc. * All rights reserved. @@ -612,7 +1192,7 @@ var BeforeInputEventPlugin = { module.exports = BeforeInputEventPlugin; -},{"./EventConstants":15,"./EventPropagators":20,"./ExecutionEnvironment":21,"./FallbackCompositionState":22,"./SyntheticCompositionEvent":94,"./SyntheticInputEvent":98,"./keyOf":142}],4:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPropagators":29,"./ExecutionEnvironment":30,"./FallbackCompositionState":31,"./SyntheticCompositionEvent":103,"./SyntheticInputEvent":107,"./keyOf":151}],13:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -737,7 +1317,7 @@ var CSSProperty = { module.exports = CSSProperty; -},{}],5:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -919,7 +1499,7 @@ var CSSPropertyOperations = { module.exports = CSSPropertyOperations; }).call(this,require('_process')) -},{"./CSSProperty":4,"./ExecutionEnvironment":21,"./camelizeStyleName":109,"./dangerousStyleValue":114,"./hyphenateStyleName":134,"./memoizeStringOnly":144,"./warning":155,"_process":1}],6:[function(require,module,exports){ +},{"./CSSProperty":13,"./ExecutionEnvironment":30,"./camelizeStyleName":118,"./dangerousStyleValue":123,"./hyphenateStyleName":143,"./memoizeStringOnly":153,"./warning":164,"_process":1}],15:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -1019,7 +1599,7 @@ PooledClass.addPoolingTo(CallbackQueue); module.exports = CallbackQueue; }).call(this,require('_process')) -},{"./Object.assign":27,"./PooledClass":28,"./invariant":136,"_process":1}],7:[function(require,module,exports){ +},{"./Object.assign":36,"./PooledClass":37,"./invariant":145,"_process":1}],16:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -1401,7 +1981,7 @@ var ChangeEventPlugin = { module.exports = ChangeEventPlugin; -},{"./EventConstants":15,"./EventPluginHub":17,"./EventPropagators":20,"./ExecutionEnvironment":21,"./ReactUpdates":88,"./SyntheticEvent":96,"./isEventSupported":137,"./isTextInputElement":139,"./keyOf":142}],8:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPluginHub":26,"./EventPropagators":29,"./ExecutionEnvironment":30,"./ReactUpdates":97,"./SyntheticEvent":105,"./isEventSupported":146,"./isTextInputElement":148,"./keyOf":151}],17:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -1426,7 +2006,7 @@ var ClientReactRootIndex = { module.exports = ClientReactRootIndex; -},{}],9:[function(require,module,exports){ +},{}],18:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -1564,7 +2144,7 @@ var DOMChildrenOperations = { module.exports = DOMChildrenOperations; }).call(this,require('_process')) -},{"./Danger":12,"./ReactMultiChildUpdateTypes":73,"./invariant":136,"./setTextContent":150,"_process":1}],10:[function(require,module,exports){ +},{"./Danger":21,"./ReactMultiChildUpdateTypes":82,"./invariant":145,"./setTextContent":159,"_process":1}],19:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -1863,7 +2443,7 @@ var DOMProperty = { module.exports = DOMProperty; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],11:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],20:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -2055,7 +2635,7 @@ var DOMPropertyOperations = { module.exports = DOMPropertyOperations; }).call(this,require('_process')) -},{"./DOMProperty":10,"./quoteAttributeValueForBrowser":148,"./warning":155,"_process":1}],12:[function(require,module,exports){ +},{"./DOMProperty":19,"./quoteAttributeValueForBrowser":157,"./warning":164,"_process":1}],21:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -2242,7 +2822,7 @@ var Danger = { module.exports = Danger; }).call(this,require('_process')) -},{"./ExecutionEnvironment":21,"./createNodesFromMarkup":113,"./emptyFunction":115,"./getMarkupWrap":128,"./invariant":136,"_process":1}],13:[function(require,module,exports){ +},{"./ExecutionEnvironment":30,"./createNodesFromMarkup":122,"./emptyFunction":124,"./getMarkupWrap":137,"./invariant":145,"_process":1}],22:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -2281,7 +2861,7 @@ var DefaultEventPluginOrder = [ module.exports = DefaultEventPluginOrder; -},{"./keyOf":142}],14:[function(require,module,exports){ +},{"./keyOf":151}],23:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -2421,7 +3001,7 @@ var EnterLeaveEventPlugin = { module.exports = EnterLeaveEventPlugin; -},{"./EventConstants":15,"./EventPropagators":20,"./ReactMount":71,"./SyntheticMouseEvent":100,"./keyOf":142}],15:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPropagators":29,"./ReactMount":80,"./SyntheticMouseEvent":109,"./keyOf":151}],24:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -2493,7 +3073,7 @@ var EventConstants = { module.exports = EventConstants; -},{"./keyMirror":141}],16:[function(require,module,exports){ +},{"./keyMirror":150}],25:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -2583,7 +3163,7 @@ var EventListener = { module.exports = EventListener; }).call(this,require('_process')) -},{"./emptyFunction":115,"_process":1}],17:[function(require,module,exports){ +},{"./emptyFunction":124,"_process":1}],26:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -2861,7 +3441,7 @@ var EventPluginHub = { module.exports = EventPluginHub; }).call(this,require('_process')) -},{"./EventPluginRegistry":18,"./EventPluginUtils":19,"./accumulateInto":106,"./forEachAccumulated":121,"./invariant":136,"_process":1}],18:[function(require,module,exports){ +},{"./EventPluginRegistry":27,"./EventPluginUtils":28,"./accumulateInto":115,"./forEachAccumulated":130,"./invariant":145,"_process":1}],27:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -3141,7 +3721,7 @@ var EventPluginRegistry = { module.exports = EventPluginRegistry; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],19:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],28:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -3362,7 +3942,7 @@ var EventPluginUtils = { module.exports = EventPluginUtils; }).call(this,require('_process')) -},{"./EventConstants":15,"./invariant":136,"_process":1}],20:[function(require,module,exports){ +},{"./EventConstants":24,"./invariant":145,"_process":1}],29:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -3504,7 +4084,7 @@ var EventPropagators = { module.exports = EventPropagators; }).call(this,require('_process')) -},{"./EventConstants":15,"./EventPluginHub":17,"./accumulateInto":106,"./forEachAccumulated":121,"_process":1}],21:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPluginHub":26,"./accumulateInto":115,"./forEachAccumulated":130,"_process":1}],30:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -3548,7 +4128,7 @@ var ExecutionEnvironment = { module.exports = ExecutionEnvironment; -},{}],22:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -3639,7 +4219,7 @@ PooledClass.addPoolingTo(FallbackCompositionState); module.exports = FallbackCompositionState; -},{"./Object.assign":27,"./PooledClass":28,"./getTextContentAccessor":131}],23:[function(require,module,exports){ +},{"./Object.assign":36,"./PooledClass":37,"./getTextContentAccessor":140}],32:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -3850,7 +4430,7 @@ var HTMLDOMPropertyConfig = { module.exports = HTMLDOMPropertyConfig; -},{"./DOMProperty":10,"./ExecutionEnvironment":21}],24:[function(require,module,exports){ +},{"./DOMProperty":19,"./ExecutionEnvironment":30}],33:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4006,7 +4586,7 @@ var LinkedValueUtils = { module.exports = LinkedValueUtils; }).call(this,require('_process')) -},{"./ReactPropTypes":79,"./invariant":136,"_process":1}],25:[function(require,module,exports){ +},{"./ReactPropTypes":88,"./invariant":145,"_process":1}],34:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -4063,7 +4643,7 @@ var LocalEventTrapMixin = { module.exports = LocalEventTrapMixin; }).call(this,require('_process')) -},{"./ReactBrowserEventEmitter":31,"./accumulateInto":106,"./forEachAccumulated":121,"./invariant":136,"_process":1}],26:[function(require,module,exports){ +},{"./ReactBrowserEventEmitter":40,"./accumulateInto":115,"./forEachAccumulated":130,"./invariant":145,"_process":1}],35:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -4121,7 +4701,7 @@ var MobileSafariClickEventPlugin = { module.exports = MobileSafariClickEventPlugin; -},{"./EventConstants":15,"./emptyFunction":115}],27:[function(require,module,exports){ +},{"./EventConstants":24,"./emptyFunction":124}],36:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -4170,7 +4750,7 @@ function assign(target, sources) { module.exports = assign; -},{}],28:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4286,7 +4866,7 @@ var PooledClass = { module.exports = PooledClass; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],29:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],38:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -4438,7 +5018,7 @@ React.version = '0.13.3'; module.exports = React; }).call(this,require('_process')) -},{"./EventPluginUtils":19,"./ExecutionEnvironment":21,"./Object.assign":27,"./ReactChildren":33,"./ReactClass":34,"./ReactComponent":35,"./ReactContext":39,"./ReactCurrentOwner":40,"./ReactDOM":41,"./ReactDOMTextComponent":52,"./ReactDefaultInjection":55,"./ReactElement":58,"./ReactElementValidator":59,"./ReactInstanceHandles":67,"./ReactMount":71,"./ReactPerf":76,"./ReactPropTypes":79,"./ReactReconciler":82,"./ReactServerRendering":85,"./findDOMNode":118,"./onlyChild":145,"_process":1}],30:[function(require,module,exports){ +},{"./EventPluginUtils":28,"./ExecutionEnvironment":30,"./Object.assign":36,"./ReactChildren":42,"./ReactClass":43,"./ReactComponent":44,"./ReactContext":48,"./ReactCurrentOwner":49,"./ReactDOM":50,"./ReactDOMTextComponent":61,"./ReactDefaultInjection":64,"./ReactElement":67,"./ReactElementValidator":68,"./ReactInstanceHandles":76,"./ReactMount":80,"./ReactPerf":85,"./ReactPropTypes":88,"./ReactReconciler":91,"./ReactServerRendering":94,"./findDOMNode":127,"./onlyChild":154,"_process":1}],39:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -4469,7 +5049,7 @@ var ReactBrowserComponentMixin = { module.exports = ReactBrowserComponentMixin; -},{"./findDOMNode":118}],31:[function(require,module,exports){ +},{"./findDOMNode":127}],40:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -4822,7 +5402,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, { module.exports = ReactBrowserEventEmitter; -},{"./EventConstants":15,"./EventPluginHub":17,"./EventPluginRegistry":18,"./Object.assign":27,"./ReactEventEmitterMixin":62,"./ViewportMetrics":105,"./isEventSupported":137}],32:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPluginHub":26,"./EventPluginRegistry":27,"./Object.assign":36,"./ReactEventEmitterMixin":71,"./ViewportMetrics":114,"./isEventSupported":146}],41:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -4949,7 +5529,7 @@ var ReactChildReconciler = { module.exports = ReactChildReconciler; -},{"./ReactReconciler":82,"./flattenChildren":119,"./instantiateReactComponent":135,"./shouldUpdateReactComponent":152}],33:[function(require,module,exports){ +},{"./ReactReconciler":91,"./flattenChildren":128,"./instantiateReactComponent":144,"./shouldUpdateReactComponent":161}],42:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -5102,7 +5682,7 @@ var ReactChildren = { module.exports = ReactChildren; }).call(this,require('_process')) -},{"./PooledClass":28,"./ReactFragment":64,"./traverseAllChildren":154,"./warning":155,"_process":1}],34:[function(require,module,exports){ +},{"./PooledClass":37,"./ReactFragment":73,"./traverseAllChildren":163,"./warning":164,"_process":1}],43:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -6048,7 +6628,7 @@ var ReactClass = { module.exports = ReactClass; }).call(this,require('_process')) -},{"./Object.assign":27,"./ReactComponent":35,"./ReactCurrentOwner":40,"./ReactElement":58,"./ReactErrorUtils":61,"./ReactInstanceMap":68,"./ReactLifeCycle":69,"./ReactPropTypeLocationNames":77,"./ReactPropTypeLocations":78,"./ReactUpdateQueue":87,"./invariant":136,"./keyMirror":141,"./keyOf":142,"./warning":155,"_process":1}],35:[function(require,module,exports){ +},{"./Object.assign":36,"./ReactComponent":44,"./ReactCurrentOwner":49,"./ReactElement":67,"./ReactErrorUtils":70,"./ReactInstanceMap":77,"./ReactLifeCycle":78,"./ReactPropTypeLocationNames":86,"./ReactPropTypeLocations":87,"./ReactUpdateQueue":96,"./invariant":145,"./keyMirror":150,"./keyOf":151,"./warning":164,"_process":1}],44:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -6202,7 +6782,7 @@ if ("production" !== process.env.NODE_ENV) { module.exports = ReactComponent; }).call(this,require('_process')) -},{"./ReactUpdateQueue":87,"./invariant":136,"./warning":155,"_process":1}],36:[function(require,module,exports){ +},{"./ReactUpdateQueue":96,"./invariant":145,"./warning":164,"_process":1}],45:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -6249,7 +6829,7 @@ var ReactComponentBrowserEnvironment = { module.exports = ReactComponentBrowserEnvironment; -},{"./ReactDOMIDOperations":45,"./ReactMount":71}],37:[function(require,module,exports){ +},{"./ReactDOMIDOperations":54,"./ReactMount":80}],46:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -6310,7 +6890,7 @@ var ReactComponentEnvironment = { module.exports = ReactComponentEnvironment; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],38:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],47:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -7223,7 +7803,7 @@ var ReactCompositeComponent = { module.exports = ReactCompositeComponent; }).call(this,require('_process')) -},{"./Object.assign":27,"./ReactComponentEnvironment":37,"./ReactContext":39,"./ReactCurrentOwner":40,"./ReactElement":58,"./ReactElementValidator":59,"./ReactInstanceMap":68,"./ReactLifeCycle":69,"./ReactNativeComponent":74,"./ReactPerf":76,"./ReactPropTypeLocationNames":77,"./ReactPropTypeLocations":78,"./ReactReconciler":82,"./ReactUpdates":88,"./emptyObject":116,"./invariant":136,"./shouldUpdateReactComponent":152,"./warning":155,"_process":1}],39:[function(require,module,exports){ +},{"./Object.assign":36,"./ReactComponentEnvironment":46,"./ReactContext":48,"./ReactCurrentOwner":49,"./ReactElement":67,"./ReactElementValidator":68,"./ReactInstanceMap":77,"./ReactLifeCycle":78,"./ReactNativeComponent":83,"./ReactPerf":85,"./ReactPropTypeLocationNames":86,"./ReactPropTypeLocations":87,"./ReactReconciler":91,"./ReactUpdates":97,"./emptyObject":125,"./invariant":145,"./shouldUpdateReactComponent":161,"./warning":164,"_process":1}],48:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -7301,7 +7881,7 @@ var ReactContext = { module.exports = ReactContext; }).call(this,require('_process')) -},{"./Object.assign":27,"./emptyObject":116,"./warning":155,"_process":1}],40:[function(require,module,exports){ +},{"./Object.assign":36,"./emptyObject":125,"./warning":164,"_process":1}],49:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -7335,7 +7915,7 @@ var ReactCurrentOwner = { module.exports = ReactCurrentOwner; -},{}],41:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -7514,7 +8094,7 @@ var ReactDOM = mapObject({ module.exports = ReactDOM; }).call(this,require('_process')) -},{"./ReactElement":58,"./ReactElementValidator":59,"./mapObject":143,"_process":1}],42:[function(require,module,exports){ +},{"./ReactElement":67,"./ReactElementValidator":68,"./mapObject":152,"_process":1}],51:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -7578,7 +8158,7 @@ var ReactDOMButton = ReactClass.createClass({ module.exports = ReactDOMButton; -},{"./AutoFocusMixin":2,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58,"./keyMirror":141}],43:[function(require,module,exports){ +},{"./AutoFocusMixin":11,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67,"./keyMirror":150}],52:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -8088,7 +8668,7 @@ ReactDOMComponent.injection = { module.exports = ReactDOMComponent; }).call(this,require('_process')) -},{"./CSSPropertyOperations":5,"./DOMProperty":10,"./DOMPropertyOperations":11,"./Object.assign":27,"./ReactBrowserEventEmitter":31,"./ReactComponentBrowserEnvironment":36,"./ReactMount":71,"./ReactMultiChild":72,"./ReactPerf":76,"./escapeTextContentForBrowser":117,"./invariant":136,"./isEventSupported":137,"./keyOf":142,"./warning":155,"_process":1}],44:[function(require,module,exports){ +},{"./CSSPropertyOperations":14,"./DOMProperty":19,"./DOMPropertyOperations":20,"./Object.assign":36,"./ReactBrowserEventEmitter":40,"./ReactComponentBrowserEnvironment":45,"./ReactMount":80,"./ReactMultiChild":81,"./ReactPerf":85,"./escapeTextContentForBrowser":126,"./invariant":145,"./isEventSupported":146,"./keyOf":151,"./warning":164,"_process":1}],53:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -8137,7 +8717,7 @@ var ReactDOMForm = ReactClass.createClass({ module.exports = ReactDOMForm; -},{"./EventConstants":15,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58}],45:[function(require,module,exports){ +},{"./EventConstants":24,"./LocalEventTrapMixin":34,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67}],54:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -8305,7 +8885,7 @@ ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', { module.exports = ReactDOMIDOperations; }).call(this,require('_process')) -},{"./CSSPropertyOperations":5,"./DOMChildrenOperations":9,"./DOMPropertyOperations":11,"./ReactMount":71,"./ReactPerf":76,"./invariant":136,"./setInnerHTML":149,"_process":1}],46:[function(require,module,exports){ +},{"./CSSPropertyOperations":14,"./DOMChildrenOperations":18,"./DOMPropertyOperations":20,"./ReactMount":80,"./ReactPerf":85,"./invariant":145,"./setInnerHTML":158,"_process":1}],55:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -8350,7 +8930,7 @@ var ReactDOMIframe = ReactClass.createClass({ module.exports = ReactDOMIframe; -},{"./EventConstants":15,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58}],47:[function(require,module,exports){ +},{"./EventConstants":24,"./LocalEventTrapMixin":34,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67}],56:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -8396,7 +8976,7 @@ var ReactDOMImg = ReactClass.createClass({ module.exports = ReactDOMImg; -},{"./EventConstants":15,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58}],48:[function(require,module,exports){ +},{"./EventConstants":24,"./LocalEventTrapMixin":34,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67}],57:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -8573,7 +9153,7 @@ var ReactDOMInput = ReactClass.createClass({ module.exports = ReactDOMInput; }).call(this,require('_process')) -},{"./AutoFocusMixin":2,"./DOMPropertyOperations":11,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58,"./ReactMount":71,"./ReactUpdates":88,"./invariant":136,"_process":1}],49:[function(require,module,exports){ +},{"./AutoFocusMixin":11,"./DOMPropertyOperations":20,"./LinkedValueUtils":33,"./Object.assign":36,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67,"./ReactMount":80,"./ReactUpdates":97,"./invariant":145,"_process":1}],58:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -8625,7 +9205,7 @@ var ReactDOMOption = ReactClass.createClass({ module.exports = ReactDOMOption; }).call(this,require('_process')) -},{"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58,"./warning":155,"_process":1}],50:[function(require,module,exports){ +},{"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67,"./warning":164,"_process":1}],59:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -8803,7 +9383,7 @@ var ReactDOMSelect = ReactClass.createClass({ module.exports = ReactDOMSelect; -},{"./AutoFocusMixin":2,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58,"./ReactUpdates":88}],51:[function(require,module,exports){ +},{"./AutoFocusMixin":11,"./LinkedValueUtils":33,"./Object.assign":36,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67,"./ReactUpdates":97}],60:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9016,7 +9596,7 @@ var ReactDOMSelection = { module.exports = ReactDOMSelection; -},{"./ExecutionEnvironment":21,"./getNodeForCharacterOffset":129,"./getTextContentAccessor":131}],52:[function(require,module,exports){ +},{"./ExecutionEnvironment":30,"./getNodeForCharacterOffset":138,"./getTextContentAccessor":140}],61:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9133,7 +9713,7 @@ assign(ReactDOMTextComponent.prototype, { module.exports = ReactDOMTextComponent; -},{"./DOMPropertyOperations":11,"./Object.assign":27,"./ReactComponentBrowserEnvironment":36,"./ReactDOMComponent":43,"./escapeTextContentForBrowser":117}],53:[function(require,module,exports){ +},{"./DOMPropertyOperations":20,"./Object.assign":36,"./ReactComponentBrowserEnvironment":45,"./ReactDOMComponent":52,"./escapeTextContentForBrowser":126}],62:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -9273,7 +9853,7 @@ var ReactDOMTextarea = ReactClass.createClass({ module.exports = ReactDOMTextarea; }).call(this,require('_process')) -},{"./AutoFocusMixin":2,"./DOMPropertyOperations":11,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactElement":58,"./ReactUpdates":88,"./invariant":136,"./warning":155,"_process":1}],54:[function(require,module,exports){ +},{"./AutoFocusMixin":11,"./DOMPropertyOperations":20,"./LinkedValueUtils":33,"./Object.assign":36,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactElement":67,"./ReactUpdates":97,"./invariant":145,"./warning":164,"_process":1}],63:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9346,7 +9926,7 @@ var ReactDefaultBatchingStrategy = { module.exports = ReactDefaultBatchingStrategy; -},{"./Object.assign":27,"./ReactUpdates":88,"./Transaction":104,"./emptyFunction":115}],55:[function(require,module,exports){ +},{"./Object.assign":36,"./ReactUpdates":97,"./Transaction":113,"./emptyFunction":124}],64:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -9505,7 +10085,7 @@ module.exports = { }; }).call(this,require('_process')) -},{"./BeforeInputEventPlugin":3,"./ChangeEventPlugin":7,"./ClientReactRootIndex":8,"./DefaultEventPluginOrder":13,"./EnterLeaveEventPlugin":14,"./ExecutionEnvironment":21,"./HTMLDOMPropertyConfig":23,"./MobileSafariClickEventPlugin":26,"./ReactBrowserComponentMixin":30,"./ReactClass":34,"./ReactComponentBrowserEnvironment":36,"./ReactDOMButton":42,"./ReactDOMComponent":43,"./ReactDOMForm":44,"./ReactDOMIDOperations":45,"./ReactDOMIframe":46,"./ReactDOMImg":47,"./ReactDOMInput":48,"./ReactDOMOption":49,"./ReactDOMSelect":50,"./ReactDOMTextComponent":52,"./ReactDOMTextarea":53,"./ReactDefaultBatchingStrategy":54,"./ReactDefaultPerf":56,"./ReactElement":58,"./ReactEventListener":63,"./ReactInjection":65,"./ReactInstanceHandles":67,"./ReactMount":71,"./ReactReconcileTransaction":81,"./SVGDOMPropertyConfig":89,"./SelectEventPlugin":90,"./ServerReactRootIndex":91,"./SimpleEventPlugin":92,"./createFullPageComponent":112,"_process":1}],56:[function(require,module,exports){ +},{"./BeforeInputEventPlugin":12,"./ChangeEventPlugin":16,"./ClientReactRootIndex":17,"./DefaultEventPluginOrder":22,"./EnterLeaveEventPlugin":23,"./ExecutionEnvironment":30,"./HTMLDOMPropertyConfig":32,"./MobileSafariClickEventPlugin":35,"./ReactBrowserComponentMixin":39,"./ReactClass":43,"./ReactComponentBrowserEnvironment":45,"./ReactDOMButton":51,"./ReactDOMComponent":52,"./ReactDOMForm":53,"./ReactDOMIDOperations":54,"./ReactDOMIframe":55,"./ReactDOMImg":56,"./ReactDOMInput":57,"./ReactDOMOption":58,"./ReactDOMSelect":59,"./ReactDOMTextComponent":61,"./ReactDOMTextarea":62,"./ReactDefaultBatchingStrategy":63,"./ReactDefaultPerf":65,"./ReactElement":67,"./ReactEventListener":72,"./ReactInjection":74,"./ReactInstanceHandles":76,"./ReactMount":80,"./ReactReconcileTransaction":90,"./SVGDOMPropertyConfig":98,"./SelectEventPlugin":99,"./ServerReactRootIndex":100,"./SimpleEventPlugin":101,"./createFullPageComponent":121,"_process":1}],65:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9771,7 +10351,7 @@ var ReactDefaultPerf = { module.exports = ReactDefaultPerf; -},{"./DOMProperty":10,"./ReactDefaultPerfAnalysis":57,"./ReactMount":71,"./ReactPerf":76,"./performanceNow":147}],57:[function(require,module,exports){ +},{"./DOMProperty":19,"./ReactDefaultPerfAnalysis":66,"./ReactMount":80,"./ReactPerf":85,"./performanceNow":156}],66:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -9977,7 +10557,7 @@ var ReactDefaultPerfAnalysis = { module.exports = ReactDefaultPerfAnalysis; -},{"./Object.assign":27}],58:[function(require,module,exports){ +},{"./Object.assign":36}],67:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -10285,7 +10865,7 @@ ReactElement.isValidElement = function(object) { module.exports = ReactElement; }).call(this,require('_process')) -},{"./Object.assign":27,"./ReactContext":39,"./ReactCurrentOwner":40,"./warning":155,"_process":1}],59:[function(require,module,exports){ +},{"./Object.assign":36,"./ReactContext":48,"./ReactCurrentOwner":49,"./warning":164,"_process":1}],68:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -10750,7 +11330,7 @@ var ReactElementValidator = { module.exports = ReactElementValidator; }).call(this,require('_process')) -},{"./ReactCurrentOwner":40,"./ReactElement":58,"./ReactFragment":64,"./ReactNativeComponent":74,"./ReactPropTypeLocationNames":77,"./ReactPropTypeLocations":78,"./getIteratorFn":127,"./invariant":136,"./warning":155,"_process":1}],60:[function(require,module,exports){ +},{"./ReactCurrentOwner":49,"./ReactElement":67,"./ReactFragment":73,"./ReactNativeComponent":83,"./ReactPropTypeLocationNames":86,"./ReactPropTypeLocations":87,"./getIteratorFn":136,"./invariant":145,"./warning":164,"_process":1}],69:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -10845,7 +11425,7 @@ var ReactEmptyComponent = { module.exports = ReactEmptyComponent; }).call(this,require('_process')) -},{"./ReactElement":58,"./ReactInstanceMap":68,"./invariant":136,"_process":1}],61:[function(require,module,exports){ +},{"./ReactElement":67,"./ReactInstanceMap":77,"./invariant":145,"_process":1}],70:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10877,7 +11457,7 @@ var ReactErrorUtils = { module.exports = ReactErrorUtils; -},{}],62:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -10927,7 +11507,7 @@ var ReactEventEmitterMixin = { module.exports = ReactEventEmitterMixin; -},{"./EventPluginHub":17}],63:[function(require,module,exports){ +},{"./EventPluginHub":26}],72:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11110,7 +11690,7 @@ var ReactEventListener = { module.exports = ReactEventListener; -},{"./EventListener":16,"./ExecutionEnvironment":21,"./Object.assign":27,"./PooledClass":28,"./ReactInstanceHandles":67,"./ReactMount":71,"./ReactUpdates":88,"./getEventTarget":126,"./getUnboundedScrollPosition":132}],64:[function(require,module,exports){ +},{"./EventListener":25,"./ExecutionEnvironment":30,"./Object.assign":36,"./PooledClass":37,"./ReactInstanceHandles":76,"./ReactMount":80,"./ReactUpdates":97,"./getEventTarget":135,"./getUnboundedScrollPosition":141}],73:[function(require,module,exports){ (function (process){ /** * Copyright 2015, Facebook, Inc. @@ -11295,7 +11875,7 @@ var ReactFragment = { module.exports = ReactFragment; }).call(this,require('_process')) -},{"./ReactElement":58,"./warning":155,"_process":1}],65:[function(require,module,exports){ +},{"./ReactElement":67,"./warning":164,"_process":1}],74:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11337,7 +11917,7 @@ var ReactInjection = { module.exports = ReactInjection; -},{"./DOMProperty":10,"./EventPluginHub":17,"./ReactBrowserEventEmitter":31,"./ReactClass":34,"./ReactComponentEnvironment":37,"./ReactDOMComponent":43,"./ReactEmptyComponent":60,"./ReactNativeComponent":74,"./ReactPerf":76,"./ReactRootIndex":84,"./ReactUpdates":88}],66:[function(require,module,exports){ +},{"./DOMProperty":19,"./EventPluginHub":26,"./ReactBrowserEventEmitter":40,"./ReactClass":43,"./ReactComponentEnvironment":46,"./ReactDOMComponent":52,"./ReactEmptyComponent":69,"./ReactNativeComponent":83,"./ReactPerf":85,"./ReactRootIndex":93,"./ReactUpdates":97}],75:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11472,7 +12052,7 @@ var ReactInputSelection = { module.exports = ReactInputSelection; -},{"./ReactDOMSelection":51,"./containsNode":110,"./focusNode":120,"./getActiveElement":122}],67:[function(require,module,exports){ +},{"./ReactDOMSelection":60,"./containsNode":119,"./focusNode":129,"./getActiveElement":131}],76:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -11808,7 +12388,7 @@ var ReactInstanceHandles = { module.exports = ReactInstanceHandles; }).call(this,require('_process')) -},{"./ReactRootIndex":84,"./invariant":136,"_process":1}],68:[function(require,module,exports){ +},{"./ReactRootIndex":93,"./invariant":145,"_process":1}],77:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11857,7 +12437,7 @@ var ReactInstanceMap = { module.exports = ReactInstanceMap; -},{}],69:[function(require,module,exports){ +},{}],78:[function(require,module,exports){ /** * Copyright 2015, Facebook, Inc. * All rights reserved. @@ -11894,7 +12474,7 @@ var ReactLifeCycle = { module.exports = ReactLifeCycle; -},{}],70:[function(require,module,exports){ +},{}],79:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -11942,7 +12522,7 @@ var ReactMarkupChecksum = { module.exports = ReactMarkupChecksum; -},{"./adler32":107}],71:[function(require,module,exports){ +},{"./adler32":116}],80:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -12833,7 +13413,7 @@ ReactPerf.measureMethods(ReactMount, 'ReactMount', { module.exports = ReactMount; }).call(this,require('_process')) -},{"./DOMProperty":10,"./ReactBrowserEventEmitter":31,"./ReactCurrentOwner":40,"./ReactElement":58,"./ReactElementValidator":59,"./ReactEmptyComponent":60,"./ReactInstanceHandles":67,"./ReactInstanceMap":68,"./ReactMarkupChecksum":70,"./ReactPerf":76,"./ReactReconciler":82,"./ReactUpdateQueue":87,"./ReactUpdates":88,"./containsNode":110,"./emptyObject":116,"./getReactRootElementInContainer":130,"./instantiateReactComponent":135,"./invariant":136,"./setInnerHTML":149,"./shouldUpdateReactComponent":152,"./warning":155,"_process":1}],72:[function(require,module,exports){ +},{"./DOMProperty":19,"./ReactBrowserEventEmitter":40,"./ReactCurrentOwner":49,"./ReactElement":67,"./ReactElementValidator":68,"./ReactEmptyComponent":69,"./ReactInstanceHandles":76,"./ReactInstanceMap":77,"./ReactMarkupChecksum":79,"./ReactPerf":85,"./ReactReconciler":91,"./ReactUpdateQueue":96,"./ReactUpdates":97,"./containsNode":119,"./emptyObject":125,"./getReactRootElementInContainer":139,"./instantiateReactComponent":144,"./invariant":145,"./setInnerHTML":158,"./shouldUpdateReactComponent":161,"./warning":164,"_process":1}],81:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13263,7 +13843,7 @@ var ReactMultiChild = { module.exports = ReactMultiChild; -},{"./ReactChildReconciler":32,"./ReactComponentEnvironment":37,"./ReactMultiChildUpdateTypes":73,"./ReactReconciler":82}],73:[function(require,module,exports){ +},{"./ReactChildReconciler":41,"./ReactComponentEnvironment":46,"./ReactMultiChildUpdateTypes":82,"./ReactReconciler":91}],82:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13296,7 +13876,7 @@ var ReactMultiChildUpdateTypes = keyMirror({ module.exports = ReactMultiChildUpdateTypes; -},{"./keyMirror":141}],74:[function(require,module,exports){ +},{"./keyMirror":150}],83:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -13403,7 +13983,7 @@ var ReactNativeComponent = { module.exports = ReactNativeComponent; }).call(this,require('_process')) -},{"./Object.assign":27,"./invariant":136,"_process":1}],75:[function(require,module,exports){ +},{"./Object.assign":36,"./invariant":145,"_process":1}],84:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -13515,7 +14095,7 @@ var ReactOwner = { module.exports = ReactOwner; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],76:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],85:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -13619,7 +14199,7 @@ function _noMeasure(objName, fnName, func) { module.exports = ReactPerf; }).call(this,require('_process')) -},{"_process":1}],77:[function(require,module,exports){ +},{"_process":1}],86:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -13647,7 +14227,7 @@ if ("production" !== process.env.NODE_ENV) { module.exports = ReactPropTypeLocationNames; }).call(this,require('_process')) -},{"_process":1}],78:[function(require,module,exports){ +},{"_process":1}],87:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -13671,7 +14251,7 @@ var ReactPropTypeLocations = keyMirror({ module.exports = ReactPropTypeLocations; -},{"./keyMirror":141}],79:[function(require,module,exports){ +},{"./keyMirror":150}],88:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -14020,7 +14600,7 @@ function getPreciseType(propValue) { module.exports = ReactPropTypes; -},{"./ReactElement":58,"./ReactFragment":64,"./ReactPropTypeLocationNames":77,"./emptyFunction":115}],80:[function(require,module,exports){ +},{"./ReactElement":67,"./ReactFragment":73,"./ReactPropTypeLocationNames":86,"./emptyFunction":124}],89:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -14076,7 +14656,7 @@ PooledClass.addPoolingTo(ReactPutListenerQueue); module.exports = ReactPutListenerQueue; -},{"./Object.assign":27,"./PooledClass":28,"./ReactBrowserEventEmitter":31}],81:[function(require,module,exports){ +},{"./Object.assign":36,"./PooledClass":37,"./ReactBrowserEventEmitter":40}],90:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -14252,7 +14832,7 @@ PooledClass.addPoolingTo(ReactReconcileTransaction); module.exports = ReactReconcileTransaction; -},{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactBrowserEventEmitter":31,"./ReactInputSelection":66,"./ReactPutListenerQueue":80,"./Transaction":104}],82:[function(require,module,exports){ +},{"./CallbackQueue":15,"./Object.assign":36,"./PooledClass":37,"./ReactBrowserEventEmitter":40,"./ReactInputSelection":75,"./ReactPutListenerQueue":89,"./Transaction":113}],91:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -14376,7 +14956,7 @@ var ReactReconciler = { module.exports = ReactReconciler; }).call(this,require('_process')) -},{"./ReactElementValidator":59,"./ReactRef":83,"_process":1}],83:[function(require,module,exports){ +},{"./ReactElementValidator":68,"./ReactRef":92,"_process":1}],92:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -14447,7 +15027,7 @@ ReactRef.detachRefs = function(instance, element) { module.exports = ReactRef; -},{"./ReactOwner":75}],84:[function(require,module,exports){ +},{"./ReactOwner":84}],93:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -14478,7 +15058,7 @@ var ReactRootIndex = { module.exports = ReactRootIndex; -},{}],85:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -14560,7 +15140,7 @@ module.exports = { }; }).call(this,require('_process')) -},{"./ReactElement":58,"./ReactInstanceHandles":67,"./ReactMarkupChecksum":70,"./ReactServerRenderingTransaction":86,"./emptyObject":116,"./instantiateReactComponent":135,"./invariant":136,"_process":1}],86:[function(require,module,exports){ +},{"./ReactElement":67,"./ReactInstanceHandles":76,"./ReactMarkupChecksum":79,"./ReactServerRenderingTransaction":95,"./emptyObject":125,"./instantiateReactComponent":144,"./invariant":145,"_process":1}],95:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -14673,7 +15253,7 @@ PooledClass.addPoolingTo(ReactServerRenderingTransaction); module.exports = ReactServerRenderingTransaction; -},{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactPutListenerQueue":80,"./Transaction":104,"./emptyFunction":115}],87:[function(require,module,exports){ +},{"./CallbackQueue":15,"./Object.assign":36,"./PooledClass":37,"./ReactPutListenerQueue":89,"./Transaction":113,"./emptyFunction":124}],96:[function(require,module,exports){ (function (process){ /** * Copyright 2015, Facebook, Inc. @@ -14972,7 +15552,7 @@ var ReactUpdateQueue = { module.exports = ReactUpdateQueue; }).call(this,require('_process')) -},{"./Object.assign":27,"./ReactCurrentOwner":40,"./ReactElement":58,"./ReactInstanceMap":68,"./ReactLifeCycle":69,"./ReactUpdates":88,"./invariant":136,"./warning":155,"_process":1}],88:[function(require,module,exports){ +},{"./Object.assign":36,"./ReactCurrentOwner":49,"./ReactElement":67,"./ReactInstanceMap":77,"./ReactLifeCycle":78,"./ReactUpdates":97,"./invariant":145,"./warning":164,"_process":1}],97:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -15254,7 +15834,7 @@ var ReactUpdates = { module.exports = ReactUpdates; }).call(this,require('_process')) -},{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactCurrentOwner":40,"./ReactPerf":76,"./ReactReconciler":82,"./Transaction":104,"./invariant":136,"./warning":155,"_process":1}],89:[function(require,module,exports){ +},{"./CallbackQueue":15,"./Object.assign":36,"./PooledClass":37,"./ReactCurrentOwner":49,"./ReactPerf":85,"./ReactReconciler":91,"./Transaction":113,"./invariant":145,"./warning":164,"_process":1}],98:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15348,7 +15928,7 @@ var SVGDOMPropertyConfig = { module.exports = SVGDOMPropertyConfig; -},{"./DOMProperty":10}],90:[function(require,module,exports){ +},{"./DOMProperty":19}],99:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15543,7 +16123,7 @@ var SelectEventPlugin = { module.exports = SelectEventPlugin; -},{"./EventConstants":15,"./EventPropagators":20,"./ReactInputSelection":66,"./SyntheticEvent":96,"./getActiveElement":122,"./isTextInputElement":139,"./keyOf":142,"./shallowEqual":151}],91:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPropagators":29,"./ReactInputSelection":75,"./SyntheticEvent":105,"./getActiveElement":131,"./isTextInputElement":148,"./keyOf":151,"./shallowEqual":160}],100:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -15574,7 +16154,7 @@ var ServerReactRootIndex = { module.exports = ServerReactRootIndex; -},{}],92:[function(require,module,exports){ +},{}],101:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -16002,7 +16582,7 @@ var SimpleEventPlugin = { module.exports = SimpleEventPlugin; }).call(this,require('_process')) -},{"./EventConstants":15,"./EventPluginUtils":19,"./EventPropagators":20,"./SyntheticClipboardEvent":93,"./SyntheticDragEvent":95,"./SyntheticEvent":96,"./SyntheticFocusEvent":97,"./SyntheticKeyboardEvent":99,"./SyntheticMouseEvent":100,"./SyntheticTouchEvent":101,"./SyntheticUIEvent":102,"./SyntheticWheelEvent":103,"./getEventCharCode":123,"./invariant":136,"./keyOf":142,"./warning":155,"_process":1}],93:[function(require,module,exports){ +},{"./EventConstants":24,"./EventPluginUtils":28,"./EventPropagators":29,"./SyntheticClipboardEvent":102,"./SyntheticDragEvent":104,"./SyntheticEvent":105,"./SyntheticFocusEvent":106,"./SyntheticKeyboardEvent":108,"./SyntheticMouseEvent":109,"./SyntheticTouchEvent":110,"./SyntheticUIEvent":111,"./SyntheticWheelEvent":112,"./getEventCharCode":132,"./invariant":145,"./keyOf":151,"./warning":164,"_process":1}],102:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16047,7 +16627,7 @@ SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface); module.exports = SyntheticClipboardEvent; -},{"./SyntheticEvent":96}],94:[function(require,module,exports){ +},{"./SyntheticEvent":105}],103:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16092,7 +16672,7 @@ SyntheticEvent.augmentClass( module.exports = SyntheticCompositionEvent; -},{"./SyntheticEvent":96}],95:[function(require,module,exports){ +},{"./SyntheticEvent":105}],104:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16131,7 +16711,7 @@ SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface); module.exports = SyntheticDragEvent; -},{"./SyntheticMouseEvent":100}],96:[function(require,module,exports){ +},{"./SyntheticMouseEvent":109}],105:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16297,7 +16877,7 @@ PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler); module.exports = SyntheticEvent; -},{"./Object.assign":27,"./PooledClass":28,"./emptyFunction":115,"./getEventTarget":126}],97:[function(require,module,exports){ +},{"./Object.assign":36,"./PooledClass":37,"./emptyFunction":124,"./getEventTarget":135}],106:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16336,7 +16916,7 @@ SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface); module.exports = SyntheticFocusEvent; -},{"./SyntheticUIEvent":102}],98:[function(require,module,exports){ +},{"./SyntheticUIEvent":111}],107:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16382,7 +16962,7 @@ SyntheticEvent.augmentClass( module.exports = SyntheticInputEvent; -},{"./SyntheticEvent":96}],99:[function(require,module,exports){ +},{"./SyntheticEvent":105}],108:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16469,7 +17049,7 @@ SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface); module.exports = SyntheticKeyboardEvent; -},{"./SyntheticUIEvent":102,"./getEventCharCode":123,"./getEventKey":124,"./getEventModifierState":125}],100:[function(require,module,exports){ +},{"./SyntheticUIEvent":111,"./getEventCharCode":132,"./getEventKey":133,"./getEventModifierState":134}],109:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16550,7 +17130,7 @@ SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface); module.exports = SyntheticMouseEvent; -},{"./SyntheticUIEvent":102,"./ViewportMetrics":105,"./getEventModifierState":125}],101:[function(require,module,exports){ +},{"./SyntheticUIEvent":111,"./ViewportMetrics":114,"./getEventModifierState":134}],110:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16598,7 +17178,7 @@ SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface); module.exports = SyntheticTouchEvent; -},{"./SyntheticUIEvent":102,"./getEventModifierState":125}],102:[function(require,module,exports){ +},{"./SyntheticUIEvent":111,"./getEventModifierState":134}],111:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16660,7 +17240,7 @@ SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface); module.exports = SyntheticUIEvent; -},{"./SyntheticEvent":96,"./getEventTarget":126}],103:[function(require,module,exports){ +},{"./SyntheticEvent":105,"./getEventTarget":135}],112:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16721,7 +17301,7 @@ SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface); module.exports = SyntheticWheelEvent; -},{"./SyntheticMouseEvent":100}],104:[function(require,module,exports){ +},{"./SyntheticMouseEvent":109}],113:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -16962,7 +17542,7 @@ var Transaction = { module.exports = Transaction; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],105:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],114:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -16991,7 +17571,7 @@ var ViewportMetrics = { module.exports = ViewportMetrics; -},{}],106:[function(require,module,exports){ +},{}],115:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -17057,7 +17637,7 @@ function accumulateInto(current, next) { module.exports = accumulateInto; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],107:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],116:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17091,7 +17671,7 @@ function adler32(data) { module.exports = adler32; -},{}],108:[function(require,module,exports){ +},{}],117:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17123,7 +17703,7 @@ function camelize(string) { module.exports = camelize; -},{}],109:[function(require,module,exports){ +},{}],118:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -17165,7 +17745,7 @@ function camelizeStyleName(string) { module.exports = camelizeStyleName; -},{"./camelize":108}],110:[function(require,module,exports){ +},{"./camelize":117}],119:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17209,7 +17789,7 @@ function containsNode(outerNode, innerNode) { module.exports = containsNode; -},{"./isTextNode":140}],111:[function(require,module,exports){ +},{"./isTextNode":149}],120:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17295,7 +17875,7 @@ function createArrayFromMixed(obj) { module.exports = createArrayFromMixed; -},{"./toArray":153}],112:[function(require,module,exports){ +},{"./toArray":162}],121:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17357,7 +17937,7 @@ function createFullPageComponent(tag) { module.exports = createFullPageComponent; }).call(this,require('_process')) -},{"./ReactClass":34,"./ReactElement":58,"./invariant":136,"_process":1}],113:[function(require,module,exports){ +},{"./ReactClass":43,"./ReactElement":67,"./invariant":145,"_process":1}],122:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17447,7 +18027,7 @@ function createNodesFromMarkup(markup, handleScript) { module.exports = createNodesFromMarkup; }).call(this,require('_process')) -},{"./ExecutionEnvironment":21,"./createArrayFromMixed":111,"./getMarkupWrap":128,"./invariant":136,"_process":1}],114:[function(require,module,exports){ +},{"./ExecutionEnvironment":30,"./createArrayFromMixed":120,"./getMarkupWrap":137,"./invariant":145,"_process":1}],123:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17505,7 +18085,7 @@ function dangerousStyleValue(name, value) { module.exports = dangerousStyleValue; -},{"./CSSProperty":4}],115:[function(require,module,exports){ +},{"./CSSProperty":13}],124:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17539,7 +18119,7 @@ emptyFunction.thatReturnsArgument = function(arg) { return arg; }; module.exports = emptyFunction; -},{}],116:[function(require,module,exports){ +},{}],125:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17563,7 +18143,7 @@ if ("production" !== process.env.NODE_ENV) { module.exports = emptyObject; }).call(this,require('_process')) -},{"_process":1}],117:[function(require,module,exports){ +},{"_process":1}],126:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17603,7 +18183,7 @@ function escapeTextContentForBrowser(text) { module.exports = escapeTextContentForBrowser; -},{}],118:[function(require,module,exports){ +},{}],127:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17676,7 +18256,7 @@ function findDOMNode(componentOrElement) { module.exports = findDOMNode; }).call(this,require('_process')) -},{"./ReactCurrentOwner":40,"./ReactInstanceMap":68,"./ReactMount":71,"./invariant":136,"./isNode":138,"./warning":155,"_process":1}],119:[function(require,module,exports){ +},{"./ReactCurrentOwner":49,"./ReactInstanceMap":77,"./ReactMount":80,"./invariant":145,"./isNode":147,"./warning":164,"_process":1}],128:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -17734,7 +18314,7 @@ function flattenChildren(children) { module.exports = flattenChildren; }).call(this,require('_process')) -},{"./traverseAllChildren":154,"./warning":155,"_process":1}],120:[function(require,module,exports){ +},{"./traverseAllChildren":163,"./warning":164,"_process":1}],129:[function(require,module,exports){ /** * Copyright 2014-2015, Facebook, Inc. * All rights reserved. @@ -17763,7 +18343,7 @@ function focusNode(node) { module.exports = focusNode; -},{}],121:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17794,7 +18374,7 @@ var forEachAccumulated = function(arr, cb, scope) { module.exports = forEachAccumulated; -},{}],122:[function(require,module,exports){ +},{}],131:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17823,7 +18403,7 @@ function getActiveElement() /*?DOMElement*/ { module.exports = getActiveElement; -},{}],123:[function(require,module,exports){ +},{}],132:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17875,7 +18455,7 @@ function getEventCharCode(nativeEvent) { module.exports = getEventCharCode; -},{}],124:[function(require,module,exports){ +},{}],133:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -17980,7 +18560,7 @@ function getEventKey(nativeEvent) { module.exports = getEventKey; -},{"./getEventCharCode":123}],125:[function(require,module,exports){ +},{"./getEventCharCode":132}],134:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18027,7 +18607,7 @@ function getEventModifierState(nativeEvent) { module.exports = getEventModifierState; -},{}],126:[function(require,module,exports){ +},{}],135:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18058,7 +18638,7 @@ function getEventTarget(nativeEvent) { module.exports = getEventTarget; -},{}],127:[function(require,module,exports){ +},{}],136:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18102,7 +18682,7 @@ function getIteratorFn(maybeIterable) { module.exports = getIteratorFn; -},{}],128:[function(require,module,exports){ +},{}],137:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -18221,7 +18801,7 @@ function getMarkupWrap(nodeName) { module.exports = getMarkupWrap; }).call(this,require('_process')) -},{"./ExecutionEnvironment":21,"./invariant":136,"_process":1}],129:[function(require,module,exports){ +},{"./ExecutionEnvironment":30,"./invariant":145,"_process":1}],138:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18296,7 +18876,7 @@ function getNodeForCharacterOffset(root, offset) { module.exports = getNodeForCharacterOffset; -},{}],130:[function(require,module,exports){ +},{}],139:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18331,7 +18911,7 @@ function getReactRootElementInContainer(container) { module.exports = getReactRootElementInContainer; -},{}],131:[function(require,module,exports){ +},{}],140:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18368,7 +18948,7 @@ function getTextContentAccessor() { module.exports = getTextContentAccessor; -},{"./ExecutionEnvironment":21}],132:[function(require,module,exports){ +},{"./ExecutionEnvironment":30}],141:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18408,7 +18988,7 @@ function getUnboundedScrollPosition(scrollable) { module.exports = getUnboundedScrollPosition; -},{}],133:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18441,7 +19021,7 @@ function hyphenate(string) { module.exports = hyphenate; -},{}],134:[function(require,module,exports){ +},{}],143:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18482,7 +19062,7 @@ function hyphenateStyleName(string) { module.exports = hyphenateStyleName; -},{"./hyphenate":133}],135:[function(require,module,exports){ +},{"./hyphenate":142}],144:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -18620,7 +19200,7 @@ function instantiateReactComponent(node, parentCompositeType) { module.exports = instantiateReactComponent; }).call(this,require('_process')) -},{"./Object.assign":27,"./ReactCompositeComponent":38,"./ReactEmptyComponent":60,"./ReactNativeComponent":74,"./invariant":136,"./warning":155,"_process":1}],136:[function(require,module,exports){ +},{"./Object.assign":36,"./ReactCompositeComponent":47,"./ReactEmptyComponent":69,"./ReactNativeComponent":83,"./invariant":145,"./warning":164,"_process":1}],145:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -18677,7 +19257,7 @@ var invariant = function(condition, format, a, b, c, d, e, f) { module.exports = invariant; }).call(this,require('_process')) -},{"_process":1}],137:[function(require,module,exports){ +},{"_process":1}],146:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18742,7 +19322,7 @@ function isEventSupported(eventNameSuffix, capture) { module.exports = isEventSupported; -},{"./ExecutionEnvironment":21}],138:[function(require,module,exports){ +},{"./ExecutionEnvironment":30}],147:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18769,7 +19349,7 @@ function isNode(object) { module.exports = isNode; -},{}],139:[function(require,module,exports){ +},{}],148:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18812,7 +19392,7 @@ function isTextInputElement(elem) { module.exports = isTextInputElement; -},{}],140:[function(require,module,exports){ +},{}],149:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18837,7 +19417,7 @@ function isTextNode(object) { module.exports = isTextNode; -},{"./isNode":138}],141:[function(require,module,exports){ +},{"./isNode":147}],150:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -18892,7 +19472,7 @@ var keyMirror = function(obj) { module.exports = keyMirror; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],142:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],151:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18928,7 +19508,7 @@ var keyOf = function(oneKeyObj) { module.exports = keyOf; -},{}],143:[function(require,module,exports){ +},{}],152:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -18981,7 +19561,7 @@ function mapObject(object, callback, context) { module.exports = mapObject; -},{}],144:[function(require,module,exports){ +},{}],153:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19014,7 +19594,7 @@ function memoizeStringOnly(callback) { module.exports = memoizeStringOnly; -},{}],145:[function(require,module,exports){ +},{}],154:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19054,7 +19634,7 @@ function onlyChild(children) { module.exports = onlyChild; }).call(this,require('_process')) -},{"./ReactElement":58,"./invariant":136,"_process":1}],146:[function(require,module,exports){ +},{"./ReactElement":67,"./invariant":145,"_process":1}],155:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19082,7 +19662,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = performance || {}; -},{"./ExecutionEnvironment":21}],147:[function(require,module,exports){ +},{"./ExecutionEnvironment":30}],156:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19110,7 +19690,7 @@ var performanceNow = performance.now.bind(performance); module.exports = performanceNow; -},{"./performance":146}],148:[function(require,module,exports){ +},{"./performance":155}],157:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19138,7 +19718,7 @@ function quoteAttributeValueForBrowser(value) { module.exports = quoteAttributeValueForBrowser; -},{"./escapeTextContentForBrowser":117}],149:[function(require,module,exports){ +},{"./escapeTextContentForBrowser":126}],158:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19227,7 +19807,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = setInnerHTML; -},{"./ExecutionEnvironment":21}],150:[function(require,module,exports){ +},{"./ExecutionEnvironment":30}],159:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19269,7 +19849,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = setTextContent; -},{"./ExecutionEnvironment":21,"./escapeTextContentForBrowser":117,"./setInnerHTML":149}],151:[function(require,module,exports){ +},{"./ExecutionEnvironment":30,"./escapeTextContentForBrowser":126,"./setInnerHTML":158}],160:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. * All rights reserved. @@ -19313,7 +19893,7 @@ function shallowEqual(objA, objB) { module.exports = shallowEqual; -},{}],152:[function(require,module,exports){ +},{}],161:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19417,7 +19997,7 @@ function shouldUpdateReactComponent(prevElement, nextElement) { module.exports = shouldUpdateReactComponent; }).call(this,require('_process')) -},{"./warning":155,"_process":1}],153:[function(require,module,exports){ +},{"./warning":164,"_process":1}],162:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -19489,7 +20069,7 @@ function toArray(obj) { module.exports = toArray; }).call(this,require('_process')) -},{"./invariant":136,"_process":1}],154:[function(require,module,exports){ +},{"./invariant":145,"_process":1}],163:[function(require,module,exports){ (function (process){ /** * Copyright 2013-2015, Facebook, Inc. @@ -19742,7 +20322,7 @@ function traverseAllChildren(children, callback, traverseContext) { module.exports = traverseAllChildren; }).call(this,require('_process')) -},{"./ReactElement":58,"./ReactFragment":64,"./ReactInstanceHandles":67,"./getIteratorFn":127,"./invariant":136,"./warning":155,"_process":1}],155:[function(require,module,exports){ +},{"./ReactElement":67,"./ReactFragment":73,"./ReactInstanceHandles":76,"./getIteratorFn":136,"./invariant":145,"./warning":164,"_process":1}],164:[function(require,module,exports){ (function (process){ /** * Copyright 2014-2015, Facebook, Inc. @@ -19805,1615 +20385,5895 @@ if ("production" !== process.env.NODE_ENV) { module.exports = warning; }).call(this,require('_process')) -},{"./emptyFunction":115,"_process":1}],156:[function(require,module,exports){ +},{"./emptyFunction":124,"_process":1}],165:[function(require,module,exports){ module.exports = require('./lib/React'); -},{"./lib/React":29}],157:[function(require,module,exports){ +},{"./lib/React":38}],166:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports['default'] = createStore; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _utilsIsPlainObject = require('./utils/isPlainObject'); + +var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject); + +/** + * These are private action types reserved by Redux. + * For any unknown actions, you must return the current state. + * If the current state is undefined, you must return the initial state. + * Do not reference these action types directly in your code. + */ +var ActionTypes = { + INIT: '@@redux/INIT' +}; + +exports.ActionTypes = ActionTypes; +/** + * Creates a Redux store that holds the state tree. + * The only way to change the data in the store is to call `dispatch()` on it. + * + * There should only be a single store in your app. To specify how different + * parts of the state tree respond to actions, you may combine several reducers + * into a single reducer function by using `combineReducers`. + * + * @param {Function} reducer A function that returns the next state tree, given + * the current state tree and the action to handle. + * + * @param {any} [initialState] The initial state. You may optionally specify it + * to hydrate the state from the server in universal apps, or to restore a + * previously serialized user session. + * If you use `combineReducers` to produce the root reducer function, this must be + * an object with the same shape as `combineReducers` keys. + * + * @returns {Store} A Redux store that lets you read the state, dispatch actions + * and subscribe to changes. + */ + +function createStore(reducer, initialState) { + if (typeof reducer !== 'function') { + throw new Error('Expected the reducer to be a function.'); + } + + var currentReducer = reducer; + var currentState = initialState; + var listeners = []; + var isDispatching = false; + + /** + * Reads the state tree managed by the store. + * + * @returns {any} The current state tree of your application. + */ + function getState() { + return currentState; + } + + /** + * Adds a change listener. It will be called any time an action is dispatched, + * and some part of the state tree may potentially have changed. You may then + * call `getState()` to read the current state tree inside the callback. + * + * @param {Function} listener A callback to be invoked on every dispatch. + * @returns {Function} A function to remove this change listener. + */ + function subscribe(listener) { + listeners.push(listener); + + return function unsubscribe() { + var index = listeners.indexOf(listener); + listeners.splice(index, 1); + }; + } + + /** + * Dispatches an action. It is the only way to trigger a state change. + * + * The `reducer` function, used to create the store, will be called with the + * current state tree and the given `action`. Its return value will + * be considered the **next** state of the tree, and the change listeners + * will be notified. + * + * The base implementation only supports plain object actions. If you want to + * dispatch a Promise, an Observable, a thunk, or something else, you need to + * wrap your store creating function into the corresponding middleware. For + * example, see the documentation for the `redux-thunk` package. Even the + * middleware will eventually dispatch plain object actions using this method. + * + * @param {Object} action A plain object representing “what changed”. It is + * a good idea to keep actions serializable so you can record and replay user + * sessions, or use the time travelling `redux-devtools`. + * + * @returns {Object} For convenience, the same action object you dispatched. + * + * Note that, if you use a custom middleware, it may wrap `dispatch()` to + * return something else (for example, a Promise you can await). + */ + function dispatch(action) { + if (!_utilsIsPlainObject2['default'](action)) { + throw new Error('Actions must be plain objects. Use custom middleware for async actions.'); + } + + if (isDispatching) { + throw new Error('Reducers may not dispatch actions.'); + } + + try { + isDispatching = true; + currentState = currentReducer(currentState, action); + } finally { + isDispatching = false; + } + + listeners.slice().forEach(function (listener) { + return listener(); + }); + return action; + } + + /** + * Returns the reducer currently used by the store to calculate the state. + * + * It is likely that you will only need this function if you implement a hot + * reloading mechanism for Redux. + * + * @returns {Function} The reducer used by the current store. + */ + function getReducer() { + return currentReducer; + } + + /** + * Replaces the reducer currently used by the store to calculate the state. + * + * You might need this if your app implements code splitting and you want to + * load some of the reducers dynamically. You might also need this if you + * implement a hot reloading mechanism for Redux. + * + * @param {Function} nextReducer The reducer for the store to use instead. + * @returns {void} + */ + function replaceReducer(nextReducer) { + currentReducer = nextReducer; + dispatch({ type: ActionTypes.INIT }); + } + + // When a store is created, an "INIT" action is dispatched so that every + // reducer returns their initial state. This effectively populates + // the initial state tree. + dispatch({ type: ActionTypes.INIT }); + + return { + dispatch: dispatch, + subscribe: subscribe, + getState: getState, + getReducer: getReducer, + replaceReducer: replaceReducer + }; +} +},{"./utils/isPlainObject":172}],167:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _createStore = require('./createStore'); + +var _createStore2 = _interopRequireDefault(_createStore); + +var _utilsCombineReducers = require('./utils/combineReducers'); + +var _utilsCombineReducers2 = _interopRequireDefault(_utilsCombineReducers); + +var _utilsBindActionCreators = require('./utils/bindActionCreators'); + +var _utilsBindActionCreators2 = _interopRequireDefault(_utilsBindActionCreators); + +var _utilsApplyMiddleware = require('./utils/applyMiddleware'); + +var _utilsApplyMiddleware2 = _interopRequireDefault(_utilsApplyMiddleware); + +var _utilsCompose = require('./utils/compose'); + +var _utilsCompose2 = _interopRequireDefault(_utilsCompose); + +exports.createStore = _createStore2['default']; +exports.combineReducers = _utilsCombineReducers2['default']; +exports.bindActionCreators = _utilsBindActionCreators2['default']; +exports.applyMiddleware = _utilsApplyMiddleware2['default']; +exports.compose = _utilsCompose2['default']; +},{"./createStore":166,"./utils/applyMiddleware":168,"./utils/bindActionCreators":169,"./utils/combineReducers":170,"./utils/compose":171}],168:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +exports['default'] = applyMiddleware; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _compose = require('./compose'); + +var _compose2 = _interopRequireDefault(_compose); + +/** + * Creates a store enhancer that applies middleware to the dispatch method + * of the Redux store. This is handy for a variety of tasks, such as expressing + * asynchronous actions in a concise manner, or logging every action payload. + * + * See `redux-thunk` package as an example of the Redux middleware. + * + * Because middleware is potentially asynchronous, this should be the first + * store enhancer in the composition chain. + * + * Note that each middleware will be given the `dispatch` and `getState` functions + * as named arguments. + * + * @param {...Function} middlewares The middleware chain to be applied. + * @returns {Function} A store enhancer applying the middleware. + */ + +function applyMiddleware() { + for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) { + middlewares[_key] = arguments[_key]; + } + + return function (next) { + return function (reducer, initialState) { + var store = next(reducer, initialState); + var _dispatch = store.dispatch; + var chain = []; + + var middlewareAPI = { + getState: store.getState, + dispatch: function dispatch(action) { + return _dispatch(action); + } + }; + chain = middlewares.map(function (middleware) { + return middleware(middlewareAPI); + }); + _dispatch = _compose2['default'].apply(undefined, chain.concat([store.dispatch])); + + return _extends({}, store, { + dispatch: _dispatch + }); + }; + }; +} + +module.exports = exports['default']; +},{"./compose":171}],169:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports['default'] = bindActionCreators; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _utilsMapValues = require('../utils/mapValues'); + +var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues); + +function bindActionCreator(actionCreator, dispatch) { + return function () { + return dispatch(actionCreator.apply(undefined, arguments)); + }; +} + +/** + * Turns an object whose values are action creators, into an object with the + * same keys, but with every function wrapped into a `dispatch` call so they + * may be invoked directly. This is just a convenience method, as you can call + * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. + * + * For convenience, you can also pass a single function as the first argument, + * and get a function in return. + * + * @param {Function|Object} actionCreators An object whose values are action + * creator functions. One handy way to obtain it is to use ES6 `import * as` + * syntax. You may also pass a single function. + * + * @param {Function} dispatch The `dispatch` function available on your Redux + * store. + * + * @returns {Function|Object} The object mimicking the original object, but with + * every action creator wrapped into the `dispatch` call. If you passed a + * function as `actionCreators`, the return value will also be a single + * function. + */ + +function bindActionCreators(actionCreators, dispatch) { + if (typeof actionCreators === 'function') { + return bindActionCreator(actionCreators, dispatch); + } + + if (typeof actionCreators !== 'object' || actionCreators == null) { + throw new Error('bindActionCreators expected an object or a function, instead received ' + typeof actionCreators + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'); + } + + return _utilsMapValues2['default'](actionCreators, function (actionCreator) { + return bindActionCreator(actionCreator, dispatch); + }); +} + +module.exports = exports['default']; +},{"../utils/mapValues":173}],170:[function(require,module,exports){ +(function (process){ +'use strict'; + +exports.__esModule = true; +exports['default'] = combineReducers; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _createStore = require('../createStore'); + +var _utilsIsPlainObject = require('../utils/isPlainObject'); + +var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject); + +var _utilsMapValues = require('../utils/mapValues'); + +var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues); + +var _utilsPick = require('../utils/pick'); + +var _utilsPick2 = _interopRequireDefault(_utilsPick); + +function getErrorMessage(key, action) { + var actionType = action && action.type; + var actionName = actionType && '"' + actionType.toString() + '"' || 'an action'; + + return 'Reducer "' + key + '" returned undefined handling ' + actionName + '. ' + 'To ignore an action, you must explicitly return the previous state.'; +} + +function verifyStateShape(initialState, currentState) { + var reducerKeys = Object.keys(currentState); + + if (reducerKeys.length === 0) { + console.error('Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'); + return; + } + + if (!_utilsIsPlainObject2['default'](initialState)) { + console.error('initialState has unexpected type of "' + ({}).toString.call(initialState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected initialState to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"')); + return; + } + + var unexpectedKeys = Object.keys(initialState).filter(function (key) { + return reducerKeys.indexOf(key) < 0; + }); + + if (unexpectedKeys.length > 0) { + console.error('Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" in initialState will be ignored. ') + ('Expected to find one of the known reducer keys instead: "' + reducerKeys.join('", "') + '"')); + } +} + +/** + * Turns an object whose values are different reducer functions, into a single + * reducer function. It will call every child reducer, and gather their results + * into a single state object, whose keys correspond to the keys of the passed + * reducer functions. + * + * @param {Object} reducers An object whose values correspond to different + * reducer functions that need to be combined into one. One handy way to obtain + * it is to use ES6 `import * as reducers` syntax. The reducers may never return + * undefined for any action. Instead, they should return their initial state + * if the state passed to them was undefined, and the current state for any + * unrecognized action. + * + * @returns {Function} A reducer function that invokes every reducer inside the + * passed object, and builds a state object with the same shape. + */ + +function combineReducers(reducers) { + var finalReducers = _utilsPick2['default'](reducers, function (val) { + return typeof val === 'function'; + }); + + Object.keys(finalReducers).forEach(function (key) { + var reducer = finalReducers[key]; + if (typeof reducer(undefined, { type: _createStore.ActionTypes.INIT }) === 'undefined') { + throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined.'); + } + + var type = Math.random().toString(36).substring(7).split('').join('.'); + if (typeof reducer(undefined, { type: type }) === 'undefined') { + throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + _createStore.ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined.'); + } + }); + + var defaultState = _utilsMapValues2['default'](finalReducers, function () { + return undefined; + }); + var stateShapeVerified; + + return function combination(state, action) { + if (state === undefined) state = defaultState; + + var finalState = _utilsMapValues2['default'](finalReducers, function (reducer, key) { + var newState = reducer(state[key], action); + if (typeof newState === 'undefined') { + throw new Error(getErrorMessage(key, action)); + } + return newState; + }); + + if ( + // Node-like CommonJS environments (Browserify, Webpack) + typeof process !== 'undefined' && typeof process.env !== 'undefined' && process.env.NODE_ENV !== 'production' || + // React Native + typeof __DEV__ !== 'undefined' && __DEV__ //eslint-disable-line no-undef + ) { + if (!stateShapeVerified) { + verifyStateShape(state, finalState); + stateShapeVerified = true; + } + } + + return finalState; + }; +} + +module.exports = exports['default']; +}).call(this,require('_process')) +},{"../createStore":166,"../utils/isPlainObject":172,"../utils/mapValues":173,"../utils/pick":174,"_process":1}],171:[function(require,module,exports){ +/** + * Composes functions from left to right. + * + * @param {...Function} funcs - The functions to compose. Each is expected to + * accept a function as an argument and to return a function. + * @returns {Function} A function obtained by composing functions from left to + * right. + */ +"use strict"; + +exports.__esModule = true; +exports["default"] = compose; + +function compose() { + for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { + funcs[_key] = arguments[_key]; + } + + return funcs.reduceRight(function (composed, f) { + return f(composed); + }); +} + +module.exports = exports["default"]; +},{}],172:[function(require,module,exports){ +arguments[4][7][0].apply(exports,arguments) +},{"dup":7}],173:[function(require,module,exports){ +/** + * Applies a function to every key-value pair inside an object. + * + * @param {Object} obj The source object. + * @param {Function} fn The mapper function taht receives the value and the key. + * @returns {Object} A new object that contains the mapped values for the keys. + */ +"use strict"; + +exports.__esModule = true; +exports["default"] = mapValues; + +function mapValues(obj, fn) { + return Object.keys(obj).reduce(function (result, key) { + result[key] = fn(obj[key], key); + return result; + }, {}); +} + +module.exports = exports["default"]; +},{}],174:[function(require,module,exports){ +/** + * Picks key-value pairs from an object where values satisfy a predicate. + * + * @param {Object} obj The object to pick from. + * @param {Function} fn The predicate the values must satisfy to be copied. + * @returns {Object} The object with the values that satisfied the predicate. + */ +"use strict"; + +exports.__esModule = true; +exports["default"] = pick; + +function pick(obj, fn) { + return Object.keys(obj).reduce(function (result, key) { + if (fn(obj[key])) { + result[key] = obj[key]; + } + return result; + }, {}); +} + +module.exports = exports["default"]; +},{}],175:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports['default'] = changedir; + +var _actionsTypes = require('actions/types'); + +function changedir(dir) { + return { + type: _actionsTypes.CHANGE_DIRECTORY, + dir: dir + }; +} + +module.exports = exports['default']; + +},{"actions/types":177}],176:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports['default'] = listFiles; + +var _actionsTypes = require('actions/types'); + +function listFiles(files) { + return { + type: _actionsTypes.LIST_FILES, + files: files + }; +} + +module.exports = exports['default']; + +},{"actions/types":177}],177:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = React.createClass({ - displayName: "root", +var TYPES = { + CHANGE_DIRECTORY: Symbol(), + LIST_FILES: Symbol(), + SORT: Symbol(), + SEARCH: Symbol(), + REFRESH: Symbol() +}; - render: function render() { - return React.createElement("div", null); - } -}); +exports["default"] = TYPES; module.exports = exports["default"]; -},{}],158:[function(require,module,exports){ -// This is the Gaia version of l20n: https://github.com/l20n/l20n.js -// l20n is Apache 2.0 licensed: https://github.com/l20n/l20n.js/blob/master/LICENSE +},{}],178:[function(require,module,exports){ 'use strict'; -(function (window, undefined) { - 'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); - /* jshint validthis:true */ - function L10nError(message, id, loc) { - this.name = 'L10nError'; - this.message = message; - this.id = id; - this.loc = loc; - } - L10nError.prototype = Object.create(Error.prototype); - L10nError.prototype.constructor = L10nError; +var directory = _asyncToGenerator(function* () { + var dir = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0]; - /* jshint browser:true */ + var storage = navigator.getDeviceStorage('sdcard'); + var root = yield storage.getRoot(); - var io = { - load: function load(url, callback, sync) { - var xhr = new XMLHttpRequest(); + if (dir === '/' || !dir) return root; - if (xhr.overrideMimeType) { - xhr.overrideMimeType('text/plain'); - } + return yield root.get(dir); +}); - xhr.open('GET', url, !sync); +exports.directory = directory; - xhr.addEventListener('load', function io_load(e) { - if (e.target.status === 200 || e.target.status === 0) { - callback(null, e.target.responseText); - } else { - callback(new L10nError('Not found: ' + url)); - } - }); - xhr.addEventListener('error', callback); - xhr.addEventListener('timeout', callback); +var children = _asyncToGenerator(function* (dir) { + var parent = yield directory(dir); + return yield parent.getFilesAndDirectories(); +}); - // the app: protocol throws on 404, see https://bugzil.la/827243 - try { - xhr.send(null); - } catch (e) { - callback(new L10nError('Not found: ' + url)); - } - }, +exports.children = children; - loadJSON: function loadJSON(url, callback) { - var xhr = new XMLHttpRequest(); +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(); }); }; } - if (xhr.overrideMimeType) { - xhr.overrideMimeType('application/json'); - } - - xhr.open('GET', url); - - xhr.responseType = 'json'; - xhr.addEventListener('load', function io_loadjson(e) { - if (e.target.status === 200 || e.target.status === 0) { - callback(null, e.target.response); - } else { - callback(new L10nError('Not found: ' + url)); - } - }); - xhr.addEventListener('error', callback); - xhr.addEventListener('timeout', callback); - - // the app: protocol throws on 404, see https://bugzil.la/827243 - try { - xhr.send(null); - } catch (e) { - callback(new L10nError('Not found: ' + url)); - } - } - }; - - function EventEmitter() {} - - EventEmitter.prototype.emit = function ee_emit() { - if (!this._listeners) { - return; - } - - var args = Array.prototype.slice.call(arguments); - var type = args.shift(); - if (!this._listeners[type]) { - return; - } - - var typeListeners = this._listeners[type].slice(); - for (var i = 0; i < typeListeners.length; i++) { - typeListeners[i].apply(this, args); - } - }; - - EventEmitter.prototype.addEventListener = function ee_add(type, listener) { - if (!this._listeners) { - this._listeners = {}; - } - if (!(type in this._listeners)) { - this._listeners[type] = []; - } - this._listeners[type].push(listener); - }; - - EventEmitter.prototype.removeEventListener = function ee_rm(type, listener) { - if (!this._listeners) { - return; - } - - var typeListeners = this._listeners[type]; - var pos = typeListeners.indexOf(listener); - if (pos === -1) { - return; - } - - typeListeners.splice(pos, 1); - }; - - function getPluralRule(lang) { - var locales2rules = { - 'af': 3, - 'ak': 4, - 'am': 4, - 'ar': 1, - 'asa': 3, - 'az': 0, - 'be': 11, - 'bem': 3, - 'bez': 3, - 'bg': 3, - 'bh': 4, - 'bm': 0, - 'bn': 3, - 'bo': 0, - 'br': 20, - 'brx': 3, - 'bs': 11, - 'ca': 3, - 'cgg': 3, - 'chr': 3, - 'cs': 12, - 'cy': 17, - 'da': 3, - 'de': 3, - 'dv': 3, - 'dz': 0, - 'ee': 3, - 'el': 3, - 'en': 3, - 'eo': 3, - 'es': 3, - 'et': 3, - 'eu': 3, - 'fa': 0, - 'ff': 5, - 'fi': 3, - 'fil': 4, - 'fo': 3, - 'fr': 5, - 'fur': 3, - 'fy': 3, - 'ga': 8, - 'gd': 24, - 'gl': 3, - 'gsw': 3, - 'gu': 3, - 'guw': 4, - 'gv': 23, - 'ha': 3, - 'haw': 3, - 'he': 2, - 'hi': 4, - 'hr': 11, - 'hu': 0, - 'id': 0, - 'ig': 0, - 'ii': 0, - 'is': 3, - 'it': 3, - 'iu': 7, - 'ja': 0, - 'jmc': 3, - 'jv': 0, - 'ka': 0, - 'kab': 5, - 'kaj': 3, - 'kcg': 3, - 'kde': 0, - 'kea': 0, - 'kk': 3, - 'kl': 3, - 'km': 0, - 'kn': 0, - 'ko': 0, - 'ksb': 3, - 'ksh': 21, - 'ku': 3, - 'kw': 7, - 'lag': 18, - 'lb': 3, - 'lg': 3, - 'ln': 4, - 'lo': 0, - 'lt': 10, - 'lv': 6, - 'mas': 3, - 'mg': 4, - 'mk': 16, - 'ml': 3, - 'mn': 3, - 'mo': 9, - 'mr': 3, - 'ms': 0, - 'mt': 15, - 'my': 0, - 'nah': 3, - 'naq': 7, - 'nb': 3, - 'nd': 3, - 'ne': 3, - 'nl': 3, - 'nn': 3, - 'no': 3, - 'nr': 3, - 'nso': 4, - 'ny': 3, - 'nyn': 3, - 'om': 3, - 'or': 3, - 'pa': 3, - 'pap': 3, - 'pl': 13, - 'ps': 3, - 'pt': 3, - 'rm': 3, - 'ro': 9, - 'rof': 3, - 'ru': 11, - 'rwk': 3, - 'sah': 0, - 'saq': 3, - 'se': 7, - 'seh': 3, - 'ses': 0, - 'sg': 0, - 'sh': 11, - 'shi': 19, - 'sk': 12, - 'sl': 14, - 'sma': 7, - 'smi': 7, - 'smj': 7, - 'smn': 7, - 'sms': 7, - 'sn': 3, - 'so': 3, - 'sq': 3, - 'sr': 11, - 'ss': 3, - 'ssy': 3, - 'st': 3, - 'sv': 3, - 'sw': 3, - 'syr': 3, - 'ta': 3, - 'te': 3, - 'teo': 3, - 'th': 0, - 'ti': 4, - 'tig': 3, - 'tk': 3, - 'tl': 4, - 'tn': 3, - 'to': 0, - 'tr': 0, - 'ts': 3, - 'tzm': 22, - 'uk': 11, - 'ur': 3, - 've': 3, - 'vi': 0, - 'vun': 3, - 'wa': 4, - 'wae': 3, - 'wo': 0, - 'xh': 3, - 'xog': 3, - 'yo': 0, - 'zh': 0, - 'zu': 3 - }; - - // utility functions for plural rules methods - function isIn(n, list) { - return list.indexOf(n) !== -1; - } - function isBetween(n, start, end) { - return start <= n && n <= end; - } - - // list of all plural rules methods: - // map an integer to the plural form name to use - var pluralRules = { - '0': function _() { - return 'other'; - }, - '1': function _(n) { - if (isBetween(n % 100, 3, 10)) { - return 'few'; - } - if (n === 0) { - return 'zero'; - } - if (isBetween(n % 100, 11, 99)) { - return 'many'; - } - if (n === 2) { - return 'two'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '2': function _(n) { - if (n !== 0 && n % 10 === 0) { - return 'many'; - } - if (n === 2) { - return 'two'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '3': function _(n) { - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '4': function _(n) { - if (isBetween(n, 0, 1)) { - return 'one'; - } - return 'other'; - }, - '5': function _(n) { - if (isBetween(n, 0, 2) && n !== 2) { - return 'one'; - } - return 'other'; - }, - '6': function _(n) { - if (n === 0) { - return 'zero'; - } - if (n % 10 === 1 && n % 100 !== 11) { - return 'one'; - } - return 'other'; - }, - '7': function _(n) { - if (n === 2) { - return 'two'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '8': function _(n) { - if (isBetween(n, 3, 6)) { - return 'few'; - } - if (isBetween(n, 7, 10)) { - return 'many'; - } - if (n === 2) { - return 'two'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '9': function _(n) { - if (n === 0 || n !== 1 && isBetween(n % 100, 1, 19)) { - return 'few'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '10': function _(n) { - if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) { - return 'few'; - } - if (n % 10 === 1 && !isBetween(n % 100, 11, 19)) { - return 'one'; - } - return 'other'; - }, - '11': function _(n) { - if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) { - return 'few'; - } - if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) { - return 'many'; - } - if (n % 10 === 1 && n % 100 !== 11) { - return 'one'; - } - return 'other'; - }, - '12': function _(n) { - if (isBetween(n, 2, 4)) { - return 'few'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '13': function _(n) { - if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) { - return 'few'; - } - if (n !== 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) { - return 'many'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '14': function _(n) { - if (isBetween(n % 100, 3, 4)) { - return 'few'; - } - if (n % 100 === 2) { - return 'two'; - } - if (n % 100 === 1) { - return 'one'; - } - return 'other'; - }, - '15': function _(n) { - if (n === 0 || isBetween(n % 100, 2, 10)) { - return 'few'; - } - if (isBetween(n % 100, 11, 19)) { - return 'many'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '16': function _(n) { - if (n % 10 === 1 && n !== 11) { - return 'one'; - } - return 'other'; - }, - '17': function _(n) { - if (n === 3) { - return 'few'; - } - if (n === 0) { - return 'zero'; - } - if (n === 6) { - return 'many'; - } - if (n === 2) { - return 'two'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '18': function _(n) { - if (n === 0) { - return 'zero'; - } - if (isBetween(n, 0, 2) && n !== 0 && n !== 2) { - return 'one'; - } - return 'other'; - }, - '19': function _(n) { - if (isBetween(n, 2, 10)) { - return 'few'; - } - if (isBetween(n, 0, 1)) { - return 'one'; - } - return 'other'; - }, - '20': function _(n) { - if ((isBetween(n % 10, 3, 4) || n % 10 === 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) { - return 'few'; - } - if (n % 1000000 === 0 && n !== 0) { - return 'many'; - } - if (n % 10 === 2 && !isIn(n % 100, [12, 72, 92])) { - return 'two'; - } - if (n % 10 === 1 && !isIn(n % 100, [11, 71, 91])) { - return 'one'; - } - return 'other'; - }, - '21': function _(n) { - if (n === 0) { - return 'zero'; - } - if (n === 1) { - return 'one'; - } - return 'other'; - }, - '22': function _(n) { - if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) { - return 'one'; - } - return 'other'; - }, - '23': function _(n) { - if (isBetween(n % 10, 1, 2) || n % 20 === 0) { - return 'one'; - } - return 'other'; - }, - '24': function _(n) { - if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) { - return 'few'; - } - if (isIn(n, [2, 12])) { - return 'two'; - } - if (isIn(n, [1, 11])) { - return 'one'; - } - return 'other'; - } - }; - - // return a function that gives the plural form name for a given integer - var index = locales2rules[lang.replace(/-.*$/, '')]; - if (!(index in pluralRules)) { - return function () { - return 'other'; - }; - } - return pluralRules[index]; - } - - var nestedProps = ['style', 'dataset']; - - var parsePatterns; - - function parse(ctx, source) { - var ast = {}; - - if (!parsePatterns) { - parsePatterns = { - comment: /^\s*#|^\s*$/, - entity: /^([^=\s]+)\s*=\s*(.+)$/, - multiline: /[^\\]\\$/, - macro: /\{\[\s*(\w+)\(([^\)]*)\)\s*\]\}/i, - unicode: /\\u([0-9a-fA-F]{1,4})/g, - entries: /[\r\n]+/, - controlChars: /\\([\\\n\r\t\b\f\{\}\"\'])/g - }; - } - - var entries = source.split(parsePatterns.entries); - for (var i = 0; i < entries.length; i++) { - var line = entries[i]; - - if (parsePatterns.comment.test(line)) { - continue; - } - - while (parsePatterns.multiline.test(line) && i < entries.length) { - line = line.slice(0, -1) + entries[++i].trim(); - } - - var entityMatch = line.match(parsePatterns.entity); - if (entityMatch) { - try { - parseEntity(entityMatch[1], entityMatch[2], ast); - } catch (e) { - if (ctx) { - ctx._emitter.emit('error', e); - } else { - throw e; - } - } - } - } - return ast; - } - - function setEntityValue(id, attr, key, value, ast) { - var obj = ast; - var prop = id; - - if (attr) { - if (!(id in obj)) { - obj[id] = {}; - } - if (typeof obj[id] === 'string') { - obj[id] = { '_': obj[id] }; - } - obj = obj[id]; - prop = attr; - } - - if (!key) { - obj[prop] = value; - return; - } - - if (!(prop in obj)) { - obj[prop] = { '_': {} }; - } else if (typeof obj[prop] === 'string') { - obj[prop] = { '_index': parseMacro(obj[prop]), '_': {} }; - } - obj[prop]._[key] = value; - } - - function parseEntity(id, value, ast) { - var name, key; - - var pos = id.indexOf('['); - if (pos !== -1) { - name = id.substr(0, pos); - key = id.substring(pos + 1, id.length - 1); - } else { - name = id; - key = null; - } - - var nameElements = name.split('.'); - - var attr; - if (nameElements.length > 1) { - var attrElements = []; - attrElements.push(nameElements.pop()); - if (nameElements.length > 1) { - // Usually the last dot separates an attribute from an id - // - // In case when there are more than one dot in the id - // and the second to last item is "style" or "dataset" then the last two - // items are becoming the attribute. - // - // ex. - // id.style.color = foo => - // - // id: - // style.color: foo - // - // id.other.color = foo => - // - // id.other: - // color: foo - if (nestedProps.indexOf(nameElements[nameElements.length - 1]) !== -1) { - attrElements.push(nameElements.pop()); - } - } - name = nameElements.join('.'); - attr = attrElements.reverse().join('.'); - } else { - attr = null; - } - - setEntityValue(name, attr, key, unescapeString(value), ast); - } - - function unescapeControlCharacters(str) { - return str.replace(parsePatterns.controlChars, '$1'); - } - - function unescapeUnicode(str) { - return str.replace(parsePatterns.unicode, function (match, token) { - return unescape('%u' + '0000'.slice(token.length) + token); - }); - } - - function unescapeString(str) { - if (str.lastIndexOf('\\') !== -1) { - str = unescapeControlCharacters(str); - } - return unescapeUnicode(str); - } - - function parseMacro(str) { - var match = str.match(parsePatterns.macro); - if (!match) { - throw new L10nError('Malformed macro'); - } - return [match[1], match[2]]; - } - - var MAX_PLACEABLE_LENGTH = 2500; - var MAX_PLACEABLES = 100; - var rePlaceables = /\{\{\s*(.+?)\s*\}\}/g; - - function Entity(id, node, env) { - this.id = id; - this.env = env; - // the dirty guard prevents cyclic or recursive references from other - // Entities; see Entity.prototype.resolve - this.dirty = false; - if (typeof node === 'string') { - this.value = node; - } else { - // it's either a hash or it has attrs, or both - for (var key in node) { - if (node.hasOwnProperty(key) && key[0] !== '_') { - if (!this.attributes) { - this.attributes = {}; - } - this.attributes[key] = new Entity(this.id + '.' + key, node[key], env); - } - } - this.value = node._ || null; - this.index = node._index; - } - } - - Entity.prototype.resolve = function E_resolve(ctxdata) { - if (this.dirty) { - return undefined; - } - - this.dirty = true; - var val; - // if resolve fails, we want the exception to bubble up and stop the whole - // resolving process; however, we still need to clean up the dirty flag - try { - val = resolve(ctxdata, this.env, this.value, this.index); - } finally { - this.dirty = false; - } - return val; - }; - - Entity.prototype.toString = function E_toString(ctxdata) { - try { - return this.resolve(ctxdata); - } catch (e) { - return undefined; - } - }; - - Entity.prototype.valueOf = function E_valueOf(ctxdata) { - if (!this.attributes) { - return this.toString(ctxdata); - } - - var entity = { - value: this.toString(ctxdata), - attributes: {} - }; - - for (var key in this.attributes) { - if (this.attributes.hasOwnProperty(key)) { - entity.attributes[key] = this.attributes[key].toString(ctxdata); - } - } - - return entity; - }; - - function subPlaceable(ctxdata, env, match, id) { - if (ctxdata && ctxdata.hasOwnProperty(id) && (typeof ctxdata[id] === 'string' || typeof ctxdata[id] === 'number' && !isNaN(ctxdata[id]))) { - return ctxdata[id]; - } - - if (env.hasOwnProperty(id)) { - if (!(env[id] instanceof Entity)) { - env[id] = new Entity(id, env[id], env); - } - var value = env[id].resolve(ctxdata); - if (typeof value === 'string') { - // prevent Billion Laughs attacks - if (value.length >= MAX_PLACEABLE_LENGTH) { - throw new L10nError('Too many characters in placeable (' + value.length + ', max allowed is ' + MAX_PLACEABLE_LENGTH + ')'); - } - return value; - } - } - return match; - } - - function interpolate(ctxdata, env, str) { - var placeablesCount = 0; - var value = str.replace(rePlaceables, function (match, id) { - // prevent Quadratic Blowup attacks - if (placeablesCount++ >= MAX_PLACEABLES) { - throw new L10nError('Too many placeables (' + placeablesCount + ', max allowed is ' + MAX_PLACEABLES + ')'); - } - return subPlaceable(ctxdata, env, match, id); - }); - placeablesCount = 0; - return value; - } - - function resolve(_x, _x2, _x3, _x4) { - var _again = true; - - _function: while (_again) { - var ctxdata = _x, - env = _x2, - expr = _x3, - index = _x4; - argValue = selector = undefined; - _again = false; - - if (typeof expr === 'string') { - return interpolate(ctxdata, env, expr); - } - - if (typeof expr === 'boolean' || typeof expr === 'number' || !expr) { - return expr; - } - - // otherwise, it's a dict - - if (index && ctxdata && ctxdata.hasOwnProperty(index[1])) { - var argValue = ctxdata[index[1]]; - - // special cases for zero, one, two if they are defined on the hash - if (argValue === 0 && 'zero' in expr) { - _x = ctxdata; - _x2 = env; - _x3 = expr.zero; - _x4 = undefined; - _again = true; - continue _function; - } - if (argValue === 1 && 'one' in expr) { - _x = ctxdata; - _x2 = env; - _x3 = expr.one; - _x4 = undefined; - _again = true; - continue _function; - } - if (argValue === 2 && 'two' in expr) { - _x = ctxdata; - _x2 = env; - _x3 = expr.two; - _x4 = undefined; - _again = true; - continue _function; - } - - var selector = env.__plural(argValue); - if (expr.hasOwnProperty(selector)) { - _x = ctxdata; - _x2 = env; - _x3 = expr[selector]; - _x4 = undefined; - _again = true; - continue _function; - } - } - - // if there was no index or no selector was found, try 'other' - if ('other' in expr) { - _x = ctxdata; - _x2 = env; - _x3 = expr.other; - _x4 = undefined; - _again = true; - continue _function; - } - - return undefined; - } - } - - function compile(env, ast) { - env = env || {}; - for (var id in ast) { - if (ast.hasOwnProperty(id)) { - env[id] = new Entity(id, ast[id], env); - } - } - return env; - } - - function Locale(id, ctx) { - this.id = id; - this.ctx = ctx; - this.isReady = false; - this.entries = { - __plural: getPluralRule(id) - }; - } - - Locale.prototype.getEntry = function L_getEntry(id) { - /* jshint -W093 */ - - var entries = this.entries; - - if (!entries.hasOwnProperty(id)) { - return undefined; - } - - if (entries[id] instanceof Entity) { - return entries[id]; - } - - return entries[id] = new Entity(id, entries[id], entries); - }; - - Locale.prototype.build = function L_build(callback) { - var sync = !callback; - var ctx = this.ctx; - var self = this; - - var l10nLoads = ctx.resLinks.length; - - function onL10nLoaded(err) { - if (err) { - ctx._emitter.emit('error', err); - } - if (--l10nLoads <= 0) { - self.isReady = true; - if (callback) { - callback(); - } - } - } - - if (l10nLoads === 0) { - onL10nLoaded(); - return; - } - - function onJSONLoaded(err, json) { - if (!err && json) { - self.addAST(json); - } - onL10nLoaded(err); - } - - function onPropLoaded(err, source) { - if (!err && source) { - var ast = parse(ctx, source); - self.addAST(ast); - } - onL10nLoaded(err); - } - - for (var i = 0; i < ctx.resLinks.length; i++) { - var path = ctx.resLinks[i].replace('{{locale}}', this.id); - var type = path.substr(path.lastIndexOf('.') + 1); - - switch (type) { - case 'json': - io.loadJSON(path, onJSONLoaded, sync); - break; - case 'properties': - io.load(path, onPropLoaded, sync); - break; - } - } - }; - - Locale.prototype.addAST = function (ast) { - for (var id in ast) { - if (ast.hasOwnProperty(id)) { - this.entries[id] = ast[id]; - } - } - }; - - Locale.prototype.getEntity = function (id, ctxdata) { - var entry = this.getEntry(id); - - if (!entry) { - return null; - } - return entry.valueOf(ctxdata); - }; - - function Context(id) { - - this.id = id; - this.isReady = false; - this.isLoading = false; - - this.supportedLocales = []; - this.resLinks = []; - this.locales = {}; - - this._emitter = new EventEmitter(); - - // Getting translations - - function getWithFallback(id) { - /* jshint -W084 */ - - if (!this.isReady) { - throw new L10nError('Context not ready'); - } - - var cur = 0; - var loc; - var locale; - while (loc = this.supportedLocales[cur]) { - locale = this.getLocale(loc); - if (!locale.isReady) { - // build without callback, synchronously - locale.build(null); - } - var entry = locale.getEntry(id); - if (entry === undefined) { - cur++; - warning.call(this, new L10nError(id + ' not found in ' + loc, id, loc)); - continue; - } - return entry; - } - - error.call(this, new L10nError(id + ' not found', id)); - return null; - } - - this.get = function get(id, ctxdata) { - var entry = getWithFallback.call(this, id); - if (entry === null) { - return ''; - } - - return entry.toString(ctxdata) || ''; - }; - - this.getEntity = function getEntity(id, ctxdata) { - var entry = getWithFallback.call(this, id); - if (entry === null) { - return null; - } - - return entry.valueOf(ctxdata); - }; - - // Helpers - - this.getLocale = function getLocale(code) { - /* jshint -W093 */ - - var locales = this.locales; - if (locales[code]) { - return locales[code]; - } - - return locales[code] = new Locale(code, this); - }; - - // Getting ready - - function negotiate(available, requested, defaultLocale) { - if (available.indexOf(requested[0]) === -1 || requested[0] === defaultLocale) { - return [defaultLocale]; - } else { - return [requested[0], defaultLocale]; - } - } - - function freeze(supported) { - var locale = this.getLocale(supported[0]); - if (locale.isReady) { - setReady.call(this, supported); - } else { - locale.build(setReady.bind(this, supported)); - } - } - - function setReady(supported) { - this.supportedLocales = supported; - this.isReady = true; - this._emitter.emit('ready'); - } - - this.requestLocales = function requestLocales() { - if (this.isLoading && !this.isReady) { - throw new L10nError('Context not ready'); - } - - this.isLoading = true; - var requested = Array.prototype.slice.call(arguments); - - var supported = negotiate(requested.concat('en-US'), requested, 'en-US'); - freeze.call(this, supported); - }; - - // Events - - this.addEventListener = function addEventListener(type, listener) { - this._emitter.addEventListener(type, listener); - }; - - this.removeEventListener = function removeEventListener(type, listener) { - this._emitter.removeEventListener(type, listener); - }; - - this.ready = function ready(callback) { - if (this.isReady) { - setTimeout(callback); - } - this.addEventListener('ready', callback); - }; - - this.once = function once(callback) { - /* jshint -W068 */ - if (this.isReady) { - setTimeout(callback); - return; - } - - var callAndRemove = (function () { - this.removeEventListener('ready', callAndRemove); - callback(); - }).bind(this); - this.addEventListener('ready', callAndRemove); - }; - - // Errors - - function warning(e) { - this._emitter.emit('warning', e); - return e; - } - - function error(e) { - this._emitter.emit('error', e); - return e; - } - } - - /* jshint -W104 */ - - var DEBUG = false; - var isPretranslated = false; - var rtlList = ['ar', 'he', 'fa', 'ps', 'qps-plocm', 'ur']; - - // Public API - - navigator.mozL10n = Object.defineProperties({ - ctx: new Context(), - get: function get(id, ctxdata) { - return navigator.mozL10n.ctx.get(id, ctxdata); - }, - localize: function localize(element, id, args) { - return localizeElement.call(navigator.mozL10n, element, id, args); - }, - translate: function translate(element) { - return translateFragment.call(navigator.mozL10n, element); - }, - ready: function ready(callback) { - return navigator.mozL10n.ctx.ready(callback); - }, - once: function once(callback) { - return navigator.mozL10n.ctx.once(callback); - }, - - language: Object.defineProperties({}, { - code: { - set: function set(lang) { - navigator.mozL10n.ctx.requestLocales(lang); - }, - get: function get() { - return navigator.mozL10n.ctx.supportedLocales[0]; - }, - configurable: true, - enumerable: true - }, - direction: { - get: function get() { - return getDirection(navigator.mozL10n.ctx.supportedLocales[0]); - }, - configurable: true, - enumerable: true - } - }), - _getInternalAPI: function _getInternalAPI() { - return { - Error: L10nError, - Context: Context, - Locale: Locale, - Entity: Entity, - getPluralRule: getPluralRule, - rePlaceables: rePlaceables, - getTranslatableChildren: getTranslatableChildren, - getL10nAttributes: getL10nAttributes, - loadINI: loadINI, - fireLocalizedEvent: fireLocalizedEvent, - parse: parse, - compile: compile - }; - } - }, { - readyState: { - get: function get() { - return navigator.mozL10n.ctx.isReady ? 'complete' : 'loading'; - }, - configurable: true, - enumerable: true - } - }); - - navigator.mozL10n.ctx.ready(onReady.bind(navigator.mozL10n)); - - if (DEBUG) { - navigator.mozL10n.ctx.addEventListener('error', console.error); - navigator.mozL10n.ctx.addEventListener('warning', console.warn); - } - - function getDirection(lang) { - return rtlList.indexOf(lang) >= 0 ? 'rtl' : 'ltr'; - } - - var readyStates = { - 'loading': 0, - 'interactive': 1, - 'complete': 2 - }; - - function waitFor(state, callback) { - state = readyStates[state]; - if (readyStates[document.readyState] >= state) { - callback(); - return; - } - - document.addEventListener('readystatechange', function l10n_onrsc() { - if (readyStates[document.readyState] >= state) { - document.removeEventListener('readystatechange', l10n_onrsc); - callback(); - } - }); - } - - if (window.document) { - isPretranslated = document.documentElement.lang === navigator.language; - - // this is a special case for netError bug; see https://bugzil.la/444165 - if (document.documentElement.dataset.noCompleteBug) { - pretranslate.call(navigator.mozL10n); - return; - } - - if (isPretranslated) { - waitFor('interactive', function () { - window.setTimeout(initResources.bind(navigator.mozL10n)); - }); - } else { - if (document.readyState === 'complete') { - window.setTimeout(initResources.bind(navigator.mozL10n)); - } else { - waitFor('interactive', pretranslate.bind(navigator.mozL10n)); - } - } - } - - function pretranslate() { - /* jshint -W068 */ - if (inlineLocalization.call(this)) { - waitFor('interactive', (function () { - window.setTimeout(initResources.bind(this)); - }).bind(this)); - } else { - initResources.call(this); - } - } - - function inlineLocalization() { - var script = document.documentElement.querySelector('script[type="application/l10n"]' + '[lang="' + navigator.language + '"]'); - if (!script) { - return false; - } - - var locale = this.ctx.getLocale(navigator.language); - // the inline localization is happenning very early, when the ctx is not - // yet ready and when the resources haven't been downloaded yet; add the - // inlined JSON directly to the current locale - locale.addAST(JSON.parse(script.innerHTML)); - // localize the visible DOM - var l10n = { - ctx: locale, - language: { - code: locale.id, - direction: getDirection(locale.id) - } - }; - translateFragment.call(l10n); - // the visible DOM is now pretranslated - isPretranslated = true; - return true; - } - - function initResources() { - var resLinks = document.head.querySelectorAll('link[type="application/l10n"]'); - var iniLinks = []; - var i; - - for (i = 0; i < resLinks.length; i++) { - var link = resLinks[i]; - var url = link.getAttribute('href'); - var type = url.substr(url.lastIndexOf('.') + 1); - if (type === 'ini') { - iniLinks.push(url); - } - this.ctx.resLinks.push(url); - } - - var iniLoads = iniLinks.length; - if (iniLoads === 0) { - initLocale.call(this); - return; - } - - function onIniLoaded(err) { - if (err) { - this.ctx._emitter.emit('error', err); - } - if (--iniLoads === 0) { - initLocale.call(this); - } - } - - for (i = 0; i < iniLinks.length; i++) { - loadINI.call(this, iniLinks[i], onIniLoaded.bind(this)); - } - } - - function initLocale() { - this.ctx.requestLocales(navigator.language); - window.addEventListener('languagechange', function l10n_langchange() { - navigator.mozL10n.language.code = navigator.language; - }); - } - - function onReady() { - if (!isPretranslated) { - this.translate(); - } - isPretranslated = false; - - fireLocalizedEvent.call(this); - } - - function fireLocalizedEvent() { - var event = new CustomEvent('localized', { - 'bubbles': false, - 'cancelable': false, - 'detail': { - 'language': this.ctx.supportedLocales[0] - } - }); - window.dispatchEvent(event); - } - - /* jshint -W104 */ - - function loadINI(url, callback) { - var ctx = this.ctx; - io.load(url, function (err, source) { - var pos = ctx.resLinks.indexOf(url); - - if (err) { - // remove the ini link from resLinks - ctx.resLinks.splice(pos, 1); - return callback(err); - } - - if (!source) { - ctx.resLinks.splice(pos, 1); - return callback(new Error('Empty file: ' + url)); - } - - var patterns = parseINI(source, url).resources.map(function (x) { - return x.replace('en-US', '{{locale}}'); - }); - ctx.resLinks.splice.apply(ctx.resLinks, [pos, 1].concat(patterns)); - callback(); - }); - } - - function relativePath(baseUrl, url) { - if (url[0] === '/') { - return url; - } - - var dirs = baseUrl.split('/').slice(0, -1).concat(url.split('/')).filter(function (path) { - return path !== '.'; - }); - - return dirs.join('/'); - } - - var iniPatterns = { - 'section': /^\s*\[(.*)\]\s*$/, - 'import': /^\s*@import\s+url\((.*)\)\s*$/i, - 'entry': /[\r\n]+/ - }; - - function parseINI(source, iniPath) { - var entries = source.split(iniPatterns.entry); - var locales = ['en-US']; - var genericSection = true; - var uris = []; - var match; - - for (var i = 0; i < entries.length; i++) { - var line = entries[i]; - // we only care about en-US resources - if (genericSection && iniPatterns['import'].test(line)) { - match = iniPatterns['import'].exec(line); - var uri = relativePath(iniPath, match[1]); - uris.push(uri); - continue; - } - - // but we need the list of all locales in the ini, too - if (iniPatterns.section.test(line)) { - genericSection = false; - match = iniPatterns.section.exec(line); - locales.push(match[1]); - } - } - return { - locales: locales, - resources: uris - }; - } - - /* jshint -W104 */ - - function translateFragment(element) { - if (!element) { - element = document.documentElement; - document.documentElement.lang = this.language.code; - document.documentElement.dir = this.language.direction; - } - translateElement.call(this, element); - - var nodes = getTranslatableChildren(element); - for (var i = 0; i < nodes.length; i++) { - translateElement.call(this, nodes[i]); - } - } - - function getTranslatableChildren(element) { - return element ? element.querySelectorAll('*[data-l10n-id]') : []; - } - - function localizeElement(element, id, args) { - if (!element) { - return; - } - - if (!id) { - element.removeAttribute('data-l10n-id'); - element.removeAttribute('data-l10n-args'); - setTextContent(element, ''); - return; - } - - element.setAttribute('data-l10n-id', id); - if (args && typeof args === 'object') { - element.setAttribute('data-l10n-args', JSON.stringify(args)); - } else { - element.removeAttribute('data-l10n-args'); - } - - if (this.ctx.isReady) { - translateElement.call(this, element); - } - } - - function getL10nAttributes(element) { - if (!element) { - return {}; - } - - var l10nId = element.getAttribute('data-l10n-id'); - var l10nArgs = element.getAttribute('data-l10n-args'); - - var args = l10nArgs ? JSON.parse(l10nArgs) : null; - - return { id: l10nId, args: args }; - } - - function translateElement(element) { - var l10n = getL10nAttributes(element); - - if (!l10n.id) { - return; - } - - var entity = this.ctx.getEntity(l10n.id, l10n.args); - - if (!entity) { - return; - } - - if (typeof entity === 'string') { - setTextContent(element, entity); - return true; - } - - if (entity.value) { - setTextContent(element, entity.value); - } - - for (var key in entity.attributes) { - if (entity.attributes.hasOwnProperty(key)) { - var attr = entity.attributes[key]; - var pos = key.indexOf('.'); - if (pos !== -1) { - element[key.substr(0, pos)][key.substr(pos + 1)] = attr; - } else if (key === 'ariaLabel') { - element.setAttribute('aria-label', attr); - } else { - element[key] = attr; - } - } - } - - return true; - } - - function setTextContent(element, text) { - // standard case: no element children - if (!element.firstElementChild) { - element.textContent = text; - return; - } - - // this element has element children: replace the content of the first - // (non-blank) child textNode and clear other child textNodes - var found = false; - var reNotBlank = /\S/; - for (var child = element.firstChild; child; child = child.nextSibling) { - if (child.nodeType === Node.TEXT_NODE && reNotBlank.test(child.nodeValue)) { - if (found) { - child.nodeValue = ''; - } else { - child.nodeValue = text; - found = true; - } - } - } - // if no (non-empty) textNode is found, insert a textNode before the - // element's first child. - if (!found) { - element.insertBefore(document.createTextNode(text), element.firstChild); - } - } -})(undefined); -// You can find the latest build for Gaia here: https://github.com/mozilla-b2g/gaia/blob/master/shared/js/l10n.js - -},{}],159:[function(require,module,exports){ +},{}],179:[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); } } }; + +var getFiles = _asyncToGenerator(function* (dir) { + var storage = navigator.getDeviceStorage('sdcard'); + var root = yield storage.get(dir); + + return yield root.getFilesAndDirectories(); +}); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var _componentsRoot = require('components/root'); +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(); }); }; } -var _componentsRoot2 = _interopRequireDefault(_componentsRoot); +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 x = "I'm just testing"; +var _reactRedux = require('react-redux'); -},{"components/root":157,"react":156}]},{},[157,158,159]); +var _file = require('./file'); + +var _file2 = _interopRequireDefault(_file); + +var FileList = (function (_Component) { + _inherits(FileList, _Component); + + function FileList() { + _classCallCheck(this, _FileList); + + _get(Object.getPrototypeOf(_FileList.prototype), 'constructor', this).call(this); + } + + _createClass(FileList, [{ + key: 'render', + value: function render() { + var _props = this.props; + var cwd = _props.cwd; + var files = _props.files; + + var els = files.map(function (file, index) { + return _react2['default'].createElement(_file2['default'], { key: index, index: index, name: file.name }); + }); + + return _react2['default'].createElement( + 'div', + null, + _react2['default'].createElement( + 'strong', + null, + 'cwd: ', + cwd + ), + els + ); + } + }]); + + var _FileList = FileList; + FileList = (0, _reactRedux.connect)(props)(FileList) || FileList; + return FileList; +})(_react.Component); + +exports['default'] = FileList; + +function props(state) { + return { + cwd: state.get('cwd'), + files: state.get('files') + }; +} + +module.exports = exports['default']; + +},{"./file":180,"react":165,"react-redux":5}],180:[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 _store = require('store'); + +var _store2 = _interopRequireDefault(_store); + +var _actionsChangedir = require('actions/changedir'); + +var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir); + +var File = (function (_Component) { + _inherits(File, _Component); + + function File() { + _classCallCheck(this, File); + + _get(Object.getPrototypeOf(File.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(File, [{ + key: 'render', + value: function render() { + return _react2['default'].createElement( + 'div', + { onClick: this.peekInside.bind(this) }, + _react2['default'].createElement( + 'p', + null, + this.props.index, + '. ', + this.props.name + ) + ); + } + }, { + key: 'peekInside', + value: function peekInside() { + var file = _store2['default'].getState().get('files')[this.props.index]; + + console.log(file); + _store2['default'].dispatch((0, _actionsChangedir2['default'])(file.path.slice(1) + file.name)); + } + }]); + + return File; +})(_react.Component); + +exports['default'] = File; +module.exports = exports['default']; + +},{"actions/changedir":175,"react":165,"store":"store"}],181:[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 _componentsFileList = require('components/file-list'); + +var _componentsFileList2 = _interopRequireDefault(_componentsFileList); + +var _actionsChangedir = require('actions/changedir'); + +var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir); + +var _store = require('store'); + +var _store2 = _interopRequireDefault(_store); + +window.store = _store2['default']; +window.changedir = _actionsChangedir2['default']; + +var Root = (function (_Component) { + _inherits(Root, _Component); + + function Root() { + _classCallCheck(this, Root); + + _get(Object.getPrototypeOf(Root.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(Root, [{ + key: 'render', + value: function render() { + return _react2['default'].createElement( + 'div', + null, + 'Hawk!', + _react2['default'].createElement(_componentsFileList2['default'], null) + ); + } + }]); + + return Root; +})(_react.Component); + +exports['default'] = Root; +module.exports = exports['default']; + +},{"actions/changedir":175,"components/file-list":179,"react":165,"store":"store"}],182:[function(require,module,exports){ +'use strict'; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + +var _componentsRoot = require('components/root'); + +var _componentsRoot2 = _interopRequireDefault(_componentsRoot); + +var _store = require('store'); + +var _store2 = _interopRequireDefault(_store); + +var _reactRedux = require('react-redux'); + +var wrapper = document.getElementById('wrapper'); +_react2['default'].render(_react2['default'].createElement( + _reactRedux.Provider, + { store: _store2['default'] }, + function () { + return _react2['default'].createElement(_componentsRoot2['default'], null); + } +), wrapper); + +},{"components/root":181,"react":165,"react-redux":5,"store":"store"}],183:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _immutable = require('immutable'); + +var _immutable2 = _interopRequireDefault(_immutable); + +var _cwd = require('./cwd'); + +var _cwd2 = _interopRequireDefault(_cwd); + +var _files = require('./files'); + +var _files2 = _interopRequireDefault(_files); + +exports['default'] = function (state, action) { + if (state === undefined) state = new _immutable2['default'].Map(); + + return new _immutable2['default'].Map({ + cwd: (0, _cwd2['default'])(state.get('cwd'), action), + files: (0, _files2['default'])(state.get('files'), action) + }); +}; + +module.exports = exports['default']; + +},{"./cwd":184,"./files":185,"immutable":186}],184:[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 _actionsListFiles = require('actions/list-files'); + +var _actionsListFiles2 = _interopRequireDefault(_actionsListFiles); + +var _apiFiles = require('api/files'); + +var _store = require('store'); + +var _store2 = _interopRequireDefault(_store); + +exports['default'] = function (state, action) { + if (state === undefined) state = '/'; + + switch (action.type) { + case _actionsTypes.CHANGE_DIRECTORY: + (0, _apiFiles.children)(action.dir).then(function (files) { + _store2['default'].dispatch((0, _actionsListFiles2['default'])(files)); + }); + return action.dir; + default: + return state; + } +}; + +module.exports = exports['default']; + +},{"actions/list-files":176,"actions/types":177,"api/files":178,"store":"store"}],185:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _actionsTypes = require('actions/types'); + +exports['default'] = function (state, action) { + if (state === undefined) state = []; + + switch (action.type) { + case _actionsTypes.LIST_FILES: + return action.files; + default: + return state; + } +}; + +module.exports = exports['default']; + +},{"actions/types":177}],186:[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) { + 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; + } + 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({}, '@', {}); + 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; + + 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 Immutable; + +})); +},{}],"store":[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +var _redux = require('redux'); + +var _reducersAll = require('reducers/all'); + +var _reducersAll2 = _interopRequireDefault(_reducersAll); + +var _actionsChangedir = require('actions/changedir'); + +var _actionsChangedir2 = _interopRequireDefault(_actionsChangedir); + +var _immutable = require('immutable'); + +var _immutable2 = _interopRequireDefault(_immutable); + +var DEFAULT = new _immutable2['default'].Map({ + dir: '/', + files: [] +}); + +var store = (0, _redux.createStore)(_reducersAll2['default'], DEFAULT); +store.dispatch((0, _actionsChangedir2['default'])(DEFAULT.dir)); + +exports['default'] = store; +module.exports = exports['default']; + +},{"actions/changedir":175,"immutable":186,"reducers/all":183,"redux":167}]},{},[175,176,177,178,179,180,181,182,183,184,185,"store"]); diff --git a/manifest.webapp b/build/manifest.webapp similarity index 62% rename from manifest.webapp rename to build/manifest.webapp index 77d71a5..6a6102c 100644 --- a/manifest.webapp +++ b/build/manifest.webapp @@ -14,7 +14,14 @@ "url": "http://dibaiee.ir" }, "type": "privileged", - "permissions": {}, + "permissions": { + "device-storage:videos": {"access": "readwrite"}, + "device-storage:pictures": {"access": "readwrite"}, + "device-storage:music": {"access": "readwrite"}, + "device-storage:sdcard": {"access": "readwrite"}, + "device-storage:apps": {"access": "readwrite"}, + "webapps-manage": {} + }, "installs_allowed_from": [ "*" ], diff --git a/design/userinterface.sketch b/design/userinterface.sketch new file mode 100644 index 0000000..394b651 Binary files /dev/null and b/design/userinterface.sketch differ diff --git a/package.json b/package.json index cdd5f29..14deaa8 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,8 @@ "browserify": "^11.0.1", "grunt": "^0.4.5", "grunt-browserify": "^4.0.0", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-copy": "^0.8.1", "grunt-contrib-less": "^1.0.1", "grunt-contrib-watch": "^0.6.1", "grunt-fxos": "^0.1.2", diff --git a/src/data/es.properties b/src/data/es.properties deleted file mode 100644 index e076c6a..0000000 --- a/src/data/es.properties +++ /dev/null @@ -1,3 +0,0 @@ -app_title = Aplicación vacía privilegiada -app_description.innerHTML = Esta aplicación está vacía. ¡Lista para que añadas tu código! -message = ¡Hola, mundo! diff --git a/src/data/locales.ini b/src/data/locales.ini deleted file mode 100644 index c73ee6f..0000000 --- a/src/data/locales.ini +++ /dev/null @@ -1,5 +0,0 @@ -@import url(en-US.properties) - -[es] -@import url(es.properties) - diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..f0d774e --- /dev/null +++ b/src/index.html @@ -0,0 +1,13 @@ + + + + + Hawk + + + +
+ + + + diff --git a/src/js/actions/changedir.js b/src/js/actions/changedir.js new file mode 100644 index 0000000..d74f764 --- /dev/null +++ b/src/js/actions/changedir.js @@ -0,0 +1,8 @@ +import { CHANGE_DIRECTORY } from 'actions/types'; + +export default function changedir(dir) { + return { + type: CHANGE_DIRECTORY, + dir + }; +} diff --git a/src/js/actions/list-files.js b/src/js/actions/list-files.js new file mode 100644 index 0000000..aa8aa9e --- /dev/null +++ b/src/js/actions/list-files.js @@ -0,0 +1,8 @@ +import { LIST_FILES } from 'actions/types'; + +export default function listFiles(files) { + return { + type: LIST_FILES, + files + }; +} diff --git a/src/js/actions/types.js b/src/js/actions/types.js new file mode 100644 index 0000000..9174cd6 --- /dev/null +++ b/src/js/actions/types.js @@ -0,0 +1,9 @@ +const TYPES = { + CHANGE_DIRECTORY: Symbol(), + LIST_FILES: Symbol(), + SORT: Symbol(), + SEARCH: Symbol(), + REFRESH: Symbol() +}; + +export default TYPES; diff --git a/src/js/api/files.js b/src/js/api/files.js new file mode 100644 index 0000000..baf2aff --- /dev/null +++ b/src/js/api/files.js @@ -0,0 +1,13 @@ +export async function directory(dir = '/') { + let storage = navigator.getDeviceStorage('sdcard'); + let root = await storage.getRoot(); + + if (dir === '/' || !dir) return root; + + return await root.get(dir); +} + +export async function children(dir) { + let parent = await directory(dir); + return await parent.getFilesAndDirectories(); +} diff --git a/src/js/components/file-list.js b/src/js/components/file-list.js new file mode 100644 index 0000000..8d37044 --- /dev/null +++ b/src/js/components/file-list.js @@ -0,0 +1,38 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import File from './file'; + +@connect(props) +export default class FileList extends Component { + constructor() { + super(); + } + + render() { + let { cwd, files } = this.props; + + let els = files.map((file, index) => { + return ; + }); + + return ( +
cwd: {cwd} + {els} +
+ ); + } +} + +function props(state) { + return { + cwd: state.get('cwd'), + files: state.get('files') + } +} + +async function getFiles(dir) { + let storage = navigator.getDeviceStorage('sdcard'); + let root = await storage.get(dir); + + return await root.getFilesAndDirectories(); +} diff --git a/src/js/components/file.js b/src/js/components/file.js new file mode 100644 index 0000000..6081c45 --- /dev/null +++ b/src/js/components/file.js @@ -0,0 +1,20 @@ +import React, { Component } from 'react'; +import store from 'store'; +import changedir from 'actions/changedir'; + +export default class File extends Component { + render() { + return ( +
+

{this.props.index}. {this.props.name}

+
+ ); + } + + peekInside() { + let file = store.getState().get('files')[this.props.index]; + + console.log(file); + store.dispatch(changedir(file.path.slice(1) + file.name)); + } +} diff --git a/src/js/components/root.js b/src/js/components/root.js index 9430e67..d5e4c8c 100644 --- a/src/js/components/root.js +++ b/src/js/components/root.js @@ -1,5 +1,18 @@ -export default React.createClass({ +import React, { Component } from 'react' +import FileList from 'components/file-list'; +import changedir from 'actions/changedir'; +import store from 'store'; + +window.store = store; +window.changedir = changedir; + +export default class Root extends Component { render() { - return
; + return ( +
+ Hawk! + +
+ ); } -}); +} diff --git a/src/js/main.js b/src/js/main.js index 6ff08f1..079e20a 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -1,2 +1,7 @@ -import Root from 'components/root' -let x = "I'm just testing"; +import React from 'react'; +import Root from 'components/root'; +import store from 'store'; +import { Provider } from 'react-redux'; + +let wrapper = document.getElementById('wrapper'); +React.render({() => }, wrapper); diff --git a/src/js/reducers/all.js b/src/js/reducers/all.js new file mode 100644 index 0000000..9c4678b --- /dev/null +++ b/src/js/reducers/all.js @@ -0,0 +1,10 @@ +import Immutable from 'immutable'; +import cwd from './cwd'; +import files from './files'; + +export default function(state = new Immutable.Map(), action) { + return new Immutable.Map({ + cwd: cwd(state.get('cwd'), action), + files: files(state.get('files'), action) + }); +} diff --git a/src/js/reducers/cwd.js b/src/js/reducers/cwd.js new file mode 100644 index 0000000..9e48939 --- /dev/null +++ b/src/js/reducers/cwd.js @@ -0,0 +1,16 @@ +import { CHANGE_DIRECTORY } from 'actions/types'; +import listFiles from 'actions/list-files'; +import { children } from 'api/files'; +import store from 'store'; + +export default function(state = '/', action) { + switch (action.type) { + case CHANGE_DIRECTORY: + children(action.dir).then(files => { + store.dispatch(listFiles(files)); + }); + return action.dir; + default: + return state; + } +} diff --git a/src/js/reducers/files.js b/src/js/reducers/files.js new file mode 100644 index 0000000..9e64a41 --- /dev/null +++ b/src/js/reducers/files.js @@ -0,0 +1,10 @@ +import { LIST_FILES } from 'actions/types'; + +export default function(state = [], action) { + switch (action.type) { + case LIST_FILES: + return action.files; + default: + return state; + } +} diff --git a/src/js/store.js b/src/js/store.js new file mode 100644 index 0000000..2f92cbf --- /dev/null +++ b/src/js/store.js @@ -0,0 +1,14 @@ +import { createStore } from 'redux'; +import reducers from 'reducers/all'; +import changedir from 'actions/changedir'; +import Immutable from 'immutable'; + +const DEFAULT = new Immutable.Map({ + dir: '/', + files: [] +}); + +let store = createStore(reducers, DEFAULT); +store.dispatch(changedir(DEFAULT.dir)); + +export default store; diff --git a/src/less/main.less b/src/less/main.less new file mode 100644 index 0000000..e69de29 diff --git a/src/less/variables.less b/src/less/variables.less new file mode 100644 index 0000000..59c227c --- /dev/null +++ b/src/less/variables.less @@ -0,0 +1 @@ +@ diff --git a/src/manifest.webapp b/src/manifest.webapp new file mode 100644 index 0000000..6a6102c --- /dev/null +++ b/src/manifest.webapp @@ -0,0 +1,31 @@ +{ + "version": "0.1.0", + "name": "Hawk", + "description": "Keep an eye on your files with a full-featured file-manager", + "launch_path": "/index.html", + "icons": { + "16": "/img/icons/icon16x16.png", + "48": "/img/icons/icon48x48.png", + "60": "/img/icons/icon60x60.png", + "128": "/img/icons/icon128x128.png" + }, + "developer": { + "name": "Mahdi Dibaiee", + "url": "http://dibaiee.ir" + }, + "type": "privileged", + "permissions": { + "device-storage:videos": {"access": "readwrite"}, + "device-storage:pictures": {"access": "readwrite"}, + "device-storage:music": {"access": "readwrite"}, + "device-storage:sdcard": {"access": "readwrite"}, + "device-storage:apps": {"access": "readwrite"}, + "webapps-manage": {} + }, + "installs_allowed_from": [ + "*" + ], + "locales": { + }, + "default_locale": "en" +}