Skip to content

Instantly share code, notes, and snippets.

@ceremcem
Created September 1, 2020 12:22
Show Gist options
  • Save ceremcem/f378161ac6a3c9a224567b6e06c7080c to your computer and use it in GitHub Desktop.
Save ceremcem/f378161ac6a3c9a224567b6e06c7080c to your computer and use it in GitHub Desktop.
template.ls bundled with Rollup (has a problem)
This file has been truncated, but you can view the full file.
'use strict';
var util = require('util');
var os = require('os');
var buffer = require('buffer');
var crypto = require('crypto');
var tty = require('tty');
var fs$1 = require('fs');
var net = require('net');
var ractive = require('ractive');
var path = require('path');
var preludeLs = require('prelude-ls');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
var buffer__default = /*#__PURE__*/_interopDefaultLegacy(buffer);
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
var tty__default = /*#__PURE__*/_interopDefaultLegacy(tty);
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
var net__default = /*#__PURE__*/_interopDefaultLegacy(net);
var ractive__default = /*#__PURE__*/_interopDefaultLegacy(ractive);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var preludeLs__default = /*#__PURE__*/_interopDefaultLegacy(preludeLs);
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function (path, base) {
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function getCjsExportFromNamespace (n) {
return n && n['default'] || n;
}
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}
var styles_1 = createCommonjsModule(function (module) {
/*
The MIT License (MIT)
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
var styles = {};
module['exports'] = styles;
var codes = {
reset: [0, 0],
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29],
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39],
grey: [90, 39],
brightRed: [91, 39],
brightGreen: [92, 39],
brightYellow: [93, 39],
brightBlue: [94, 39],
brightMagenta: [95, 39],
brightCyan: [96, 39],
brightWhite: [97, 39],
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
bgGray: [100, 49],
bgGrey: [100, 49],
bgBrightRed: [101, 49],
bgBrightGreen: [102, 49],
bgBrightYellow: [103, 49],
bgBrightBlue: [104, 49],
bgBrightMagenta: [105, 49],
bgBrightCyan: [106, 49],
bgBrightWhite: [107, 49],
// legacy styles for colors pre v1.0.0
blackBG: [40, 49],
redBG: [41, 49],
greenBG: [42, 49],
yellowBG: [43, 49],
blueBG: [44, 49],
magentaBG: [45, 49],
cyanBG: [46, 49],
whiteBG: [47, 49],
};
Object.keys(codes).forEach(function(key) {
var val = codes[key];
var style = styles[key] = [];
style.open = '\u001b[' + val[0] + 'm';
style.close = '\u001b[' + val[1] + 'm';
});
});
/*
MIT License
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var hasFlag = function(flag, argv) {
argv = argv || process.argv;
var terminatorPos = argv.indexOf('--');
var prefix = /^-{1,2}/.test(flag) ? '' : '--';
var pos = argv.indexOf(prefix + flag);
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
};
var env = process.env;
var forceColor = void 0;
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
forceColor = false;
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true')
|| hasFlag('color=always')) {
forceColor = true;
}
if ('FORCE_COLOR' in env) {
forceColor = env.FORCE_COLOR.length === 0
|| parseInt(env.FORCE_COLOR, 10) !== 0;
}
function translateLevel(level) {
if (level === 0) {
return false;
}
return {
level: level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3,
};
}
function supportsColor(stream) {
if (forceColor === false) {
return 0;
}
if (hasFlag('color=16m') || hasFlag('color=full')
|| hasFlag('color=truecolor')) {
return 3;
}
if (hasFlag('color=256')) {
return 2;
}
if (stream && !stream.isTTY && forceColor !== true) {
return 0;
}
var min = forceColor ? 1 : 0;
if (process.platform === 'win32') {
// Node.js 7.5.0 is the first version of Node.js to include a patch to
// libuv that enables 256 color output on Windows. Anything earlier and it
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
// release, and Node.js 7 is not. Windows 10 build 10586 is the first
// Windows release that supports 256 colors. Windows 10 build 14931 is the
// first release that supports 16m/TrueColor.
var osRelease = os__default['default'].release().split('.');
if (Number(process.versions.node.split('.')[0]) >= 8
&& Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
return Number(osRelease[2]) >= 14931 ? 3 : 2;
}
return 1;
}
if ('CI' in env) {
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) {
return sign in env;
}) || env.CI_NAME === 'codeship') {
return 1;
}
return min;
}
if ('TEAMCITY_VERSION' in env) {
return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0
);
}
if ('TERM_PROGRAM' in env) {
var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
switch (env.TERM_PROGRAM) {
case 'iTerm.app':
return version >= 3 ? 3 : 2;
case 'Hyper':
return 3;
case 'Apple_Terminal':
return 2;
// No default
}
}
if (/-256(color)?$/i.test(env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
return 1;
}
if ('COLORTERM' in env) {
return 1;
}
if (env.TERM === 'dumb') {
return min;
}
return min;
}
function getSupportLevel(stream) {
var level = supportsColor(stream);
return translateLevel(level);
}
var supportsColors = {
supportsColor: getSupportLevel,
stdout: getSupportLevel(process.stdout),
stderr: getSupportLevel(process.stderr),
};
var trap = createCommonjsModule(function (module) {
module['exports'] = function runTheTrap(text, options) {
var result = '';
text = text || 'Run the trap, drop the bass';
text = text.split('');
var trap = {
a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'],
b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'],
c: ['\u00a9', '\u023b', '\u03fe'],
d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'],
e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc',
'\u0a6c'],
f: ['\u04fa'],
g: ['\u0262'],
h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'],
i: ['\u0f0f'],
j: ['\u0134'],
k: ['\u0138', '\u04a0', '\u04c3', '\u051e'],
l: ['\u0139'],
m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'],
n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'],
o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd',
'\u06dd', '\u0e4f'],
p: ['\u01f7', '\u048e'],
q: ['\u09cd'],
r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'],
s: ['\u00a7', '\u03de', '\u03df', '\u03e8'],
t: ['\u0141', '\u0166', '\u0373'],
u: ['\u01b1', '\u054d'],
v: ['\u05d8'],
w: ['\u0428', '\u0460', '\u047c', '\u0d70'],
x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'],
y: ['\u00a5', '\u04b0', '\u04cb'],
z: ['\u01b5', '\u0240'],
};
text.forEach(function(c) {
c = c.toLowerCase();
var chars = trap[c] || [' '];
var rand = Math.floor(Math.random() * chars.length);
if (typeof trap[c] !== 'undefined') {
result += trap[c][rand];
} else {
result += c;
}
});
return result;
};
});
var zalgo = createCommonjsModule(function (module) {
// please no
module['exports'] = function zalgo(text, options) {
text = text || ' he is here ';
var soul = {
'up': [
'̍', '̎', '̄', '̅',
'̿', '̑', '̆', '̐',
'͒', '͗', '͑', '̇',
'̈', '̊', '͂', '̓',
'̈', '͊', '͋', '͌',
'̃', '̂', '̌', '͐',
'̀', '́', '̋', '̏',
'̒', '̓', '̔', '̽',
'̉', 'ͣ', 'ͤ', 'ͥ',
'ͦ', 'ͧ', 'ͨ', 'ͩ',
'ͪ', 'ͫ', 'ͬ', 'ͭ',
'ͮ', 'ͯ', '̾', '͛',
'͆', '̚',
],
'down': [
'̖', '̗', '̘', '̙',
'̜', '̝', '̞', '̟',
'̠', '̤', '̥', '̦',
'̩', '̪', '̫', '̬',
'̭', '̮', '̯', '̰',
'̱', '̲', '̳', '̹',
'̺', '̻', '̼', 'ͅ',
'͇', '͈', '͉', '͍',
'͎', '͓', '͔', '͕',
'͖', '͙', '͚', '̣',
],
'mid': [
'̕', '̛', '̀', '́',
'͘', '̡', '̢', '̧',
'̨', '̴', '̵', '̶',
'͜', '͝', '͞',
'͟', '͠', '͢', '̸',
'̷', '͡', ' ҉',
],
};
var all = [].concat(soul.up, soul.down, soul.mid);
function randomNumber(range) {
var r = Math.floor(Math.random() * range);
return r;
}
function isChar(character) {
var bool = false;
all.filter(function(i) {
bool = (i === character);
});
return bool;
}
function heComes(text, options) {
var result = '';
var counts;
var l;
options = options || {};
options['up'] =
typeof options['up'] !== 'undefined' ? options['up'] : true;
options['mid'] =
typeof options['mid'] !== 'undefined' ? options['mid'] : true;
options['down'] =
typeof options['down'] !== 'undefined' ? options['down'] : true;
options['size'] =
typeof options['size'] !== 'undefined' ? options['size'] : 'maxi';
text = text.split('');
for (l in text) {
if (isChar(l)) {
continue;
}
result = result + text[l];
counts = {'up': 0, 'down': 0, 'mid': 0};
switch (options.size) {
case 'mini':
counts.up = randomNumber(8);
counts.mid = randomNumber(2);
counts.down = randomNumber(8);
break;
case 'maxi':
counts.up = randomNumber(16) + 3;
counts.mid = randomNumber(4) + 1;
counts.down = randomNumber(64) + 3;
break;
default:
counts.up = randomNumber(8) + 1;
counts.mid = randomNumber(6) / 2;
counts.down = randomNumber(8) + 1;
break;
}
var arr = ['up', 'mid', 'down'];
for (var d in arr) {
var index = arr[d];
for (var i = 0; i <= counts[index]; i++) {
if (options[index]) {
result = result + soul[index][randomNumber(soul[index].length)];
}
}
}
}
return result;
}
// don't summon him
return heComes(text, options);
};
});
var america = createCommonjsModule(function (module) {
module['exports'] = function(colors) {
return function(letter, i, exploded) {
if (letter === ' ') return letter;
switch (i%3) {
case 0: return colors.red(letter);
case 1: return colors.white(letter);
case 2: return colors.blue(letter);
}
};
};
});
var zebra = createCommonjsModule(function (module) {
module['exports'] = function(colors) {
return function(letter, i, exploded) {
return i % 2 === 0 ? letter : colors.inverse(letter);
};
};
});
var rainbow = createCommonjsModule(function (module) {
module['exports'] = function(colors) {
// RoY G BiV
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
return function(letter, i, exploded) {
if (letter === ' ') {
return letter;
} else {
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
}
};
};
});
var random = createCommonjsModule(function (module) {
module['exports'] = function(colors) {
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta'];
return function(letter, i, exploded) {
return letter === ' ' ? letter :
colors[
available[Math.round(Math.random() * (available.length - 2))]
](letter);
};
};
});
var colors_1 = createCommonjsModule(function (module) {
/*
The MIT License (MIT)
Original Library
- Copyright (c) Marak Squires
Additional functionality
- Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
var colors = {};
module['exports'] = colors;
colors.themes = {};
var ansiStyles = colors.styles = styles_1;
var defineProps = Object.defineProperties;
var newLineRegex = new RegExp(/[\r\n]+/g);
colors.supportsColor = supportsColors.supportsColor;
if (typeof colors.enabled === 'undefined') {
colors.enabled = colors.supportsColor() !== false;
}
colors.enable = function() {
colors.enabled = true;
};
colors.disable = function() {
colors.enabled = false;
};
colors.stripColors = colors.strip = function(str) {
return ('' + str).replace(/\x1B\[\d+m/g, '');
};
// eslint-disable-next-line no-unused-vars
var stylize = colors.stylize = function stylize(str, style) {
if (!colors.enabled) {
return str+'';
}
var styleMap = ansiStyles[style];
// Stylize should work for non-ANSI styles, too
if(!styleMap && style in colors){
// Style maps like trap operate as functions on strings;
// they don't have properties like open or close.
return colors[style](str);
}
return styleMap.open + str + styleMap.close;
};
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
var escapeStringRegexp = function(str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(matchOperatorsRe, '\\$&');
};
function build(_styles) {
var builder = function builder() {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
builder.__proto__ = proto;
return builder;
}
var styles = (function() {
var ret = {};
ansiStyles.grey = ansiStyles.gray;
Object.keys(ansiStyles).forEach(function(key) {
ansiStyles[key].closeRe =
new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function() {
return build(this._styles.concat(key));
},
};
});
return ret;
})();
var proto = defineProps(function colors() {}, styles);
function applyStyle() {
var args = Array.prototype.slice.call(arguments);
var str = args.map(function(arg) {
// Use weak equality check so we can colorize null/undefined in safe mode
if (arg != null && arg.constructor === String) {
return arg;
} else {
return util__default['default'].inspect(arg);
}
}).join(' ');
if (!colors.enabled || !str) {
return str;
}
var newLinesPresent = str.indexOf('\n') != -1;
var nestedStyles = this._styles;
var i = nestedStyles.length;
while (i--) {
var code = ansiStyles[nestedStyles[i]];
str = code.open + str.replace(code.closeRe, code.open) + code.close;
if (newLinesPresent) {
str = str.replace(newLineRegex, function(match) {
return code.close + match + code.open;
});
}
}
return str;
}
colors.setTheme = function(theme) {
if (typeof theme === 'string') {
console.log('colors.setTheme now only accepts an object, not a string. ' +
'If you are trying to set a theme from a file, it is now your (the ' +
'caller\'s) responsibility to require the file. The old syntax ' +
'looked like colors.setTheme(__dirname + ' +
'\'/../themes/generic-logging.js\'); The new syntax looks like '+
'colors.setTheme(require(__dirname + ' +
'\'/../themes/generic-logging.js\'));');
return;
}
for (var style in theme) {
(function(style) {
colors[style] = function(str) {
if (typeof theme[style] === 'object') {
var out = str;
for (var i in theme[style]) {
out = colors[theme[style][i]](out);
}
return out;
}
return colors[theme[style]](str);
};
})(style);
}
};
function init() {
var ret = {};
Object.keys(styles).forEach(function(name) {
ret[name] = {
get: function() {
return build([name]);
},
};
});
return ret;
}
var sequencer = function sequencer(map, str) {
var exploded = str.split('');
exploded = exploded.map(map);
return exploded.join('');
};
// custom formatter methods
colors.trap = trap;
colors.zalgo = zalgo;
// maps
colors.maps = {};
colors.maps.america = america(colors);
colors.maps.zebra = zebra(colors);
colors.maps.rainbow = rainbow(colors);
colors.maps.random = random(colors);
for (var map in colors.maps) {
(function(map) {
colors[map] = function(str) {
return sequencer(colors.maps[map], str);
};
})(map);
}
defineProps(colors, init());
});
var extendStringPrototype = createCommonjsModule(function (module) {
module['exports'] = function() {
//
// Extends prototype of native string object to allow for "foo".red syntax
//
var addProperty = function(color, func) {
String.prototype.__defineGetter__(color, func);
};
addProperty('strip', function() {
return colors_1.strip(this);
});
addProperty('stripColors', function() {
return colors_1.strip(this);
});
addProperty('trap', function() {
return colors_1.trap(this);
});
addProperty('zalgo', function() {
return colors_1.zalgo(this);
});
addProperty('zebra', function() {
return colors_1.zebra(this);
});
addProperty('rainbow', function() {
return colors_1.rainbow(this);
});
addProperty('random', function() {
return colors_1.random(this);
});
addProperty('america', function() {
return colors_1.america(this);
});
//
// Iterate through all default styles and colors
//
var x = Object.keys(colors_1.styles);
x.forEach(function(style) {
addProperty(style, function() {
return colors_1.stylize(this, style);
});
});
function applyTheme(theme) {
//
// Remark: This is a list of methods that exist
// on String that you should not overwrite.
//
var stringPrototypeBlacklist = [
'__defineGetter__', '__defineSetter__', '__lookupGetter__',
'__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty',
'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString',
'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length',
'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice',
'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase',
'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight',
];
Object.keys(theme).forEach(function(prop) {
if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
console.log('warn: '.red + ('String.prototype' + prop).magenta +
' is probably something you don\'t want to override. ' +
'Ignoring style name');
} else {
if (typeof(theme[prop]) === 'string') {
colors_1[prop] = colors_1[theme[prop]];
addProperty(prop, function() {
return colors_1[prop](this);
});
} else {
var themePropApplicator = function(str) {
var ret = str || this;
for (var t = 0; t < theme[prop].length; t++) {
ret = colors_1[theme[prop][t]](ret);
}
return ret;
};
addProperty(prop, themePropApplicator);
colors_1[prop] = function(str) {
return themePropApplicator(str);
};
}
}
});
}
colors_1.setTheme = function(theme) {
if (typeof theme === 'string') {
console.log('colors.setTheme now only accepts an object, not a string. ' +
'If you are trying to set a theme from a file, it is now your (the ' +
'caller\'s) responsibility to require the file. The old syntax ' +
'looked like colors.setTheme(__dirname + ' +
'\'/../themes/generic-logging.js\'); The new syntax looks like '+
'colors.setTheme(require(__dirname + ' +
'\'/../themes/generic-logging.js\'));');
return;
} else {
applyTheme(theme);
}
};
};
});
var lib = createCommonjsModule(function (module) {
module['exports'] = colors_1;
// Remark: By default, colors will add style properties to String.prototype.
//
// If you don't wish to extend String.prototype, you can do this instead and
// native String will not be touched:
//
// var colors = require('colors/safe);
// colors.red("foo")
//
//
extendStringPrototype();
});
var moment = createCommonjsModule(function (module, exports) {
(function (global, factory) {
module.exports = factory() ;
}(commonjsGlobal, (function () {
var hookCallback;
function hooks() {
return hookCallback.apply(null, arguments);
}
// This is done to register the method called with moment()
// without creating circular dependencies.
function setHookCallback(callback) {
hookCallback = callback;
}
function isArray(input) {
return (
input instanceof Array ||
Object.prototype.toString.call(input) === '[object Array]'
);
}
function isObject(input) {
// IE8 will treat undefined and null as object if it wasn't for
// input != null
return (
input != null &&
Object.prototype.toString.call(input) === '[object Object]'
);
}
function hasOwnProp(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
function isObjectEmpty(obj) {
if (Object.getOwnPropertyNames) {
return Object.getOwnPropertyNames(obj).length === 0;
} else {
var k;
for (k in obj) {
if (hasOwnProp(obj, k)) {
return false;
}
}
return true;
}
}
function isUndefined(input) {
return input === void 0;
}
function isNumber(input) {
return (
typeof input === 'number' ||
Object.prototype.toString.call(input) === '[object Number]'
);
}
function isDate(input) {
return (
input instanceof Date ||
Object.prototype.toString.call(input) === '[object Date]'
);
}
function map(arr, fn) {
var res = [],
i;
for (i = 0; i < arr.length; ++i) {
res.push(fn(arr[i], i));
}
return res;
}
function extend(a, b) {
for (var i in b) {
if (hasOwnProp(b, i)) {
a[i] = b[i];
}
}
if (hasOwnProp(b, 'toString')) {
a.toString = b.toString;
}
if (hasOwnProp(b, 'valueOf')) {
a.valueOf = b.valueOf;
}
return a;
}
function createUTC(input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, true).utc();
}
function defaultParsingFlags() {
// We need to deep clone this object.
return {
empty: false,
unusedTokens: [],
unusedInput: [],
overflow: -2,
charsLeftOver: 0,
nullInput: false,
invalidEra: null,
invalidMonth: null,
invalidFormat: false,
userInvalidated: false,
iso: false,
parsedDateParts: [],
era: null,
meridiem: null,
rfc2822: false,
weekdayMismatch: false,
};
}
function getParsingFlags(m) {
if (m._pf == null) {
m._pf = defaultParsingFlags();
}
return m._pf;
}
var some;
if (Array.prototype.some) {
some = Array.prototype.some;
} else {
some = function (fun) {
var t = Object(this),
len = t.length >>> 0,
i;
for (i = 0; i < len; i++) {
if (i in t && fun.call(this, t[i], i, t)) {
return true;
}
}
return false;
};
}
function isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m),
parsedParts = some.call(flags.parsedDateParts, function (i) {
return i != null;
}),
isNowValid =
!isNaN(m._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
!flags.invalidEra &&
!flags.invalidMonth &&
!flags.invalidWeekday &&
!flags.weekdayMismatch &&
!flags.nullInput &&
!flags.invalidFormat &&
!flags.userInvalidated &&
(!flags.meridiem || (flags.meridiem && parsedParts));
if (m._strict) {
isNowValid =
isNowValid &&
flags.charsLeftOver === 0 &&
flags.unusedTokens.length === 0 &&
flags.bigHour === undefined;
}
if (Object.isFrozen == null || !Object.isFrozen(m)) {
m._isValid = isNowValid;
} else {
return isNowValid;
}
}
return m._isValid;
}
function createInvalid(flags) {
var m = createUTC(NaN);
if (flags != null) {
extend(getParsingFlags(m), flags);
} else {
getParsingFlags(m).userInvalidated = true;
}
return m;
}
// Plugins that add properties should also add the key here (null value),
// so we can properly clone ourselves.
var momentProperties = (hooks.momentProperties = []),
updateInProgress = false;
function copyConfig(to, from) {
var i, prop, val;
if (!isUndefined(from._isAMomentObject)) {
to._isAMomentObject = from._isAMomentObject;
}
if (!isUndefined(from._i)) {
to._i = from._i;
}
if (!isUndefined(from._f)) {
to._f = from._f;
}
if (!isUndefined(from._l)) {
to._l = from._l;
}
if (!isUndefined(from._strict)) {
to._strict = from._strict;
}
if (!isUndefined(from._tzm)) {
to._tzm = from._tzm;
}
if (!isUndefined(from._isUTC)) {
to._isUTC = from._isUTC;
}
if (!isUndefined(from._offset)) {
to._offset = from._offset;
}
if (!isUndefined(from._pf)) {
to._pf = getParsingFlags(from);
}
if (!isUndefined(from._locale)) {
to._locale = from._locale;
}
if (momentProperties.length > 0) {
for (i = 0; i < momentProperties.length; i++) {
prop = momentProperties[i];
val = from[prop];
if (!isUndefined(val)) {
to[prop] = val;
}
}
}
return to;
}
// Moment prototype object
function Moment(config) {
copyConfig(this, config);
this._d = new Date(config._d != null ? config._d.getTime() : NaN);
if (!this.isValid()) {
this._d = new Date(NaN);
}
// Prevent infinite loop in case updateOffset creates new moment
// objects.
if (updateInProgress === false) {
updateInProgress = true;
hooks.updateOffset(this);
updateInProgress = false;
}
}
function isMoment(obj) {
return (
obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
);
}
function warn(msg) {
if (
hooks.suppressDeprecationWarnings === false &&
typeof console !== 'undefined' &&
console.warn
) {
console.warn('Deprecation warning: ' + msg);
}
}
function deprecate(msg, fn) {
var firstTime = true;
return extend(function () {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(null, msg);
}
if (firstTime) {
var args = [],
arg,
i,
key;
for (i = 0; i < arguments.length; i++) {
arg = '';
if (typeof arguments[i] === 'object') {
arg += '\n[' + i + '] ';
for (key in arguments[0]) {
if (hasOwnProp(arguments[0], key)) {
arg += key + ': ' + arguments[0][key] + ', ';
}
}
arg = arg.slice(0, -2); // Remove trailing comma and space
} else {
arg = arguments[i];
}
args.push(arg);
}
warn(
msg +
'\nArguments: ' +
Array.prototype.slice.call(args).join('') +
'\n' +
new Error().stack
);
firstTime = false;
}
return fn.apply(this, arguments);
}, fn);
}
var deprecations = {};
function deprecateSimple(name, msg) {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(name, msg);
}
if (!deprecations[name]) {
warn(msg);
deprecations[name] = true;
}
}
hooks.suppressDeprecationWarnings = false;
hooks.deprecationHandler = null;
function isFunction(input) {
return (
(typeof Function !== 'undefined' && input instanceof Function) ||
Object.prototype.toString.call(input) === '[object Function]'
);
}
function set(config) {
var prop, i;
for (i in config) {
if (hasOwnProp(config, i)) {
prop = config[i];
if (isFunction(prop)) {
this[i] = prop;
} else {
this['_' + i] = prop;
}
}
}
this._config = config;
// Lenient ordinal parsing accepts just a number in addition to
// number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
// TODO: Remove "ordinalParse" fallback in next major release.
this._dayOfMonthOrdinalParseLenient = new RegExp(
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
'|' +
/\d{1,2}/.source
);
}
function mergeConfigs(parentConfig, childConfig) {
var res = extend({}, parentConfig),
prop;
for (prop in childConfig) {
if (hasOwnProp(childConfig, prop)) {
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
res[prop] = {};
extend(res[prop], parentConfig[prop]);
extend(res[prop], childConfig[prop]);
} else if (childConfig[prop] != null) {
res[prop] = childConfig[prop];
} else {
delete res[prop];
}
}
}
for (prop in parentConfig) {
if (
hasOwnProp(parentConfig, prop) &&
!hasOwnProp(childConfig, prop) &&
isObject(parentConfig[prop])
) {
// make sure changes to properties don't modify parent config
res[prop] = extend({}, res[prop]);
}
}
return res;
}
function Locale(config) {
if (config != null) {
this.set(config);
}
}
var keys;
if (Object.keys) {
keys = Object.keys;
} else {
keys = function (obj) {
var i,
res = [];
for (i in obj) {
if (hasOwnProp(obj, i)) {
res.push(i);
}
}
return res;
};
}
var defaultCalendar = {
sameDay: '[Today at] LT',
nextDay: '[Tomorrow at] LT',
nextWeek: 'dddd [at] LT',
lastDay: '[Yesterday at] LT',
lastWeek: '[Last] dddd [at] LT',
sameElse: 'L',
};
function calendar(key, mom, now) {
var output = this._calendar[key] || this._calendar['sameElse'];
return isFunction(output) ? output.call(mom, now) : output;
}
function zeroFill(number, targetLength, forceSign) {
var absNumber = '' + Math.abs(number),
zerosToFill = targetLength - absNumber.length,
sign = number >= 0;
return (
(sign ? (forceSign ? '+' : '') : '-') +
Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
absNumber
);
}
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
formatFunctions = {},
formatTokenFunctions = {};
// token: 'M'
// padded: ['MM', 2]
// ordinal: 'Mo'
// callback: function () { this.month() + 1 }
function addFormatToken(token, padded, ordinal, callback) {
var func = callback;
if (typeof callback === 'string') {
func = function () {
return this[callback]();
};
}
if (token) {
formatTokenFunctions[token] = func;
}
if (padded) {
formatTokenFunctions[padded[0]] = function () {
return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
};
}
if (ordinal) {
formatTokenFunctions[ordinal] = function () {
return this.localeData().ordinal(
func.apply(this, arguments),
token
);
};
}
}
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, '');
}
return input.replace(/\\/g, '');
}
function makeFormatFunction(format) {
var array = format.match(formattingTokens),
i,
length;
for (i = 0, length = array.length; i < length; i++) {
if (formatTokenFunctions[array[i]]) {
array[i] = formatTokenFunctions[array[i]];
} else {
array[i] = removeFormattingTokens(array[i]);
}
}
return function (mom) {
var output = '',
i;
for (i = 0; i < length; i++) {
output += isFunction(array[i])
? array[i].call(mom, format)
: array[i];
}
return output;
};
}
// format date using native date object
function formatMoment(m, format) {
if (!m.isValid()) {
return m.localeData().invalidDate();
}
format = expandFormat(format, m.localeData());
formatFunctions[format] =
formatFunctions[format] || makeFormatFunction(format);
return formatFunctions[format](m);
}
function expandFormat(format, locale) {
var i = 5;
function replaceLongDateFormatTokens(input) {
return locale.longDateFormat(input) || input;
}
localFormattingTokens.lastIndex = 0;
while (i >= 0 && localFormattingTokens.test(format)) {
format = format.replace(
localFormattingTokens,
replaceLongDateFormatTokens
);
localFormattingTokens.lastIndex = 0;
i -= 1;
}
return format;
}
var defaultLongDateFormat = {
LTS: 'h:mm:ss A',
LT: 'h:mm A',
L: 'MM/DD/YYYY',
LL: 'MMMM D, YYYY',
LLL: 'MMMM D, YYYY h:mm A',
LLLL: 'dddd, MMMM D, YYYY h:mm A',
};
function longDateFormat(key) {
var format = this._longDateFormat[key],
formatUpper = this._longDateFormat[key.toUpperCase()];
if (format || !formatUpper) {
return format;
}
this._longDateFormat[key] = formatUpper
.match(formattingTokens)
.map(function (tok) {
if (
tok === 'MMMM' ||
tok === 'MM' ||
tok === 'DD' ||
tok === 'dddd'
) {
return tok.slice(1);
}
return tok;
})
.join('');
return this._longDateFormat[key];
}
var defaultInvalidDate = 'Invalid date';
function invalidDate() {
return this._invalidDate;
}
var defaultOrdinal = '%d',
defaultDayOfMonthOrdinalParse = /\d{1,2}/;
function ordinal(number) {
return this._ordinal.replace('%d', number);
}
var defaultRelativeTime = {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
ss: '%d seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
w: 'a week',
ww: '%d weeks',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years',
};
function relativeTime(number, withoutSuffix, string, isFuture) {
var output = this._relativeTime[string];
return isFunction(output)
? output(number, withoutSuffix, string, isFuture)
: output.replace(/%d/i, number);
}
function pastFuture(diff, output) {
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
}
var aliases = {};
function addUnitAlias(unit, shorthand) {
var lowerCase = unit.toLowerCase();
aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
}
function normalizeUnits(units) {
return typeof units === 'string'
? aliases[units] || aliases[units.toLowerCase()]
: undefined;
}
function normalizeObjectUnits(inputObject) {
var normalizedInput = {},
normalizedProp,
prop;
for (prop in inputObject) {
if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
}
}
}
return normalizedInput;
}
var priorities = {};
function addUnitPriority(unit, priority) {
priorities[unit] = priority;
}
function getPrioritizedUnits(unitsObj) {
var units = [],
u;
for (u in unitsObj) {
if (hasOwnProp(unitsObj, u)) {
units.push({ unit: u, priority: priorities[u] });
}
}
units.sort(function (a, b) {
return a.priority - b.priority;
});
return units;
}
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}
function absFloor(number) {
if (number < 0) {
// -0 -> 0
return Math.ceil(number) || 0;
} else {
return Math.floor(number);
}
}
function toInt(argumentForCoercion) {
var coercedNumber = +argumentForCoercion,
value = 0;
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
value = absFloor(coercedNumber);
}
return value;
}
function makeGetSet(unit, keepTime) {
return function (value) {
if (value != null) {
set$1(this, unit, value);
hooks.updateOffset(this, keepTime);
return this;
} else {
return get(this, unit);
}
};
}
function get(mom, unit) {
return mom.isValid()
? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
: NaN;
}
function set$1(mom, unit, value) {
if (mom.isValid() && !isNaN(value)) {
if (
unit === 'FullYear' &&
isLeapYear(mom.year()) &&
mom.month() === 1 &&
mom.date() === 29
) {
value = toInt(value);
mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
value,
mom.month(),
daysInMonth(value, mom.month())
);
} else {
mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
}
}
}
// MOMENTS
function stringGet(units) {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units]();
}
return this;
}
function stringSet(units, value) {
if (typeof units === 'object') {
units = normalizeObjectUnits(units);
var prioritized = getPrioritizedUnits(units),
i;
for (i = 0; i < prioritized.length; i++) {
this[prioritized[i].unit](units[prioritized[i].unit]);
}
} else {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units](value);
}
}
return this;
}
var match1 = /\d/, // 0 - 9
match2 = /\d\d/, // 00 - 99
match3 = /\d{3}/, // 000 - 999
match4 = /\d{4}/, // 0000 - 9999
match6 = /[+-]?\d{6}/, // -999999 - 999999
match1to2 = /\d\d?/, // 0 - 99
match3to4 = /\d\d\d\d?/, // 999 - 9999
match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
match1to3 = /\d{1,3}/, // 0 - 999
match1to4 = /\d{1,4}/, // 0 - 9999
match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
matchUnsigned = /\d+/, // 0 - inf
matchSigned = /[+-]?\d+/, // -inf - inf
matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
regexes;
regexes = {};
function addRegexToken(token, regex, strictRegex) {
regexes[token] = isFunction(regex)
? regex
: function (isStrict, localeData) {
return isStrict && strictRegex ? strictRegex : regex;
};
}
function getParseRegexForToken(token, config) {
if (!hasOwnProp(regexes, token)) {
return new RegExp(unescapeFormat(token));
}
return regexes[token](config._strict, config._locale);
}
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(s) {
return regexEscape(
s
.replace('\\', '')
.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (
matched,
p1,
p2,
p3,
p4
) {
return p1 || p2 || p3 || p4;
})
);
}
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
var tokens = {};
function addParseToken(token, callback) {
var i,
func = callback;
if (typeof token === 'string') {
token = [token];
}
if (isNumber(callback)) {
func = function (input, array) {
array[callback] = toInt(input);
};
}
for (i = 0; i < token.length; i++) {
tokens[token[i]] = func;
}
}
function addWeekParseToken(token, callback) {
addParseToken(token, function (input, array, config, token) {
config._w = config._w || {};
callback(input, config._w, config, token);
});
}
function addTimeToArrayFromToken(token, input, config) {
if (input != null && hasOwnProp(tokens, token)) {
tokens[token](input, config._a, config, token);
}
}
var YEAR = 0,
MONTH = 1,
DATE = 2,
HOUR = 3,
MINUTE = 4,
SECOND = 5,
MILLISECOND = 6,
WEEK = 7,
WEEKDAY = 8;
function mod(n, x) {
return ((n % x) + x) % x;
}
var indexOf;
if (Array.prototype.indexOf) {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function (o) {
// I know
var i;
for (i = 0; i < this.length; ++i) {
if (this[i] === o) {
return i;
}
}
return -1;
};
}
function daysInMonth(year, month) {
if (isNaN(year) || isNaN(month)) {
return NaN;
}
var modMonth = mod(month, 12);
year += (month - modMonth) / 12;
return modMonth === 1
? isLeapYear(year)
? 29
: 28
: 31 - ((modMonth % 7) % 2);
}
// FORMATTING
addFormatToken('M', ['MM', 2], 'Mo', function () {
return this.month() + 1;
});
addFormatToken('MMM', 0, 0, function (format) {
return this.localeData().monthsShort(this, format);
});
addFormatToken('MMMM', 0, 0, function (format) {
return this.localeData().months(this, format);
});
// ALIASES
addUnitAlias('month', 'M');
// PRIORITY
addUnitPriority('month', 8);
// PARSING
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
addRegexToken('MMM', function (isStrict, locale) {
return locale.monthsShortRegex(isStrict);
});
addRegexToken('MMMM', function (isStrict, locale) {
return locale.monthsRegex(isStrict);
});
addParseToken(['M', 'MM'], function (input, array) {
array[MONTH] = toInt(input) - 1;
});
addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
var month = config._locale.monthsParse(input, token, config._strict);
// if we didn't find a month name, mark the date as invalid.
if (month != null) {
array[MONTH] = month;
} else {
getParsingFlags(config).invalidMonth = input;
}
});
// LOCALES
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
'_'
),
defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(
'_'
),
MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
defaultMonthsShortRegex = matchWord,
defaultMonthsRegex = matchWord;
function localeMonths(m, format) {
if (!m) {
return isArray(this._months)
? this._months
: this._months['standalone'];
}
return isArray(this._months)
? this._months[m.month()]
: this._months[
(this._months.isFormat || MONTHS_IN_FORMAT).test(format)
? 'format'
: 'standalone'
][m.month()];
}
function localeMonthsShort(m, format) {
if (!m) {
return isArray(this._monthsShort)
? this._monthsShort
: this._monthsShort['standalone'];
}
return isArray(this._monthsShort)
? this._monthsShort[m.month()]
: this._monthsShort[
MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
][m.month()];
}
function handleStrictParse(monthName, format, strict) {
var i,
ii,
mom,
llc = monthName.toLocaleLowerCase();
if (!this._monthsParse) {
// this is not used
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
for (i = 0; i < 12; ++i) {
mom = createUTC([2000, i]);
this._shortMonthsParse[i] = this.monthsShort(
mom,
''
).toLocaleLowerCase();
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'MMM') {
ii = indexOf.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format === 'MMM') {
ii = indexOf.call(this._shortMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._longMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeMonthsParse(monthName, format, strict) {
var i, mom, regex;
if (this._monthsParseExact) {
return handleStrictParse.call(this, monthName, format, strict);
}
if (!this._monthsParse) {
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
}
// TODO: add sorting
// Sorting makes sure if one month (or abbr) is a prefix of another
// see sorting in computeMonthsParse
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
if (strict && !this._longMonthsParse[i]) {
this._longMonthsParse[i] = new RegExp(
'^' + this.months(mom, '').replace('.', '') + '$',
'i'
);
this._shortMonthsParse[i] = new RegExp(
'^' + this.monthsShort(mom, '').replace('.', '') + '$',
'i'
);
}
if (!strict && !this._monthsParse[i]) {
regex =
'^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (
strict &&
format === 'MMMM' &&
this._longMonthsParse[i].test(monthName)
) {
return i;
} else if (
strict &&
format === 'MMM' &&
this._shortMonthsParse[i].test(monthName)
) {
return i;
} else if (!strict && this._monthsParse[i].test(monthName)) {
return i;
}
}
}
// MOMENTS
function setMonth(mom, value) {
var dayOfMonth;
if (!mom.isValid()) {
// No op
return mom;
}
if (typeof value === 'string') {
if (/^\d+$/.test(value)) {
value = toInt(value);
} else {
value = mom.localeData().monthsParse(value);
// TODO: Another silent failure?
if (!isNumber(value)) {
return mom;
}
}
}
dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
return mom;
}
function getSetMonth(value) {
if (value != null) {
setMonth(this, value);
hooks.updateOffset(this, true);
return this;
} else {
return get(this, 'Month');
}
}
function getDaysInMonth() {
return daysInMonth(this.year(), this.month());
}
function monthsShortRegex(isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsShortStrictRegex;
} else {
return this._monthsShortRegex;
}
} else {
if (!hasOwnProp(this, '_monthsShortRegex')) {
this._monthsShortRegex = defaultMonthsShortRegex;
}
return this._monthsShortStrictRegex && isStrict
? this._monthsShortStrictRegex
: this._monthsShortRegex;
}
}
function monthsRegex(isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsStrictRegex;
} else {
return this._monthsRegex;
}
} else {
if (!hasOwnProp(this, '_monthsRegex')) {
this._monthsRegex = defaultMonthsRegex;
}
return this._monthsStrictRegex && isStrict
? this._monthsStrictRegex
: this._monthsRegex;
}
}
function computeMonthsParse() {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var shortPieces = [],
longPieces = [],
mixedPieces = [],
i,
mom;
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
shortPieces.push(this.monthsShort(mom, ''));
longPieces.push(this.months(mom, ''));
mixedPieces.push(this.months(mom, ''));
mixedPieces.push(this.monthsShort(mom, ''));
}
// Sorting makes sure if one month (or abbr) is a prefix of another it
// will match the longer piece.
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 12; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
}
for (i = 0; i < 24; i++) {
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._monthsShortRegex = this._monthsRegex;
this._monthsStrictRegex = new RegExp(
'^(' + longPieces.join('|') + ')',
'i'
);
this._monthsShortStrictRegex = new RegExp(
'^(' + shortPieces.join('|') + ')',
'i'
);
}
// FORMATTING
addFormatToken('Y', 0, 0, function () {
var y = this.year();
return y <= 9999 ? zeroFill(y, 4) : '+' + y;
});
addFormatToken(0, ['YY', 2], 0, function () {
return this.year() % 100;
});
addFormatToken(0, ['YYYY', 4], 0, 'year');
addFormatToken(0, ['YYYYY', 5], 0, 'year');
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
// ALIASES
addUnitAlias('year', 'y');
// PRIORITIES
addUnitPriority('year', 1);
// PARSING
addRegexToken('Y', matchSigned);
addRegexToken('YY', match1to2, match2);
addRegexToken('YYYY', match1to4, match4);
addRegexToken('YYYYY', match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);
addParseToken(['YYYYY', 'YYYYYY'], YEAR);
addParseToken('YYYY', function (input, array) {
array[YEAR] =
input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
});
addParseToken('YY', function (input, array) {
array[YEAR] = hooks.parseTwoDigitYear(input);
});
addParseToken('Y', function (input, array) {
array[YEAR] = parseInt(input, 10);
});
// HELPERS
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
// HOOKS
hooks.parseTwoDigitYear = function (input) {
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
};
// MOMENTS
var getSetYear = makeGetSet('FullYear', true);
function getIsLeapYear() {
return isLeapYear(this.year());
}
function createDate(y, m, d, h, M, s, ms) {
// can't just apply() to create a date:
// https://stackoverflow.com/q/181348
var date;
// the date constructor remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
// preserve leap years using a full 400 year cycle, then reset
date = new Date(y + 400, m, d, h, M, s, ms);
if (isFinite(date.getFullYear())) {
date.setFullYear(y);
}
} else {
date = new Date(y, m, d, h, M, s, ms);
}
return date;
}
function createUTCDate(y) {
var date, args;
// the Date.UTC function remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
args = Array.prototype.slice.call(arguments);
// preserve leap years using a full 400 year cycle, then reset
args[0] = y + 400;
date = new Date(Date.UTC.apply(null, args));
if (isFinite(date.getUTCFullYear())) {
date.setUTCFullYear(y);
}
} else {
date = new Date(Date.UTC.apply(null, arguments));
}
return date;
}
// start-of-first-week - start-of-year
function firstWeekOffset(year, dow, doy) {
var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
fwd = 7 + dow - doy,
// first-week day local weekday -- which local weekday is fwd
fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
return -fwdlw + fwd - 1;
}
// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
var localWeekday = (7 + weekday - dow) % 7,
weekOffset = firstWeekOffset(year, dow, doy),
dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
resYear,
resDayOfYear;
if (dayOfYear <= 0) {
resYear = year - 1;
resDayOfYear = daysInYear(resYear) + dayOfYear;
} else if (dayOfYear > daysInYear(year)) {
resYear = year + 1;
resDayOfYear = dayOfYear - daysInYear(year);
} else {
resYear = year;
resDayOfYear = dayOfYear;
}
return {
year: resYear,
dayOfYear: resDayOfYear,
};
}
function weekOfYear(mom, dow, doy) {
var weekOffset = firstWeekOffset(mom.year(), dow, doy),
week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
resWeek,
resYear;
if (week < 1) {
resYear = mom.year() - 1;
resWeek = week + weeksInYear(resYear, dow, doy);
} else if (week > weeksInYear(mom.year(), dow, doy)) {
resWeek = week - weeksInYear(mom.year(), dow, doy);
resYear = mom.year() + 1;
} else {
resYear = mom.year();
resWeek = week;
}
return {
week: resWeek,
year: resYear,
};
}
function weeksInYear(year, dow, doy) {
var weekOffset = firstWeekOffset(year, dow, doy),
weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
}
// FORMATTING
addFormatToken('w', ['ww', 2], 'wo', 'week');
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
// ALIASES
addUnitAlias('week', 'w');
addUnitAlias('isoWeek', 'W');
// PRIORITIES
addUnitPriority('week', 5);
addUnitPriority('isoWeek', 5);
// PARSING
addRegexToken('w', match1to2);
addRegexToken('ww', match1to2, match2);
addRegexToken('W', match1to2);
addRegexToken('WW', match1to2, match2);
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (
input,
week,
config,
token
) {
week[token.substr(0, 1)] = toInt(input);
});
// HELPERS
// LOCALES
function localeWeek(mom) {
return weekOfYear(mom, this._week.dow, this._week.doy).week;
}
var defaultLocaleWeek = {
dow: 0, // Sunday is the first day of the week.
doy: 6, // The week that contains Jan 6th is the first week of the year.
};
function localeFirstDayOfWeek() {
return this._week.dow;
}
function localeFirstDayOfYear() {
return this._week.doy;
}
// MOMENTS
function getSetWeek(input) {
var week = this.localeData().week(this);
return input == null ? week : this.add((input - week) * 7, 'd');
}
function getSetISOWeek(input) {
var week = weekOfYear(this, 1, 4).week;
return input == null ? week : this.add((input - week) * 7, 'd');
}
// FORMATTING
addFormatToken('d', 0, 'do', 'day');
addFormatToken('dd', 0, 0, function (format) {
return this.localeData().weekdaysMin(this, format);
});
addFormatToken('ddd', 0, 0, function (format) {
return this.localeData().weekdaysShort(this, format);
});
addFormatToken('dddd', 0, 0, function (format) {
return this.localeData().weekdays(this, format);
});
addFormatToken('e', 0, 0, 'weekday');
addFormatToken('E', 0, 0, 'isoWeekday');
// ALIASES
addUnitAlias('day', 'd');
addUnitAlias('weekday', 'e');
addUnitAlias('isoWeekday', 'E');
// PRIORITY
addUnitPriority('day', 11);
addUnitPriority('weekday', 11);
addUnitPriority('isoWeekday', 11);
// PARSING
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
addRegexToken('dd', function (isStrict, locale) {
return locale.weekdaysMinRegex(isStrict);
});
addRegexToken('ddd', function (isStrict, locale) {
return locale.weekdaysShortRegex(isStrict);
});
addRegexToken('dddd', function (isStrict, locale) {
return locale.weekdaysRegex(isStrict);
});
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
// if we didn't get a weekday name, mark the date as invalid
if (weekday != null) {
week.d = weekday;
} else {
getParsingFlags(config).invalidWeekday = input;
}
});
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
week[token] = toInt(input);
});
// HELPERS
function parseWeekday(input, locale) {
if (typeof input !== 'string') {
return input;
}
if (!isNaN(input)) {
return parseInt(input, 10);
}
input = locale.weekdaysParse(input);
if (typeof input === 'number') {
return input;
}
return null;
}
function parseIsoWeekday(input, locale) {
if (typeof input === 'string') {
return locale.weekdaysParse(input) % 7 || 7;
}
return isNaN(input) ? null : input;
}
// LOCALES
function shiftWeekdays(ws, n) {
return ws.slice(n, 7).concat(ws.slice(0, n));
}
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(
'_'
),
defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
defaultWeekdaysRegex = matchWord,
defaultWeekdaysShortRegex = matchWord,
defaultWeekdaysMinRegex = matchWord;
function localeWeekdays(m, format) {
var weekdays = isArray(this._weekdays)
? this._weekdays
: this._weekdays[
m && m !== true && this._weekdays.isFormat.test(format)
? 'format'
: 'standalone'
];
return m === true
? shiftWeekdays(weekdays, this._week.dow)
: m
? weekdays[m.day()]
: weekdays;
}
function localeWeekdaysShort(m) {
return m === true
? shiftWeekdays(this._weekdaysShort, this._week.dow)
: m
? this._weekdaysShort[m.day()]
: this._weekdaysShort;
}
function localeWeekdaysMin(m) {
return m === true
? shiftWeekdays(this._weekdaysMin, this._week.dow)
: m
? this._weekdaysMin[m.day()]
: this._weekdaysMin;
}
function handleStrictParse$1(weekdayName, format, strict) {
var i,
ii,
mom,
llc = weekdayName.toLocaleLowerCase();
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._shortWeekdaysParse = [];
this._minWeekdaysParse = [];
for (i = 0; i < 7; ++i) {
mom = createUTC([2000, 1]).day(i);
this._minWeekdaysParse[i] = this.weekdaysMin(
mom,
''
).toLocaleLowerCase();
this._shortWeekdaysParse[i] = this.weekdaysShort(
mom,
''
).toLocaleLowerCase();
this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'dddd') {
ii = indexOf.call(this._weekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format === 'ddd') {
ii = indexOf.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format === 'dddd') {
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format === 'ddd') {
ii = indexOf.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._minWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeWeekdaysParse(weekdayName, format, strict) {
var i, mom, regex;
if (this._weekdaysParseExact) {
return handleStrictParse$1.call(this, weekdayName, format, strict);
}
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._minWeekdaysParse = [];
this._shortWeekdaysParse = [];
this._fullWeekdaysParse = [];
}
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp(
'^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
'i'
);
this._shortWeekdaysParse[i] = new RegExp(
'^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
'i'
);
this._minWeekdaysParse[i] = new RegExp(
'^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
'i'
);
}
if (!this._weekdaysParse[i]) {
regex =
'^' +
this.weekdays(mom, '') +
'|^' +
this.weekdaysShort(mom, '') +
'|^' +
this.weekdaysMin(mom, '');
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (
strict &&
format === 'dddd' &&
this._fullWeekdaysParse[i].test(weekdayName)
) {
return i;
} else if (
strict &&
format === 'ddd' &&
this._shortWeekdaysParse[i].test(weekdayName)
) {
return i;
} else if (
strict &&
format === 'dd' &&
this._minWeekdaysParse[i].test(weekdayName)
) {
return i;
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
return i;
}
}
}
// MOMENTS
function getSetDayOfWeek(input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
if (input != null) {
input = parseWeekday(input, this.localeData());
return this.add(input - day, 'd');
} else {
return day;
}
}
function getSetLocaleDayOfWeek(input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
return input == null ? weekday : this.add(input - weekday, 'd');
}
function getSetISODayOfWeek(input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
// behaves the same as moment#day except
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
// as a setter, sunday should belong to the previous week.
if (input != null) {
var weekday = parseIsoWeekday(input, this.localeData());
return this.day(this.day() % 7 ? weekday : weekday - 7);
} else {
return this.day() || 7;
}
}
function weekdaysRegex(isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysStrictRegex;
} else {
return this._weekdaysRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this._weekdaysRegex = defaultWeekdaysRegex;
}
return this._weekdaysStrictRegex && isStrict
? this._weekdaysStrictRegex
: this._weekdaysRegex;
}
}
function weekdaysShortRegex(isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysShortStrictRegex;
} else {
return this._weekdaysShortRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysShortRegex')) {
this._weekdaysShortRegex = defaultWeekdaysShortRegex;
}
return this._weekdaysShortStrictRegex && isStrict
? this._weekdaysShortStrictRegex
: this._weekdaysShortRegex;
}
}
function weekdaysMinRegex(isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysMinStrictRegex;
} else {
return this._weekdaysMinRegex;
}
} else {
if (!hasOwnProp(this, '_weekdaysMinRegex')) {
this._weekdaysMinRegex = defaultWeekdaysMinRegex;
}
return this._weekdaysMinStrictRegex && isStrict
? this._weekdaysMinStrictRegex
: this._weekdaysMinRegex;
}
}
function computeWeekdaysParse() {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var minPieces = [],
shortPieces = [],
longPieces = [],
mixedPieces = [],
i,
mom,
minp,
shortp,
longp;
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, 1]).day(i);
minp = regexEscape(this.weekdaysMin(mom, ''));
shortp = regexEscape(this.weekdaysShort(mom, ''));
longp = regexEscape(this.weekdays(mom, ''));
minPieces.push(minp);
shortPieces.push(shortp);
longPieces.push(longp);
mixedPieces.push(minp);
mixedPieces.push(shortp);
mixedPieces.push(longp);
}
// Sorting makes sure if one weekday (or abbr) is a prefix of another it
// will match the longer piece.
minPieces.sort(cmpLenRev);
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._weekdaysShortRegex = this._weekdaysRegex;
this._weekdaysMinRegex = this._weekdaysRegex;
this._weekdaysStrictRegex = new RegExp(
'^(' + longPieces.join('|') + ')',
'i'
);
this._weekdaysShortStrictRegex = new RegExp(
'^(' + shortPieces.join('|') + ')',
'i'
);
this._weekdaysMinStrictRegex = new RegExp(
'^(' + minPieces.join('|') + ')',
'i'
);
}
// FORMATTING
function hFormat() {
return this.hours() % 12 || 12;
}
function kFormat() {
return this.hours() || 24;
}
addFormatToken('H', ['HH', 2], 0, 'hour');
addFormatToken('h', ['hh', 2], 0, hFormat);
addFormatToken('k', ['kk', 2], 0, kFormat);
addFormatToken('hmm', 0, 0, function () {
return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
});
addFormatToken('hmmss', 0, 0, function () {
return (
'' +
hFormat.apply(this) +
zeroFill(this.minutes(), 2) +
zeroFill(this.seconds(), 2)
);
});
addFormatToken('Hmm', 0, 0, function () {
return '' + this.hours() + zeroFill(this.minutes(), 2);
});
addFormatToken('Hmmss', 0, 0, function () {
return (
'' +
this.hours() +
zeroFill(this.minutes(), 2) +
zeroFill(this.seconds(), 2)
);
});
function meridiem(token, lowercase) {
addFormatToken(token, 0, 0, function () {
return this.localeData().meridiem(
this.hours(),
this.minutes(),
lowercase
);
});
}
meridiem('a', true);
meridiem('A', false);
// ALIASES
addUnitAlias('hour', 'h');
// PRIORITY
addUnitPriority('hour', 13);
// PARSING
function matchMeridiem(isStrict, locale) {
return locale._meridiemParse;
}
addRegexToken('a', matchMeridiem);
addRegexToken('A', matchMeridiem);
addRegexToken('H', match1to2);
addRegexToken('h', match1to2);
addRegexToken('k', match1to2);
addRegexToken('HH', match1to2, match2);
addRegexToken('hh', match1to2, match2);
addRegexToken('kk', match1to2, match2);
addRegexToken('hmm', match3to4);
addRegexToken('hmmss', match5to6);
addRegexToken('Hmm', match3to4);
addRegexToken('Hmmss', match5to6);
addParseToken(['H', 'HH'], HOUR);
addParseToken(['k', 'kk'], function (input, array, config) {
var kInput = toInt(input);
array[HOUR] = kInput === 24 ? 0 : kInput;
});
addParseToken(['a', 'A'], function (input, array, config) {
config._isPm = config._locale.isPM(input);
config._meridiem = input;
});
addParseToken(['h', 'hh'], function (input, array, config) {
array[HOUR] = toInt(input);
getParsingFlags(config).bigHour = true;
});
addParseToken('hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
getParsingFlags(config).bigHour = true;
});
addParseToken('hmmss', function (input, array, config) {
var pos1 = input.length - 4,
pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
getParsingFlags(config).bigHour = true;
});
addParseToken('Hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
});
addParseToken('Hmmss', function (input, array, config) {
var pos1 = input.length - 4,
pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
});
// LOCALES
function localeIsPM(input) {
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
// Using charAt should be more compatible.
return (input + '').toLowerCase().charAt(0) === 'p';
}
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
// Setting the hour should keep the time, because the user explicitly
// specified which hour they want. So trying to maintain the same hour (in
// a new timezone) makes sense. Adding/subtracting hours does not follow
// this rule.
getSetHour = makeGetSet('Hours', true);
function localeMeridiem(hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'pm' : 'PM';
} else {
return isLower ? 'am' : 'AM';
}
}
var baseConfig = {
calendar: defaultCalendar,
longDateFormat: defaultLongDateFormat,
invalidDate: defaultInvalidDate,
ordinal: defaultOrdinal,
dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
relativeTime: defaultRelativeTime,
months: defaultLocaleMonths,
monthsShort: defaultLocaleMonthsShort,
week: defaultLocaleWeek,
weekdays: defaultLocaleWeekdays,
weekdaysMin: defaultLocaleWeekdaysMin,
weekdaysShort: defaultLocaleWeekdaysShort,
meridiemParse: defaultLocaleMeridiemParse,
};
// internal storage for locale config files
var locales = {},
localeFamilies = {},
globalLocale;
function commonPrefix(arr1, arr2) {
var i,
minl = Math.min(arr1.length, arr2.length);
for (i = 0; i < minl; i += 1) {
if (arr1[i] !== arr2[i]) {
return i;
}
}
return minl;
}
function normalizeLocale(key) {
return key ? key.toLowerCase().replace('_', '-') : key;
}
// pick the locale from the array
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
function chooseLocale(names) {
var i = 0,
j,
next,
locale,
split;
while (i < names.length) {
split = normalizeLocale(names[i]).split('-');
j = split.length;
next = normalizeLocale(names[i + 1]);
next = next ? next.split('-') : null;
while (j > 0) {
locale = loadLocale(split.slice(0, j).join('-'));
if (locale) {
return locale;
}
if (
next &&
next.length >= j &&
commonPrefix(split, next) >= j - 1
) {
//the next array item is better than a shallower substring of this one
break;
}
j--;
}
i++;
}
return globalLocale;
}
function loadLocale(name) {
var oldLocale = null,
aliasedRequire;
// TODO: Find a better way to register and load all the locales in Node
if (
locales[name] === undefined &&
'object' !== 'undefined' &&
module &&
module.exports
) {
try {
oldLocale = globalLocale._abbr;
aliasedRequire = commonjsRequire;
aliasedRequire('./locale/' + name);
getSetGlobalLocale(oldLocale);
} catch (e) {
// mark as not found to avoid repeating expensive file require call causing high CPU
// when trying to find en-US, en_US, en-us for every format call
locales[name] = null; // null means not found
}
}
return locales[name];
}
// This function will load locale and then set the global locale. If
// no arguments are passed in, it will simply return the current global
// locale key.
function getSetGlobalLocale(key, values) {
var data;
if (key) {
if (isUndefined(values)) {
data = getLocale(key);
} else {
data = defineLocale(key, values);
}
if (data) {
// moment.duration._locale = moment._locale = data;
globalLocale = data;
} else {
if (typeof console !== 'undefined' && console.warn) {
//warn user if arguments are passed but the locale could not be set
console.warn(
'Locale ' + key + ' not found. Did you forget to load it?'
);
}
}
}
return globalLocale._abbr;
}
function defineLocale(name, config) {
if (config !== null) {
var locale,
parentConfig = baseConfig;
config.abbr = name;
if (locales[name] != null) {
deprecateSimple(
'defineLocaleOverride',
'use moment.updateLocale(localeName, config) to change ' +
'an existing locale. moment.defineLocale(localeName, ' +
'config) should only be used for creating a new locale ' +
'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
);
parentConfig = locales[name]._config;
} else if (config.parentLocale != null) {
if (locales[config.parentLocale] != null) {
parentConfig = locales[config.parentLocale]._config;
} else {
locale = loadLocale(config.parentLocale);
if (locale != null) {
parentConfig = locale._config;
} else {
if (!localeFamilies[config.parentLocale]) {
localeFamilies[config.parentLocale] = [];
}
localeFamilies[config.parentLocale].push({
name: name,
config: config,
});
return null;
}
}
}
locales[name] = new Locale(mergeConfigs(parentConfig, config));
if (localeFamilies[name]) {
localeFamilies[name].forEach(function (x) {
defineLocale(x.name, x.config);
});
}
// backwards compat for now: also set the locale
// make sure we set the locale AFTER all child locales have been
// created, so we won't end up with the child locale set.
getSetGlobalLocale(name);
return locales[name];
} else {
// useful for testing
delete locales[name];
return null;
}
}
function updateLocale(name, config) {
if (config != null) {
var locale,
tmpLocale,
parentConfig = baseConfig;
if (locales[name] != null && locales[name].parentLocale != null) {
// Update existing child locale in-place to avoid memory-leaks
locales[name].set(mergeConfigs(locales[name]._config, config));
} else {
// MERGE
tmpLocale = loadLocale(name);
if (tmpLocale != null) {
parentConfig = tmpLocale._config;
}
config = mergeConfigs(parentConfig, config);
if (tmpLocale == null) {
// updateLocale is called for creating a new locale
// Set abbr so it will have a name (getters return
// undefined otherwise).
config.abbr = name;
}
locale = new Locale(config);
locale.parentLocale = locales[name];
locales[name] = locale;
}
// backwards compat for now: also set the locale
getSetGlobalLocale(name);
} else {
// pass null for config to unupdate, useful for tests
if (locales[name] != null) {
if (locales[name].parentLocale != null) {
locales[name] = locales[name].parentLocale;
if (name === getSetGlobalLocale()) {
getSetGlobalLocale(name);
}
} else if (locales[name] != null) {
delete locales[name];
}
}
}
return locales[name];
}
// returns locale data
function getLocale(key) {
var locale;
if (key && key._locale && key._locale._abbr) {
key = key._locale._abbr;
}
if (!key) {
return globalLocale;
}
if (!isArray(key)) {
//short-circuit everything else
locale = loadLocale(key);
if (locale) {
return locale;
}
key = [key];
}
return chooseLocale(key);
}
function listLocales() {
return keys(locales);
}
function checkOverflow(m) {
var overflow,
a = m._a;
if (a && getParsingFlags(m).overflow === -2) {
overflow =
a[MONTH] < 0 || a[MONTH] > 11
? MONTH
: a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
? DATE
: a[HOUR] < 0 ||
a[HOUR] > 24 ||
(a[HOUR] === 24 &&
(a[MINUTE] !== 0 ||
a[SECOND] !== 0 ||
a[MILLISECOND] !== 0))
? HOUR
: a[MINUTE] < 0 || a[MINUTE] > 59
? MINUTE
: a[SECOND] < 0 || a[SECOND] > 59
? SECOND
: a[MILLISECOND] < 0 || a[MILLISECOND] > 999
? MILLISECOND
: -1;
if (
getParsingFlags(m)._overflowDayOfYear &&
(overflow < YEAR || overflow > DATE)
) {
overflow = DATE;
}
if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
overflow = WEEK;
}
if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
overflow = WEEKDAY;
}
getParsingFlags(m).overflow = overflow;
}
return m;
}
// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
isoDates = [
['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
['GGGG-[W]WW', /\d{4}-W\d\d/, false],
['YYYY-DDD', /\d{4}-\d{3}/],
['YYYY-MM', /\d{4}-\d\d/, false],
['YYYYYYMMDD', /[+-]\d{10}/],
['YYYYMMDD', /\d{8}/],
['GGGG[W]WWE', /\d{4}W\d{3}/],
['GGGG[W]WW', /\d{4}W\d{2}/, false],
['YYYYDDD', /\d{7}/],
['YYYYMM', /\d{6}/, false],
['YYYY', /\d{4}/, false],
],
// iso time formats and regexes
isoTimes = [
['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
['HH:mm:ss', /\d\d:\d\d:\d\d/],
['HH:mm', /\d\d:\d\d/],
['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
['HHmmss', /\d\d\d\d\d\d/],
['HHmm', /\d\d\d\d/],
['HH', /\d\d/],
],
aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,
obsOffsets = {
UT: 0,
GMT: 0,
EDT: -4 * 60,
EST: -5 * 60,
CDT: -5 * 60,
CST: -6 * 60,
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
PST: -8 * 60,
};
// date from iso format
function configFromISO(config) {
var i,
l,
string = config._i,
match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
allowTime,
dateFormat,
timeFormat,
tzFormat;
if (match) {
getParsingFlags(config).iso = true;
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(match[1])) {
dateFormat = isoDates[i][0];
allowTime = isoDates[i][2] !== false;
break;
}
}
if (dateFormat == null) {
config._isValid = false;
return;
}
if (match[3]) {
for (i = 0, l = isoTimes.length; i < l; i++) {
if (isoTimes[i][1].exec(match[3])) {
// match[2] should be 'T' or space
timeFormat = (match[2] || ' ') + isoTimes[i][0];
break;
}
}
if (timeFormat == null) {
config._isValid = false;
return;
}
}
if (!allowTime && timeFormat != null) {
config._isValid = false;
return;
}
if (match[4]) {
if (tzRegex.exec(match[4])) {
tzFormat = 'Z';
} else {
config._isValid = false;
return;
}
}
config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
configFromStringAndFormat(config);
} else {
config._isValid = false;
}
}
function extractFromRFC2822Strings(
yearStr,
monthStr,
dayStr,
hourStr,
minuteStr,
secondStr
) {
var result = [
untruncateYear(yearStr),
defaultLocaleMonthsShort.indexOf(monthStr),
parseInt(dayStr, 10),
parseInt(hourStr, 10),
parseInt(minuteStr, 10),
];
if (secondStr) {
result.push(parseInt(secondStr, 10));
}
return result;
}
function untruncateYear(yearStr) {
var year = parseInt(yearStr, 10);
if (year <= 49) {
return 2000 + year;
} else if (year <= 999) {
return 1900 + year;
}
return year;
}
function preprocessRFC2822(s) {
// Remove comments and folding whitespace and replace multiple-spaces with a single space
return s
.replace(/\([^)]*\)|[\n\t]/g, ' ')
.replace(/(\s\s+)/g, ' ')
.replace(/^\s\s*/, '')
.replace(/\s\s*$/, '');
}
function checkWeekday(weekdayStr, parsedInput, config) {
if (weekdayStr) {
// TODO: Replace the vanilla JS Date object with an independent day-of-week check.
var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
weekdayActual = new Date(
parsedInput[0],
parsedInput[1],
parsedInput[2]
).getDay();
if (weekdayProvided !== weekdayActual) {
getParsingFlags(config).weekdayMismatch = true;
config._isValid = false;
return false;
}
}
return true;
}
function calculateOffset(obsOffset, militaryOffset, numOffset) {
if (obsOffset) {
return obsOffsets[obsOffset];
} else if (militaryOffset) {
// the only allowed military tz is Z
return 0;
} else {
var hm = parseInt(numOffset, 10),
m = hm % 100,
h = (hm - m) / 100;
return h * 60 + m;
}
}
// date and time from ref 2822 format
function configFromRFC2822(config) {
var match = rfc2822.exec(preprocessRFC2822(config._i)),
parsedArray;
if (match) {
parsedArray = extractFromRFC2822Strings(
match[4],
match[3],
match[2],
match[5],
match[6],
match[7]
);
if (!checkWeekday(match[1], parsedArray, config)) {
return;
}
config._a = parsedArray;
config._tzm = calculateOffset(match[8], match[9], match[10]);
config._d = createUTCDate.apply(null, config._a);
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
getParsingFlags(config).rfc2822 = true;
} else {
config._isValid = false;
}
}
// date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
function configFromString(config) {
var matched = aspNetJsonRegex.exec(config._i);
if (matched !== null) {
config._d = new Date(+matched[1]);
return;
}
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
configFromRFC2822(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
if (config._strict) {
config._isValid = false;
} else {
// Final attempt, use Input Fallback
hooks.createFromInputFallback(config);
}
}
hooks.createFromInputFallback = deprecate(
'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
'discouraged and will be removed in an upcoming major release. Please refer to ' +
'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
function (config) {
config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
}
);
// Pick the first defined of two or three arguments.
function defaults(a, b, c) {
if (a != null) {
return a;
}
if (b != null) {
return b;
}
return c;
}
function currentDateArray(config) {
// hooks is actually the exported moment object
var nowValue = new Date(hooks.now());
if (config._useUTC) {
return [
nowValue.getUTCFullYear(),
nowValue.getUTCMonth(),
nowValue.getUTCDate(),
];
}
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
// convert an array to a date.
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
function configFromArray(config) {
var i,
date,
input = [],
currentDate,
expectedWeekday,
yearToUse;
if (config._d) {
return;
}
currentDate = currentDateArray(config);
//compute day of the year from weeks and weekdays
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
dayOfYearFromWeekInfo(config);
}
//if the day of the year is set, figure out what it is
if (config._dayOfYear != null) {
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
if (
config._dayOfYear > daysInYear(yearToUse) ||
config._dayOfYear === 0
) {
getParsingFlags(config)._overflowDayOfYear = true;
}
date = createUTCDate(yearToUse, 0, config._dayOfYear);
config._a[MONTH] = date.getUTCMonth();
config._a[DATE] = date.getUTCDate();
}
// Default to current date.
// * if no year, month, day of month are given, default to today
// * if day of month is given, default month and year
// * if month is given, default only year
// * if year is given, don't default anything
for (i = 0; i < 3 && config._a[i] == null; ++i) {
config._a[i] = input[i] = currentDate[i];
}
// Zero out whatever was not defaulted, including time
for (; i < 7; i++) {
config._a[i] = input[i] =
config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
}
// Check for 24:00:00.000
if (
config._a[HOUR] === 24 &&
config._a[MINUTE] === 0 &&
config._a[SECOND] === 0 &&
config._a[MILLISECOND] === 0
) {
config._nextDay = true;
config._a[HOUR] = 0;
}
config._d = (config._useUTC ? createUTCDate : createDate).apply(
null,
input
);
expectedWeekday = config._useUTC
? config._d.getUTCDay()
: config._d.getDay();
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
config._a[HOUR] = 24;
}
// check for mismatching day of week
if (
config._w &&
typeof config._w.d !== 'undefined' &&
config._w.d !== expectedWeekday
) {
getParsingFlags(config).weekdayMismatch = true;
}
}
function dayOfYearFromWeekInfo(config) {
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
dow = 1;
doy = 4;
// TODO: We need to take the current isoWeekYear, but that depends on
// how we interpret now (local, utc, fixed offset). So create
// a now version of current config (take local/utc/offset flags, and
// create now).
weekYear = defaults(
w.GG,
config._a[YEAR],
weekOfYear(createLocal(), 1, 4).year
);
week = defaults(w.W, 1);
weekday = defaults(w.E, 1);
if (weekday < 1 || weekday > 7) {
weekdayOverflow = true;
}
} else {
dow = config._locale._week.dow;
doy = config._locale._week.doy;
curWeek = weekOfYear(createLocal(), dow, doy);
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
// Default to current week.
week = defaults(w.w, curWeek.week);
if (w.d != null) {
// weekday -- low day numbers are considered next week
weekday = w.d;
if (weekday < 0 || weekday > 6) {
weekdayOverflow = true;
}
} else if (w.e != null) {
// local weekday -- counting starts from beginning of week
weekday = w.e + dow;
if (w.e < 0 || w.e > 6) {
weekdayOverflow = true;
}
} else {
// default to beginning of week
weekday = dow;
}
}
if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
getParsingFlags(config)._overflowWeeks = true;
} else if (weekdayOverflow != null) {
getParsingFlags(config)._overflowWeekday = true;
} else {
temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
config._a[YEAR] = temp.year;
config._dayOfYear = temp.dayOfYear;
}
}
// constant that refers to the ISO standard
hooks.ISO_8601 = function () {};
// constant that refers to the RFC 2822 form
hooks.RFC_2822 = function () {};
// date from string and format string
function configFromStringAndFormat(config) {
// TODO: Move this to another part of the creation flow to prevent circular deps
if (config._f === hooks.ISO_8601) {
configFromISO(config);
return;
}
if (config._f === hooks.RFC_2822) {
configFromRFC2822(config);
return;
}
config._a = [];
getParsingFlags(config).empty = true;
// This array is used to make a Date, either with `new Date` or `Date.UTC`
var string = '' + config._i,
i,
parsedInput,
tokens,
token,
skipped,
stringLength = string.length,
totalParsedInputLength = 0,
era;
tokens =
expandFormat(config._f, config._locale).match(formattingTokens) || [];
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (string.match(getParseRegexForToken(token, config)) ||
[])[0];
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
getParsingFlags(config).unusedInput.push(skipped);
}
string = string.slice(
string.indexOf(parsedInput) + parsedInput.length
);
totalParsedInputLength += parsedInput.length;
}
// don't parse if it's not a known token
if (formatTokenFunctions[token]) {
if (parsedInput) {
getParsingFlags(config).empty = false;
} else {
getParsingFlags(config).unusedTokens.push(token);
}
addTimeToArrayFromToken(token, parsedInput, config);
} else if (config._strict && !parsedInput) {
getParsingFlags(config).unusedTokens.push(token);
}
}
// add remaining unparsed input length to the string
getParsingFlags(config).charsLeftOver =
stringLength - totalParsedInputLength;
if (string.length > 0) {
getParsingFlags(config).unusedInput.push(string);
}
// clear _12h flag if hour is <= 12
if (
config._a[HOUR] <= 12 &&
getParsingFlags(config).bigHour === true &&
config._a[HOUR] > 0
) {
getParsingFlags(config).bigHour = undefined;
}
getParsingFlags(config).parsedDateParts = config._a.slice(0);
getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(
config._locale,
config._a[HOUR],
config._meridiem
);
// handle era
era = getParsingFlags(config).era;
if (era !== null) {
config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
}
configFromArray(config);
checkOverflow(config);
}
function meridiemFixWrap(locale, hour, meridiem) {
var isPm;
if (meridiem == null) {
// nothing to do
return hour;
}
if (locale.meridiemHour != null) {
return locale.meridiemHour(hour, meridiem);
} else if (locale.isPM != null) {
// Fallback
isPm = locale.isPM(meridiem);
if (isPm && hour < 12) {
hour += 12;
}
if (!isPm && hour === 12) {
hour = 0;
}
return hour;
} else {
// this is not supposed to happen
return hour;
}
}
// date from string and array of format strings
function configFromStringAndArray(config) {
var tempConfig,
bestMoment,
scoreToBeat,
i,
currentScore,
validFormatFound,
bestFormatIsValid = false;
if (config._f.length === 0) {
getParsingFlags(config).invalidFormat = true;
config._d = new Date(NaN);
return;
}
for (i = 0; i < config._f.length; i++) {
currentScore = 0;
validFormatFound = false;
tempConfig = copyConfig({}, config);
if (config._useUTC != null) {
tempConfig._useUTC = config._useUTC;
}
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
if (isValid(tempConfig)) {
validFormatFound = true;
}
// if there is any input that was not parsed add a penalty for that format
currentScore += getParsingFlags(tempConfig).charsLeftOver;
//or tokens
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
getParsingFlags(tempConfig).score = currentScore;
if (!bestFormatIsValid) {
if (
scoreToBeat == null ||
currentScore < scoreToBeat ||
validFormatFound
) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
if (validFormatFound) {
bestFormatIsValid = true;
}
}
} else {
if (currentScore < scoreToBeat) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
}
}
}
extend(config, bestMoment || tempConfig);
}
function configFromObject(config) {
if (config._d) {
return;
}
var i = normalizeObjectUnits(config._i),
dayOrDate = i.day === undefined ? i.date : i.day;
config._a = map(
[i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
function (obj) {
return obj && parseInt(obj, 10);
}
);
configFromArray(config);
}
function createFromConfig(config) {
var res = new Moment(checkOverflow(prepareConfig(config)));
if (res._nextDay) {
// Adding is smart enough around DST
res.add(1, 'd');
res._nextDay = undefined;
}
return res;
}
function prepareConfig(config) {
var input = config._i,
format = config._f;
config._locale = config._locale || getLocale(config._l);
if (input === null || (format === undefined && input === '')) {
return createInvalid({ nullInput: true });
}
if (typeof input === 'string') {
config._i = input = config._locale.preparse(input);
}
if (isMoment(input)) {
return new Moment(checkOverflow(input));
} else if (isDate(input)) {
config._d = input;
} else if (isArray(format)) {
configFromStringAndArray(config);
} else if (format) {
configFromStringAndFormat(config);
} else {
configFromInput(config);
}
if (!isValid(config)) {
config._d = null;
}
return config;
}
function configFromInput(config) {
var input = config._i;
if (isUndefined(input)) {
config._d = new Date(hooks.now());
} else if (isDate(input)) {
config._d = new Date(input.valueOf());
} else if (typeof input === 'string') {
configFromString(config);
} else if (isArray(input)) {
config._a = map(input.slice(0), function (obj) {
return parseInt(obj, 10);
});
configFromArray(config);
} else if (isObject(input)) {
configFromObject(config);
} else if (isNumber(input)) {
// from milliseconds
config._d = new Date(input);
} else {
hooks.createFromInputFallback(config);
}
}
function createLocalOrUTC(input, format, locale, strict, isUTC) {
var c = {};
if (format === true || format === false) {
strict = format;
format = undefined;
}
if (locale === true || locale === false) {
strict = locale;
locale = undefined;
}
if (
(isObject(input) && isObjectEmpty(input)) ||
(isArray(input) && input.length === 0)
) {
input = undefined;
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
c._isAMomentObject = true;
c._useUTC = c._isUTC = isUTC;
c._l = locale;
c._i = input;
c._f = format;
c._strict = strict;
return createFromConfig(c);
}
function createLocal(input, format, locale, strict) {
return createLocalOrUTC(input, format, locale, strict, false);
}
var prototypeMin = deprecate(
'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other < this ? this : other;
} else {
return createInvalid();
}
}
),
prototypeMax = deprecate(
'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
function () {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other > this ? this : other;
} else {
return createInvalid();
}
}
);
// Pick a moment m from moments so that m[fn](other) is true for all
// other. This relies on the function fn to be transitive.
//
// moments should either be an array of moment objects or an array, whose
// first element is an array of moment objects.
function pickBy(fn, moments) {
var res, i;
if (moments.length === 1 && isArray(moments[0])) {
moments = moments[0];
}
if (!moments.length) {
return createLocal();
}
res = moments[0];
for (i = 1; i < moments.length; ++i) {
if (!moments[i].isValid() || moments[i][fn](res)) {
res = moments[i];
}
}
return res;
}
// TODO: Use [].sort instead?
function min() {
var args = [].slice.call(arguments, 0);
return pickBy('isBefore', args);
}
function max() {
var args = [].slice.call(arguments, 0);
return pickBy('isAfter', args);
}
var now = function () {
return Date.now ? Date.now() : +new Date();
};
var ordering = [
'year',
'quarter',
'month',
'week',
'day',
'hour',
'minute',
'second',
'millisecond',
];
function isDurationValid(m) {
var key,
unitHasDecimal = false,
i;
for (key in m) {
if (
hasOwnProp(m, key) &&
!(
indexOf.call(ordering, key) !== -1 &&
(m[key] == null || !isNaN(m[key]))
)
) {
return false;
}
}
for (i = 0; i < ordering.length; ++i) {
if (m[ordering[i]]) {
if (unitHasDecimal) {
return false; // only allow non-integers for smallest unit
}
if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
unitHasDecimal = true;
}
}
}
return true;
}
function isValid$1() {
return this._isValid;
}
function createInvalid$1() {
return createDuration(NaN);
}
function Duration(duration) {
var normalizedInput = normalizeObjectUnits(duration),
years = normalizedInput.year || 0,
quarters = normalizedInput.quarter || 0,
months = normalizedInput.month || 0,
weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
days = normalizedInput.day || 0,
hours = normalizedInput.hour || 0,
minutes = normalizedInput.minute || 0,
seconds = normalizedInput.second || 0,
milliseconds = normalizedInput.millisecond || 0;
this._isValid = isDurationValid(normalizedInput);
// representation for dateAddRemove
this._milliseconds =
+milliseconds +
seconds * 1e3 + // 1000
minutes * 6e4 + // 1000 * 60
hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days + weeks * 7;
// It is impossible to translate months into days without knowing
// which months you are are talking about, so we have to store
// it separately.
this._months = +months + quarters * 3 + years * 12;
this._data = {};
this._locale = getLocale();
this._bubble();
}
function isDuration(obj) {
return obj instanceof Duration;
}
function absRound(number) {
if (number < 0) {
return Math.round(-1 * number) * -1;
} else {
return Math.round(number);
}
}
// compare two arrays, return the number of differences
function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length),
lengthDiff = Math.abs(array1.length - array2.length),
diffs = 0,
i;
for (i = 0; i < len; i++) {
if (
(dontConvert && array1[i] !== array2[i]) ||
(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
) {
diffs++;
}
}
return diffs + lengthDiff;
}
// FORMATTING
function offset(token, separator) {
addFormatToken(token, 0, 0, function () {
var offset = this.utcOffset(),
sign = '+';
if (offset < 0) {
offset = -offset;
sign = '-';
}
return (
sign +
zeroFill(~~(offset / 60), 2) +
separator +
zeroFill(~~offset % 60, 2)
);
});
}
offset('Z', ':');
offset('ZZ', '');
// PARSING
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
config._useUTC = true;
config._tzm = offsetFromString(matchShortOffset, input);
});
// HELPERS
// timezone chunker
// '+10:00' > ['10', '00']
// '-1530' > ['-15', '30']
var chunkOffset = /([\+\-]|\d\d)/gi;
function offsetFromString(matcher, string) {
var matches = (string || '').match(matcher),
chunk,
parts,
minutes;
if (matches === null) {
return null;
}
chunk = matches[matches.length - 1] || [];
parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
minutes = +(parts[1] * 60) + toInt(parts[2]);
return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
}
// Return a moment from input, that is local/utc/zone equivalent to model.
function cloneWithOffset(input, model) {
var res, diff;
if (model._isUTC) {
res = model.clone();
diff =
(isMoment(input) || isDate(input)
? input.valueOf()
: createLocal(input).valueOf()) - res.valueOf();
// Use low-level api, because this fn is low-level api.
res._d.setTime(res._d.valueOf() + diff);
hooks.updateOffset(res, false);
return res;
} else {
return createLocal(input).local();
}
}
function getDateOffset(m) {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
return -Math.round(m._d.getTimezoneOffset());
}
// HOOKS
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
hooks.updateOffset = function () {};
// MOMENTS
// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
// from the actual represented time. That is why we call updateOffset
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
function getSetOffset(input, keepLocalTime, keepMinutes) {
var offset = this._offset || 0,
localAdjust;
if (!this.isValid()) {
return input != null ? this : NaN;
}
if (input != null) {
if (typeof input === 'string') {
input = offsetFromString(matchShortOffset, input);
if (input === null) {
return this;
}
} else if (Math.abs(input) < 16 && !keepMinutes) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
localAdjust = getDateOffset(this);
}
this._offset = input;
this._isUTC = true;
if (localAdjust != null) {
this.add(localAdjust, 'm');
}
if (offset !== input) {
if (!keepLocalTime || this._changeInProgress) {
addSubtract(
this,
createDuration(input - offset, 'm'),
1,
false
);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
hooks.updateOffset(this, true);
this._changeInProgress = null;
}
}
return this;
} else {
return this._isUTC ? offset : getDateOffset(this);
}
}
function getSetZone(input, keepLocalTime) {
if (input != null) {
if (typeof input !== 'string') {
input = -input;
}
this.utcOffset(input, keepLocalTime);
return this;
} else {
return -this.utcOffset();
}
}
function setOffsetToUTC(keepLocalTime) {
return this.utcOffset(0, keepLocalTime);
}
function setOffsetToLocal(keepLocalTime) {
if (this._isUTC) {
this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
this.subtract(getDateOffset(this), 'm');
}
}
return this;
}
function setOffsetToParsedOffset() {
if (this._tzm != null) {
this.utcOffset(this._tzm, false, true);
} else if (typeof this._i === 'string') {
var tZone = offsetFromString(matchOffset, this._i);
if (tZone != null) {
this.utcOffset(tZone);
} else {
this.utcOffset(0, true);
}
}
return this;
}
function hasAlignedHourOffset(input) {
if (!this.isValid()) {
return false;
}
input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
}
function isDaylightSavingTime() {
return (
this.utcOffset() > this.clone().month(0).utcOffset() ||
this.utcOffset() > this.clone().month(5).utcOffset()
);
}
function isDaylightSavingTimeShifted() {
if (!isUndefined(this._isDSTShifted)) {
return this._isDSTShifted;
}
var c = {},
other;
copyConfig(c, this);
c = prepareConfig(c);
if (c._a) {
other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
this._isDSTShifted =
this.isValid() && compareArrays(c._a, other.toArray()) > 0;
} else {
this._isDSTShifted = false;
}
return this._isDSTShifted;
}
function isLocal() {
return this.isValid() ? !this._isUTC : false;
}
function isUtcOffset() {
return this.isValid() ? this._isUTC : false;
}
function isUtc() {
return this.isValid() ? this._isUTC && this._offset === 0 : false;
}
// ASP.NET json date format regex
var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
// and further modified to allow for strings containing both week and day
isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
function createDuration(input, key) {
var duration = input,
// matching against regexp is expensive, do it on demand
match = null,
sign,
ret,
diffRes;
if (isDuration(input)) {
duration = {
ms: input._milliseconds,
d: input._days,
M: input._months,
};
} else if (isNumber(input) || !isNaN(+input)) {
duration = {};
if (key) {
duration[key] = +input;
} else {
duration.milliseconds = +input;
}
} else if ((match = aspNetRegex.exec(input))) {
sign = match[1] === '-' ? -1 : 1;
duration = {
y: 0,
d: toInt(match[DATE]) * sign,
h: toInt(match[HOUR]) * sign,
m: toInt(match[MINUTE]) * sign,
s: toInt(match[SECOND]) * sign,
ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
};
} else if ((match = isoRegex.exec(input))) {
sign = match[1] === '-' ? -1 : 1;
duration = {
y: parseIso(match[2], sign),
M: parseIso(match[3], sign),
w: parseIso(match[4], sign),
d: parseIso(match[5], sign),
h: parseIso(match[6], sign),
m: parseIso(match[7], sign),
s: parseIso(match[8], sign),
};
} else if (duration == null) {
// checks for null or undefined
duration = {};
} else if (
typeof duration === 'object' &&
('from' in duration || 'to' in duration)
) {
diffRes = momentsDifference(
createLocal(duration.from),
createLocal(duration.to)
);
duration = {};
duration.ms = diffRes.milliseconds;
duration.M = diffRes.months;
}
ret = new Duration(duration);
if (isDuration(input) && hasOwnProp(input, '_locale')) {
ret._locale = input._locale;
}
if (isDuration(input) && hasOwnProp(input, '_isValid')) {
ret._isValid = input._isValid;
}
return ret;
}
createDuration.fn = Duration.prototype;
createDuration.invalid = createInvalid$1;
function parseIso(inp, sign) {
// We'd normally use ~~inp for this, but unfortunately it also
// converts floats to ints.
// inp may be undefined, so careful calling replace on it.
var res = inp && parseFloat(inp.replace(',', '.'));
// apply sign while we're at it
return (isNaN(res) ? 0 : res) * sign;
}
function positiveMomentsDifference(base, other) {
var res = {};
res.months =
other.month() - base.month() + (other.year() - base.year()) * 12;
if (base.clone().add(res.months, 'M').isAfter(other)) {
--res.months;
}
res.milliseconds = +other - +base.clone().add(res.months, 'M');
return res;
}
function momentsDifference(base, other) {
var res;
if (!(base.isValid() && other.isValid())) {
return { milliseconds: 0, months: 0 };
}
other = cloneWithOffset(other, base);
if (base.isBefore(other)) {
res = positiveMomentsDifference(base, other);
} else {
res = positiveMomentsDifference(other, base);
res.milliseconds = -res.milliseconds;
res.months = -res.months;
}
return res;
}
// TODO: remove 'name' arg after deprecation is removed
function createAdder(direction, name) {
return function (val, period) {
var dur, tmp;
//invert the arguments, but complain about it
if (period !== null && !isNaN(+period)) {
deprecateSimple(
name,
'moment().' +
name +
'(period, number) is deprecated. Please use moment().' +
name +
'(number, period). ' +
'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
);
tmp = val;
val = period;
period = tmp;
}
dur = createDuration(val, period);
addSubtract(this, dur, direction);
return this;
};
}
function addSubtract(mom, duration, isAdding, updateOffset) {
var milliseconds = duration._milliseconds,
days = absRound(duration._days),
months = absRound(duration._months);
if (!mom.isValid()) {
// No op
return;
}
updateOffset = updateOffset == null ? true : updateOffset;
if (months) {
setMonth(mom, get(mom, 'Month') + months * isAdding);
}
if (days) {
set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
}
if (milliseconds) {
mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
}
if (updateOffset) {
hooks.updateOffset(mom, days || months);
}
}
var add = createAdder(1, 'add'),
subtract = createAdder(-1, 'subtract');
function isString(input) {
return typeof input === 'string' || input instanceof String;
}
// type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
function isMomentInput(input) {
return (
isMoment(input) ||
isDate(input) ||
isString(input) ||
isNumber(input) ||
isNumberOrStringArray(input) ||
isMomentInputObject(input) ||
input === null ||
input === undefined
);
}
function isMomentInputObject(input) {
var objectTest = isObject(input) && !isObjectEmpty(input),
propertyTest = false,
properties = [
'years',
'year',
'y',
'months',
'month',
'M',
'days',
'day',
'd',
'dates',
'date',
'D',
'hours',
'hour',
'h',
'minutes',
'minute',
'm',
'seconds',
'second',
's',
'milliseconds',
'millisecond',
'ms',
],
i,
property;
for (i = 0; i < properties.length; i += 1) {
property = properties[i];
propertyTest = propertyTest || hasOwnProp(input, property);
}
return objectTest && propertyTest;
}
function isNumberOrStringArray(input) {
var arrayTest = isArray(input),
dataTypeTest = false;
if (arrayTest) {
dataTypeTest =
input.filter(function (item) {
return !isNumber(item) && isString(input);
}).length === 0;
}
return arrayTest && dataTypeTest;
}
function isCalendarSpec(input) {
var objectTest = isObject(input) && !isObjectEmpty(input),
propertyTest = false,
properties = [
'sameDay',
'nextDay',
'lastDay',
'nextWeek',
'lastWeek',
'sameElse',
],
i,
property;
for (i = 0; i < properties.length; i += 1) {
property = properties[i];
propertyTest = propertyTest || hasOwnProp(input, property);
}
return objectTest && propertyTest;
}
function getCalendarFormat(myMoment, now) {
var diff = myMoment.diff(now, 'days', true);
return diff < -6
? 'sameElse'
: diff < -1
? 'lastWeek'
: diff < 0
? 'lastDay'
: diff < 1
? 'sameDay'
: diff < 2
? 'nextDay'
: diff < 7
? 'nextWeek'
: 'sameElse';
}
function calendar$1(time, formats) {
// Support for single parameter, formats only overload to the calendar function
if (arguments.length === 1) {
if (isMomentInput(arguments[0])) {
time = arguments[0];
formats = undefined;
} else if (isCalendarSpec(arguments[0])) {
formats = arguments[0];
time = undefined;
}
}
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
var now = time || createLocal(),
sod = cloneWithOffset(now, this).startOf('day'),
format = hooks.calendarFormat(this, sod) || 'sameElse',
output =
formats &&
(isFunction(formats[format])
? formats[format].call(this, now)
: formats[format]);
return this.format(
output || this.localeData().calendar(format, this, createLocal(now))
);
}
function clone() {
return new Moment(this);
}
function isAfter(input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || 'millisecond';
if (units === 'millisecond') {
return this.valueOf() > localInput.valueOf();
} else {
return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
function isBefore(input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || 'millisecond';
if (units === 'millisecond') {
return this.valueOf() < localInput.valueOf();
} else {
return this.clone().endOf(units).valueOf() < localInput.valueOf();
}
}
function isBetween(from, to, units, inclusivity) {
var localFrom = isMoment(from) ? from : createLocal(from),
localTo = isMoment(to) ? to : createLocal(to);
if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
return false;
}
inclusivity = inclusivity || '()';
return (
(inclusivity[0] === '('
? this.isAfter(localFrom, units)
: !this.isBefore(localFrom, units)) &&
(inclusivity[1] === ')'
? this.isBefore(localTo, units)
: !this.isAfter(localTo, units))
);
}
function isSame(input, units) {
var localInput = isMoment(input) ? input : createLocal(input),
inputMs;
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || 'millisecond';
if (units === 'millisecond') {
return this.valueOf() === localInput.valueOf();
} else {
inputMs = localInput.valueOf();
return (
this.clone().startOf(units).valueOf() <= inputMs &&
inputMs <= this.clone().endOf(units).valueOf()
);
}
}
function isSameOrAfter(input, units) {
return this.isSame(input, units) || this.isAfter(input, units);
}
function isSameOrBefore(input, units) {
return this.isSame(input, units) || this.isBefore(input, units);
}
function diff(input, units, asFloat) {
var that, zoneDelta, output;
if (!this.isValid()) {
return NaN;
}
that = cloneWithOffset(input, this);
if (!that.isValid()) {
return NaN;
}
zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
units = normalizeUnits(units);
switch (units) {
case 'year':
output = monthDiff(this, that) / 12;
break;
case 'month':
output = monthDiff(this, that);
break;
case 'quarter':
output = monthDiff(this, that) / 3;
break;
case 'second':
output = (this - that) / 1e3;
break; // 1000
case 'minute':
output = (this - that) / 6e4;
break; // 1000 * 60
case 'hour':
output = (this - that) / 36e5;
break; // 1000 * 60 * 60
case 'day':
output = (this - that - zoneDelta) / 864e5;
break; // 1000 * 60 * 60 * 24, negate dst
case 'week':
output = (this - that - zoneDelta) / 6048e5;
break; // 1000 * 60 * 60 * 24 * 7, negate dst
default:
output = this - that;
}
return asFloat ? output : absFloor(output);
}
function monthDiff(a, b) {
if (a.date() < b.date()) {
// end-of-month calculations work correct when the start month has more
// days than the end month.
return -monthDiff(b, a);
}
// difference in months
var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
// b is in (anchor - 1 month, anchor + 1 month)
anchor = a.clone().add(wholeMonthDiff, 'months'),
anchor2,
adjust;
if (b - anchor < 0) {
anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor - anchor2);
} else {
anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
// linear across the month
adjust = (b - anchor) / (anchor2 - anchor);
}
//check for negative zero, return zero if negative zero
return -(wholeMonthDiff + adjust) || 0;
}
hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
function toString() {
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
}
function toISOString(keepOffset) {
if (!this.isValid()) {
return null;
}
var utc = keepOffset !== true,
m = utc ? this.clone().utc() : this;
if (m.year() < 0 || m.year() > 9999) {
return formatMoment(
m,
utc
? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
: 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
);
}
if (isFunction(Date.prototype.toISOString)) {
// native implementation is ~50x faster, use it when we can
if (utc) {
return this.toDate().toISOString();
} else {
return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
.toISOString()
.replace('Z', formatMoment(m, 'Z'));
}
}
return formatMoment(
m,
utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
);
}
/**
* Return a human readable representation of a moment that can
* also be evaluated to get a new moment which is the same
*
* @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
*/
function inspect() {
if (!this.isValid()) {
return 'moment.invalid(/* ' + this._i + ' */)';
}
var func = 'moment',
zone = '',
prefix,
year,
datetime,
suffix;
if (!this.isLocal()) {
func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
zone = 'Z';
}
prefix = '[' + func + '("]';
year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
datetime = '-MM-DD[T]HH:mm:ss.SSS';
suffix = zone + '[")]';
return this.format(prefix + year + datetime + suffix);
}
function format(inputString) {
if (!inputString) {
inputString = this.isUtc()
? hooks.defaultFormatUtc
: hooks.defaultFormat;
}
var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
function from(time, withoutSuffix) {
if (
this.isValid() &&
((isMoment(time) && time.isValid()) || createLocal(time).isValid())
) {
return createDuration({ to: this, from: time })
.locale(this.locale())
.humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function fromNow(withoutSuffix) {
return this.from(createLocal(), withoutSuffix);
}
function to(time, withoutSuffix) {
if (
this.isValid() &&
((isMoment(time) && time.isValid()) || createLocal(time).isValid())
) {
return createDuration({ from: this, to: time })
.locale(this.locale())
.humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function toNow(withoutSuffix) {
return this.to(createLocal(), withoutSuffix);
}
// If passed a locale key, it will set the locale for this
// instance. Otherwise, it will return the locale configuration
// variables for this instance.
function locale(key) {
var newLocaleData;
if (key === undefined) {
return this._locale._abbr;
} else {
newLocaleData = getLocale(key);
if (newLocaleData != null) {
this._locale = newLocaleData;
}
return this;
}
}
var lang = deprecate(
'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
function (key) {
if (key === undefined) {
return this.localeData();
} else {
return this.locale(key);
}
}
);
function localeData() {
return this._locale;
}
var MS_PER_SECOND = 1000,
MS_PER_MINUTE = 60 * MS_PER_SECOND,
MS_PER_HOUR = 60 * MS_PER_MINUTE,
MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
// actual modulo - handles negative numbers (for dates before 1970):
function mod$1(dividend, divisor) {
return ((dividend % divisor) + divisor) % divisor;
}
function localStartOfDate(y, m, d) {
// the date constructor remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
// preserve leap years using a full 400 year cycle, then reset
return new Date(y + 400, m, d) - MS_PER_400_YEARS;
} else {
return new Date(y, m, d).valueOf();
}
}
function utcStartOfDate(y, m, d) {
// Date.UTC remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0) {
// preserve leap years using a full 400 year cycle, then reset
return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
} else {
return Date.UTC(y, m, d);
}
}
function startOf(units) {
var time, startOfDate;
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond' || !this.isValid()) {
return this;
}
startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
switch (units) {
case 'year':
time = startOfDate(this.year(), 0, 1);
break;
case 'quarter':
time = startOfDate(
this.year(),
this.month() - (this.month() % 3),
1
);
break;
case 'month':
time = startOfDate(this.year(), this.month(), 1);
break;
case 'week':
time = startOfDate(
this.year(),
this.month(),
this.date() - this.weekday()
);
break;
case 'isoWeek':
time = startOfDate(
this.year(),
this.month(),
this.date() - (this.isoWeekday() - 1)
);
break;
case 'day':
case 'date':
time = startOfDate(this.year(), this.month(), this.date());
break;
case 'hour':
time = this._d.valueOf();
time -= mod$1(
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
MS_PER_HOUR
);
break;
case 'minute':
time = this._d.valueOf();
time -= mod$1(time, MS_PER_MINUTE);
break;
case 'second':
time = this._d.valueOf();
time -= mod$1(time, MS_PER_SECOND);
break;
}
this._d.setTime(time);
hooks.updateOffset(this, true);
return this;
}
function endOf(units) {
var time, startOfDate;
units = normalizeUnits(units);
if (units === undefined || units === 'millisecond' || !this.isValid()) {
return this;
}
startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
switch (units) {
case 'year':
time = startOfDate(this.year() + 1, 0, 1) - 1;
break;
case 'quarter':
time =
startOfDate(
this.year(),
this.month() - (this.month() % 3) + 3,
1
) - 1;
break;
case 'month':
time = startOfDate(this.year(), this.month() + 1, 1) - 1;
break;
case 'week':
time =
startOfDate(
this.year(),
this.month(),
this.date() - this.weekday() + 7
) - 1;
break;
case 'isoWeek':
time =
startOfDate(
this.year(),
this.month(),
this.date() - (this.isoWeekday() - 1) + 7
) - 1;
break;
case 'day':
case 'date':
time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
break;
case 'hour':
time = this._d.valueOf();
time +=
MS_PER_HOUR -
mod$1(
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
MS_PER_HOUR
) -
1;
break;
case 'minute':
time = this._d.valueOf();
time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
break;
case 'second':
time = this._d.valueOf();
time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
break;
}
this._d.setTime(time);
hooks.updateOffset(this, true);
return this;
}
function valueOf() {
return this._d.valueOf() - (this._offset || 0) * 60000;
}
function unix() {
return Math.floor(this.valueOf() / 1000);
}
function toDate() {
return new Date(this.valueOf());
}
function toArray() {
var m = this;
return [
m.year(),
m.month(),
m.date(),
m.hour(),
m.minute(),
m.second(),
m.millisecond(),
];
}
function toObject() {
var m = this;
return {
years: m.year(),
months: m.month(),
date: m.date(),
hours: m.hours(),
minutes: m.minutes(),
seconds: m.seconds(),
milliseconds: m.milliseconds(),
};
}
function toJSON() {
// new Date(NaN).toJSON() === null
return this.isValid() ? this.toISOString() : null;
}
function isValid$2() {
return isValid(this);
}
function parsingFlags() {
return extend({}, getParsingFlags(this));
}
function invalidAt() {
return getParsingFlags(this).overflow;
}
function creationData() {
return {
input: this._i,
format: this._f,
locale: this._locale,
isUTC: this._isUTC,
strict: this._strict,
};
}
addFormatToken('N', 0, 0, 'eraAbbr');
addFormatToken('NN', 0, 0, 'eraAbbr');
addFormatToken('NNN', 0, 0, 'eraAbbr');
addFormatToken('NNNN', 0, 0, 'eraName');
addFormatToken('NNNNN', 0, 0, 'eraNarrow');
addFormatToken('y', ['y', 1], 'yo', 'eraYear');
addFormatToken('y', ['yy', 2], 0, 'eraYear');
addFormatToken('y', ['yyy', 3], 0, 'eraYear');
addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
addRegexToken('N', matchEraAbbr);
addRegexToken('NN', matchEraAbbr);
addRegexToken('NNN', matchEraAbbr);
addRegexToken('NNNN', matchEraName);
addRegexToken('NNNNN', matchEraNarrow);
addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (
input,
array,
config,
token
) {
var era = config._locale.erasParse(input, token, config._strict);
if (era) {
getParsingFlags(config).era = era;
} else {
getParsingFlags(config).invalidEra = input;
}
});
addRegexToken('y', matchUnsigned);
addRegexToken('yy', matchUnsigned);
addRegexToken('yyy', matchUnsigned);
addRegexToken('yyyy', matchUnsigned);
addRegexToken('yo', matchEraYearOrdinal);
addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
addParseToken(['yo'], function (input, array, config, token) {
var match;
if (config._locale._eraYearOrdinalRegex) {
match = input.match(config._locale._eraYearOrdinalRegex);
}
if (config._locale.eraYearOrdinalParse) {
array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
} else {
array[YEAR] = parseInt(input, 10);
}
});
function localeEras(m, format) {
var i,
l,
date,
eras = this._eras || getLocale('en')._eras;
for (i = 0, l = eras.length; i < l; ++i) {
switch (typeof eras[i].since) {
case 'string':
// truncate time
date = hooks(eras[i].since).startOf('day');
eras[i].since = date.valueOf();
break;
}
switch (typeof eras[i].until) {
case 'undefined':
eras[i].until = +Infinity;
break;
case 'string':
// truncate time
date = hooks(eras[i].until).startOf('day').valueOf();
eras[i].until = date.valueOf();
break;
}
}
return eras;
}
function localeErasParse(eraName, format, strict) {
var i,
l,
eras = this.eras(),
name,
abbr,
narrow;
eraName = eraName.toUpperCase();
for (i = 0, l = eras.length; i < l; ++i) {
name = eras[i].name.toUpperCase();
abbr = eras[i].abbr.toUpperCase();
narrow = eras[i].narrow.toUpperCase();
if (strict) {
switch (format) {
case 'N':
case 'NN':
case 'NNN':
if (abbr === eraName) {
return eras[i];
}
break;
case 'NNNN':
if (name === eraName) {
return eras[i];
}
break;
case 'NNNNN':
if (narrow === eraName) {
return eras[i];
}
break;
}
} else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
return eras[i];
}
}
}
function localeErasConvertYear(era, year) {
var dir = era.since <= era.until ? +1 : -1;
if (year === undefined) {
return hooks(era.since).year();
} else {
return hooks(era.since).year() + (year - era.offset) * dir;
}
}
function getEraName() {
var i,
l,
val,
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
// truncate time
val = this.startOf('day').valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
return eras[i].name;
}
if (eras[i].until <= val && val <= eras[i].since) {
return eras[i].name;
}
}
return '';
}
function getEraNarrow() {
var i,
l,
val,
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
// truncate time
val = this.startOf('day').valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
return eras[i].narrow;
}
if (eras[i].until <= val && val <= eras[i].since) {
return eras[i].narrow;
}
}
return '';
}
function getEraAbbr() {
var i,
l,
val,
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
// truncate time
val = this.startOf('day').valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
return eras[i].abbr;
}
if (eras[i].until <= val && val <= eras[i].since) {
return eras[i].abbr;
}
}
return '';
}
function getEraYear() {
var i,
l,
dir,
val,
eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
dir = eras[i].since <= eras[i].until ? +1 : -1;
// truncate time
val = this.startOf('day').valueOf();
if (
(eras[i].since <= val && val <= eras[i].until) ||
(eras[i].until <= val && val <= eras[i].since)
) {
return (
(this.year() - hooks(eras[i].since).year()) * dir +
eras[i].offset
);
}
}
return this.year();
}
function erasNameRegex(isStrict) {
if (!hasOwnProp(this, '_erasNameRegex')) {
computeErasParse.call(this);
}
return isStrict ? this._erasNameRegex : this._erasRegex;
}
function erasAbbrRegex(isStrict) {
if (!hasOwnProp(this, '_erasAbbrRegex')) {
computeErasParse.call(this);
}
return isStrict ? this._erasAbbrRegex : this._erasRegex;
}
function erasNarrowRegex(isStrict) {
if (!hasOwnProp(this, '_erasNarrowRegex')) {
computeErasParse.call(this);
}
return isStrict ? this._erasNarrowRegex : this._erasRegex;
}
function matchEraAbbr(isStrict, locale) {
return locale.erasAbbrRegex(isStrict);
}
function matchEraName(isStrict, locale) {
return locale.erasNameRegex(isStrict);
}
function matchEraNarrow(isStrict, locale) {
return locale.erasNarrowRegex(isStrict);
}
function matchEraYearOrdinal(isStrict, locale) {
return locale._eraYearOrdinalRegex || matchUnsigned;
}
function computeErasParse() {
var abbrPieces = [],
namePieces = [],
narrowPieces = [],
mixedPieces = [],
i,
l,
eras = this.eras();
for (i = 0, l = eras.length; i < l; ++i) {
namePieces.push(regexEscape(eras[i].name));
abbrPieces.push(regexEscape(eras[i].abbr));
narrowPieces.push(regexEscape(eras[i].narrow));
mixedPieces.push(regexEscape(eras[i].name));
mixedPieces.push(regexEscape(eras[i].abbr));
mixedPieces.push(regexEscape(eras[i].narrow));
}
this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
this._erasNarrowRegex = new RegExp(
'^(' + narrowPieces.join('|') + ')',
'i'
);
}
// FORMATTING
addFormatToken(0, ['gg', 2], 0, function () {
return this.weekYear() % 100;
});
addFormatToken(0, ['GG', 2], 0, function () {
return this.isoWeekYear() % 100;
});
function addWeekYearFormatToken(token, getter) {
addFormatToken(0, [token, token.length], 0, getter);
}
addWeekYearFormatToken('gggg', 'weekYear');
addWeekYearFormatToken('ggggg', 'weekYear');
addWeekYearFormatToken('GGGG', 'isoWeekYear');
addWeekYearFormatToken('GGGGG', 'isoWeekYear');
// ALIASES
addUnitAlias('weekYear', 'gg');
addUnitAlias('isoWeekYear', 'GG');
// PRIORITY
addUnitPriority('weekYear', 1);
addUnitPriority('isoWeekYear', 1);
// PARSING
addRegexToken('G', matchSigned);
addRegexToken('g', matchSigned);
addRegexToken('GG', match1to2, match2);
addRegexToken('gg', match1to2, match2);
addRegexToken('GGGG', match1to4, match4);
addRegexToken('gggg', match1to4, match4);
addRegexToken('GGGGG', match1to6, match6);
addRegexToken('ggggg', match1to6, match6);
addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (
input,
week,
config,
token
) {
week[token.substr(0, 2)] = toInt(input);
});
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
week[token] = hooks.parseTwoDigitYear(input);
});
// MOMENTS
function getSetWeekYear(input) {
return getSetWeekYearHelper.call(
this,
input,
this.week(),
this.weekday(),
this.localeData()._week.dow,
this.localeData()._week.doy
);
}
function getSetISOWeekYear(input) {
return getSetWeekYearHelper.call(
this,
input,
this.isoWeek(),
this.isoWeekday(),
1,
4
);
}
function getISOWeeksInYear() {
return weeksInYear(this.year(), 1, 4);
}
function getISOWeeksInISOWeekYear() {
return weeksInYear(this.isoWeekYear(), 1, 4);
}
function getWeeksInYear() {
var weekInfo = this.localeData()._week;
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
}
function getWeeksInWeekYear() {
var weekInfo = this.localeData()._week;
return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
}
function getSetWeekYearHelper(input, week, weekday, dow, doy) {
var weeksTarget;
if (input == null) {
return weekOfYear(this, dow, doy).year;
} else {
weeksTarget = weeksInYear(input, dow, doy);
if (week > weeksTarget) {
week = weeksTarget;
}
return setWeekAll.call(this, input, week, weekday, dow, doy);
}
}
function setWeekAll(weekYear, week, weekday, dow, doy) {
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
return this;
}
// FORMATTING
addFormatToken('Q', 0, 'Qo', 'quarter');
// ALIASES
addUnitAlias('quarter', 'Q');
// PRIORITY
addUnitPriority('quarter', 7);
// PARSING
addRegexToken('Q', match1);
addParseToken('Q', function (input, array) {
array[MONTH] = (toInt(input) - 1) * 3;
});
// MOMENTS
function getSetQuarter(input) {
return input == null
? Math.ceil((this.month() + 1) / 3)
: this.month((input - 1) * 3 + (this.month() % 3));
}
// FORMATTING
addFormatToken('D', ['DD', 2], 'Do', 'date');
// ALIASES
addUnitAlias('date', 'D');
// PRIORITY
addUnitPriority('date', 9);
// PARSING
addRegexToken('D', match1to2);
addRegexToken('DD', match1to2, match2);
addRegexToken('Do', function (isStrict, locale) {
// TODO: Remove "ordinalParse" fallback in next major release.
return isStrict
? locale._dayOfMonthOrdinalParse || locale._ordinalParse
: locale._dayOfMonthOrdinalParseLenient;
});
addParseToken(['D', 'DD'], DATE);
addParseToken('Do', function (input, array) {
array[DATE] = toInt(input.match(match1to2)[0]);
});
// MOMENTS
var getSetDayOfMonth = makeGetSet('Date', true);
// FORMATTING
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
// ALIASES
addUnitAlias('dayOfYear', 'DDD');
// PRIORITY
addUnitPriority('dayOfYear', 4);
// PARSING
addRegexToken('DDD', match1to3);
addRegexToken('DDDD', match3);
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
config._dayOfYear = toInt(input);
});
// HELPERS
// MOMENTS
function getSetDayOfYear(input) {
var dayOfYear =
Math.round(
(this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
) + 1;
return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
}
// FORMATTING
addFormatToken('m', ['mm', 2], 0, 'minute');
// ALIASES
addUnitAlias('minute', 'm');
// PRIORITY
addUnitPriority('minute', 14);
// PARSING
addRegexToken('m', match1to2);
addRegexToken('mm', match1to2, match2);
addParseToken(['m', 'mm'], MINUTE);
// MOMENTS
var getSetMinute = makeGetSet('Minutes', false);
// FORMATTING
addFormatToken('s', ['ss', 2], 0, 'second');
// ALIASES
addUnitAlias('second', 's');
// PRIORITY
addUnitPriority('second', 15);
// PARSING
addRegexToken('s', match1to2);
addRegexToken('ss', match1to2, match2);
addParseToken(['s', 'ss'], SECOND);
// MOMENTS
var getSetSecond = makeGetSet('Seconds', false);
// FORMATTING
addFormatToken('S', 0, 0, function () {
return ~~(this.millisecond() / 100);
});
addFormatToken(0, ['SS', 2], 0, function () {
return ~~(this.millisecond() / 10);
});
addFormatToken(0, ['SSS', 3], 0, 'millisecond');
addFormatToken(0, ['SSSS', 4], 0, function () {
return this.millisecond() * 10;
});
addFormatToken(0, ['SSSSS', 5], 0, function () {
return this.millisecond() * 100;
});
addFormatToken(0, ['SSSSSS', 6], 0, function () {
return this.millisecond() * 1000;
});
addFormatToken(0, ['SSSSSSS', 7], 0, function () {
return this.millisecond() * 10000;
});
addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
return this.millisecond() * 100000;
});
addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
return this.millisecond() * 1000000;
});
// ALIASES
addUnitAlias('millisecond', 'ms');
// PRIORITY
addUnitPriority('millisecond', 16);
// PARSING
addRegexToken('S', match1to3, match1);
addRegexToken('SS', match1to3, match2);
addRegexToken('SSS', match1to3, match3);
var token, getSetMillisecond;
for (token = 'SSSS'; token.length <= 9; token += 'S') {
addRegexToken(token, matchUnsigned);
}
function parseMs(input, array) {
array[MILLISECOND] = toInt(('0.' + input) * 1000);
}
for (token = 'S'; token.length <= 9; token += 'S') {
addParseToken(token, parseMs);
}
getSetMillisecond = makeGetSet('Milliseconds', false);
// FORMATTING
addFormatToken('z', 0, 0, 'zoneAbbr');
addFormatToken('zz', 0, 0, 'zoneName');
// MOMENTS
function getZoneAbbr() {
return this._isUTC ? 'UTC' : '';
}
function getZoneName() {
return this._isUTC ? 'Coordinated Universal Time' : '';
}
var proto = Moment.prototype;
proto.add = add;
proto.calendar = calendar$1;
proto.clone = clone;
proto.diff = diff;
proto.endOf = endOf;
proto.format = format;
proto.from = from;
proto.fromNow = fromNow;
proto.to = to;
proto.toNow = toNow;
proto.get = stringGet;
proto.invalidAt = invalidAt;
proto.isAfter = isAfter;
proto.isBefore = isBefore;
proto.isBetween = isBetween;
proto.isSame = isSame;
proto.isSameOrAfter = isSameOrAfter;
proto.isSameOrBefore = isSameOrBefore;
proto.isValid = isValid$2;
proto.lang = lang;
proto.locale = locale;
proto.localeData = localeData;
proto.max = prototypeMax;
proto.min = prototypeMin;
proto.parsingFlags = parsingFlags;
proto.set = stringSet;
proto.startOf = startOf;
proto.subtract = subtract;
proto.toArray = toArray;
proto.toObject = toObject;
proto.toDate = toDate;
proto.toISOString = toISOString;
proto.inspect = inspect;
if (typeof Symbol !== 'undefined' && Symbol.for != null) {
proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
return 'Moment<' + this.format() + '>';
};
}
proto.toJSON = toJSON;
proto.toString = toString;
proto.unix = unix;
proto.valueOf = valueOf;
proto.creationData = creationData;
proto.eraName = getEraName;
proto.eraNarrow = getEraNarrow;
proto.eraAbbr = getEraAbbr;
proto.eraYear = getEraYear;
proto.year = getSetYear;
proto.isLeapYear = getIsLeapYear;
proto.weekYear = getSetWeekYear;
proto.isoWeekYear = getSetISOWeekYear;
proto.quarter = proto.quarters = getSetQuarter;
proto.month = getSetMonth;
proto.daysInMonth = getDaysInMonth;
proto.week = proto.weeks = getSetWeek;
proto.isoWeek = proto.isoWeeks = getSetISOWeek;
proto.weeksInYear = getWeeksInYear;
proto.weeksInWeekYear = getWeeksInWeekYear;
proto.isoWeeksInYear = getISOWeeksInYear;
proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
proto.date = getSetDayOfMonth;
proto.day = proto.days = getSetDayOfWeek;
proto.weekday = getSetLocaleDayOfWeek;
proto.isoWeekday = getSetISODayOfWeek;
proto.dayOfYear = getSetDayOfYear;
proto.hour = proto.hours = getSetHour;
proto.minute = proto.minutes = getSetMinute;
proto.second = proto.seconds = getSetSecond;
proto.millisecond = proto.milliseconds = getSetMillisecond;
proto.utcOffset = getSetOffset;
proto.utc = setOffsetToUTC;
proto.local = setOffsetToLocal;
proto.parseZone = setOffsetToParsedOffset;
proto.hasAlignedHourOffset = hasAlignedHourOffset;
proto.isDST = isDaylightSavingTime;
proto.isLocal = isLocal;
proto.isUtcOffset = isUtcOffset;
proto.isUtc = isUtc;
proto.isUTC = isUtc;
proto.zoneAbbr = getZoneAbbr;
proto.zoneName = getZoneName;
proto.dates = deprecate(
'dates accessor is deprecated. Use date instead.',
getSetDayOfMonth
);
proto.months = deprecate(
'months accessor is deprecated. Use month instead',
getSetMonth
);
proto.years = deprecate(
'years accessor is deprecated. Use year instead',
getSetYear
);
proto.zone = deprecate(
'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
getSetZone
);
proto.isDSTShifted = deprecate(
'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
isDaylightSavingTimeShifted
);
function createUnix(input) {
return createLocal(input * 1000);
}
function createInZone() {
return createLocal.apply(null, arguments).parseZone();
}
function preParsePostFormat(string) {
return string;
}
var proto$1 = Locale.prototype;
proto$1.calendar = calendar;
proto$1.longDateFormat = longDateFormat;
proto$1.invalidDate = invalidDate;
proto$1.ordinal = ordinal;
proto$1.preparse = preParsePostFormat;
proto$1.postformat = preParsePostFormat;
proto$1.relativeTime = relativeTime;
proto$1.pastFuture = pastFuture;
proto$1.set = set;
proto$1.eras = localeEras;
proto$1.erasParse = localeErasParse;
proto$1.erasConvertYear = localeErasConvertYear;
proto$1.erasAbbrRegex = erasAbbrRegex;
proto$1.erasNameRegex = erasNameRegex;
proto$1.erasNarrowRegex = erasNarrowRegex;
proto$1.months = localeMonths;
proto$1.monthsShort = localeMonthsShort;
proto$1.monthsParse = localeMonthsParse;
proto$1.monthsRegex = monthsRegex;
proto$1.monthsShortRegex = monthsShortRegex;
proto$1.week = localeWeek;
proto$1.firstDayOfYear = localeFirstDayOfYear;
proto$1.firstDayOfWeek = localeFirstDayOfWeek;
proto$1.weekdays = localeWeekdays;
proto$1.weekdaysMin = localeWeekdaysMin;
proto$1.weekdaysShort = localeWeekdaysShort;
proto$1.weekdaysParse = localeWeekdaysParse;
proto$1.weekdaysRegex = weekdaysRegex;
proto$1.weekdaysShortRegex = weekdaysShortRegex;
proto$1.weekdaysMinRegex = weekdaysMinRegex;
proto$1.isPM = localeIsPM;
proto$1.meridiem = localeMeridiem;
function get$1(format, index, field, setter) {
var locale = getLocale(),
utc = createUTC().set(setter, index);
return locale[field](utc, format);
}
function listMonthsImpl(format, index, field) {
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
if (index != null) {
return get$1(format, index, field, 'month');
}
var i,
out = [];
for (i = 0; i < 12; i++) {
out[i] = get$1(format, i, field, 'month');
}
return out;
}
// ()
// (5)
// (fmt, 5)
// (fmt)
// (true)
// (true, 5)
// (true, fmt, 5)
// (true, fmt)
function listWeekdaysImpl(localeSorted, format, index, field) {
if (typeof localeSorted === 'boolean') {
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
} else {
format = localeSorted;
index = format;
localeSorted = false;
if (isNumber(format)) {
index = format;
format = undefined;
}
format = format || '';
}
var locale = getLocale(),
shift = localeSorted ? locale._week.dow : 0,
i,
out = [];
if (index != null) {
return get$1(format, (index + shift) % 7, field, 'day');
}
for (i = 0; i < 7; i++) {
out[i] = get$1(format, (i + shift) % 7, field, 'day');
}
return out;
}
function listMonths(format, index) {
return listMonthsImpl(format, index, 'months');
}
function listMonthsShort(format, index) {
return listMonthsImpl(format, index, 'monthsShort');
}
function listWeekdays(localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
}
function listWeekdaysShort(localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
}
function listWeekdaysMin(localeSorted, format, index) {
return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
}
getSetGlobalLocale('en', {
eras: [
{
since: '0001-01-01',
until: +Infinity,
offset: 1,
name: 'Anno Domini',
narrow: 'AD',
abbr: 'AD',
},
{
since: '0000-12-31',
until: -Infinity,
offset: 1,
name: 'Before Christ',
narrow: 'BC',
abbr: 'BC',
},
],
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal: function (number) {
var b = number % 10,
output =
toInt((number % 100) / 10) === 1
? 'th'
: b === 1
? 'st'
: b === 2
? 'nd'
: b === 3
? 'rd'
: 'th';
return number + output;
},
});
// Side effect imports
hooks.lang = deprecate(
'moment.lang is deprecated. Use moment.locale instead.',
getSetGlobalLocale
);
hooks.langData = deprecate(
'moment.langData is deprecated. Use moment.localeData instead.',
getLocale
);
var mathAbs = Math.abs;
function abs() {
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
this._days = mathAbs(this._days);
this._months = mathAbs(this._months);
data.milliseconds = mathAbs(data.milliseconds);
data.seconds = mathAbs(data.seconds);
data.minutes = mathAbs(data.minutes);
data.hours = mathAbs(data.hours);
data.months = mathAbs(data.months);
data.years = mathAbs(data.years);
return this;
}
function addSubtract$1(duration, input, value, direction) {
var other = createDuration(input, value);
duration._milliseconds += direction * other._milliseconds;
duration._days += direction * other._days;
duration._months += direction * other._months;
return duration._bubble();
}
// supports only 2.0-style add(1, 's') or add(duration)
function add$1(input, value) {
return addSubtract$1(this, input, value, 1);
}
// supports only 2.0-style subtract(1, 's') or subtract(duration)
function subtract$1(input, value) {
return addSubtract$1(this, input, value, -1);
}
function absCeil(number) {
if (number < 0) {
return Math.floor(number);
} else {
return Math.ceil(number);
}
}
function bubble() {
var milliseconds = this._milliseconds,
days = this._days,
months = this._months,
data = this._data,
seconds,
minutes,
hours,
years,
monthsFromDays;
// if we have a mix of positive and negative values, bubble down first
// check: https://github.com/moment/moment/issues/2166
if (
!(
(milliseconds >= 0 && days >= 0 && months >= 0) ||
(milliseconds <= 0 && days <= 0 && months <= 0)
)
) {
milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
days = 0;
months = 0;
}
// The following code bubbles up values, see the tests for
// examples of what that means.
data.milliseconds = milliseconds % 1000;
seconds = absFloor(milliseconds / 1000);
data.seconds = seconds % 60;
minutes = absFloor(seconds / 60);
data.minutes = minutes % 60;
hours = absFloor(minutes / 60);
data.hours = hours % 24;
days += absFloor(hours / 24);
// convert days to months
monthsFromDays = absFloor(daysToMonths(days));
months += monthsFromDays;
days -= absCeil(monthsToDays(monthsFromDays));
// 12 months -> 1 year
years = absFloor(months / 12);
months %= 12;
data.days = days;
data.months = months;
data.years = years;
return this;
}
function daysToMonths(days) {
// 400 years have 146097 days (taking into account leap year rules)
// 400 years have 12 months === 4800
return (days * 4800) / 146097;
}
function monthsToDays(months) {
// the reverse of daysToMonths
return (months * 146097) / 4800;
}
function as(units) {
if (!this.isValid()) {
return NaN;
}
var days,
months,
milliseconds = this._milliseconds;
units = normalizeUnits(units);
if (units === 'month' || units === 'quarter' || units === 'year') {
days = this._days + milliseconds / 864e5;
months = this._months + daysToMonths(days);
switch (units) {
case 'month':
return months;
case 'quarter':
return months / 3;
case 'year':
return months / 12;
}
} else {
// handle milliseconds separately because of floating point math errors (issue #1867)
days = this._days + Math.round(monthsToDays(this._months));
switch (units) {
case 'week':
return days / 7 + milliseconds / 6048e5;
case 'day':
return days + milliseconds / 864e5;
case 'hour':
return days * 24 + milliseconds / 36e5;
case 'minute':
return days * 1440 + milliseconds / 6e4;
case 'second':
return days * 86400 + milliseconds / 1000;
// Math.floor prevents floating point math errors here
case 'millisecond':
return Math.floor(days * 864e5) + milliseconds;
default:
throw new Error('Unknown unit ' + units);
}
}
}
// TODO: Use this.as('ms')?
function valueOf$1() {
if (!this.isValid()) {
return NaN;
}
return (
this._milliseconds +
this._days * 864e5 +
(this._months % 12) * 2592e6 +
toInt(this._months / 12) * 31536e6
);
}
function makeAs(alias) {
return function () {
return this.as(alias);
};
}
var asMilliseconds = makeAs('ms'),
asSeconds = makeAs('s'),
asMinutes = makeAs('m'),
asHours = makeAs('h'),
asDays = makeAs('d'),
asWeeks = makeAs('w'),
asMonths = makeAs('M'),
asQuarters = makeAs('Q'),
asYears = makeAs('y');
function clone$1() {
return createDuration(this);
}
function get$2(units) {
units = normalizeUnits(units);
return this.isValid() ? this[units + 's']() : NaN;
}
function makeGetter(name) {
return function () {
return this.isValid() ? this._data[name] : NaN;
};
}
var milliseconds = makeGetter('milliseconds'),
seconds = makeGetter('seconds'),
minutes = makeGetter('minutes'),
hours = makeGetter('hours'),
days = makeGetter('days'),
months = makeGetter('months'),
years = makeGetter('years');
function weeks() {
return absFloor(this.days() / 7);
}
var round = Math.round,
thresholds = {
ss: 44, // a few seconds to seconds
s: 45, // seconds to minute
m: 45, // minutes to hour
h: 22, // hours to day
d: 26, // days to month/week
w: null, // weeks to month
M: 11, // months to year
};
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
var duration = createDuration(posNegDuration).abs(),
seconds = round(duration.as('s')),
minutes = round(duration.as('m')),
hours = round(duration.as('h')),
days = round(duration.as('d')),
months = round(duration.as('M')),
weeks = round(duration.as('w')),
years = round(duration.as('y')),
a =
(seconds <= thresholds.ss && ['s', seconds]) ||
(seconds < thresholds.s && ['ss', seconds]) ||
(minutes <= 1 && ['m']) ||
(minutes < thresholds.m && ['mm', minutes]) ||
(hours <= 1 && ['h']) ||
(hours < thresholds.h && ['hh', hours]) ||
(days <= 1 && ['d']) ||
(days < thresholds.d && ['dd', days]);
if (thresholds.w != null) {
a =
a ||
(weeks <= 1 && ['w']) ||
(weeks < thresholds.w && ['ww', weeks]);
}
a = a ||
(months <= 1 && ['M']) ||
(months < thresholds.M && ['MM', months]) ||
(years <= 1 && ['y']) || ['yy', years];
a[2] = withoutSuffix;
a[3] = +posNegDuration > 0;
a[4] = locale;
return substituteTimeAgo.apply(null, a);
}
// This function allows you to set the rounding function for relative time strings
function getSetRelativeTimeRounding(roundingFunction) {
if (roundingFunction === undefined) {
return round;
}
if (typeof roundingFunction === 'function') {
round = roundingFunction;
return true;
}
return false;
}
// This function allows you to set a threshold for relative time strings
function getSetRelativeTimeThreshold(threshold, limit) {
if (thresholds[threshold] === undefined) {
return false;
}
if (limit === undefined) {
return thresholds[threshold];
}
thresholds[threshold] = limit;
if (threshold === 's') {
thresholds.ss = limit - 1;
}
return true;
}
function humanize(argWithSuffix, argThresholds) {
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var withSuffix = false,
th = thresholds,
locale,
output;
if (typeof argWithSuffix === 'object') {
argThresholds = argWithSuffix;
argWithSuffix = false;
}
if (typeof argWithSuffix === 'boolean') {
withSuffix = argWithSuffix;
}
if (typeof argThresholds === 'object') {
th = Object.assign({}, thresholds, argThresholds);
if (argThresholds.s != null && argThresholds.ss == null) {
th.ss = argThresholds.s - 1;
}
}
locale = this.localeData();
output = relativeTime$1(this, !withSuffix, th, locale);
if (withSuffix) {
output = locale.pastFuture(+this, output);
}
return locale.postformat(output);
}
var abs$1 = Math.abs;
function sign(x) {
return (x > 0) - (x < 0) || +x;
}
function toISOString$1() {
// for ISO strings we do not use the normal bubbling rules:
// * milliseconds bubble up until they become hours
// * days do not bubble at all
// * months bubble up until they become years
// This is because there is no context-free conversion between hours and days
// (think of clock changes)
// and also not between days and months (28-31 days per month)
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var seconds = abs$1(this._milliseconds) / 1000,
days = abs$1(this._days),
months = abs$1(this._months),
minutes,
hours,
years,
s,
total = this.asSeconds(),
totalSign,
ymSign,
daysSign,
hmsSign;
if (!total) {
// this is the same as C#'s (Noda) and python (isodate)...
// but not other JS (goog.date)
return 'P0D';
}
// 3600 seconds -> 60 minutes -> 1 hour
minutes = absFloor(seconds / 60);
hours = absFloor(minutes / 60);
seconds %= 60;
minutes %= 60;
// 12 months -> 1 year
years = absFloor(months / 12);
months %= 12;
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
totalSign = total < 0 ? '-' : '';
ymSign = sign(this._months) !== sign(total) ? '-' : '';
daysSign = sign(this._days) !== sign(total) ? '-' : '';
hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
return (
totalSign +
'P' +
(years ? ymSign + years + 'Y' : '') +
(months ? ymSign + months + 'M' : '') +
(days ? daysSign + days + 'D' : '') +
(hours || minutes || seconds ? 'T' : '') +
(hours ? hmsSign + hours + 'H' : '') +
(minutes ? hmsSign + minutes + 'M' : '') +
(seconds ? hmsSign + s + 'S' : '')
);
}
var proto$2 = Duration.prototype;
proto$2.isValid = isValid$1;
proto$2.abs = abs;
proto$2.add = add$1;
proto$2.subtract = subtract$1;
proto$2.as = as;
proto$2.asMilliseconds = asMilliseconds;
proto$2.asSeconds = asSeconds;
proto$2.asMinutes = asMinutes;
proto$2.asHours = asHours;
proto$2.asDays = asDays;
proto$2.asWeeks = asWeeks;
proto$2.asMonths = asMonths;
proto$2.asQuarters = asQuarters;
proto$2.asYears = asYears;
proto$2.valueOf = valueOf$1;
proto$2._bubble = bubble;
proto$2.clone = clone$1;
proto$2.get = get$2;
proto$2.milliseconds = milliseconds;
proto$2.seconds = seconds;
proto$2.minutes = minutes;
proto$2.hours = hours;
proto$2.days = days;
proto$2.weeks = weeks;
proto$2.months = months;
proto$2.years = years;
proto$2.humanize = humanize;
proto$2.toISOString = toISOString$1;
proto$2.toString = toISOString$1;
proto$2.toJSON = toISOString$1;
proto$2.locale = locale;
proto$2.localeData = localeData;
proto$2.toIsoString = deprecate(
'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
toISOString$1
);
proto$2.lang = lang;
// FORMATTING
addFormatToken('X', 0, 0, 'unix');
addFormatToken('x', 0, 0, 'valueOf');
// PARSING
addRegexToken('x', matchSigned);
addRegexToken('X', matchTimestamp);
addParseToken('X', function (input, array, config) {
config._d = new Date(parseFloat(input) * 1000);
});
addParseToken('x', function (input, array, config) {
config._d = new Date(toInt(input));
});
//! moment.js
hooks.version = '2.27.0';
setHookCallback(createLocal);
hooks.fn = proto;
hooks.min = min;
hooks.max = max;
hooks.now = now;
hooks.utc = createUTC;
hooks.unix = createUnix;
hooks.months = listMonths;
hooks.isDate = isDate;
hooks.locale = getSetGlobalLocale;
hooks.invalid = createInvalid;
hooks.duration = createDuration;
hooks.isMoment = isMoment;
hooks.weekdays = listWeekdays;
hooks.parseZone = createInZone;
hooks.localeData = getLocale;
hooks.isDuration = isDuration;
hooks.monthsShort = listMonthsShort;
hooks.weekdaysMin = listWeekdaysMin;
hooks.defineLocale = defineLocale;
hooks.updateLocale = updateLocale;
hooks.locales = listLocales;
hooks.weekdaysShort = listWeekdaysShort;
hooks.normalizeUnits = normalizeUnits;
hooks.relativeTimeRounding = getSetRelativeTimeRounding;
hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
hooks.calendarFormat = getCalendarFormat;
hooks.prototype = proto;
// currently HTML5 input type only supports 24-hour formats
hooks.HTML5_FMT = {
DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
DATE: 'YYYY-MM-DD', // <input type="date" />
TIME: 'HH:mm', // <input type="time" />
TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
WEEK: 'GGGG-[W]WW', // <input type="week" />
MONTH: 'YYYY-MM', // <input type="month" />
};
return hooks;
})));
});
// Generated by LiveScript 1.6.0
var apply, curry, flip, fix, over, memoize, toString$ = {}.toString;
apply = curry$(function(f, list){
return f.apply(null, list);
});
curry = function(f){
return curry$(f);
};
flip = curry$(function(f, x, y){
return f(y, x);
});
fix = function(f){
return function(g){
return function(){
return f(g(g)).apply(null, arguments);
};
}(function(g){
return function(){
return f(g(g)).apply(null, arguments);
};
});
};
over = curry$(function(f, g, x, y){
return f(g(x), g(y));
});
memoize = function(f){
var memo;
memo = {};
return function(){
var args, res$, i$, to$, key, arg;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
key = (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
arg = ref$[i$];
results$.push(arg + toString$.call(arg).slice(8, -1));
}
return results$;
}()).join('');
return memo[key] = key in memo
? memo[key]
: f.apply(null, args);
};
};
var Func = {
curry: curry,
flip: flip,
fix: fix,
apply: apply,
over: over,
memoize: memoize
};
function curry$(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
// Generated by LiveScript 1.6.0
var each, map, compact, filter, reject, remove, partition, find, head, first, tail, last, initial, empty, reverse, unique, uniqueBy, fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, concat, concatMap, flatten, difference, intersection, union, countBy, groupBy, andList, orList, any, all, sort, sortWith, sortBy, sum, product, mean, average, maximum, minimum, maximumBy, minimumBy, scan, scanl, scan1, scanl1, scanr, scanr1, slice, take, drop, splitAt, takeWhile, dropWhile, span, breakList, zip, zipWith, zipAll, zipAllWith, at, elemIndex, elemIndices, findIndex, findIndices, toString$$1 = {}.toString;
each = curry$$1(function(f, xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
f(x);
}
return xs;
});
map = curry$$1(function(f, xs){
var i$, len$, x, results$ = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
results$.push(f(x));
}
return results$;
});
compact = function(xs){
var i$, len$, x, results$ = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (x) {
results$.push(x);
}
}
return results$;
};
filter = curry$$1(function(f, xs){
var i$, len$, x, results$ = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (f(x)) {
results$.push(x);
}
}
return results$;
});
reject = curry$$1(function(f, xs){
var i$, len$, x, results$ = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (!f(x)) {
results$.push(x);
}
}
return results$;
});
remove = curry$$1(function(el, xs){
var i, x$;
i = elemIndex(el, xs);
x$ = xs.slice();
if (i != null) {
x$.splice(i, 1);
}
return x$;
});
partition = curry$$1(function(f, xs){
var passed, failed, i$, len$, x;
passed = [];
failed = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
(f(x) ? passed : failed).push(x);
}
return [passed, failed];
});
find = curry$$1(function(f, xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (f(x)) {
return x;
}
}
});
head = first = function(xs){
return xs[0];
};
tail = function(xs){
if (!xs.length) {
return;
}
return xs.slice(1);
};
last = function(xs){
return xs[xs.length - 1];
};
initial = function(xs){
if (!xs.length) {
return;
}
return xs.slice(0, -1);
};
empty = function(xs){
return !xs.length;
};
reverse = function(xs){
return xs.concat().reverse();
};
unique = function(xs){
var result, i$, len$, x;
result = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (!in$(x, result)) {
result.push(x);
}
}
return result;
};
uniqueBy = curry$$1(function(f, xs){
var seen, i$, len$, x, val, results$ = [];
seen = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
val = f(x);
if (in$(val, seen)) {
continue;
}
seen.push(val);
results$.push(x);
}
return results$;
});
fold = foldl = curry$$1(function(f, memo, xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
memo = f(memo, x);
}
return memo;
});
fold1 = foldl1 = curry$$1(function(f, xs){
return fold(f, xs[0], xs.slice(1));
});
foldr = curry$$1(function(f, memo, xs){
var i$, x;
for (i$ = xs.length - 1; i$ >= 0; --i$) {
x = xs[i$];
memo = f(x, memo);
}
return memo;
});
foldr1 = curry$$1(function(f, xs){
return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
});
unfoldr = curry$$1(function(f, b){
var result, x, that;
result = [];
x = b;
while ((that = f(x)) != null) {
result.push(that[0]);
x = that[1];
}
return result;
});
concat = function(xss){
return [].concat.apply([], xss);
};
concatMap = curry$$1(function(f, xs){
var x;
return [].concat.apply([], (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
x = ref$[i$];
results$.push(f(x));
}
return results$;
}()));
});
flatten = function(xs){
var x;
return [].concat.apply([], (function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
x = ref$[i$];
if (toString$$1.call(x).slice(8, -1) === 'Array') {
results$.push(flatten(x));
} else {
results$.push(x);
}
}
return results$;
}()));
};
difference = function(xs){
var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
yss = res$;
results = [];
outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
ys = yss[j$];
if (in$(x, ys)) {
continue outer;
}
}
results.push(x);
}
return results;
};
intersection = function(xs){
var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
yss = res$;
results = [];
outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
ys = yss[j$];
if (!in$(x, ys)) {
continue outer;
}
}
results.push(x);
}
return results;
};
union = function(){
var xss, res$, i$, to$, results, len$, xs, j$, len1$, x;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
xss = res$;
results = [];
for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
xs = xss[i$];
for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
x = xs[j$];
if (!in$(x, results)) {
results.push(x);
}
}
}
return results;
};
countBy = curry$$1(function(f, xs){
var results, i$, len$, x, key;
results = {};
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
key = f(x);
if (key in results) {
results[key] += 1;
} else {
results[key] = 1;
}
}
return results;
});
groupBy = curry$$1(function(f, xs){
var results, i$, len$, x, key;
results = {};
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
key = f(x);
if (key in results) {
results[key].push(x);
} else {
results[key] = [x];
}
}
return results;
});
andList = function(xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (!x) {
return false;
}
}
return true;
};
orList = function(xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (x) {
return true;
}
}
return false;
};
any = curry$$1(function(f, xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (f(x)) {
return true;
}
}
return false;
});
all = curry$$1(function(f, xs){
var i$, len$, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
if (!f(x)) {
return false;
}
}
return true;
});
sort = function(xs){
return xs.concat().sort(function(x, y){
if (x > y) {
return 1;
} else if (x < y) {
return -1;
} else {
return 0;
}
});
};
sortWith = curry$$1(function(f, xs){
return xs.concat().sort(f);
});
sortBy = curry$$1(function(f, xs){
return xs.concat().sort(function(x, y){
if (f(x) > f(y)) {
return 1;
} else if (f(x) < f(y)) {
return -1;
} else {
return 0;
}
});
});
sum = function(xs){
var result, i$, len$, x;
result = 0;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
result += x;
}
return result;
};
product = function(xs){
var result, i$, len$, x;
result = 1;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
result *= x;
}
return result;
};
mean = average = function(xs){
var sum, i$, len$, x;
sum = 0;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
x = xs[i$];
sum += x;
}
return sum / xs.length;
};
maximum = function(xs){
var max, i$, ref$, len$, x;
max = xs[0];
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
x = ref$[i$];
if (x > max) {
max = x;
}
}
return max;
};
minimum = function(xs){
var min, i$, ref$, len$, x;
min = xs[0];
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
x = ref$[i$];
if (x < min) {
min = x;
}
}
return min;
};
maximumBy = curry$$1(function(f, xs){
var max, i$, ref$, len$, x;
max = xs[0];
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
x = ref$[i$];
if (f(x) > f(max)) {
max = x;
}
}
return max;
});
minimumBy = curry$$1(function(f, xs){
var min, i$, ref$, len$, x;
min = xs[0];
for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
x = ref$[i$];
if (f(x) < f(min)) {
min = x;
}
}
return min;
});
scan = scanl = curry$$1(function(f, memo, xs){
var last, x;
last = memo;
return [memo].concat((function(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
x = ref$[i$];
results$.push(last = f(last, x));
}
return results$;
}()));
});
scan1 = scanl1 = curry$$1(function(f, xs){
if (!xs.length) {
return;
}
return scan(f, xs[0], xs.slice(1));
});
scanr = curry$$1(function(f, memo, xs){
xs = xs.concat().reverse();
return scan(f, memo, xs).reverse();
});
scanr1 = curry$$1(function(f, xs){
if (!xs.length) {
return;
}
xs = xs.concat().reverse();
return scan(f, xs[0], xs.slice(1)).reverse();
});
slice = curry$$1(function(x, y, xs){
return xs.slice(x, y);
});
take = curry$$1(function(n, xs){
if (n <= 0) {
return xs.slice(0, 0);
} else {
return xs.slice(0, n);
}
});
drop = curry$$1(function(n, xs){
if (n <= 0) {
return xs;
} else {
return xs.slice(n);
}
});
splitAt = curry$$1(function(n, xs){
return [take(n, xs), drop(n, xs)];
});
takeWhile = curry$$1(function(p, xs){
var len, i;
len = xs.length;
if (!len) {
return xs;
}
i = 0;
while (i < len && p(xs[i])) {
i += 1;
}
return xs.slice(0, i);
});
dropWhile = curry$$1(function(p, xs){
var len, i;
len = xs.length;
if (!len) {
return xs;
}
i = 0;
while (i < len && p(xs[i])) {
i += 1;
}
return xs.slice(i);
});
span = curry$$1(function(p, xs){
return [takeWhile(p, xs), dropWhile(p, xs)];
});
breakList = curry$$1(function(p, xs){
return span(compose$(p, not$), xs);
});
zip = curry$$1(function(xs, ys){
var result, len, i$, len$, i, x;
result = [];
len = ys.length;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
i = i$;
x = xs[i$];
if (i === len) {
break;
}
result.push([x, ys[i]]);
}
return result;
});
zipWith = curry$$1(function(f, xs, ys){
var result, len, i$, len$, i, x;
result = [];
len = ys.length;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
i = i$;
x = xs[i$];
if (i === len) {
break;
}
result.push(f(x, ys[i]));
}
return result;
});
zipAll = function(){
var xss, res$, i$, to$, minLength, len$, xs, ref$, i, lresult$, j$, results$ = [];
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
xss = res$;
minLength = undefined;
for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
xs = xss[i$];
minLength <= (ref$ = xs.length) || (minLength = ref$);
}
for (i$ = 0; i$ < minLength; ++i$) {
i = i$;
lresult$ = [];
for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
xs = xss[j$];
lresult$.push(xs[i]);
}
results$.push(lresult$);
}
return results$;
};
zipAllWith = function(f){
var xss, res$, i$, to$, minLength, len$, xs, ref$, i, results$ = [];
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
xss = res$;
minLength = undefined;
for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
xs = xss[i$];
minLength <= (ref$ = xs.length) || (minLength = ref$);
}
for (i$ = 0; i$ < minLength; ++i$) {
i = i$;
results$.push(f.apply(null, (fn$())));
}
return results$;
function fn$(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) {
xs = ref$[i$];
results$.push(xs[i]);
}
return results$;
}
};
at = curry$$1(function(n, xs){
if (n < 0) {
return xs[xs.length + n];
} else {
return xs[n];
}
});
elemIndex = curry$$1(function(el, xs){
var i$, len$, i, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
i = i$;
x = xs[i$];
if (x === el) {
return i;
}
}
});
elemIndices = curry$$1(function(el, xs){
var i$, len$, i, x, results$ = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
i = i$;
x = xs[i$];
if (x === el) {
results$.push(i);
}
}
return results$;
});
findIndex = curry$$1(function(f, xs){
var i$, len$, i, x;
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
i = i$;
x = xs[i$];
if (f(x)) {
return i;
}
}
});
findIndices = curry$$1(function(f, xs){
var i$, len$, i, x, results$ = [];
for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
i = i$;
x = xs[i$];
if (f(x)) {
results$.push(i);
}
}
return results$;
});
var List = {
each: each,
map: map,
filter: filter,
compact: compact,
reject: reject,
remove: remove,
partition: partition,
find: find,
head: head,
first: first,
tail: tail,
last: last,
initial: initial,
empty: empty,
reverse: reverse,
difference: difference,
intersection: intersection,
union: union,
countBy: countBy,
groupBy: groupBy,
fold: fold,
fold1: fold1,
foldl: foldl,
foldl1: foldl1,
foldr: foldr,
foldr1: foldr1,
unfoldr: unfoldr,
andList: andList,
orList: orList,
any: any,
all: all,
unique: unique,
uniqueBy: uniqueBy,
sort: sort,
sortWith: sortWith,
sortBy: sortBy,
sum: sum,
product: product,
mean: mean,
average: average,
concat: concat,
concatMap: concatMap,
flatten: flatten,
maximum: maximum,
minimum: minimum,
maximumBy: maximumBy,
minimumBy: minimumBy,
scan: scan,
scan1: scan1,
scanl: scanl,
scanl1: scanl1,
scanr: scanr,
scanr1: scanr1,
slice: slice,
take: take,
drop: drop,
splitAt: splitAt,
takeWhile: takeWhile,
dropWhile: dropWhile,
span: span,
breakList: breakList,
zip: zip,
zipWith: zipWith,
zipAll: zipAll,
zipAllWith: zipAllWith,
at: at,
elemIndex: elemIndex,
elemIndices: elemIndices,
findIndex: findIndex,
findIndices: findIndices
};
function curry$$1(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
function compose$() {
var functions = arguments;
return function() {
var i, result;
result = functions[0].apply(this, arguments);
for (i = 1; i < functions.length; ++i) {
result = functions[i](result);
}
return result;
};
}
function not$(x){ return !x; }
// Generated by LiveScript 1.6.0
var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty$1, each$1, map$1, compact$1, filter$1, reject$1, partition$1, find$1;
values = function(object){
var i$, x, results$ = [];
for (i$ in object) {
x = object[i$];
results$.push(x);
}
return results$;
};
keys = function(object){
var x, results$ = [];
for (x in object) {
results$.push(x);
}
return results$;
};
pairsToObj = function(object){
var i$, len$, x, resultObj$ = {};
for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
x = object[i$];
resultObj$[x[0]] = x[1];
}
return resultObj$;
};
objToPairs = function(object){
var key, value, results$ = [];
for (key in object) {
value = object[key];
results$.push([key, value]);
}
return results$;
};
listsToObj = curry$$2(function(keys, values){
var i$, len$, i, key, resultObj$ = {};
for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) {
i = i$;
key = keys[i$];
resultObj$[key] = values[i];
}
return resultObj$;
});
objToLists = function(object){
var keys, values, key, value;
keys = [];
values = [];
for (key in object) {
value = object[key];
keys.push(key);
values.push(value);
}
return [keys, values];
};
empty$1 = function(object){
var x;
for (x in object) {
return false;
}
return true;
};
each$1 = curry$$2(function(f, object){
var i$, x;
for (i$ in object) {
x = object[i$];
f(x);
}
return object;
});
map$1 = curry$$2(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
resultObj$[k] = f(x);
}
return resultObj$;
});
compact$1 = function(object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (x) {
resultObj$[k] = x;
}
}
return resultObj$;
};
filter$1 = curry$$2(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (f(x)) {
resultObj$[k] = x;
}
}
return resultObj$;
});
reject$1 = curry$$2(function(f, object){
var k, x, resultObj$ = {};
for (k in object) {
x = object[k];
if (!f(x)) {
resultObj$[k] = x;
}
}
return resultObj$;
});
partition$1 = curry$$2(function(f, object){
var passed, failed, k, x;
passed = {};
failed = {};
for (k in object) {
x = object[k];
(f(x) ? passed : failed)[k] = x;
}
return [passed, failed];
});
find$1 = curry$$2(function(f, object){
var i$, x;
for (i$ in object) {
x = object[i$];
if (f(x)) {
return x;
}
}
});
var Obj = {
values: values,
keys: keys,
pairsToObj: pairsToObj,
objToPairs: objToPairs,
listsToObj: listsToObj,
objToLists: objToLists,
empty: empty$1,
each: each$1,
map: map$1,
filter: filter$1,
compact: compact$1,
reject: reject$1,
partition: partition$1,
find: find$1
};
function curry$$2(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
// Generated by LiveScript 1.6.0
var split, join, lines, unlines, words, unwords, chars, unchars, reverse$1, repeat, capitalize, camelize, dasherize;
split = curry$$3(function(sep, str){
return str.split(sep);
});
join = curry$$3(function(sep, xs){
return xs.join(sep);
});
lines = function(str){
if (!str.length) {
return [];
}
return str.split('\n');
};
unlines = function(it){
return it.join('\n');
};
words = function(str){
if (!str.length) {
return [];
}
return str.split(/[ ]+/);
};
unwords = function(it){
return it.join(' ');
};
chars = function(it){
return it.split('');
};
unchars = function(it){
return it.join('');
};
reverse$1 = function(str){
return str.split('').reverse().join('');
};
repeat = curry$$3(function(n, str){
var result, i$;
result = '';
for (i$ = 0; i$ < n; ++i$) {
result += str;
}
return result;
});
capitalize = function(str){
return str.charAt(0).toUpperCase() + str.slice(1);
};
camelize = function(it){
return it.replace(/[-_]+(.)?/g, function(arg$, c){
return (c != null ? c : '').toUpperCase();
});
};
dasherize = function(str){
return str.replace(/([^-A-Z])([A-Z]+)/g, function(arg$, lower, upper){
return lower + "-" + (upper.length > 1
? upper
: upper.toLowerCase());
}).replace(/^([A-Z]+)/, function(arg$, upper){
if (upper.length > 1) {
return upper + "-";
} else {
return upper.toLowerCase();
}
});
};
var Str = {
split: split,
join: join,
lines: lines,
unlines: unlines,
words: words,
unwords: unwords,
chars: chars,
unchars: unchars,
reverse: reverse$1,
repeat: repeat,
capitalize: capitalize,
camelize: camelize,
dasherize: dasherize
};
function curry$$3(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
// Generated by LiveScript 1.6.0
var max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm;
max = curry$$4(function(x$, y$){
return x$ > y$ ? x$ : y$;
});
min = curry$$4(function(x$, y$){
return x$ < y$ ? x$ : y$;
});
negate = function(x){
return -x;
};
abs = Math.abs;
signum = function(x){
if (x < 0) {
return -1;
} else if (x > 0) {
return 1;
} else {
return 0;
}
};
quot = curry$$4(function(x, y){
return ~~(x / y);
});
rem = curry$$4(function(x$, y$){
return x$ % y$;
});
div = curry$$4(function(x, y){
return Math.floor(x / y);
});
mod = curry$$4(function(x$, y$){
var ref$;
return ((x$) % (ref$ = y$) + ref$) % ref$;
});
recip = (function(it){
return 1 / it;
});
pi = Math.PI;
tau = pi * 2;
exp = Math.exp;
sqrt = Math.sqrt;
ln = Math.log;
pow = curry$$4(function(x$, y$){
return Math.pow(x$, y$);
});
sin = Math.sin;
tan = Math.tan;
cos = Math.cos;
asin = Math.asin;
acos = Math.acos;
atan = Math.atan;
atan2 = curry$$4(function(x, y){
return Math.atan2(x, y);
});
truncate = function(x){
return ~~x;
};
round = Math.round;
ceiling = Math.ceil;
floor = Math.floor;
isItNaN = function(x){
return x !== x;
};
even = function(x){
return x % 2 === 0;
};
odd = function(x){
return x % 2 !== 0;
};
gcd = curry$$4(function(x, y){
var z;
x = Math.abs(x);
y = Math.abs(y);
while (y !== 0) {
z = x % y;
x = y;
y = z;
}
return x;
});
lcm = curry$$4(function(x, y){
return Math.abs(Math.floor(x / gcd(x, y) * y));
});
var Num = {
max: max,
min: min,
negate: negate,
abs: abs,
signum: signum,
quot: quot,
rem: rem,
div: div,
mod: mod,
recip: recip,
pi: pi,
tau: tau,
exp: exp,
sqrt: sqrt,
ln: ln,
pow: pow,
sin: sin,
tan: tan,
cos: cos,
acos: acos,
asin: asin,
atan: atan,
atan2: atan2,
truncate: truncate,
round: round,
ceiling: ceiling,
floor: floor,
isItNaN: isItNaN,
even: even,
odd: odd,
gcd: gcd,
lcm: lcm
};
function curry$$4(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
// Generated by LiveScript 1.6.0
var Func$1, List$1, Obj$1, Str$1, Num$1, id, isType, replicate, prelude, toString$$2 = {}.toString;
Func$1 = Func;
List$1 = List;
Obj$1 = Obj;
Str$1 = Str;
Num$1 = Num;
id = function(x){
return x;
};
isType = curry$$5(function(type, x){
return toString$$2.call(x).slice(8, -1) === type;
});
replicate = curry$$5(function(n, x){
var i$, results$ = [];
for (i$ = 0; i$ < n; ++i$) {
results$.push(x);
}
return results$;
});
Str$1.empty = List$1.empty;
Str$1.slice = List$1.slice;
Str$1.take = List$1.take;
Str$1.drop = List$1.drop;
Str$1.splitAt = List$1.splitAt;
Str$1.takeWhile = List$1.takeWhile;
Str$1.dropWhile = List$1.dropWhile;
Str$1.span = List$1.span;
Str$1.breakStr = List$1.breakList;
prelude = {
Func: Func$1,
List: List$1,
Obj: Obj$1,
Str: Str$1,
Num: Num$1,
id: id,
isType: isType,
replicate: replicate
};
prelude.each = List$1.each;
prelude.map = List$1.map;
prelude.filter = List$1.filter;
prelude.compact = List$1.compact;
prelude.reject = List$1.reject;
prelude.partition = List$1.partition;
prelude.find = List$1.find;
prelude.head = List$1.head;
prelude.first = List$1.first;
prelude.tail = List$1.tail;
prelude.last = List$1.last;
prelude.initial = List$1.initial;
prelude.empty = List$1.empty;
prelude.reverse = List$1.reverse;
prelude.difference = List$1.difference;
prelude.intersection = List$1.intersection;
prelude.union = List$1.union;
prelude.countBy = List$1.countBy;
prelude.groupBy = List$1.groupBy;
prelude.fold = List$1.fold;
prelude.foldl = List$1.foldl;
prelude.fold1 = List$1.fold1;
prelude.foldl1 = List$1.foldl1;
prelude.foldr = List$1.foldr;
prelude.foldr1 = List$1.foldr1;
prelude.unfoldr = List$1.unfoldr;
prelude.andList = List$1.andList;
prelude.orList = List$1.orList;
prelude.any = List$1.any;
prelude.all = List$1.all;
prelude.unique = List$1.unique;
prelude.uniqueBy = List$1.uniqueBy;
prelude.sort = List$1.sort;
prelude.sortWith = List$1.sortWith;
prelude.sortBy = List$1.sortBy;
prelude.sum = List$1.sum;
prelude.product = List$1.product;
prelude.mean = List$1.mean;
prelude.average = List$1.average;
prelude.concat = List$1.concat;
prelude.concatMap = List$1.concatMap;
prelude.flatten = List$1.flatten;
prelude.maximum = List$1.maximum;
prelude.minimum = List$1.minimum;
prelude.maximumBy = List$1.maximumBy;
prelude.minimumBy = List$1.minimumBy;
prelude.scan = List$1.scan;
prelude.scanl = List$1.scanl;
prelude.scan1 = List$1.scan1;
prelude.scanl1 = List$1.scanl1;
prelude.scanr = List$1.scanr;
prelude.scanr1 = List$1.scanr1;
prelude.slice = List$1.slice;
prelude.take = List$1.take;
prelude.drop = List$1.drop;
prelude.splitAt = List$1.splitAt;
prelude.takeWhile = List$1.takeWhile;
prelude.dropWhile = List$1.dropWhile;
prelude.span = List$1.span;
prelude.breakList = List$1.breakList;
prelude.zip = List$1.zip;
prelude.zipWith = List$1.zipWith;
prelude.zipAll = List$1.zipAll;
prelude.zipAllWith = List$1.zipAllWith;
prelude.at = List$1.at;
prelude.elemIndex = List$1.elemIndex;
prelude.elemIndices = List$1.elemIndices;
prelude.findIndex = List$1.findIndex;
prelude.findIndices = List$1.findIndices;
prelude.apply = Func$1.apply;
prelude.curry = Func$1.curry;
prelude.flip = Func$1.flip;
prelude.fix = Func$1.fix;
prelude.over = Func$1.over;
prelude.split = Str$1.split;
prelude.join = Str$1.join;
prelude.lines = Str$1.lines;
prelude.unlines = Str$1.unlines;
prelude.words = Str$1.words;
prelude.unwords = Str$1.unwords;
prelude.chars = Str$1.chars;
prelude.unchars = Str$1.unchars;
prelude.repeat = Str$1.repeat;
prelude.capitalize = Str$1.capitalize;
prelude.camelize = Str$1.camelize;
prelude.dasherize = Str$1.dasherize;
prelude.values = Obj$1.values;
prelude.keys = Obj$1.keys;
prelude.pairsToObj = Obj$1.pairsToObj;
prelude.objToPairs = Obj$1.objToPairs;
prelude.listsToObj = Obj$1.listsToObj;
prelude.objToLists = Obj$1.objToLists;
prelude.max = Num$1.max;
prelude.min = Num$1.min;
prelude.negate = Num$1.negate;
prelude.abs = Num$1.abs;
prelude.signum = Num$1.signum;
prelude.quot = Num$1.quot;
prelude.rem = Num$1.rem;
prelude.div = Num$1.div;
prelude.mod = Num$1.mod;
prelude.recip = Num$1.recip;
prelude.pi = Num$1.pi;
prelude.tau = Num$1.tau;
prelude.exp = Num$1.exp;
prelude.sqrt = Num$1.sqrt;
prelude.ln = Num$1.ln;
prelude.pow = Num$1.pow;
prelude.sin = Num$1.sin;
prelude.tan = Num$1.tan;
prelude.cos = Num$1.cos;
prelude.acos = Num$1.acos;
prelude.asin = Num$1.asin;
prelude.atan = Num$1.atan;
prelude.atan2 = Num$1.atan2;
prelude.truncate = Num$1.truncate;
prelude.round = Num$1.round;
prelude.ceiling = Num$1.ceiling;
prelude.floor = Num$1.floor;
prelude.isItNaN = Num$1.isItNaN;
prelude.even = Num$1.even;
prelude.odd = Num$1.odd;
prelude.gcd = Num$1.gcd;
prelude.lcm = Num$1.lcm;
prelude.VERSION = '1.2.1';
var lib$1 = prelude;
function curry$$5(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}
var eventEmitter = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, reject, maximum, map, EventEmitter, out$ = exports || commonjsGlobal, toString$ = {}.toString;
ref$ = lib$1, reject = ref$.reject, maximum = ref$.maximum, map = ref$.map;
out$.EventEmitter = EventEmitter = (function(){
EventEmitter.displayName = 'EventEmitter';
function EventEmitter(){
this._events = {};
this._one_time_events = {};
}
EventEmitter.prototype.once = function(type, callback){
var addListener, name, this$ = this;
addListener = function(type, callback){
if (toString$.call(this$._one_time_events[type]).slice(8, -1) !== 'Array') {
this$._one_time_events[type] = [];
}
return this$._one_time_events[type].push(callback.bind(this$));
};
switch (toString$.call(type).slice(8, -1)) {
case 'String':
addListener(type, callback);
break;
case 'Object':
for (name in type) {
callback = type[name];
addListener(name, callback);
}
}
};
EventEmitter.prototype.on = function(type, id, callback){
"usage:\n\n with simple string name:\n\n .on 'name', fn\n\n or with an object:\n\n .on do\n 'name1': fn\n 'name2': fn2";
var _id, addListener, control, name, this$ = this;
if (toString$.call(id).slice(8, -1) === 'Function') {
callback = id;
_id = maximum(
map(parseInt)(
(function(){
var i$, x$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = this._events).length; i$ < len$; ++i$) {
x$ = ref$[i$];
results$.push(x$.id);
}
return results$;
}.call(this))));
id = (_id || 0) + 1;
}
addListener = function(type, id, callback){
var ref$;
((ref$ = this$._events)[type] || (ref$[type] = [])).push({
id: id,
cb: callback.bind(this$)
});
return {
cancel: function(){
return this$.cancel(id);
}
};
};
control = null;
switch (toString$.call(type).slice(8, -1)) {
case 'String':
control = addListener(type, id, callback);
break;
case 'Object':
for (name in type) {
callback = type[name];
addListener(name, id, callback);
}
}
return control;
};
EventEmitter.prototype.off = function(type){
return this._events[type] = [];
};
EventEmitter.prototype.cancel = function(id){
var type, ref$, listeners, i, listener;
for (type in ref$ = this._events) {
listeners = ref$[type];
for (i in listeners) {
listener = listeners[i];
if (listener.id === id) {
listeners.splice(i, 1);
break;
}
}
}
};
EventEmitter.prototype.trigger = function(type){
"usage:\n\n .trigger \"eventName\", ...x\n";
var args, res$, i$, to$, that, len$, ref$, i, handler, results$ = [];
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
if (that = this._events[type]) {
for (i$ = 0, len$ = that.length; i$ < len$; ++i$) {
(fn$.call(this, that[i$]));
}
}
if (that = this._one_time_events[type]) {
for (i$ = 0, len$ = (ref$ = (fn1$())).length; i$ < len$; ++i$) {
i = ref$[i$];
handler = that.shift();
results$.push(handler.apply(null, args));
}
return results$;
}
function fn$(handler){
setImmediate(function(){
return handler.cb.apply(handler, args);
});
}
function fn1$(){
var i$, to$, results$ = [];
for (i$ = 1, to$ = that.length; i$ <= to$; ++i$) {
results$.push(i$);
}
return results$;
}
};
EventEmitter.prototype.hasListener = function(ev){
var that, i$, x$, len$;
if (that = this._events[ev]) {
for (i$ = 0, len$ = that.length; i$ < len$; ++i$) {
x$ = that[i$];
if (toString$.call(x$.cb).slice(8, -1) === 'Function') {
return true;
}
}
}
return false;
};
return EventEmitter;
}());
});
var logger = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, green, gray, yellow, magenta, bgRed, bgYellow, cyan, bgCyan, bgGreen, moment$1, map, EventEmitter, NEED_STACK_TRACE, fmt, startTime, alignLeft, getTimestamp, getPrefix, IS_NODE, LogManager, Logger, out$ = exports || commonjsGlobal, slice$ = [].slice, arrayFrom$ = Array.from || function(x){return slice$.call(x);}, toString$ = {}.toString;
ref$ = lib, green = ref$.green, gray = ref$.gray, yellow = ref$.yellow, magenta = ref$.magenta, bgRed = ref$.bgRed, bgYellow = ref$.bgYellow, cyan = ref$.cyan, bgCyan = ref$.bgCyan, bgGreen = ref$.bgGreen;
moment$1 = moment;
map = lib$1.map;
EventEmitter = eventEmitter.EventEmitter;
NEED_STACK_TRACE = false;
fmt = 'HH:mm:ss.SSS';
startTime = new moment$1;
alignLeft = function(width, inp){
var x;
return x = (inp + repeatString$(" ", width)).slice(0, width);
};
getTimestamp = function(){
return (new moment$1).format(fmt);
};
getPrefix = function(_source, color){
var padded;
if (!color) {
color = gray;
}
padded = alignLeft(15, _source + "");
return color("[" + getTimestamp() + "]") + (" " + padded + " :");
};
IS_NODE = function(){
var isNode;
isNode = false;
if (typeof process === 'object') {
if (typeof process.versions === 'object') {
if (typeof process.versions.node !== 'undefined') {
isNode = true;
}
}
}
return isNode;
}();
LogManager = (function(superclass){
var prototype = extend$((import$(LogManager, superclass).displayName = 'LogManager', LogManager), superclass).prototype, constructor = LogManager;
constructor.instance = null;
function LogManager(){
if (constructor.instance) {
return constructor.instance;
}
LogManager.superclass.call(this);
constructor.instance = this;
this.loggers = [];
}
LogManager.prototype.register = function(ctx){
return this.loggers.push(ctx);
};
return LogManager;
}(EventEmitter));
out$.Logger = Logger = (function(superclass){
var prototype = extend$((import$(Logger, superclass).displayName = 'Logger', Logger), superclass).prototype;
function Logger(sourceName, opts){
this.debug = bind$(this, 'debug', prototype);
this.todo = bind$(this, 'todo', prototype);
this.info = bind$(this, 'info', prototype);
this.warn = bind$(this, 'warn', prototype);
this.err = bind$(this, 'err', prototype);
this.success = bind$(this, 'success', prototype);
this.log = bind$(this, 'log', prototype);
Logger.superclass.call(this);
this.name = sourceName;
this.mgr = new LogManager();
this.prefix = null;
this.error = this.err;
}
Logger.prototype.getPrefix = function(color){
return getPrefix((this.prefix ? this.prefix + "/" : '') + "" + this.name, color);
};
Logger.prototype.log = function(){
var args, res$, i$, to$, prefix, ref$, _args, my, len$, arg, log;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
prefix = getPrefix(this.name);
if (IS_NODE) {
return (ref$ = console.log).call.apply(ref$, [console, prefix].concat(arrayFrom$(args)));
} else {
_args = [];
my = "%c";
for (i$ = 0, len$ = (ref$ = [prefix].concat(args)).length; i$ < len$; ++i$) {
arg = ref$[i$];
_args.push(arg);
my += " " + (toString$.call(arg).slice(8, -1) === 'String'
? "%s"
: toString$.call(arg).slice(8, -1) === 'Number' ? "%d" : "%O");
}
if (NEED_STACK_TRACE) {
console.groupCollapsed.apply(console, [my, "font-weight: normal;"].concat(arrayFrom$(_args)));
console.trace(prefix);
return console.groupEnd();
} else {
log = Function.prototype.bind.call(console.log, console);
return log.call.apply(log, [console, my, "font-weight: normal;"].concat(arrayFrom$(_args)));
}
}
};
Logger.prototype.success = function(){
var args, res$, i$, to$;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
return console.log.apply(console, [this.getPrefix(bgGreen)].concat(args));
};
Logger.prototype.err = function(){
var args, res$, i$, to$, ref$;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
console.error.apply(console, [this.getPrefix(bgRed)].concat(args));
this.trigger.apply(this, ['err'].concat(arrayFrom$(args)));
return (ref$ = this.mgr).trigger.apply(ref$, ['err'].concat(arrayFrom$(args)));
};
Logger.prototype.warn = function(){
var args, res$, i$, to$;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
return console.warn.apply(console, [this.getPrefix(bgYellow), yellow('[WARNING]')].concat(args));
};
Logger.prototype.info = function(){
var args, res$, i$, to$;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
return console.info.apply(console, [this.getPrefix(), cyan('[I]')].concat(args));
};
Logger.prototype.todo = function(){
var args, res$, i$, to$;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
return console.warn.apply(console, [this.getPrefix(), magenta('[TODO]')].concat(args));
};
Logger.prototype.debug = function(){
var args, res$, i$, to$;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
return console.warn.apply(console, [this.getPrefix(), yellow('[D]')].concat(args));
};
return Logger;
}(EventEmitter));
function repeatString$(str, n){
for (var r = ''; n > 0; (n >>= 1) && (str += str)) if (n & 1) r += str;
return r;
}
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
function bind$(obj, key, target){
return function(){ return (target || obj)[key].apply(obj, arguments) };
}
});
(function (global, undefined$1) {
if (global.setImmediate) {
return;
}
var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};
var currentlyRunningATask = false;
var doc = global.document;
var registerImmediate;
function setImmediate(callback) {
// Callback can either be a function or a string
if (typeof callback !== "function") {
callback = new Function("" + callback);
}
// Copy function arguments
var args = new Array(arguments.length - 1);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i + 1];
}
// Store and register the task
var task = { callback: callback, args: args };
tasksByHandle[nextHandle] = task;
registerImmediate(nextHandle);
return nextHandle++;
}
function clearImmediate(handle) {
delete tasksByHandle[handle];
}
function run(task) {
var callback = task.callback;
var args = task.args;
switch (args.length) {
case 0:
callback();
break;
case 1:
callback(args[0]);
break;
case 2:
callback(args[0], args[1]);
break;
case 3:
callback(args[0], args[1], args[2]);
break;
default:
callback.apply(undefined$1, args);
break;
}
}
function runIfPresent(handle) {
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
// So if we're currently running a task, we'll need to delay this invocation.
if (currentlyRunningATask) {
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// "too much recursion" error.
setTimeout(runIfPresent, 0, handle);
} else {
var task = tasksByHandle[handle];
if (task) {
currentlyRunningATask = true;
try {
run(task);
} finally {
clearImmediate(handle);
currentlyRunningATask = false;
}
}
}
}
function installNextTickImplementation() {
registerImmediate = function(handle) {
process.nextTick(function () { runIfPresent(handle); });
};
}
function canUsePostMessage() {
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
// where `global.postMessage` means something completely different and can't be used for this purpose.
if (global.postMessage && !global.importScripts) {
var postMessageIsAsynchronous = true;
var oldOnMessage = global.onmessage;
global.onmessage = function() {
postMessageIsAsynchronous = false;
};
global.postMessage("", "*");
global.onmessage = oldOnMessage;
return postMessageIsAsynchronous;
}
}
function installPostMessageImplementation() {
// Installs an event handler on `global` for the `message` event: see
// * https://developer.mozilla.org/en/DOM/window.postMessage
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
var messagePrefix = "setImmediate$" + Math.random() + "$";
var onGlobalMessage = function(event) {
if (event.source === global &&
typeof event.data === "string" &&
event.data.indexOf(messagePrefix) === 0) {
runIfPresent(+event.data.slice(messagePrefix.length));
}
};
if (global.addEventListener) {
global.addEventListener("message", onGlobalMessage, false);
} else {
global.attachEvent("onmessage", onGlobalMessage);
}
registerImmediate = function(handle) {
global.postMessage(messagePrefix + handle, "*");
};
}
function installMessageChannelImplementation() {
var channel = new MessageChannel();
channel.port1.onmessage = function(event) {
var handle = event.data;
runIfPresent(handle);
};
registerImmediate = function(handle) {
channel.port2.postMessage(handle);
};
}
function installReadyStateChangeImplementation() {
var html = doc.documentElement;
registerImmediate = function(handle) {
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
var script = doc.createElement("script");
script.onreadystatechange = function () {
runIfPresent(handle);
script.onreadystatechange = null;
html.removeChild(script);
script = null;
};
html.appendChild(script);
};
}
function installSetTimeoutImplementation() {
registerImmediate = function(handle) {
setTimeout(runIfPresent, 0, handle);
};
}
// If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
// Don't get fooled by e.g. browserify environments.
if ({}.toString.call(global.process) === "[object process]") {
// For Node.js before 0.9
installNextTickImplementation();
} else if (canUsePostMessage()) {
// For non-IE10 modern browsers
installPostMessageImplementation();
} else if (global.MessageChannel) {
// For web workers, where supported
installMessageChannelImplementation();
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
// For IE 6–8
installReadyStateChangeImplementation();
} else {
// For older browsers
installSetTimeoutImplementation();
}
attachTo.setImmediate = setImmediate;
attachTo.clearImmediate = clearImmediate;
}(typeof self === "undefined" ? typeof commonjsGlobal === "undefined" ? commonjsGlobal : commonjsGlobal : self));
var sleep_1 = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var sleep, clearTimer, out$ = exports || commonjsGlobal;
out$.sleep = sleep = function(ms, f){
return setTimeout(f, ms);
};
out$.clearTimer = clearTimer = function(x){
return clearInterval(x);
};
});
var isBrowser = typeof window !== 'undefined';
var environment = {
isBrowser: isBrowser
};
var Processor = function Processor(options){
this.selfOptions = options || {};
this.pipes = {};
};
Processor.prototype.options = function(options) {
if (options) {
this.selfOptions = options;
}
return this.selfOptions;
};
Processor.prototype.pipe = function(name, pipe) {
if (typeof name === 'string') {
if (typeof pipe === 'undefined') {
return this.pipes[name];
} else {
this.pipes[name] = pipe;
}
}
if (name && name.name) {
pipe = name;
if (pipe.processor === this) { return pipe; }
this.pipes[pipe.name] = pipe;
}
pipe.processor = this;
return pipe;
};
Processor.prototype.process = function(input, pipe) {
var context = input;
context.options = this.options();
var nextPipe = pipe || input.pipe || 'default';
var lastPipe, lastContext;
while (nextPipe) {
if (typeof context.nextAfterChildren !== 'undefined') {
// children processed and coming back to parent
context.next = context.nextAfterChildren;
context.nextAfterChildren = null;
}
if (typeof nextPipe === 'string') {
nextPipe = this.pipe(nextPipe);
}
nextPipe.process(context);
lastContext = context;
lastPipe = nextPipe;
nextPipe = null;
if (context) {
if (context.next) {
context = context.next;
nextPipe = lastContext.nextPipe || context.pipe || lastPipe;
}
}
}
return context.hasResult ? context.result : undefined;
};
var Processor_1 = Processor;
var processor = {
Processor: Processor_1
};
var Pipe = function Pipe(name) {
this.name = name;
this.filters = [];
};
Pipe.prototype.process = function(input) {
if (!this.processor) {
throw new Error('add this pipe to a processor before using it');
}
var debug = this.debug;
var length = this.filters.length;
var context = input;
for (var index = 0; index < length; index++) {
var filter = this.filters[index];
if (debug) {
this.log('filter: ' + filter.filterName);
}
filter(context);
if (typeof context === 'object' && context.exiting) {
context.exiting = false;
break;
}
}
if (!context.next && this.resultCheck) {
this.resultCheck(context);
}
};
Pipe.prototype.log = function(msg) {
console.log('[jsondiffpatch] ' + this.name + ' pipe, ' + msg);
};
Pipe.prototype.append = function() {
this.filters.push.apply(this.filters, arguments);
return this;
};
Pipe.prototype.prepend = function() {
this.filters.unshift.apply(this.filters, arguments);
return this;
};
Pipe.prototype.indexOf = function(filterName) {
if (!filterName) {
throw new Error('a filter name is required');
}
for (var index = 0; index < this.filters.length; index++) {
var filter = this.filters[index];
if (filter.filterName === filterName) {
return index;
}
}
throw new Error('filter not found: ' + filterName);
};
Pipe.prototype.list = function() {
var names = [];
for (var index = 0; index < this.filters.length; index++) {
var filter = this.filters[index];
names.push(filter.filterName);
}
return names;
};
Pipe.prototype.after = function(filterName) {
var index = this.indexOf(filterName);
var params = Array.prototype.slice.call(arguments, 1);
if (!params.length) {
throw new Error('a filter is required');
}
params.unshift(index + 1, 0);
Array.prototype.splice.apply(this.filters, params);
return this;
};
Pipe.prototype.before = function(filterName) {
var index = this.indexOf(filterName);
var params = Array.prototype.slice.call(arguments, 1);
if (!params.length) {
throw new Error('a filter is required');
}
params.unshift(index, 0);
Array.prototype.splice.apply(this.filters, params);
return this;
};
Pipe.prototype.replace = function(filterName) {
var index = this.indexOf(filterName);
var params = Array.prototype.slice.call(arguments, 1);
if (!params.length) {
throw new Error('a filter is required');
}
params.unshift(index, 1);
Array.prototype.splice.apply(this.filters, params);
return this;
};
Pipe.prototype.remove = function(filterName) {
var index = this.indexOf(filterName);
this.filters.splice(index, 1);
return this;
};
Pipe.prototype.clear = function() {
this.filters.length = 0;
return this;
};
Pipe.prototype.shouldHaveResult = function(should) {
if (should === false) {
this.resultCheck = null;
return;
}
if (this.resultCheck) {
return;
}
var pipe = this;
this.resultCheck = function(context) {
if (!context.hasResult) {
console.log(context);
var error = new Error(pipe.name + ' failed');
error.noResult = true;
throw error;
}
};
return this;
};
var Pipe_1 = Pipe;
var pipe = {
Pipe: Pipe_1
};
var Pipe$1 = pipe.Pipe;
var Context = function Context(){
};
Context.prototype.setResult = function(result) {
this.result = result;
this.hasResult = true;
return this;
};
Context.prototype.exit = function() {
this.exiting = true;
return this;
};
Context.prototype.switchTo = function(next, pipe) {
if (typeof next === 'string' || next instanceof Pipe$1) {
this.nextPipe = next;
} else {
this.next = next;
if (pipe) {
this.nextPipe = pipe;
}
}
return this;
};
Context.prototype.push = function(child, name) {
child.parent = this;
if (typeof name !== 'undefined') {
child.childName = name;
}
child.root = this.root || this;
child.options = child.options || this.options;
if (!this.children) {
this.children = [child];
this.nextAfterChildren = this.next || null;
this.next = child;
} else {
this.children[this.children.length - 1].next = child;
this.children.push(child);
}
child.next = this;
return this;
};
var Context_1 = Context;
var context = {
Context: Context_1
};
var isArray = (typeof Array.isArray === 'function') ?
// use native function
Array.isArray :
// use instanceof operator
function(a) {
return a instanceof Array;
};
function cloneRegExp(re) {
var regexMatch = /^\/(.*)\/([gimyu]*)$/.exec(re.toString());
return new RegExp(regexMatch[1], regexMatch[2]);
}
function clone(arg) {
if (typeof arg !== 'object') {
return arg;
}
if (arg === null) {
return null;
}
if (isArray(arg)) {
return arg.map(clone);
}
if (arg instanceof Date) {
return new Date(arg.getTime());
}
if (arg instanceof RegExp) {
return cloneRegExp(arg);
}
var cloned = {};
for (var name in arg) {
if (Object.prototype.hasOwnProperty.call(arg, name)) {
cloned[name] = clone(arg[name]);
}
}
return cloned;
}
var clone_1 = clone;
var Context$1 = context.Context;
var DiffContext = function DiffContext(left, right) {
this.left = left;
this.right = right;
this.pipe = 'diff';
};
DiffContext.prototype = new Context$1();
DiffContext.prototype.setResult = function(result) {
if (this.options.cloneDiffValues && typeof result === 'object') {
var clone = typeof this.options.cloneDiffValues === 'function' ?
this.options.cloneDiffValues : clone_1;
if (typeof result[0] === 'object') {
result[0] = clone(result[0]);
}
if (typeof result[1] === 'object') {
result[1] = clone(result[1]);
}
}
return Context$1.prototype.setResult.apply(this, arguments);
};
var DiffContext_1 = DiffContext;
var diff = {
DiffContext: DiffContext_1
};
var Context$2 = context.Context;
var PatchContext = function PatchContext(left, delta) {
this.left = left;
this.delta = delta;
this.pipe = 'patch';
};
PatchContext.prototype = new Context$2();
var PatchContext_1 = PatchContext;
var patch = {
PatchContext: PatchContext_1
};
var Context$3 = context.Context;
var ReverseContext = function ReverseContext(delta) {
this.delta = delta;
this.pipe = 'reverse';
};
ReverseContext.prototype = new Context$3();
var ReverseContext_1 = ReverseContext;
var reverse$2 = {
ReverseContext: ReverseContext_1
};
var isArray$1 = (typeof Array.isArray === 'function') ?
// use native function
Array.isArray :
// use instanceof operator
function(a) {
return a instanceof Array;
};
var diffFilter = function trivialMatchesDiffFilter(context) {
if (context.left === context.right) {
context.setResult(undefined).exit();
return;
}
if (typeof context.left === 'undefined') {
if (typeof context.right === 'function') {
throw new Error('functions are not supported');
}
context.setResult([context.right]).exit();
return;
}
if (typeof context.right === 'undefined') {
context.setResult([context.left, 0, 0]).exit();
return;
}
if (typeof context.left === 'function' || typeof context.right === 'function') {
throw new Error('functions are not supported');
}
context.leftType = context.left === null ? 'null' : typeof context.left;
context.rightType = context.right === null ? 'null' : typeof context.right;
if (context.leftType !== context.rightType) {
context.setResult([context.left, context.right]).exit();
return;
}
if (context.leftType === 'boolean' || context.leftType === 'number') {
context.setResult([context.left, context.right]).exit();
return;
}
if (context.leftType === 'object') {
context.leftIsArray = isArray$1(context.left);
}
if (context.rightType === 'object') {
context.rightIsArray = isArray$1(context.right);
}
if (context.leftIsArray !== context.rightIsArray) {
context.setResult([context.left, context.right]).exit();
return;
}
if (context.left instanceof RegExp) {
if (context.right instanceof RegExp) {
context.setResult([context.left.toString(), context.right.toString()]).exit();
} else {
context.setResult([context.left, context.right]).exit();
return;
}
}
};
diffFilter.filterName = 'trivial';
var patchFilter = function trivialMatchesPatchFilter(context) {
if (typeof context.delta === 'undefined') {
context.setResult(context.left).exit();
return;
}
context.nested = !isArray$1(context.delta);
if (context.nested) {
return;
}
if (context.delta.length === 1) {
context.setResult(context.delta[0]).exit();
return;
}
if (context.delta.length === 2) {
if (context.left instanceof RegExp) {
var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(context.delta[1]);
if (regexArgs) {
context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
return;
}
}
context.setResult(context.delta[1]).exit();
return;
}
if (context.delta.length === 3 && context.delta[2] === 0) {
context.setResult(undefined).exit();
return;
}
};
patchFilter.filterName = 'trivial';
var reverseFilter = function trivialReferseFilter(context) {
if (typeof context.delta === 'undefined') {
context.setResult(context.delta).exit();
return;
}
context.nested = !isArray$1(context.delta);
if (context.nested) {
return;
}
if (context.delta.length === 1) {
context.setResult([context.delta[0], 0, 0]).exit();
return;
}
if (context.delta.length === 2) {
context.setResult([context.delta[1], context.delta[0]]).exit();
return;
}
if (context.delta.length === 3 && context.delta[2] === 0) {
context.setResult([context.delta[0]]).exit();
return;
}
};
reverseFilter.filterName = 'trivial';
var diffFilter_1 = diffFilter;
var patchFilter_1 = patchFilter;
var reverseFilter_1 = reverseFilter;
var trivial = {
diffFilter: diffFilter_1,
patchFilter: patchFilter_1,
reverseFilter: reverseFilter_1
};
var DiffContext$1 = diff.DiffContext;
var PatchContext$1 = patch.PatchContext;
var ReverseContext$1 = reverse$2.ReverseContext;
var collectChildrenDiffFilter = function collectChildrenDiffFilter(context) {
if (!context || !context.children) {
return;
}
var length = context.children.length;
var child;
var result = context.result;
for (var index = 0; index < length; index++) {
child = context.children[index];
if (typeof child.result === 'undefined') {
continue;
}
result = result || {};
result[child.childName] = child.result;
}
if (result && context.leftIsArray) {
result._t = 'a';
}
context.setResult(result).exit();
};
collectChildrenDiffFilter.filterName = 'collectChildren';
var objectsDiffFilter = function objectsDiffFilter(context) {
if (context.leftIsArray || context.leftType !== 'object') {
return;
}
var name, child, propertyFilter = context.options.propertyFilter;
for (name in context.left) {
if (!Object.prototype.hasOwnProperty.call(context.left, name)) {
continue;
}
if (propertyFilter && !propertyFilter(name, context)) {
continue;
}
child = new DiffContext$1(context.left[name], context.right[name]);
context.push(child, name);
}
for (name in context.right) {
if (!Object.prototype.hasOwnProperty.call(context.right, name)) {
continue;
}
if (propertyFilter && !propertyFilter(name, context)) {
continue;
}
if (typeof context.left[name] === 'undefined') {
child = new DiffContext$1(undefined, context.right[name]);
context.push(child, name);
}
}
if (!context.children || context.children.length === 0) {
context.setResult(undefined).exit();
return;
}
context.exit();
};
objectsDiffFilter.filterName = 'objects';
var patchFilter$1 = function nestedPatchFilter(context) {
if (!context.nested) {
return;
}
if (context.delta._t) {
return;
}
var name, child;
for (name in context.delta) {
child = new PatchContext$1(context.left[name], context.delta[name]);
context.push(child, name);
}
context.exit();
};
patchFilter$1.filterName = 'objects';
var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
if (!context || !context.children) {
return;
}
if (context.delta._t) {
return;
}
var length = context.children.length;
var child;
for (var index = 0; index < length; index++) {
child = context.children[index];
if (Object.prototype.hasOwnProperty.call(context.left, child.childName) && child.result === undefined) {
delete context.left[child.childName];
} else if (context.left[child.childName] !== child.result) {
context.left[child.childName] = child.result;
}
}
context.setResult(context.left).exit();
};
collectChildrenPatchFilter.filterName = 'collectChildren';
var reverseFilter$1 = function nestedReverseFilter(context) {
if (!context.nested) {
return;
}
if (context.delta._t) {
return;
}
var name, child;
for (name in context.delta) {
child = new ReverseContext$1(context.delta[name]);
context.push(child, name);
}
context.exit();
};
reverseFilter$1.filterName = 'objects';
var collectChildrenReverseFilter = function collectChildrenReverseFilter(context) {
if (!context || !context.children) {
return;
}
if (context.delta._t) {
return;
}
var length = context.children.length;
var child;
var delta = {};
for (var index = 0; index < length; index++) {
child = context.children[index];
if (delta[child.childName] !== child.result) {
delta[child.childName] = child.result;
}
}
context.setResult(delta).exit();
};
collectChildrenReverseFilter.filterName = 'collectChildren';
var collectChildrenDiffFilter_1 = collectChildrenDiffFilter;
var objectsDiffFilter_1 = objectsDiffFilter;
var patchFilter_1$1 = patchFilter$1;
var collectChildrenPatchFilter_1 = collectChildrenPatchFilter;
var reverseFilter_1$1 = reverseFilter$1;
var collectChildrenReverseFilter_1 = collectChildrenReverseFilter;
var nested = {
collectChildrenDiffFilter: collectChildrenDiffFilter_1,
objectsDiffFilter: objectsDiffFilter_1,
patchFilter: patchFilter_1$1,
collectChildrenPatchFilter: collectChildrenPatchFilter_1,
reverseFilter: reverseFilter_1$1,
collectChildrenReverseFilter: collectChildrenReverseFilter_1
};
/*
LCS implementation that supports arrays or strings
reference: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
*/
var defaultMatch = function(array1, array2, index1, index2) {
return array1[index1] === array2[index2];
};
var lengthMatrix = function(array1, array2, match, context) {
var len1 = array1.length;
var len2 = array2.length;
var x, y;
// initialize empty matrix of len1+1 x len2+1
var matrix = [len1 + 1];
for (x = 0; x < len1 + 1; x++) {
matrix[x] = [len2 + 1];
for (y = 0; y < len2 + 1; y++) {
matrix[x][y] = 0;
}
}
matrix.match = match;
// save sequence lengths for each coordinate
for (x = 1; x < len1 + 1; x++) {
for (y = 1; y < len2 + 1; y++) {
if (match(array1, array2, x - 1, y - 1, context)) {
matrix[x][y] = matrix[x - 1][y - 1] + 1;
} else {
matrix[x][y] = Math.max(matrix[x - 1][y], matrix[x][y - 1]);
}
}
}
return matrix;
};
var backtrack = function(matrix, array1, array2, index1, index2, context) {
if (index1 === 0 || index2 === 0) {
return {
sequence: [],
indices1: [],
indices2: []
};
}
if (matrix.match(array1, array2, index1 - 1, index2 - 1, context)) {
var subsequence = backtrack(matrix, array1, array2, index1 - 1, index2 - 1, context);
subsequence.sequence.push(array1[index1 - 1]);
subsequence.indices1.push(index1 - 1);
subsequence.indices2.push(index2 - 1);
return subsequence;
}
if (matrix[index1][index2 - 1] > matrix[index1 - 1][index2]) {
return backtrack(matrix, array1, array2, index1, index2 - 1, context);
} else {
return backtrack(matrix, array1, array2, index1 - 1, index2, context);
}
};
var get = function(array1, array2, match, context) {
context = context || {};
var matrix = lengthMatrix(array1, array2, match || defaultMatch, context);
var result = backtrack(matrix, array1, array2, array1.length, array2.length, context);
if (typeof array1 === 'string' && typeof array2 === 'string') {
result.sequence = result.sequence.join('');
}
return result;
};
var get_1 = get;
var lcs = {
get: get_1
};
var DiffContext$2 = diff.DiffContext;
var PatchContext$2 = patch.PatchContext;
var ReverseContext$2 = reverse$2.ReverseContext;
var ARRAY_MOVE = 3;
var isArray$2 = (typeof Array.isArray === 'function') ?
// use native function
Array.isArray :
// use instanceof operator
function(a) {
return a instanceof Array;
};
var arrayIndexOf = typeof Array.prototype.indexOf === 'function' ?
function(array, item) {
return array.indexOf(item);
} : function(array, item) {
var length = array.length;
for (var i = 0; i < length; i++) {
if (array[i] === item) {
return i;
}
}
return -1;
};
function arraysHaveMatchByRef(array1, array2, len1, len2) {
for (var index1 = 0; index1 < len1; index1++) {
var val1 = array1[index1];
for (var index2 = 0; index2 < len2; index2++) {
var val2 = array2[index2];
if (index1 !== index2 && val1 === val2) {
return true;
}
}
}
}
function matchItems(array1, array2, index1, index2, context) {
var value1 = array1[index1];
var value2 = array2[index2];
if (value1 === value2) {
return true;
}
if (typeof value1 !== 'object' || typeof value2 !== 'object') {
return false;
}
var objectHash = context.objectHash;
if (!objectHash) {
// no way to match objects was provided, try match by position
return context.matchByPosition && index1 === index2;
}
var hash1;
var hash2;
if (typeof index1 === 'number') {
context.hashCache1 = context.hashCache1 || [];
hash1 = context.hashCache1[index1];
if (typeof hash1 === 'undefined') {
context.hashCache1[index1] = hash1 = objectHash(value1, index1);
}
} else {
hash1 = objectHash(value1);
}
if (typeof hash1 === 'undefined') {
return false;
}
if (typeof index2 === 'number') {
context.hashCache2 = context.hashCache2 || [];
hash2 = context.hashCache2[index2];
if (typeof hash2 === 'undefined') {
context.hashCache2[index2] = hash2 = objectHash(value2, index2);
}
} else {
hash2 = objectHash(value2);
}
if (typeof hash2 === 'undefined') {
return false;
}
return hash1 === hash2;
}
var diffFilter$1 = function arraysDiffFilter(context) {
if (!context.leftIsArray) {
return;
}
var matchContext = {
objectHash: context.options && context.options.objectHash,
matchByPosition: context.options && context.options.matchByPosition
};
var commonHead = 0;
var commonTail = 0;
var index;
var index1;
var index2;
var array1 = context.left;
var array2 = context.right;
var len1 = array1.length;
var len2 = array2.length;
var child;
if (len1 > 0 && len2 > 0 && !matchContext.objectHash &&
typeof matchContext.matchByPosition !== 'boolean') {
matchContext.matchByPosition = !arraysHaveMatchByRef(array1, array2, len1, len2);
}
// separate common head
while (commonHead < len1 && commonHead < len2 &&
matchItems(array1, array2, commonHead, commonHead, matchContext)) {
index = commonHead;
child = new DiffContext$2(context.left[index], context.right[index]);
context.push(child, index);
commonHead++;
}
// separate common tail
while (commonTail + commonHead < len1 && commonTail + commonHead < len2 &&
matchItems(array1, array2, len1 - 1 - commonTail, len2 - 1 - commonTail, matchContext)) {
index1 = len1 - 1 - commonTail;
index2 = len2 - 1 - commonTail;
child = new DiffContext$2(context.left[index1], context.right[index2]);
context.push(child, index2);
commonTail++;
}
var result;
if (commonHead + commonTail === len1) {
if (len1 === len2) {
// arrays are identical
context.setResult(undefined).exit();
return;
}
// trivial case, a block (1 or more consecutive items) was added
result = result || {
_t: 'a'
};
for (index = commonHead; index < len2 - commonTail; index++) {
result[index] = [array2[index]];
}
context.setResult(result).exit();
return;
}
if (commonHead + commonTail === len2) {
// trivial case, a block (1 or more consecutive items) was removed
result = result || {
_t: 'a'
};
for (index = commonHead; index < len1 - commonTail; index++) {
result['_' + index] = [array1[index], 0, 0];
}
context.setResult(result).exit();
return;
}
// reset hash cache
delete matchContext.hashCache1;
delete matchContext.hashCache2;
// diff is not trivial, find the LCS (Longest Common Subsequence)
var trimmed1 = array1.slice(commonHead, len1 - commonTail);
var trimmed2 = array2.slice(commonHead, len2 - commonTail);
var seq = lcs.get(
trimmed1, trimmed2,
matchItems,
matchContext
);
var removedItems = [];
result = result || {
_t: 'a'
};
for (index = commonHead; index < len1 - commonTail; index++) {
if (arrayIndexOf(seq.indices1, index - commonHead) < 0) {
// removed
result['_' + index] = [array1[index], 0, 0];
removedItems.push(index);
}
}
var detectMove = true;
if (context.options && context.options.arrays && context.options.arrays.detectMove === false) {
detectMove = false;
}
var includeValueOnMove = false;
if (context.options && context.options.arrays && context.options.arrays.includeValueOnMove) {
includeValueOnMove = true;
}
var removedItemsLength = removedItems.length;
for (index = commonHead; index < len2 - commonTail; index++) {
var indexOnArray2 = arrayIndexOf(seq.indices2, index - commonHead);
if (indexOnArray2 < 0) {
// added, try to match with a removed item and register as position move
var isMove = false;
if (detectMove && removedItemsLength > 0) {
for (var removeItemIndex1 = 0; removeItemIndex1 < removedItemsLength; removeItemIndex1++) {
index1 = removedItems[removeItemIndex1];
if (matchItems(trimmed1, trimmed2, index1 - commonHead,
index - commonHead, matchContext)) {
// store position move as: [originalValue, newPosition, ARRAY_MOVE]
result['_' + index1].splice(1, 2, index, ARRAY_MOVE);
if (!includeValueOnMove) {
// don't include moved value on diff, to save bytes
result['_' + index1][0] = '';
}
index2 = index;
child = new DiffContext$2(context.left[index1], context.right[index2]);
context.push(child, index2);
removedItems.splice(removeItemIndex1, 1);
isMove = true;
break;
}
}
}
if (!isMove) {
// added
result[index] = [array2[index]];
}
} else {
// match, do inner diff
index1 = seq.indices1[indexOnArray2] + commonHead;
index2 = seq.indices2[indexOnArray2] + commonHead;
child = new DiffContext$2(context.left[index1], context.right[index2]);
context.push(child, index2);
}
}
context.setResult(result).exit();
};
diffFilter$1.filterName = 'arrays';
var compare = {
numerically: function(a, b) {
return a - b;
},
numericallyBy: function(name) {
return function(a, b) {
return a[name] - b[name];
};
}
};
var patchFilter$2 = function nestedPatchFilter(context) {
if (!context.nested) {
return;
}
if (context.delta._t !== 'a') {
return;
}
var index, index1;
var delta = context.delta;
var array = context.left;
// first, separate removals, insertions and modifications
var toRemove = [];
var toInsert = [];
var toModify = [];
for (index in delta) {
if (index !== '_t') {
if (index[0] === '_') {
// removed item from original array
if (delta[index][2] === 0 || delta[index][2] === ARRAY_MOVE) {
toRemove.push(parseInt(index.slice(1), 10));
} else {
throw new Error('only removal or move can be applied at original array indices' +
', invalid diff type: ' + delta[index][2]);
}
} else {
if (delta[index].length === 1) {
// added item at new array
toInsert.push({
index: parseInt(index, 10),
value: delta[index][0]
});
} else {
// modified item at new array
toModify.push({
index: parseInt(index, 10),
delta: delta[index]
});
}
}
}
}
// remove items, in reverse order to avoid sawing our own floor
toRemove = toRemove.sort(compare.numerically);
for (index = toRemove.length - 1; index >= 0; index--) {
index1 = toRemove[index];
var indexDiff = delta['_' + index1];
var removedValue = array.splice(index1, 1)[0];
if (indexDiff[2] === ARRAY_MOVE) {
// reinsert later
toInsert.push({
index: indexDiff[1],
value: removedValue
});
}
}
// insert items, in reverse order to avoid moving our own floor
toInsert = toInsert.sort(compare.numericallyBy('index'));
var toInsertLength = toInsert.length;
for (index = 0; index < toInsertLength; index++) {
var insertion = toInsert[index];
array.splice(insertion.index, 0, insertion.value);
}
// apply modifications
var toModifyLength = toModify.length;
var child;
if (toModifyLength > 0) {
for (index = 0; index < toModifyLength; index++) {
var modification = toModify[index];
child = new PatchContext$2(context.left[modification.index], modification.delta);
context.push(child, modification.index);
}
}
if (!context.children) {
context.setResult(context.left).exit();
return;
}
context.exit();
};
patchFilter$2.filterName = 'arrays';
var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter(context) {
if (!context || !context.children) {
return;
}
if (context.delta._t !== 'a') {
return;
}
var length = context.children.length;
var child;
for (var index = 0; index < length; index++) {
child = context.children[index];
context.left[child.childName] = child.result;
}
context.setResult(context.left).exit();
};
collectChildrenPatchFilter$1.filterName = 'arraysCollectChildren';
var reverseFilter$2 = function arraysReverseFilter(context) {
if (!context.nested) {
if (context.delta[2] === ARRAY_MOVE) {
context.newName = '_' + context.delta[1];
context.setResult([context.delta[0], parseInt(context.childName.substr(1), 10), ARRAY_MOVE]).exit();
}
return;
}
if (context.delta._t !== 'a') {
return;
}
var name, child;
for (name in context.delta) {
if (name === '_t') {
continue;
}
child = new ReverseContext$2(context.delta[name]);
context.push(child, name);
}
context.exit();
};
reverseFilter$2.filterName = 'arrays';
var reverseArrayDeltaIndex = function(delta, index, itemDelta) {
if (typeof index === 'string' && index[0] === '_') {
return parseInt(index.substr(1), 10);
} else if (isArray$2(itemDelta) && itemDelta[2] === 0) {
return '_' + index;
}
var reverseIndex = +index;
for (var deltaIndex in delta) {
var deltaItem = delta[deltaIndex];
if (isArray$2(deltaItem)) {
if (deltaItem[2] === ARRAY_MOVE) {
var moveFromIndex = parseInt(deltaIndex.substr(1), 10);
var moveToIndex = deltaItem[1];
if (moveToIndex === +index) {
return moveFromIndex;
}
if (moveFromIndex <= reverseIndex && moveToIndex > reverseIndex) {
reverseIndex++;
} else if (moveFromIndex >= reverseIndex && moveToIndex < reverseIndex) {
reverseIndex--;
}
} else if (deltaItem[2] === 0) {
var deleteIndex = parseInt(deltaIndex.substr(1), 10);
if (deleteIndex <= reverseIndex) {
reverseIndex++;
}
} else if (deltaItem.length === 1 && deltaIndex <= reverseIndex) {
reverseIndex--;
}
}
}
return reverseIndex;
};
var collectChildrenReverseFilter$1 = function collectChildrenReverseFilter(context) {
if (!context || !context.children) {
return;
}
if (context.delta._t !== 'a') {
return;
}
var length = context.children.length;
var child;
var delta = {
_t: 'a'
};
for (var index = 0; index < length; index++) {
child = context.children[index];
var name = child.newName;
if (typeof name === 'undefined') {
name = reverseArrayDeltaIndex(context.delta, child.childName, child.result);
}
if (delta[name] !== child.result) {
delta[name] = child.result;
}
}
context.setResult(delta).exit();
};
collectChildrenReverseFilter$1.filterName = 'arraysCollectChildren';
var diffFilter_1$1 = diffFilter$1;
var patchFilter_1$2 = patchFilter$2;
var collectChildrenPatchFilter_1$1 = collectChildrenPatchFilter$1;
var reverseFilter_1$2 = reverseFilter$2;
var collectChildrenReverseFilter_1$1 = collectChildrenReverseFilter$1;
var arrays = {
diffFilter: diffFilter_1$1,
patchFilter: patchFilter_1$2,
collectChildrenPatchFilter: collectChildrenPatchFilter_1$1,
reverseFilter: reverseFilter_1$2,
collectChildrenReverseFilter: collectChildrenReverseFilter_1$1
};
var diffFilter$2 = function datesDiffFilter(context) {
if (context.left instanceof Date) {
if (context.right instanceof Date) {
if (context.left.getTime() !== context.right.getTime()) {
context.setResult([context.left, context.right]);
} else {
context.setResult(undefined);
}
} else {
context.setResult([context.left, context.right]);
}
context.exit();
} else if (context.right instanceof Date) {
context.setResult([context.left, context.right]).exit();
}
};
diffFilter$2.filterName = 'dates';
var diffFilter_1$2 = diffFilter$2;
var dates = {
diffFilter: diffFilter_1$2
};
/* global diff_match_patch */
var TEXT_DIFF = 2;
var DEFAULT_MIN_LENGTH = 60;
var cachedDiffPatch = null;
var getDiffMatchPatch = function(required) {
/*jshint camelcase: false */
if (!cachedDiffPatch) {
var instance;
if (typeof diff_match_patch !== 'undefined') {
// already loaded, probably a browser
instance = typeof diff_match_patch === 'function' ?
new diff_match_patch() : new diff_match_patch.diff_match_patch();
} else if (typeof commonjsRequire === 'function') {
try {
var dmpModuleName = 'diff_match_patch_uncompressed';
var dmp = commonjsRequire('../../public/external/' + dmpModuleName);
instance = new dmp.diff_match_patch();
} catch (err) {
instance = null;
}
}
if (!instance) {
if (!required) {
return null;
}
var error = new Error('text diff_match_patch library not found');
error.diff_match_patch_not_found = true;
throw error;
}
cachedDiffPatch = {
diff: function(txt1, txt2) {
return instance.patch_toText(instance.patch_make(txt1, txt2));
},
patch: function(txt1, patch) {
var results = instance.patch_apply(instance.patch_fromText(patch), txt1);
for (var i = 0; i < results[1].length; i++) {
if (!results[1][i]) {
var error = new Error('text patch failed');
error.textPatchFailed = true;
}
}
return results[0];
}
};
}
return cachedDiffPatch;
};
var diffFilter$3 = function textsDiffFilter(context) {
if (context.leftType !== 'string') {
return;
}
var minLength = (context.options && context.options.textDiff &&
context.options.textDiff.minLength) || DEFAULT_MIN_LENGTH;
if (context.left.length < minLength ||
context.right.length < minLength) {
context.setResult([context.left, context.right]).exit();
return;
}
// large text, try to use a text-diff algorithm
var diffMatchPatch = getDiffMatchPatch();
if (!diffMatchPatch) {
// diff-match-patch library not available, fallback to regular string replace
context.setResult([context.left, context.right]).exit();
return;
}
var diff = diffMatchPatch.diff;
context.setResult([diff(context.left, context.right), 0, TEXT_DIFF]).exit();
};
diffFilter$3.filterName = 'texts';
var patchFilter$3 = function textsPatchFilter(context) {
if (context.nested) {
return;
}
if (context.delta[2] !== TEXT_DIFF) {
return;
}
// text-diff, use a text-patch algorithm
var patch = getDiffMatchPatch(true).patch;
context.setResult(patch(context.left, context.delta[0])).exit();
};
patchFilter$3.filterName = 'texts';
var textDeltaReverse = function(delta) {
var i, l, lines, line, lineTmp, header = null,
headerRegex = /^@@ +\-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,
lineHeader;
lines = delta.split('\n');
for (i = 0, l = lines.length; i < l; i++) {
line = lines[i];
var lineStart = line.slice(0, 1);
if (lineStart === '@') {
header = headerRegex.exec(line);
lineHeader = i;
// fix header
lines[lineHeader] = '@@ -' + header[3] + ',' + header[4] + ' +' + header[1] + ',' + header[2] + ' @@';
} else if (lineStart === '+') {
lines[i] = '-' + lines[i].slice(1);
if (lines[i - 1].slice(0, 1) === '+') {
// swap lines to keep default order (-+)
lineTmp = lines[i];
lines[i] = lines[i - 1];
lines[i - 1] = lineTmp;
}
} else if (lineStart === '-') {
lines[i] = '+' + lines[i].slice(1);
}
}
return lines.join('\n');
};
var reverseFilter$3 = function textsReverseFilter(context) {
if (context.nested) {
return;
}
if (context.delta[2] !== TEXT_DIFF) {
return;
}
// text-diff, use a text-diff algorithm
context.setResult([textDeltaReverse(context.delta[0]), 0, TEXT_DIFF]).exit();
};
reverseFilter$3.filterName = 'texts';
var diffFilter_1$3 = diffFilter$3;
var patchFilter_1$3 = patchFilter$3;
var reverseFilter_1$3 = reverseFilter$3;
var texts = {
diffFilter: diffFilter_1$3,
patchFilter: patchFilter_1$3,
reverseFilter: reverseFilter_1$3
};
var Processor$1 = processor.Processor;
var Pipe$2 = pipe.Pipe;
var DiffContext$3 = diff.DiffContext;
var PatchContext$3 = patch.PatchContext;
var ReverseContext$3 = reverse$2.ReverseContext;
var DiffPatcher = function DiffPatcher(options) {
this.processor = new Processor$1(options);
this.processor.pipe(new Pipe$2('diff').append(
nested.collectChildrenDiffFilter,
trivial.diffFilter,
dates.diffFilter,
texts.diffFilter,
nested.objectsDiffFilter,
arrays.diffFilter
).shouldHaveResult());
this.processor.pipe(new Pipe$2('patch').append(
nested.collectChildrenPatchFilter,
arrays.collectChildrenPatchFilter,
trivial.patchFilter,
texts.patchFilter,
nested.patchFilter,
arrays.patchFilter
).shouldHaveResult());
this.processor.pipe(new Pipe$2('reverse').append(
nested.collectChildrenReverseFilter,
arrays.collectChildrenReverseFilter,
trivial.reverseFilter,
texts.reverseFilter,
nested.reverseFilter,
arrays.reverseFilter
).shouldHaveResult());
};
DiffPatcher.prototype.options = function() {
return this.processor.options.apply(this.processor, arguments);
};
DiffPatcher.prototype.diff = function(left, right) {
return this.processor.process(new DiffContext$3(left, right));
};
DiffPatcher.prototype.patch = function(left, delta) {
return this.processor.process(new PatchContext$3(left, delta));
};
DiffPatcher.prototype.reverse = function(delta) {
return this.processor.process(new ReverseContext$3(delta));
};
DiffPatcher.prototype.unpatch = function(right, delta) {
return this.patch(right, this.reverse(delta));
};
DiffPatcher.prototype.clone = function(value) {
return clone_1(value);
};
var DiffPatcher_1 = DiffPatcher;
var diffpatcher = {
DiffPatcher: DiffPatcher_1
};
// use as 2nd parameter for JSON.parse to revive Date instances
var dateReviver = function dateReviver(key, value) {
var parts;
if (typeof value === 'string') {
parts = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d*))?(Z|([+\-])(\d{2}):(\d{2}))$/.exec(value);
if (parts) {
return new Date(Date.UTC(+parts[1], +parts[2] - 1, +parts[3], +parts[4], +parts[5], +parts[6], +(parts[7] || 0)));
}
}
return value;
};
var main = createCommonjsModule(function (module, exports) {
var DiffPatcher = diffpatcher.DiffPatcher;
exports.DiffPatcher = DiffPatcher;
exports.create = function(options){
return new DiffPatcher(options);
};
exports.dateReviver = dateReviver;
var defaultInstance;
exports.diff = function() {
if (!defaultInstance) {
defaultInstance = new DiffPatcher();
}
return defaultInstance.diff.apply(defaultInstance, arguments);
};
exports.patch = function() {
if (!defaultInstance) {
defaultInstance = new DiffPatcher();
}
return defaultInstance.patch.apply(defaultInstance, arguments);
};
exports.unpatch = function() {
if (!defaultInstance) {
defaultInstance = new DiffPatcher();
}
return defaultInstance.unpatch.apply(defaultInstance, arguments);
};
exports.reverse = function() {
if (!defaultInstance) {
defaultInstance = new DiffPatcher();
}
return defaultInstance.reverse.apply(defaultInstance, arguments);
};
exports.clone = function() {
if (!defaultInstance) {
defaultInstance = new DiffPatcher();
}
return defaultInstance.clone.apply(defaultInstance, arguments);
};
if (environment.isBrowser) {
exports.homepage = '{{package-homepage}}';
exports.version = '{{package-version}}';
} else {
var packageInfo = commonjsRequire();
exports.homepage = packageInfo.homepage;
exports.version = packageInfo.version;
var formatters = commonjsRequire();
exports.formatters = formatters;
// shortcut for console
exports.console = formatters.console;
}
});
var packing = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var CloneError, clone, jsondiffpatch, diff, out$ = exports || commonjsGlobal, toString$ = {}.toString;
out$.pack = pack;
function pack(x){
return JSON.stringify(x, function(key, val){
if (toString$.call(val).slice(8, -1) === 'Function') {
return val + '';
}
return val;
});
}
out$.unpack = unpack;
function unpack(x){
return JSON.parse(x);
}
out$.CloneError = CloneError = (function(superclass){
var prototype = extend$((import$(CloneError, superclass).displayName = 'CloneError', CloneError), superclass).prototype;
function CloneError(message, argument){
this.message = message;
this.argument = argument;
CloneError.superclass.apply(this, arguments);
Error.captureStackTrace(this, CloneError);
}
return CloneError;
}(Error));
out$.clone = clone = function(x){
var ref$;
if ((ref$ = toString$.call(x).slice(8, -1)) === 'Object' || ref$ === 'Array') {
return unpack(pack(x));
} else {
throw new CloneError("argument must be object or array, supplied: " + pack(x), x);
}
};
jsondiffpatch = main;
out$.diff = diff = function(a, b){
return jsondiffpatch.diff(a, b);
};
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var merge_1 = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var pack, basedOn, tests, start, testCount, i$, name, test, ref$, result, expected, out$ = exports || commonjsGlobal, toString$ = {}.toString;
pack = packing.pack;
/** /
export merge = (obj1, obj2) ->
if (typeof! obj1 is \Array) and (typeof! obj2 is \Array)
for i in obj2
try
for j in obj1
throw if pack(i) is pack(j)
# append if item is not found in first one
obj1.push i
return obj1
else
for p of obj2
try
throw if typeof! obj2[p] isnt \Object
throw if typeof! obj1[p] isnt \Object
# go on if and only if right hand is object
obj1[p] `merge` obj2[p]
catch
if Array.isArray obj1[p]
# array, merge with current one
for i, j of obj2[p]
try
for a in obj1[p]
throw if pack(a) is pack(j)
obj1[p].push j
else if obj2[p] isnt void
obj1[p] = obj2[p]
else
delete obj1[p]
obj1
/**/
out$.merge = merge;
function merge(obj1, obj2){
var i$, len$, i, j$, len1$, j, p, tObj1, ref$;
if (toString$.call(obj1).slice(8, -1) === 'Array' && toString$.call(obj2).slice(8, -1) === 'Array') {
for (i$ = 0, len$ = obj2.length; i$ < len$; ++i$) {
i = obj2[i$];
try {
for (j$ = 0, len1$ = obj1.length; j$ < len1$; ++j$) {
j = obj1[j$];
if (pack(i) === pack(j)) {
throw null;
}
}
obj1.push(i);
} catch (e$) {}
}
return obj1;
} else {
for (p in obj2) {
tObj1 = toString$.call(obj1[p]).slice(8, -1);
if ((ref$ = toString$.call(obj2[p]).slice(8, -1)) === 'Object' || ref$ === 'Array') {
if (tObj1 === 'Object' || tObj1 === 'Array') {
merge(obj1[p], obj2[p]);
} else {
obj1[p] = obj2[p];
}
} else {
if (obj2[p] !== void 8) {
obj1[p] = obj2[p];
} else {
delete obj1[p];
}
}
}
return obj1;
}
}
/* */
out$.mergeAll = mergeAll;
function mergeAll(obj1){
var sources, res$, i$, to$, len$, obj2;
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
sources = res$;
for (i$ = 0, len$ = sources.length; i$ < len$; ++i$) {
obj2 = sources[i$];
merge(obj1, obj2);
}
return obj1;
}
out$.basedOn = basedOn = function(a, b){
return merge(b || {}, a || {});
};
tests = {
'simple merge': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2
};
b = {
c: 5
};
result = merge(a, b);
expected = {
a: 1,
b: 2,
c: 5
};
return {
result: result,
expected: expected
};
},
'simple merge2': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: {
ca: 1,
cb: 2
}
};
b = {
c: {
cb: 5
}
};
result = merge(a, b);
expected = {
a: 1,
b: 2,
c: {
ca: 1,
cb: 5
}
};
return {
result: result,
expected: expected
};
},
'merge lists': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: [1, 2]
};
b = {
b: 8,
c: [1, 4]
};
result = merge(a, b);
expected = {
a: 1,
b: 8,
c: [1, 2, 4]
};
return {
result: result,
expected: expected
};
},
'merge lists2': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: ['hello', 'world']
};
b = {
b: 8,
c: ['hi', 'world']
};
result = merge(a, b);
expected = {
a: 1,
b: 8,
c: ['hello', 'world', 'hi']
};
return {
result: result,
expected: expected
};
},
'merge lists of objects': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: [
{
a: 1,
b: 2
}, {
a: 3,
b: 4
}
]
};
b = {
b: 8,
c: [
{
a: 1,
b: 2
}, {
a: 5,
b: 6
}
]
};
result = merge(a, b);
expected = {
a: 1,
b: 8,
c: [
{
a: 1,
b: 2
}, {
a: 3,
b: 4
}, {
a: 5,
b: 6
}
]
};
return {
result: result,
expected: expected
};
},
'merge lists of objects2': function(){
var x, y, result, expected;
x = [
{
a: 1,
b: 2
}, {
a: 3,
b: 4
}
];
y = [
{
a: 5,
b: 6
}, {
a: 7,
b: 8
}, {
a: 9,
b: 10
}, {
a: 11,
b: 12
}
];
result = merge(x, y);
expected = [
{
a: 1,
b: 2
}, {
a: 3,
b: 4
}, {
a: 5,
b: 6
}, {
a: 7,
b: 8
}, {
a: 9,
b: 10
}, {
a: 11,
b: 12
}
];
return {
result: result,
expected: expected
};
},
'deleting something': function(){
var a, result, expected;
a = {
a: 1,
b: 2,
c: {
ca: 11,
cb: 2
}
};
result = merge(a, {
c: void 8
});
expected = {
a: 1,
b: 2
};
return {
result: result,
expected: expected
};
},
'force overwrite': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: {
ca: 11,
cb: 2
}
};
b = {
c: {
cb: 5
}
};
result = mergeAll(a, {
c: void 8
}, b);
expected = {
a: 1,
b: 2,
c: {
cb: 5
}
};
return {
result: result,
expected: expected
};
},
'merging object with functions': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: {
ca: 11,
cb: 2
}
};
b = {
c: {
cb: function(x){
return x;
}
}
};
result = merge(a, b);
expected = {
a: 1,
b: 2,
c: {
ca: 11,
cb: function(x){
return x;
}
}
};
return {
result: result,
expected: expected
};
},
'Field or method does not already exist, and cant create it on String': function(){
var a, b, result, expected;
a = {
a: 1,
b: 2,
c: "hey"
};
b = {
c: {
cb: "aa"
}
};
result = merge(a, b);
expected = {
a: 1,
b: 2,
c: {
cb: "aa"
}
};
return {
result: result,
expected: expected
};
}
};
start = Date.now();
testCount = 1;
for (i$ = 0; i$ <= testCount; ++i$) {
for (name in tests) {
test = tests[name];
ref$ = test(), result = ref$.result, expected = ref$.expected;
if (pack(expected) !== pack(result)) {
console.log("merge test failed test: ", name);
console.log("EXPECTED: ", expected);
console.log("RESULT : ", result);
throw "Test failed in merge.ls!, test: " + name;
}
}
}
if (testCount > 1) {
console.log("Merge tests took: " + (Date.now() - start) + " milliseconds...");
}
});
var ipToHex_1 = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var reverse, hex, ipToHex, out$ = exports || commonjsGlobal;
reverse = lib$1.reverse;
out$.hex = hex = function(n){
return n.toString(16).toUpperCase();
};
out$.ipToHex = ipToHex = function(ip){
var i, result, i$, ref$, len$, part;
i = 0;
result = 0;
for (i$ = 0, len$ = (ref$ = reverse(ip.split('.'))).length; i$ < len$; ++i$) {
part = ref$[i$];
result += part * Math.pow(256, i++);
}
return hex(result);
};
});
// Generated by LiveScript 1.6.0
var Logger, EventEmitter, sleep, ref$, pack, unpack, clone$1, diff$1, merge, basedOn, ipToHex, hex;
Logger = logger.Logger;
EventEmitter = eventEmitter.EventEmitter;
sleep = sleep_1.sleep;
ref$ = packing, pack = ref$.pack, unpack = ref$.unpack, clone$1 = ref$.clone, diff$1 = ref$.diff;
ref$ = merge_1, merge = ref$.merge, basedOn = ref$.basedOn;
ref$ = ipToHex_1, ipToHex = ref$.ipToHex, hex = ref$.hex;
var lib$2 = {
Logger: Logger,
EventEmitter: EventEmitter,
sleep: sleep,
pack: pack,
unpack: unpack,
clone: clone$1,
diff: diff$1,
merge: merge,
basedOn: basedOn,
ipToHex: ipToHex,
hex: hex
};
var debugTools = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var brief, out$ = exports || commonjsGlobal;
out$.brief = brief = function(msg){
var s, k, v, dataStr;
s = {};
for (k in msg) {
v = msg[k];
if (k === 'data') {
continue;
}
s[k] = v;
}
if (msg.data) {
dataStr = JSON.stringify(msg.data);
s.data = dataStr.length > 70
? "..." + dataStr.length + "..."
: msg.data;
}
if (msg.permissions) {
s.permissions = "..." + msg.permissions.length + "...";
}
return s;
};
});
var topicMatch_1 = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, max, split, splitDot, topicMatch, testTopicMatch, out$ = exports || commonjsGlobal, toString$ = {}.toString;
ref$ = lib$1, max = ref$.max, split = ref$.split;
splitDot = split('.');
out$.topicMatch = topicMatch = function(topics, keypaths, opts){
var asArray, i$, ref$, len$, topic, j$, ref1$, len1$, keypath, topicArr, keypathArr, e, k$, ref2$, len2$, index, topicPart, keypathPart;
opts == null && (opts = {});
if (!(topics != null && keypaths != null)) {
return false;
}
asArray = function(x){
if (toString$.call(x).slice(8, -1) === 'String') {
return x.trim().split(' ');
} else {
return x;
}
};
for (i$ = 0, len$ = (ref$ = asArray(
topics)).length; i$ < len$; ++i$) {
topic = ref$[i$];
for (j$ = 0, len1$ = (ref1$ = asArray(
keypaths)).length; j$ < len1$; ++j$) {
keypath = ref1$[j$];
try {
if ('**' === topic || '**' === keypath) {
if (opts.debug) {
console.log("topic is **, immediately matches with anything");
}
return true;
}
try {
topicArr = splitDot(topic);
keypathArr = splitDot(keypath);
} catch (e$) {
e = e$;
console.error("both topic and keypath should be string.");
return false;
}
for (k$ = 0, len2$ = (ref2$ = (fn$())).length; k$ < len2$; ++k$) {
index = ref2$[k$];
topicPart = (fn1$());
keypathPart = (fn2$());
if (opts.debug) {
console.log("topic-part: " + topicPart + ", keypath-part: " + keypathPart);
}
if ('*' === keypathPart || '*' === topicPart) {
if (undefined === keypathPart || undefined === topicPart) {
if (opts.debug) {
console.log("returning false because there is no command to look for match");
}
throw null;
}
continue;
}
if ('**' !== keypathPart && '**' !== topicPart) {
if (undefined === keypathPart || undefined === topicPart) {
if (opts.debug) {
console.log("returning false because there is no command to look for match");
}
throw null;
}
}
if ('**' === keypathPart || '**' === topicPart) {
if (opts.debug) {
console.log("returning true because '**' will match with anything.");
}
return true;
}
if (topicPart !== keypathPart) {
throw "not matching";
}
}
if (opts.debug) {
console.log("no condition broke the match.");
}
return true;
} catch (e$) {}
}
}
return false;
function fn$(){
var i$, to$, results$ = [];
for (i$ = 0, to$ = max(topicArr.length, keypathArr.length); i$ < to$; ++i$) {
results$.push(i$);
}
return results$;
}
function fn1$(){
try {
return topicArr[index];
} catch (e$) {}
}
function fn2$(){
try {
return keypathArr[index];
} catch (e$) {}
}
};
(testTopicMatch = function(){
/*
** will match with anything, including null
*/
var examples, num, example, result, results$ = [];
examples = [
{
topic: "foo.bar",
keypath: "foo.*",
expected: true
}, {
topic: "*.bar",
keypath: "foo.*",
expected: true
}, {
topic: "foo.bar",
keypath: "baz.bar",
expected: false
}, {
topic: "foo.bar",
keypath: "baz.bar foo.*",
expected: true
}, {
topic: "foo.bar",
keypath: "foo.*.*",
expected: false
}, {
topic: "foo.*.bar",
keypath: "foo.*",
expected: false
}, {
topic: "foo.**",
keypath: "foo",
expected: true
}, {
topic: "@foo",
keypath: ['@foo.**', '@bar.**'],
expected: true
}, {
topic: ['@bar.**', '@foo-bar.**'],
keypath: "@foo-bar",
expected: true
}, {
topic: "foo.*.**",
keypath: "foo.bar.baz",
expected: true
}, {
topic: "foo.*.**",
keypath: "foo.bar",
expected: true
}, {
topic: "foo.*.**",
keypath: "foo.bar.baz.qux",
expected: true
}, {
topic: "foo.**",
keypath: "foo.bar.baz.qux",
expected: true
}, {
topic: "foo.**",
keypath: "*.bar.baz.qux",
expected: true
}, {
topic: "foo.bar",
keypath: "*.*",
expected: true
}, {
topic: "foo.bar",
keypath: "*",
expected: false
}, {
topic: "*",
keypath: "foo.bar",
expected: false
}, {
topic: "foo.bar",
keypath: "**",
expected: true
}, {
topic: "*",
keypath: "*",
expected: true
}, {
topic: "**",
keypath: "*",
expected: true
}, {
topic: "*",
keypath: "**",
expected: true
}, {
topic: "**",
keypath: "**",
expected: true
}, {
topic: "*.*",
keypath: "**",
expected: true
}, {
topic: "**",
keypath: "*.*",
expected: true
}
];
for (num in examples) {
example = examples[num];
result = topicMatch(example.topic, example.keypath);
if (result !== example.expected) {
console.log("Test failed in #" + num + ", re-running in debug mode: ");
console.log("comparing if '" + example.topic + "' matches with '" + example.keypath + "' expecting: " + example.expected);
console.log("---------------------------------------------------");
topicMatch(example.topic, example.keypath, {
debug: true
});
console.log("---------------------------------------------------");
results$.push(process.exit(1));
}
}
return results$;
})();
});
var actorManager = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, reject, find, routeMatch, Logger, sleep, hex, brief, ActorManager, out$ = exports || commonjsGlobal, slice$ = [].slice, arrayFrom$ = Array.from || function(x){return slice$.call(x);};
ref$ = lib$1, reject = ref$.reject, find = ref$.find;
routeMatch = topicMatch_1.topicMatch;
ref$ = lib$2, Logger = ref$.Logger, sleep = ref$.sleep, hex = ref$.hex;
brief = debugTools.brief;
out$.ActorManager = ActorManager = (function(){
ActorManager.displayName = 'ActorManager';
var constructor = ActorManager;
ActorManager.instance = null;
function ActorManager(){
if (constructor.instance) {
return constructor.instance;
}
constructor.instance = this;
this.actorUid = 1;
this.actors = [];
this.managerId = hex(
Date.now());
this.log = new Logger("ActorMan." + this.managerId);
}
ActorManager.prototype.nextActorId = function(){
return "a" + (this.actorUid++) + "-" + this.managerId;
};
ActorManager.prototype.registerActor = function(actor){
if (!find(function(it){
return it.id === actor.id;
}, this.actors)) {
return this.actors.push(actor);
}
};
ActorManager.prototype.findActor = function(id){
if (!id) {
throw 'id is required!';
}
return find(function(it){
return it.id === id;
}, this.actors);
};
ActorManager.prototype.deregisterActor = function(actor){
return this.actors = reject(function(it){
return it.id === actor.id;
}, this.actors);
};
ActorManager.prototype.distribute = function(msg, sender){
var dueDate, i$, ref$, len$, actor, that, delay, results$ = [];
if (msg.debug) {
this.log.debug("Distributing message: ", brief(msg));
}
dueDate = Date.now();
for (i$ = 0, len$ = (ref$ = this.actors).length; i$ < len$; ++i$) {
actor = ref$[i$];
if (actor.id !== sender) {
if (routeMatch(msg.to, actor.subscriptions)) {
if (that = msg._exclude) {
if (that === actor.id) {
continue;
}
delete msg._exclude;
}
delay = Date.now() - dueDate;
if (delay > 10) {
this.log.warn("System load is high? Message is delivered after " + delay + "ms");
}
results$.push(actor._inbox(msg));
} else {
results$.push(null);
}
}
}
return results$;
};
ActorManager.prototype.kill = function(){
var args, res$, i$, to$, ref$, len$, actor, results$ = [];
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
for (i$ = 0, len$ = (ref$ = this.actors).length; i$ < len$; ++i$) {
actor = ref$[i$];
results$.push(actor.trigger.apply(actor, ['kill'].concat(arrayFrom$(args))));
}
return results$;
};
return ActorManager;
}());
});
// Generated by LiveScript 1.6.0
var ref$$1, sleep$1, Logger$1, getFormattedDate, slice$ = [].slice, arrayFrom$ = Array.from || function(x){return slice$.call(x);};
try {
ref$$1 = lib$2, sleep$1 = ref$$1.sleep, Logger$1 = ref$$1.Logger;
} catch (e$) {
sleep$1 = function(ms, f){
return setTimeout(f, ms);
};
getFormattedDate = function(){
var d;
d = new Date;
return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
};
Logger$1 = (function(){
Logger.displayName = 'Logger';
function Logger(name){
this.name = name;
}
Logger.prototype.log = function(){
return console.log.apply(console, ['[', getFormattedDate(), ']', this.name + ":"].concat(arrayFrom$(arguments)));
};
return Logger;
}());
}
var deps = {
sleep: sleep$1,
Logger: Logger$1
};
var signal = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, sleep, Logger, isItNaN, Signal, out$ = exports || commonjsGlobal, toString$ = {}.toString, slice$ = [].slice, arrayFrom$ = Array.from || function(x){return slice$.call(x);};
ref$ = deps, sleep = ref$.sleep, Logger = ref$.Logger;
isItNaN = lib$1.isItNaN;
out$.Signal = Signal = (function(){
Signal.displayName = 'Signal';
function Signal(opts){
opts == null && (opts = {});
if (opts.debug) {
this.debug = true;
}
this.name = opts.name || 'Signal';
this.log = new Logger(this.name);
this.response = [];
this.callback = {
ctx: null,
handler: null
};
if (this.debug) {
this.log.debug("Initialized new signal.");
}
this.reusable = opts.reusable;
this.reset();
}
Signal.prototype.cancel = function(){
return this.reset();
};
Signal.prototype.reset = function(){
if (!this.reusable) {
delete this.callback.handler;
delete this.callback.ctx;
}
this.shouldRun = false;
try {
clearTimeout(this.timer);
} catch (e$) {}
this.timer = void 8;
return this.skipNext = false;
};
Object.defineProperty(Signal.prototype, 'waiting', {
get: function(){
var ref$;
return toString$.call((ref$ = this.callback) != null ? ref$.handler : void 8).slice(8, -1) === 'Function';
},
configurable: true,
enumerable: true
});
Signal.prototype.fire = function(error){
var ref$, params, ref1$, handler, ctx, t0, err, this$ = this;
if (toString$.call((ref$ = this.callback) != null ? ref$.handler : void 8).slice(8, -1) !== 'Function') {
return;
}
params = !this.error
? this.response
: [];
ref1$ = this.callback, handler = ref1$.handler, ctx = ref1$.ctx;
t0 = Date.now();
err = this.error;
return setImmediate(function(){
this$.reset();
handler.call.apply(handler, [ctx, err].concat(arrayFrom$(params)));
if (this$.debug) {
this$.log.debug("...signal has been fired.");
}
if (Date.now() - t0 > 100) {
return this$.log.warn("System seems busy now? Actual firing took place after " + (Date.now() - t0) + "ms");
}
});
};
Signal.prototype.wait = function(timeout, callback){
if (toString$.call(timeout).slice(8, -1) === 'Function') {
callback = timeout;
timeout = 0;
}
if (this.waiting) {
this.log.error("Can not wait over and over, skipping this one.");
return;
}
this.callback = {
ctx: this,
handler: callback
};
if (!isItNaN(timeout)) {
if (timeout > 0) {
this.timeout = timeout;
if (this.debug) {
this.log.info("Heartbeating! timeout: " + this.timeout);
}
this.heartbeat();
}
}
if (this.shouldRun) {
return this.fire();
}
};
Signal.prototype.skipNextGo = function(){
return this.skipNext = true;
};
Signal.prototype.clear = function(){
return this.shouldRun = false;
};
Signal.prototype.go = function(err){
var args, res$, i$, to$;
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
if (this.skipNext) {
this.skipNext = false;
return;
}
this.shouldRun = true;
this.response = args;
this.error = err;
if (this.waiting) {
return this.fire();
}
};
Signal.prototype.heartbeat = function(duration){
var this$ = this;
if (duration > 0) {
this.timeout = duration;
}
try {
clearTimeout(this.timer);
} catch (e$) {}
return this.timer = sleep(this.timeout, function(){
if (this$.waiting) {
this$.shouldRun = true;
if (this$.debug) {
this$.log.log("firing with timeout! timeout: " + this$.timeout);
}
if (toString$.call(this$.timeoutHandler).slice(8, -1) === 'Function') {
return this$.timeoutHandler();
} else {
this$.error = 'TIMEOUT';
return this$.fire();
}
}
});
};
Signal.prototype.onTimeout = function(callback){
return this.timeoutHandler = callback;
};
return Signal;
}());
});
var signalBranch = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var Signal, SignalBranch, out$ = exports || commonjsGlobal;
Signal = signal.Signal;
out$.SignalBranch = SignalBranch = (function(){
SignalBranch.displayName = 'SignalBranch';
function SignalBranch(opts){
opts == null && (opts = {});
this.timeout = opts.timeout || -1;
this.count = 0;
this.main = new Signal;
this.signals = [];
this.error = null;
this.branches = [];
}
SignalBranch.prototype.cancel = function(){
var i, results$ = [];
this.main.cancel();
this.main = null;
for (i in this.signals) {
this.signals[i].cancel();
results$.push(this.signals[i] = null);
}
return results$;
};
SignalBranch.prototype.add = function(opts){
var timeout, name, signal, this$ = this;
timeout = (opts != null ? opts.timeout : void 8) || this.timeout;
name = (opts != null ? opts.name : void 8) || this.count + "";
signal = new Signal({
name: name
});
this.signals.push(signal);
this.count++;
signal.wait(timeout, function(err){
var that;
if (that = err) {
this$.error = that;
}
if (--this$.count === 0) {
return this$.main.go(this$.error);
}
});
return signal;
};
SignalBranch.prototype.joined = function(callback){
var err, this$ = this;
if (this.count === 0) {
this.main.go(err = null);
}
return this.main.wait(this.timeout, function(err){
var i$, x$, ref$, len$;
for (i$ = 0, len$ = (ref$ = this$.signals).length; i$ < len$; ++i$) {
x$ = ref$[i$];
if (x$.error) {
if (!err) {
err = {};
}
err.signals = true;
}
x$.clear();
}
return callback(err, this$.signals);
});
};
return SignalBranch;
}());
});
// Generated by LiveScript 1.6.0
var Signal$1, SignalBranch;
Signal$1 = signal.Signal;
SignalBranch = signalBranch.SignalBranch;
var signal$1 = {
Signal: Signal$1,
SignalBranch: SignalBranch
};
commonjsGlobal.Signal = Signal$1;
commonjsGlobal.SignalBranch = SignalBranch;
var request = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var merge, out$ = exports || commonjsGlobal, toString$ = {}.toString;
merge = lib$2.merge;
import$(out$, {
sendRequest: function(opts, data, callback){
var meta, timeout, that, seq, requestId, enveloped, partHandler, completeHandler, lastPartSent, regPartHandlers, responseSignal, error, message, mergeMethodManual, requestDate, this$ = this;
meta = {};
timeout = 5000;
if (toString$.call(opts).slice(8, -1) === 'String') {
meta.to = opts;
} else {
meta.to = opts.topic || opts.route || opts.to;
if (that = opts.timeout) {
timeout = that;
}
}
seq = this.msgSeq++;
requestId = seq + "";
meta.part = this.getNextPartId(opts.part, requestId);
if (opts.debug) {
meta.debug = true;
}
if (toString$.call(data).slice(8, -1) === 'Function') {
callback = data;
data = null;
}
enveloped = (meta.from = this.me, meta.seq = seq, meta.data = data, meta.req = true, meta.timestamp = Date.now(), meta);
this.subscribe(meta.to);
partHandler = function(){};
completeHandler = function(){};
lastPartSent = false;
regPartHandlers = {
onPart: function(func){
return partHandler = func;
},
onReceive: function(func){
return completeHandler = func;
},
sendPart: function(data, lastPart){
var msg;
lastPart == null && (lastPart = true);
if (lastPartSent) {
this$.log.err("Last part is already sent.");
return;
}
msg = (enveloped.data = data, enveloped);
msg.part = this$.getNextPartId(!lastPart, requestId);
this$.log.log("Sending next part with id: ", msg.part);
this$.sendEnveloped(msg);
if (lastPart) {
return lastPartSent = true;
}
}
};
responseSignal = new Signal({
debug: enveloped.debug,
name: "ReqSig:" + enveloped.seq
});
this.requestQueue[requestId] = responseSignal;
error = null;
message = {};
mergeMethodManual = false;
requestDate = Date.now();
(function lo(op){
responseSignal.clear();
return responseSignal.wait(timeout, function(err, msg){
if (err) {
error = err;
return op();
} else {
partHandler(msg);
if (requestDate != null) {
if (requestDate + 200 < Date.now()) {
this$.log.debug("First response is too late for seq:" + enveloped.seq + " latency:" + (Date.now() - requestDate) + "ms, req: ", enveloped);
}
requestDate = undefined;
}
if (msg.timeout) {
if (enveloped.debug) {
this$.log.debug("New timeout is set from target: " + msg.timeout + "ms for request seq: " + enveloped.seq);
}
timeout = msg.timeout;
}
if (msg.merge != null && msg.merge === false) {
mergeMethodManual = true;
}
if (!mergeMethodManual) {
merge(message, msg);
}
if (msg.part == null || msg.part < 0) {
/*
if not msg.part?
@log.debug "this was a single part response."
else
@log.debug "this was the last part of the message chain."
*/
return op();
}
}
return lo(op);
});
})(function(){
if (this$._state.killFinished) {
this$.log.warn("Got response activity after killed?", error, message);
return;
}
if (!callback) {
if (error === 'TIMEOUT') {
this$.log.warn("Request is timed out. Timeout was " + timeout + "ms, seq: " + enveloped.seq + ". req was:", brief(enveloped));
}
}
this$.unsubscribe(meta.to);
delete this$.requestQueue[requestId];
if (mergeMethodManual) {
error = "Merge method is set to manual. We can't concat the messages.";
}
completeHandler(error, message);
if (toString$.call(callback).slice(8, -1) === 'Function') {
return callback(error, message);
}
});
if (meta.debug) {
this.log.debug("Sending request seq: " + enveloped.seq);
}
this.sendEnveloped(enveloped);
return regPartHandlers;
}
});
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var actor = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, sleep, pack, EventEmitter, Logger, merge, brief, ActorManager, split, flatten, keys, unique, isItNaN, routeMatch, request$1, TopicTypeError, LAST_PART, messageOwner, Actor, A1, A2, out$ = exports || commonjsGlobal, toString$ = {}.toString;
ref$ = lib$2, sleep = ref$.sleep, pack = ref$.pack, EventEmitter = ref$.EventEmitter, Logger = ref$.Logger, merge = ref$.merge;
brief = debugTools.brief;
ActorManager = actorManager.ActorManager;
ref$ = lib$1, split = ref$.split, flatten = ref$.flatten, keys = ref$.keys, unique = ref$.unique, isItNaN = ref$.isItNaN;
routeMatch = topicMatch_1.topicMatch;
request$1 = request;
out$.TopicTypeError = TopicTypeError = (function(superclass){
var prototype = extend$((import$(TopicTypeError, superclass).displayName = 'TopicTypeError', TopicTypeError), superclass).prototype;
function TopicTypeError(message, route){
this.message = message;
this.route = route;
TopicTypeError.superclass.apply(this, arguments);
Error.captureStackTrace(this, TopicTypeError);
this.type = 'TopicTypeError';
}
return TopicTypeError;
}(Error));
LAST_PART = -1;
messageOwner = function(it){
var ref$;
return (ref$ = it.to.split('.'))[ref$.length - 1];
};
out$.Actor = Actor = (function(superclass){
var prototype = extend$((import$(Actor, superclass).displayName = 'Actor', Actor), superclass).prototype;
importAll$(prototype, arguments[1]);
function Actor(name, opts){
this.send = bind$(this, 'send', prototype);
Actor.superclass.call(this);
this.mgr = new ActorManager();
this.id = this.mgr.nextActorId();
this.me = this.id;
this.name = name || this.id;
this.log = new Logger(this.name);
this.msgSeq = 0;
this.subscriptions = [this.me];
this.requestQueue = {};
this._route_handlers = {};
this._state = {};
this._partial_msg_states = {};
this._request_concat_cache = {};
this._last_login = 0;
this.mgr.registerActor(this);
if (toString$.call(this.action).slice(8, -1) === 'Function') {
this.action();
}
}
Actor.prototype.setName = function(name){
this.name = name;
return this.log.name = name;
};
Actor.prototype.subscribe = function(routes){
var i$, ref$, len$, route, results$ = [];
for (i$ = 0, len$ = (ref$ = unique(flatten([routes]))).length; i$ < len$; ++i$) {
route = ref$[i$];
results$.push(this.subscriptions.push(route));
}
return results$;
};
Actor.prototype.unsubscribe = function(route){
return this.subscriptions.splice(this.subscriptions.indexOf(route), 1);
};
Actor.prototype.send = function(route, data){
var enveloped;
if (toString$.call(route).slice(8, -1) === 'String') {
route = {
to: route
};
}
enveloped = import$({
from: this.me,
data: data,
seq: this.msgSeq++
}, route);
return this.sendEnveloped(enveloped);
};
Actor.prototype.getNextPartId = function(autoinc, msgId){
var nextPart;
nextPart = undefined;
if (autoinc) {
if (this._partial_msg_states[msgId] == null) {
this._partial_msg_states[msgId] = 0;
}
nextPart = this._partial_msg_states[msgId]++;
} else {
if (this._partial_msg_states[msgId] != null) {
delete this._partial_msg_states[msgId];
nextPart = LAST_PART;
}
}
return nextPart;
};
Actor.prototype.sendResponse = function(req, meta, data){
var enveloped;
if (!req.req) {
this.log.err("No request is required, doing nothing.");
debugger;
return;
}
if (toString$.call(data).slice(8, -1) === 'Undefined') {
data = meta;
meta = {};
}
meta.part = this.getNextPartId(meta.part, req.from + "." + req.seq);
enveloped = import$({
from: this.me,
to: req.from,
seq: this.msgSeq++,
data: data,
re: req.seq,
resToken: req.resToken,
debug: req.debug
}, meta);
if (req.debug || meta.debug) {
this.log.debug("sending the response for request: ", brief(enveloped));
}
return this.sendEnveloped(enveloped);
};
Actor.prototype._inbox = function(msg){
var this$ = this;
if (this.debug || msg.debug) {
this.log.debug("Got msg to inbox: ", brief(msg));
}
if (this._state.killFinished) {
debugger;
}
msg.permissions = msg.permissions || [];
return setImmediate(function(){
var ref$;
if (msg.re != null && messageOwner(msg) === this$.me) {
if (this$.requestQueue[msg.re]) {
if (this$.debug || msg.debug) {
this$.log.debug("We were expecting this response: ", msg);
this$.log.debug("Current request queue: ", keys(this$.requestQueue));
}
if ((ref$ = this$.requestQueue[msg.re]) != null) {
ref$.go(null, msg);
}
} else {
this$.log.err("This is not a message we were expecting (or interested in)?is it timed out already? I'm " + this$.me + ")", msg);
if (this$.debug) {
this$.log.warn("Current request queue: ", this$.requestQueue);
}
}
return;
}
if ('data' in msg) {
this$.trigger('data', msg);
}
return this$.trigger('receive', msg);
});
};
Actor.prototype.onTopic = function(route, handler){
var ref$, this$ = this;
if (!route) {
throw "Need a route.";
}
if (!in$(route, this.subscriptions)) {
this.subscribe(route);
}
this.on('data', function(msg){
var requestId;
if (routeMatch(msg.to, route)) {
if (msg.req && msg.part != null) {
this$.sendResponse(msg, {
part: true,
ack: true
}, null);
requestId = msg.from + "." + msg.seq;
if (!this$._request_concat_cache[requestId]) {
this$._request_concat_cache[requestId] = function(){
var message;
message = {};
return function(msg){
var ref$, ref1$;
merge(message, msg);
if (msg.part === LAST_PART) {
handler.call(this$, message);
return ref1$ = (ref$ = this$._request_concat_cache)[requestId], delete ref$[requestId], ref1$;
}
};
}();
}
return this$._request_concat_cache[requestId](msg);
} else {
return handler.call(this$, msg);
}
}
});
return ((ref$ = this._route_handlers)[route] || (ref$[route] = [])).push(handler);
};
Actor.prototype.triggerTopic = function(route){
var args, res$, i$, to$, that, len$, handler, results$ = [];
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
if (that = this._route_handlers[route]) {
for (i$ = 0, len$ = that.length; i$ < len$; ++i$) {
handler = that[i$];
results$.push(handler.apply(null, args));
}
return results$;
} else {
return this.log.debug("No such route handler found: " + route);
}
};
Actor.prototype.onceTopic = function(route, handler){
var this$ = this;
if (!in$(route, this.subscriptions)) {
this.subscribe(route);
}
return this.once('data', function(msg){
if (routeMatch(msg.to, route)) {
handler(msg);
return this$.unsubscribe(route);
}
});
};
Actor.prototype.sendEnveloped = function(msg){
var this$ = this;
if (!(msg.to || 'auth' in msg)) {
debugger;
return this.log.err("send-enveloped: Message has no route. Not sending.", msg);
}
setImmediate(function(){
if (!msg.timestamp) {
msg.timestamp = Date.now();
}
if (this$.debug) {
this$.log.debug("sending message: ", msg);
}
return this$.mgr.distribute(msg, this$.id);
});
};
Actor.prototype.kill = function(reason){
var id, ref$, signal;
if (!this._state.killStarted) {
this._state.killStarted = true;
this.mgr.deregisterActor(this);
for (id in ref$ = this.requestQueue) {
signal = ref$[id];
signal.reset();
delete this.requestQueue[id];
}
this.trigger('kill', reason);
return this._state.killFinished = true;
}
};
Actor.prototype.onEveryLogin = function(callback){
var minPeriod, this$ = this;
minPeriod = 1000;
this.onTopic('app.dcs.connect', function(msg){
if (this$._last_login + minPeriod < Date.now()) {
callback(msg);
return this$._last_login = Date.now();
}
});
return this.sendRequest('app.dcs.update', function(err, msg){
if (!err && (msg != null && msg.data)) {
if (this$._last_login + minPeriod < Date.now()) {
callback(msg);
return this$._last_login = Date.now();
}
}
});
};
return Actor;
}(EventEmitter, request$1));
if (commonjsRequire.main === module) {
console.log("initializing actor test");
new (A1 = (function(superclass){
var prototype = extend$((import$(A1, superclass).displayName = 'A1', A1), superclass).prototype;
A1.prototype.action = function(){
var this$ = this;
return this.onTopic("hello", function(msg){
return this$.log.log("received hello message", msg);
});
};
function A1(){
A1.superclass.apply(this, arguments);
}
return A1;
}(Actor)));
new (A2 = (function(superclass){
var prototype = extend$((import$(A2, superclass).displayName = 'A2', A2), superclass).prototype;
A2.prototype.action = function(){
var this$ = this;
this.onTopic("hello", function(msg){
return this$.log.err("received hello message", msg);
});
return this.send("hello", {
hello: 'there'
});
};
function A2(){
A2.superclass.apply(this, arguments);
}
return A2;
}(Actor)));
}
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
function bind$(obj, key, target){
return function(){ return (target || obj)[key].apply(obj, arguments) };
}
function importAll$(obj, src){
for (var key in src) obj[key] = src[key];
return obj;
}
function in$(x, xs){
var i = -1, l = xs.length >>> 0;
while (++i < l) if (x === xs[i]) return true;
return false;
}
});
var filters = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var sleep, FpsExec, out$ = exports || commonjsGlobal, toString$ = {}.toString;
sleep = lib$2.sleep;
out$.FpsExec = FpsExec = (function(){
FpsExec.displayName = 'FpsExec';
var prototype = FpsExec.prototype;
function FpsExec(opts){
var fps, this$ = this instanceof ctor$ ? this : new ctor$;
opts == null && (opts = 20);
fps = toString$.call(opts).slice(8, -1) === 'Number' ? opts : void 8;
this$.debug = (function(){
try {
return opts.debug;
} catch (e$) {}
}());
this$.period = opts.period || 1000 / fps;
this$.timer = null;
this$.lastExec = 0;
this$.paused = false;
return this$;
} function ctor$(){} ctor$.prototype = prototype;
FpsExec.prototype.now = function(){
return new Date().getTime();
};
FpsExec.prototype.pause = function(){
return this.paused = true;
};
FpsExec.prototype.resume = function(){
var that;
if ((that = this._fn) != null) {
that.apply(null, this._args);
this._fn = null;
}
return this.paused = false;
};
FpsExec.prototype.exec = function(func){
var args, res$, i$, to$, timeToExec, this$ = this;
res$ = [];
for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
timeToExec = this.period - (this.now() - this.lastExec);
if (timeToExec < 0) {
timeToExec = 0;
}
try {
clearTimeout(this.timer);
if (this.debug) {
console.info("FpsExec is skipping an execution.");
}
} catch (e$) {}
return this.timer = sleep(timeToExec, function(){
if (!this$.paused) {
func.apply(null, args);
return this$.lastExec = this$.now();
} else {
this$._fn = func;
return this$._args = args;
}
});
};
return FpsExec;
}());
/*
x = new FpsExec 15fps
# or
x = new FpsExec period: 3000ms
### Example Output:
[13:39:26.587] DbLogger : Read something: 10487
[13:39:27.089] DbLogger : Read something: 10488
[13:39:27.590] DbLogger : Read something: 10489
[13:39:28.087] DbLogger : This is going to be recorded: 10489
[13:39:28.091] DbLogger : Read something: 10490
[13:39:28.591] DbLogger : Read something: 10491
[13:39:29.092] DbLogger : Read something: 10492
[13:39:29.593] DbLogger : Read something: 10493
[13:39:30.091] DbLogger : This is going to be recorded: 10493
[13:39:30.093] DbLogger : Read something: 10494
[13:39:30.594] DbLogger : Read something: 10495
[13:39:31.094] DbLogger : Read something: 10496
[13:39:31.593] DbLogger : Read something: 10497
[13:39:32.093] DbLogger : This is going to be recorded: 10497
[13:39:32.096] DbLogger : Read something: 10498
[13:39:32.597] DbLogger : Read something: 10499
[13:39:33.098] DbLogger : Read something: 10500
[13:39:33.598] DbLogger : Read something: 10501
[13:39:34.096] DbLogger : This is going to be recorded: 10501
[13:39:34.099] DbLogger : Read something: 10502
[13:39:34.599] DbLogger : Read something: 10503
[13:39:35.100] DbLogger : Read something: 10504
[13:39:35.601] DbLogger : Read something: 10505
[13:39:36.099] DbLogger : This is going to be recorded: 10505
*/
});
var inherits_browser = createCommonjsModule(function (module) {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor;
var TempCtor = function () {};
TempCtor.prototype = superCtor.prototype;
ctor.prototype = new TempCtor();
ctor.prototype.constructor = ctor;
}
};
}
});
var inherits = createCommonjsModule(function (module) {
try {
var util = util__default['default'];
/* istanbul ignore next */
if (typeof util.inherits !== 'function') throw '';
module.exports = util.inherits;
} catch (e) {
/* istanbul ignore next */
module.exports = inherits_browser;
}
});
var safeBuffer = createCommonjsModule(function (module, exports) {
/* eslint-disable node/no-deprecated-api */
var Buffer = buffer__default['default'].Buffer;
// alternative to using Object.keys for old browsers
function copyProps (src, dst) {
for (var key in src) {
dst[key] = src[key];
}
}
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
module.exports = buffer__default['default'];
} else {
// Copy properties from require('buffer')
copyProps(buffer__default['default'], exports);
exports.Buffer = SafeBuffer;
}
function SafeBuffer (arg, encodingOrOffset, length) {
return Buffer(arg, encodingOrOffset, length)
}
// Copy static methods from Buffer
copyProps(Buffer, SafeBuffer);
SafeBuffer.from = function (arg, encodingOrOffset, length) {
if (typeof arg === 'number') {
throw new TypeError('Argument must not be a number')
}
return Buffer(arg, encodingOrOffset, length)
};
SafeBuffer.alloc = function (size, fill, encoding) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
var buf = Buffer(size);
if (fill !== undefined) {
if (typeof encoding === 'string') {
buf.fill(fill, encoding);
} else {
buf.fill(fill);
}
} else {
buf.fill(0);
}
return buf
};
SafeBuffer.allocUnsafe = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return Buffer(size)
};
SafeBuffer.allocUnsafeSlow = function (size) {
if (typeof size !== 'number') {
throw new TypeError('Argument must be a number')
}
return buffer__default['default'].SlowBuffer(size)
};
});
var Buffer = safeBuffer.Buffer;
// prototype class for hash functions
function Hash (blockSize, finalSize) {
this._block = Buffer.alloc(blockSize);
this._finalSize = finalSize;
this._blockSize = blockSize;
this._len = 0;
}
Hash.prototype.update = function (data, enc) {
if (typeof data === 'string') {
enc = enc || 'utf8';
data = Buffer.from(data, enc);
}
var block = this._block;
var blockSize = this._blockSize;
var length = data.length;
var accum = this._len;
for (var offset = 0; offset < length;) {
var assigned = accum % blockSize;
var remainder = Math.min(length - offset, blockSize - assigned);
for (var i = 0; i < remainder; i++) {
block[assigned + i] = data[offset + i];
}
accum += remainder;
offset += remainder;
if ((accum % blockSize) === 0) {
this._update(block);
}
}
this._len += length;
return this
};
Hash.prototype.digest = function (enc) {
var rem = this._len % this._blockSize;
this._block[rem] = 0x80;
// zero (rem + 1) trailing bits, where (rem + 1) is the smallest
// non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
this._block.fill(0, rem + 1);
if (rem >= this._finalSize) {
this._update(this._block);
this._block.fill(0);
}
var bits = this._len * 8;
// uint32
if (bits <= 0xffffffff) {
this._block.writeUInt32BE(bits, this._blockSize - 4);
// uint64
} else {
var lowBits = (bits & 0xffffffff) >>> 0;
var highBits = (bits - lowBits) / 0x100000000;
this._block.writeUInt32BE(highBits, this._blockSize - 8);
this._block.writeUInt32BE(lowBits, this._blockSize - 4);
}
this._update(this._block);
var hash = this._hash();
return enc ? hash.toString(enc) : hash
};
Hash.prototype._update = function () {
throw new Error('_update must be implemented by subclass')
};
var hash = Hash;
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
* in FIPS PUB 180-1
* This source code is derived from sha1.js of the same repository.
* The difference between SHA-0 and SHA-1 is just a bitwise rotate left
* operation was added.
*/
var Buffer$1 = safeBuffer.Buffer;
var K = [
0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
];
var W = new Array(80);
function Sha () {
this.init();
this._w = W;
hash.call(this, 64, 56);
}
inherits(Sha, hash);
Sha.prototype.init = function () {
this._a = 0x67452301;
this._b = 0xefcdab89;
this._c = 0x98badcfe;
this._d = 0x10325476;
this._e = 0xc3d2e1f0;
return this
};
function rotl5 (num) {
return (num << 5) | (num >>> 27)
}
function rotl30 (num) {
return (num << 30) | (num >>> 2)
}
function ft (s, b, c, d) {
if (s === 0) return (b & c) | ((~b) & d)
if (s === 2) return (b & c) | (b & d) | (c & d)
return b ^ c ^ d
}
Sha.prototype._update = function (M) {
var W = this._w;
var a = this._a | 0;
var b = this._b | 0;
var c = this._c | 0;
var d = this._d | 0;
var e = this._e | 0;
for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4);
for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
for (var j = 0; j < 80; ++j) {
var s = ~~(j / 20);
var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0;
e = d;
d = c;
c = rotl30(b);
b = a;
a = t;
}
this._a = (a + this._a) | 0;
this._b = (b + this._b) | 0;
this._c = (c + this._c) | 0;
this._d = (d + this._d) | 0;
this._e = (e + this._e) | 0;
};
Sha.prototype._hash = function () {
var H = Buffer$1.allocUnsafe(20);
H.writeInt32BE(this._a | 0, 0);
H.writeInt32BE(this._b | 0, 4);
H.writeInt32BE(this._c | 0, 8);
H.writeInt32BE(this._d | 0, 12);
H.writeInt32BE(this._e | 0, 16);
return H
};
var sha = Sha;
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
var Buffer$2 = safeBuffer.Buffer;
var K$1 = [
0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
];
var W$1 = new Array(80);
function Sha1 () {
this.init();
this._w = W$1;
hash.call(this, 64, 56);
}
inherits(Sha1, hash);
Sha1.prototype.init = function () {
this._a = 0x67452301;
this._b = 0xefcdab89;
this._c = 0x98badcfe;
this._d = 0x10325476;
this._e = 0xc3d2e1f0;
return this
};
function rotl1 (num) {
return (num << 1) | (num >>> 31)
}
function rotl5$1 (num) {
return (num << 5) | (num >>> 27)
}
function rotl30$1 (num) {
return (num << 30) | (num >>> 2)
}
function ft$1 (s, b, c, d) {
if (s === 0) return (b & c) | ((~b) & d)
if (s === 2) return (b & c) | (b & d) | (c & d)
return b ^ c ^ d
}
Sha1.prototype._update = function (M) {
var W = this._w;
var a = this._a | 0;
var b = this._b | 0;
var c = this._c | 0;
var d = this._d | 0;
var e = this._e | 0;
for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4);
for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]);
for (var j = 0; j < 80; ++j) {
var s = ~~(j / 20);
var t = (rotl5$1(a) + ft$1(s, b, c, d) + e + W[j] + K$1[s]) | 0;
e = d;
d = c;
c = rotl30$1(b);
b = a;
a = t;
}
this._a = (a + this._a) | 0;
this._b = (b + this._b) | 0;
this._c = (c + this._c) | 0;
this._d = (d + this._d) | 0;
this._e = (e + this._e) | 0;
};
Sha1.prototype._hash = function () {
var H = Buffer$2.allocUnsafe(20);
H.writeInt32BE(this._a | 0, 0);
H.writeInt32BE(this._b | 0, 4);
H.writeInt32BE(this._c | 0, 8);
H.writeInt32BE(this._d | 0, 12);
H.writeInt32BE(this._e | 0, 16);
return H
};
var sha1 = Sha1;
/**
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
* in FIPS 180-2
* Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
*
*/
var Buffer$3 = safeBuffer.Buffer;
var K$2 = [
0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
];
var W$2 = new Array(64);
function Sha256 () {
this.init();
this._w = W$2; // new Array(64)
hash.call(this, 64, 56);
}
inherits(Sha256, hash);
Sha256.prototype.init = function () {
this._a = 0x6a09e667;
this._b = 0xbb67ae85;
this._c = 0x3c6ef372;
this._d = 0xa54ff53a;
this._e = 0x510e527f;
this._f = 0x9b05688c;
this._g = 0x1f83d9ab;
this._h = 0x5be0cd19;
return this
};
function ch (x, y, z) {
return z ^ (x & (y ^ z))
}
function maj (x, y, z) {
return (x & y) | (z & (x | y))
}
function sigma0 (x) {
return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
}
function sigma1 (x) {
return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
}
function gamma0 (x) {
return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
}
function gamma1 (x) {
return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
}
Sha256.prototype._update = function (M) {
var W = this._w;
var a = this._a | 0;
var b = this._b | 0;
var c = this._c | 0;
var d = this._d | 0;
var e = this._e | 0;
var f = this._f | 0;
var g = this._g | 0;
var h = this._h | 0;
for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4);
for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0;
for (var j = 0; j < 64; ++j) {
var T1 = (h + sigma1(e) + ch(e, f, g) + K$2[j] + W[j]) | 0;
var T2 = (sigma0(a) + maj(a, b, c)) | 0;
h = g;
g = f;
f = e;
e = (d + T1) | 0;
d = c;
c = b;
b = a;
a = (T1 + T2) | 0;
}
this._a = (a + this._a) | 0;
this._b = (b + this._b) | 0;
this._c = (c + this._c) | 0;
this._d = (d + this._d) | 0;
this._e = (e + this._e) | 0;
this._f = (f + this._f) | 0;
this._g = (g + this._g) | 0;
this._h = (h + this._h) | 0;
};
Sha256.prototype._hash = function () {
var H = Buffer$3.allocUnsafe(32);
H.writeInt32BE(this._a, 0);
H.writeInt32BE(this._b, 4);
H.writeInt32BE(this._c, 8);
H.writeInt32BE(this._d, 12);
H.writeInt32BE(this._e, 16);
H.writeInt32BE(this._f, 20);
H.writeInt32BE(this._g, 24);
H.writeInt32BE(this._h, 28);
return H
};
var sha256 = Sha256;
/**
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
* in FIPS 180-2
* Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
*
*/
var Buffer$4 = safeBuffer.Buffer;
var W$3 = new Array(64);
function Sha224 () {
this.init();
this._w = W$3; // new Array(64)
hash.call(this, 64, 56);
}
inherits(Sha224, sha256);
Sha224.prototype.init = function () {
this._a = 0xc1059ed8;
this._b = 0x367cd507;
this._c = 0x3070dd17;
this._d = 0xf70e5939;
this._e = 0xffc00b31;
this._f = 0x68581511;
this._g = 0x64f98fa7;
this._h = 0xbefa4fa4;
return this
};
Sha224.prototype._hash = function () {
var H = Buffer$4.allocUnsafe(28);
H.writeInt32BE(this._a, 0);
H.writeInt32BE(this._b, 4);
H.writeInt32BE(this._c, 8);
H.writeInt32BE(this._d, 12);
H.writeInt32BE(this._e, 16);
H.writeInt32BE(this._f, 20);
H.writeInt32BE(this._g, 24);
return H
};
var sha224 = Sha224;
var Buffer$5 = safeBuffer.Buffer;
var K$3 = [
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
];
var W$4 = new Array(160);
function Sha512 () {
this.init();
this._w = W$4;
hash.call(this, 128, 112);
}
inherits(Sha512, hash);
Sha512.prototype.init = function () {
this._ah = 0x6a09e667;
this._bh = 0xbb67ae85;
this._ch = 0x3c6ef372;
this._dh = 0xa54ff53a;
this._eh = 0x510e527f;
this._fh = 0x9b05688c;
this._gh = 0x1f83d9ab;
this._hh = 0x5be0cd19;
this._al = 0xf3bcc908;
this._bl = 0x84caa73b;
this._cl = 0xfe94f82b;
this._dl = 0x5f1d36f1;
this._el = 0xade682d1;
this._fl = 0x2b3e6c1f;
this._gl = 0xfb41bd6b;
this._hl = 0x137e2179;
return this
};
function Ch (x, y, z) {
return z ^ (x & (y ^ z))
}
function maj$1 (x, y, z) {
return (x & y) | (z & (x | y))
}
function sigma0$1 (x, xl) {
return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
}
function sigma1$1 (x, xl) {
return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
}
function Gamma0 (x, xl) {
return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7)
}
function Gamma0l (x, xl) {
return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25)
}
function Gamma1 (x, xl) {
return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6)
}
function Gamma1l (x, xl) {
return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
}
function getCarry (a, b) {
return (a >>> 0) < (b >>> 0) ? 1 : 0
}
Sha512.prototype._update = function (M) {
var W = this._w;
var ah = this._ah | 0;
var bh = this._bh | 0;
var ch = this._ch | 0;
var dh = this._dh | 0;
var eh = this._eh | 0;
var fh = this._fh | 0;
var gh = this._gh | 0;
var hh = this._hh | 0;
var al = this._al | 0;
var bl = this._bl | 0;
var cl = this._cl | 0;
var dl = this._dl | 0;
var el = this._el | 0;
var fl = this._fl | 0;
var gl = this._gl | 0;
var hl = this._hl | 0;
for (var i = 0; i < 32; i += 2) {
W[i] = M.readInt32BE(i * 4);
W[i + 1] = M.readInt32BE(i * 4 + 4);
}
for (; i < 160; i += 2) {
var xh = W[i - 15 * 2];
var xl = W[i - 15 * 2 + 1];
var gamma0 = Gamma0(xh, xl);
var gamma0l = Gamma0l(xl, xh);
xh = W[i - 2 * 2];
xl = W[i - 2 * 2 + 1];
var gamma1 = Gamma1(xh, xl);
var gamma1l = Gamma1l(xl, xh);
// W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
var Wi7h = W[i - 7 * 2];
var Wi7l = W[i - 7 * 2 + 1];
var Wi16h = W[i - 16 * 2];
var Wi16l = W[i - 16 * 2 + 1];
var Wil = (gamma0l + Wi7l) | 0;
var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0;
Wil = (Wil + gamma1l) | 0;
Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0;
Wil = (Wil + Wi16l) | 0;
Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0;
W[i] = Wih;
W[i + 1] = Wil;
}
for (var j = 0; j < 160; j += 2) {
Wih = W[j];
Wil = W[j + 1];
var majh = maj$1(ah, bh, ch);
var majl = maj$1(al, bl, cl);
var sigma0h = sigma0$1(ah, al);
var sigma0l = sigma0$1(al, ah);
var sigma1h = sigma1$1(eh, el);
var sigma1l = sigma1$1(el, eh);
// t1 = h + sigma1 + ch + K[j] + W[j]
var Kih = K$3[j];
var Kil = K$3[j + 1];
var chh = Ch(eh, fh, gh);
var chl = Ch(el, fl, gl);
var t1l = (hl + sigma1l) | 0;
var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0;
t1l = (t1l + chl) | 0;
t1h = (t1h + chh + getCarry(t1l, chl)) | 0;
t1l = (t1l + Kil) | 0;
t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0;
t1l = (t1l + Wil) | 0;
t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0;
// t2 = sigma0 + maj
var t2l = (sigma0l + majl) | 0;
var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0;
hh = gh;
hl = gl;
gh = fh;
gl = fl;
fh = eh;
fl = el;
el = (dl + t1l) | 0;
eh = (dh + t1h + getCarry(el, dl)) | 0;
dh = ch;
dl = cl;
ch = bh;
cl = bl;
bh = ah;
bl = al;
al = (t1l + t2l) | 0;
ah = (t1h + t2h + getCarry(al, t1l)) | 0;
}
this._al = (this._al + al) | 0;
this._bl = (this._bl + bl) | 0;
this._cl = (this._cl + cl) | 0;
this._dl = (this._dl + dl) | 0;
this._el = (this._el + el) | 0;
this._fl = (this._fl + fl) | 0;
this._gl = (this._gl + gl) | 0;
this._hl = (this._hl + hl) | 0;
this._ah = (this._ah + ah + getCarry(this._al, al)) | 0;
this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0;
this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0;
this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0;
this._eh = (this._eh + eh + getCarry(this._el, el)) | 0;
this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0;
this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0;
this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0;
};
Sha512.prototype._hash = function () {
var H = Buffer$5.allocUnsafe(64);
function writeInt64BE (h, l, offset) {
H.writeInt32BE(h, offset);
H.writeInt32BE(l, offset + 4);
}
writeInt64BE(this._ah, this._al, 0);
writeInt64BE(this._bh, this._bl, 8);
writeInt64BE(this._ch, this._cl, 16);
writeInt64BE(this._dh, this._dl, 24);
writeInt64BE(this._eh, this._el, 32);
writeInt64BE(this._fh, this._fl, 40);
writeInt64BE(this._gh, this._gl, 48);
writeInt64BE(this._hh, this._hl, 56);
return H
};
var sha512 = Sha512;
var Buffer$6 = safeBuffer.Buffer;
var W$5 = new Array(160);
function Sha384 () {
this.init();
this._w = W$5;
hash.call(this, 128, 112);
}
inherits(Sha384, sha512);
Sha384.prototype.init = function () {
this._ah = 0xcbbb9d5d;
this._bh = 0x629a292a;
this._ch = 0x9159015a;
this._dh = 0x152fecd8;
this._eh = 0x67332667;
this._fh = 0x8eb44a87;
this._gh = 0xdb0c2e0d;
this._hh = 0x47b5481d;
this._al = 0xc1059ed8;
this._bl = 0x367cd507;
this._cl = 0x3070dd17;
this._dl = 0xf70e5939;
this._el = 0xffc00b31;
this._fl = 0x68581511;
this._gl = 0x64f98fa7;
this._hl = 0xbefa4fa4;
return this
};
Sha384.prototype._hash = function () {
var H = Buffer$6.allocUnsafe(48);
function writeInt64BE (h, l, offset) {
H.writeInt32BE(h, offset);
H.writeInt32BE(l, offset + 4);
}
writeInt64BE(this._ah, this._al, 0);
writeInt64BE(this._bh, this._bl, 8);
writeInt64BE(this._ch, this._cl, 16);
writeInt64BE(this._dh, this._dl, 24);
writeInt64BE(this._eh, this._el, 32);
writeInt64BE(this._fh, this._fl, 40);
return H
};
var sha384 = Sha384;
var sha_js = createCommonjsModule(function (module) {
var exports = module.exports = function SHA (algorithm) {
algorithm = algorithm.toLowerCase();
var Algorithm = exports[algorithm];
if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)')
return new Algorithm()
};
exports.sha = sha;
exports.sha1 = sha1;
exports.sha224 = sha224;
exports.sha256 = sha256;
exports.sha384 = sha384;
exports.sha512 = sha512;
});
var authHelpers = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var createHash, hashPasswd, AuthError, out$ = exports || commonjsGlobal;
createHash = sha_js;
out$.hashPasswd = hashPasswd = function(passwd){
var sha512;
sha512 = createHash('sha512');
return sha512.update(passwd, 'utf-8').digest('hex');
};
out$.AuthError = AuthError = (function(superclass){
var prototype = extend$((import$(AuthError, superclass).displayName = 'AuthError', AuthError), superclass).prototype;
function AuthError(message){
this.message = message;
AuthError.superclass.apply(this, arguments);
Error.captureStackTrace(this, AuthError);
this.type = 'AuthError';
}
return AuthError;
}(Error));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var authRequest = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var Signal, ref$, sleep, pack, clone, EventEmitter, Logger, red, green, yellow, bgRed, bgYellow, hashPasswd, topicMatch, keys, join, AuthRequest, out$ = exports || commonjsGlobal;
Signal = signal$1.Signal;
ref$ = lib$2, sleep = ref$.sleep, pack = ref$.pack, clone = ref$.clone, EventEmitter = ref$.EventEmitter, Logger = ref$.Logger;
ref$ = lib, red = ref$.red, green = ref$.green, yellow = ref$.yellow, bgRed = ref$.bgRed, bgYellow = ref$.bgYellow;
hashPasswd = authHelpers.hashPasswd;
topicMatch = topicMatch_1.topicMatch;
ref$ = lib$1, keys = ref$.keys, join = ref$.join;
out$.AuthRequest = AuthRequest = (function(){
AuthRequest.displayName = 'AuthRequest';
var constructor = AuthRequest;
AuthRequest.i = 0;
function AuthRequest(name){
this.log = new Logger(name || "AuthRequest." + (constructor.i++));
this.replySignal = new Signal();
}
AuthRequest.prototype.inbox = function(msg){
return this.replySignal.go(null, msg);
};
AuthRequest.prototype.login = function(_credentials, callback){
var credentials, err, this$ = this;
_credentials == null && (_credentials = {});
credentials = clone(_credentials);
if (credentials.password) {
credentials.password = hashPasswd(credentials.password);
} else if (credentials.token != null) {
this.log.info("token is: ", credentials);
if (credentials.token.length < 10) {
err = "Token seems empty, not attempting to login.";
this.log.log(err);
callback(err = "Not a valid token", null);
return;
}
}
this.log.log("Trying to authenticate with", keys(credentials).join(', '));
if (keys(credentials).length === 0) {
this.log.warn("Credentials empty! (why? is server restarted?)");
callback(err = "EMPTY_CREDENTIALS");
return;
}
this.write({
auth: credentials
});
this.replySignal.clear();
return this.replySignal.wait(3000, function(err, res){
var that, ref$, ref1$, ref2$;
if (that = res != null ? (ref$ = res.auth) != null ? (ref1$ = ref$.session) != null ? ref1$.token : void 8 : void 8 : void 8) {
this$.token = that;
}
return callback(err || (res != null ? (ref2$ = res.auth) != null ? ref2$.error : void 8 : void 8), res);
});
};
AuthRequest.prototype.logout = function(callback){
var this$ = this;
this.write(this.addToken({
auth: {
logout: true
}
}));
return this.replySignal.wait(3000, function(err, msg){
if (!err && msg.auth.logout === 'ok') {
this$.log.log("clearing token from AuthRequest cache");
this$.token = null;
}
return callback(err, msg);
});
};
AuthRequest.prototype.addToken = function(msg){
return msg.token = this.token, msg;
};
return AuthRequest;
}());
});
var uuid4 = createCommonjsModule(function (module, exports) {
var uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
exports = module.exports = genUUID;
exports.valid = isUUID;
function genUUID(callback) {
if (typeof callback !== "function") {
var rnd = crypto__default['default'].randomBytes(16);
rnd[6] = (rnd[6] & 0x0f) | 0x40;
rnd[8] = (rnd[8] & 0x3f) | 0x80;
rnd = rnd.toString("hex").match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
rnd.shift();
return rnd.join("-");
}
crypto__default['default'].randomBytes(16, function(err, rnd) {
if (err) return callback(err);
try {
rnd[6] = (rnd[6] & 0x0f) | 0x40;
rnd[8] = (rnd[8] & 0x3f) | 0x80;
rnd = rnd.toString("hex").match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
rnd.shift();
return callback(null, rnd.join("-"));
} catch (err2) {
return callback(err2);
}
});
}
function isUUID(uuid) {
return uuidPattern.test(uuid);
}
});
var errors = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var CodingError, out$ = exports || commonjsGlobal;
out$.CodingError = CodingError = (function(superclass){
var prototype = extend$((import$(CodingError, superclass).displayName = 'CodingError', CodingError), superclass).prototype;
function CodingError(message){
this.message = message;
CodingError.superclass.apply(this, arguments);
Error.captureStackTrace(this, CodingError);
this.type = 'CodingError';
}
return CodingError;
}(Error));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var authHandler = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, sleep, Logger, pack, EventEmitter, uuid4$1, red, green, yellow, bgRed, bgYellow, bgGreen, bgCyan, hashPasswd, AuthError, topicMatch, CodingError, SessionCache, AuthHandler, out$ = exports || commonjsGlobal;
ref$ = lib$2, sleep = ref$.sleep, Logger = ref$.Logger, pack = ref$.pack, EventEmitter = ref$.EventEmitter;
uuid4$1 = uuid4;
ref$ = lib, red = ref$.red, green = ref$.green, yellow = ref$.yellow, bgRed = ref$.bgRed, bgYellow = ref$.bgYellow, bgGreen = ref$.bgGreen, bgCyan = ref$.bgCyan;
ref$ = authHelpers, hashPasswd = ref$.hashPasswd, AuthError = ref$.AuthError;
topicMatch = topicMatch_1.topicMatch;
CodingError = errors.CodingError;
SessionCache = (function(){
SessionCache.displayName = 'SessionCache';
var constructor = SessionCache;
SessionCache.cache = {};
SessionCache.instance = null;
function SessionCache(){
if (constructor.instance) {
return constructor.instance;
}
constructor.instance = this;
this.log = new Logger('SessionCache');
this.log.log(green("SessionCache is initialized", pack(constructor.cache)));
}
SessionCache.prototype.add = function(session){
this.log.log(green("Adding session for " + session.user, yellow(session.token)));
return constructor.cache[session.token] = session;
};
SessionCache.prototype.get = function(token){
return constructor.cache[token];
};
SessionCache.prototype.drop = function(token){
var ref$, ref1$;
this.log.log(yellow("Dropping session for user: " + constructor.cache[token].user + " token: " + token));
return ref1$ = (ref$ = constructor.cache)[token], delete ref$[token], ref1$;
};
return SessionCache;
}());
out$.AuthHandler = AuthHandler = (function(superclass){
var prototype = extend$((import$(AuthHandler, superclass).displayName = 'AuthHandler', AuthHandler), superclass).prototype, constructor = AuthHandler;
AuthHandler.loginDelay = 10;
AuthHandler.i = 0;
function AuthHandler(db, name){
var this$ = this;
db != null || (function(){
throw new CodingError("AuthDB instance is required.");
}());
AuthHandler.superclass.call(this);
this.log = new Logger(name || "AuthHandler." + (constructor.i++));
this.sessionCache = new SessionCache();
this.on('check-auth', function(msg){
var user, e, ref$, foundSession;
if (msg.debug) {
this$.log.log("Processing authentication message", msg);
}
if ('user' in msg.auth) {
try {
user = db.get(msg.auth.user);
if (user.passwdHash === msg.auth.password) {
this$.session = {
token: uuid4$1(),
user: msg.auth.user,
date: Date.now(),
routes: user.routes,
permissions: user.permissions
};
this$.sessionCache.add(this$.session);
this$.log.log(bgGreen("new Login: " + msg.auth.user + " (" + this$.session.token + ")"));
this$.log.log("(...sending with " + constructor.loginDelay + "ms delay)");
this$.trigger('login', this$.session);
return sleep(constructor.loginDelay, function(){
return this$.trigger('to-client', {
auth: {
session: this$.session
}
});
});
} else {
this$.log.err("wrong password, tried:" + msg.auth.user + ", " + msg.auth.password);
return this$.trigger('to-client', {
auth: {
error: "wrong password"
}
});
}
} catch (e$) {
e = e$;
this$.log.err("user \"" + msg.auth.user + "\" is not found. err: ", e);
return this$.trigger('to-client', {
auth: {
error: e
}
});
}
} else if ('logout' in msg.auth) {
if (!this$.sessionCache.get(msg.token)) {
this$.log.log(bgYellow("No user found with the following token: " + msg.token + " "));
this$.trigger('to-client', {
auth: {
logout: 'ok',
error: "no such user found"
}
});
return this$.trigger('logout');
} else {
this$.log.log("logging out for " + pack(this$.sessionCache.get(msg.token)));
this$.sessionCache.drop(msg.token);
this$.trigger('to-client', {
auth: {
logout: 'ok'
}
});
return this$.trigger('logout');
}
} else if ('token' in msg.auth) {
this$.log.log("Attempting to login with token: ", pack(msg.auth));
if (((ref$ = this$.sessionCache.get(msg.auth.token)) != null ? ref$.token : void 8) === msg.auth.token) {
foundSession = this$.sessionCache.get(msg.auth.token);
this$.log.log(bgCyan("User \"" + foundSession.user + "\" has been logged in with token."));
this$.trigger('login', foundSession);
return sleep(constructor.loginDelay, function(){
return this$.trigger('to-client', {
auth: {
session: foundSession
}
});
});
} else {
this$.log.log(bgYellow("client doesn't seem to be logged in yet."));
return sleep(constructor.loginDelay, function(){
return this$.trigger('to-client', {
auth: {
session: {
logout: 'yes'
}
}
});
});
}
} else {
return this$.log.err(yellow("Can not determine which auth request this was: ", pack(msg)));
}
});
}
AuthHandler.prototype.checkRoutes = function(msg){
var session, i$, x$, ref$, len$;
session = this.sessionCache.get(msg.token);
if (session) {
for (i$ = 0, len$ = (ref$ = session.routes).length; i$ < len$; ++i$) {
x$ = ref$[i$];
if (topicMatch(x$, msg.to)) {
delete msg.token;
return msg;
}
}
if (msg.re != null) {
delete msg.token;
return msg;
}
}
return this.log.err(bgRed("filter-incoming dropping unauthorized message!"), (function(){
throw new AuthError('unauthorized message route');
}()));
};
AuthHandler.prototype.modifySender = function(msg){
var session;
session = this.sessionCache.get(msg.token);
if (!session) {
throw new AuthError("No appropriate session is found.");
}
msg.from = "@" + session.user + "." + msg.from;
return msg;
};
AuthHandler.prototype.addCtx = function(msg){
var session;
session = this.sessionCache.get(msg.token);
msg.permissions = session.permissions;
msg.user = session.user;
return msg;
};
return AuthHandler;
}(EventEmitter));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
// Generated by LiveScript 1.6.0
var ref$$2, sleep$2, pack$1, unpack$1, Logger$2, clone$2, brief$1, AuthRequest, Signal$2, Actor, topicMatch, AuthHandler;
ref$$2 = lib$2, sleep$2 = ref$$2.sleep, pack$1 = ref$$2.pack, unpack$1 = ref$$2.unpack, Logger$2 = ref$$2.Logger, clone$2 = ref$$2.clone;
brief$1 = debugTools.brief;
AuthRequest = authRequest.AuthRequest;
Signal$2 = signal$1.Signal;
Actor = actor.Actor;
topicMatch = topicMatch_1.topicMatch;
AuthHandler = authHandler.AuthHandler;
var deps$1 = {
sleep: sleep$2,
pack: pack$1,
unpack: unpack$1,
clone: clone$2,
Logger: Logger$2,
AuthRequest: AuthRequest,
AuthHandler: AuthHandler,
topicMatch: topicMatch,
Actor: Actor,
Signal: Signal$2,
brief: brief$1
};
var helpers = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, sleep, pack, unpack, Logger, clone, split, flatten, splitAt, compact, MessageBinder, out$ = exports || commonjsGlobal, toString$ = {}.toString;
ref$ = lib$2, sleep = ref$.sleep, pack = ref$.pack, unpack = ref$.unpack, Logger = ref$.Logger, clone = ref$.clone;
ref$ = lib$1, split = ref$.split, flatten = ref$.flatten, splitAt = ref$.splitAt, compact = ref$.compact;
function unpackTelegrams(data){
"Search for valid JSON telegrams recursively";
var boundary, ref$, _first, _rest, nextSize, _firstTelegram, that, restTelegram, restStr, a, packets;
boundary = data.indexOf('}{');
ref$ = compact(splitAt(boundary + 1, data)), _first = ref$[0], _rest = ref$[1];
nextSize = 0;
try {
_firstTelegram = unpack(_first);
} catch (e$) {
return [[], data, nextSize];
}
if (that = _firstTelegram != null ? _firstTelegram.size : void 8) {
nextSize = that;
_firstTelegram = null;
}
restTelegram = [];
restStr = '';
if (_rest) {
ref$ = unpackTelegrams(_rest), restTelegram = ref$[0], restStr = ref$[1], a = ref$[2];
if (nextSize > 0 && restTelegram.length > 0) {
nextSize = 0;
}
}
packets = compact(flatten([_firstTelegram, restTelegram]));
return [packets, restStr, nextSize];
}
out$.MessageBinder = MessageBinder = (function(){
MessageBinder.displayName = 'MessageBinder';
function MessageBinder(){
this.log = new Logger('MessageBinder');
this.i = 0;
this.cache = "";
this.heartbeat = 0;
this.timeout = 1400;
this.maxTry = 1200;
this.nextSize = 0;
}
MessageBinder.prototype.append = function(data){
var ref$, res, y, size;
if (toString$.call(data).slice(8, -1) === 'Uint8Array') {
data = data.toString();
}
if (this.heartbeat < Date.now() - this.timeout) {
this.cache = '';
this.i = 0;
this.nextSize = 0;
}
this.cache += data;
if (this.nextSize > 0) {
if (this.cache.length < this.nextSize) {
return [];
} else {
this.nextSize = 0;
}
}
this.i++;
if (this.i > this.maxTry) {
this.log.err("Caching isn't enough, giving up.");
this.i = 0;
this.cache = data;
this.nextSize = 0;
}
this.heartbeat = Date.now();
ref$ = unpackTelegrams(this.cache), res = ref$[0], y = ref$[1], size = ref$[2];
if (size > 0) {
this.nextSize = size;
}
this.cache = y;
this.i = 0;
return res;
};
return MessageBinder;
}());
});
var client = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, AuthRequest, sleep, pack, unpack, Signal, Actor, topicMatch, clone, brief, split, flatten, splitAt, empty, reject, MessageBinder, ProxyClient, out$ = exports || commonjsGlobal, toString$ = {}.toString;
ref$ = deps$1, AuthRequest = ref$.AuthRequest, sleep = ref$.sleep, pack = ref$.pack, unpack = ref$.unpack, Signal = ref$.Signal, Actor = ref$.Actor, topicMatch = ref$.topicMatch, clone = ref$.clone, brief = ref$.brief;
ref$ = lib$1, split = ref$.split, flatten = ref$.flatten, splitAt = ref$.splitAt, empty = ref$.empty, reject = ref$.reject;
MessageBinder = helpers.MessageBinder;
out$.ProxyClient = ProxyClient = (function(superclass){
var prototype = extend$((import$(ProxyClient, superclass).displayName = 'ProxyClient', ProxyClient), superclass).prototype;
function ProxyClient(transport, opts){
this.transport = transport;
this.opts = opts;
ProxyClient.superclass.call(this, this.opts.name || 'ProxyClient');
}
ProxyClient.prototype.action = function(){
var x$, totalDelay, y$, this$ = this;
this.role = 'client';
this.connected = false;
this.session = null;
this._transport_busy = false;
x$ = this.auth = new AuthRequest(this.name);
x$.write = function(msg){
return this$.transport.write(pack(msg));
};
this.onTopic('app.dcs.update', function(msg){
var debug;
debug = false;
if (debug) {
this$.log.debug("Received connection status update: ", msg);
}
return this$.sendResponse(msg, {
debug: debug
}, this$.session);
});
this.on('disconnect', function(){
this$.subscriptions = reject(function(it){
var ref$;
return topicMatch(it, (ref$ = this$.session) != null ? ref$.routes : void 8);
}, this$.subscriptions);
this$.session = null;
return this$.send('app.dcs.disconnect');
});
this.on('connect', function(){
return this$.trigger('_login');
});
this.on('receive', function(msg){
if (!topicMatch(msg.to, "app.**")) {
if (!topicMatch(msg.to, this$.subscriptions)) {
this$.log.err("Possible coding error: We don't have a route for: ", msg);
this$.log.info("Our subscriptions: ", this$.subscriptions);
this$.sendResponse(msg, {
err: "How come the ProxyClient is subscribed a topicthat it has no rights to send? This is a DCS malfunction."
});
return;
}
if (this$._transport_busy) {
this$.log.err("Transport was busy, we shouldn't try to send ", msg);
this$.log.info("...will retry to write to transport in 500ms.");
debugger;
sleep(500, function(){
return this$.trigger('receive', msg);
});
return;
}
this$._transport_busy = true;
this$.transport.write(
function(s){
if (msg.debug) {
this$.log.debug("Sending " + msg.seq + "->" + msg.to + " size: " + s.length);
}
return pack({
size: s.length
}) + s;
}(
pack(
this$.auth.addToken(
function(m){
var responseId;
if (m.debug) {
this$.log.debug("Forwarding DCS to transport: ", brief(m));
}
if (m.re != null) {
responseId = m.to + "";
if (m.part == null || m.part === -1) {
this$.unsubscribe(responseId);
}
}
return m;
}(
msg)))));
if (msg.debug) {
this$.log.debug("Data is sent.");
}
return this$._transport_busy = false;
}
});
this.m = new MessageBinder();
totalDelay = 0;
y$ = this.transport;
y$.on('connect', function(){
this$.connected = true;
return this$.log.success("My transport is connected, re-logging-in.");
});
y$.on('disconnect', function(){
this$.connected = false;
return this$.log.warn("My transport is disconnected.");
});
y$.on("data", function(data){
var t0, x, i$, len$, msg, responseRoute, that, msg2;
t0 = Date.now();
x = this$.m.append(data);
totalDelay = totalDelay + (Date.now() - t0);
for (i$ = 0, len$ = x.length; i$ < len$; ++i$) {
msg = x[i$];
if (totalDelay > 100) {
this$.log.debug("....time spent for concatenating: " + totalDelay + "ms");
}
totalDelay = 0;
if ('auth' in msg) {
this$.auth.inbox(msg);
} else {
if (msg.debug) {
this$.log.debug("Forwarding Transport to DCS:", brief(msg));
}
if (msg.req) {
responseRoute = msg.from + "";
if (msg.debug) {
this$.log.debug("Transient subscription to response route: " + responseRoute);
}
this$.subscribe(responseRoute);
}
if (msg.re != null) {
msg.to = msg.to.replace("@" + this$.session.user + ".", '');
if (that = this$.mgr.findActor(msg.to)) {
that._inbox(msg);
}
if (msg.cc) {
msg2 = clone(msg);
msg2.to = msg.cc;
msg2._exclude = msg.to;
this$.sendEnveloped(msg2);
}
return;
}
this$.sendEnveloped(msg);
}
}
});
return y$;
};
Object.defineProperty(ProxyClient.prototype, 'connected', {
get: function(){
return this._connected;
},
set: function(curr){
var prev;
prev = this._connected;
this._connected = curr;
if (curr && !prev) {
this.trigger('connect');
}
if (!curr && prev) {
this.trigger('disconnect');
}
},
configurable: true,
enumerable: true
});
ProxyClient.prototype.login = function(credentials, callback){
var this$ = this;
if (toString$.call(credentials).slice(8, -1) === 'Function') {
callback = credentials;
credentials = null;
} else if (!callback) {
callback = function(err, res){
var ref$;
if (err) {
return this$.log.err("Something went wrong while login: ", pack(err));
} else if ((ref$ = res.auth) != null && ref$.error) {
return this$.log.err("Wrong credentials?");
} else {
return this$.log.success("Logged in into the DCS network.");
}
};
}
this.off('_login');
this.on('_login', function(opts){
this$.log.log("sending credentials...");
return this$.auth.login(credentials, function(err, res){
var error, ref$, ref1$, ref2$, i$, x$, ref3$, len$, ref4$;
error = err || (res != null ? (ref$ = res.auth) != null ? ref$.error : void 8 : void 8) || (res != null ? (ref1$ = res.auth) != null ? (ref2$ = ref1$.session) != null ? ref2$.logout : void 8 : void 8 : void 8) === 'yes';
if (!error) {
this$.session = (function(){
try {
return res.auth.session;
} catch (e$) {
this.log.error("FIXME: We have empty session: ", res);
return {};
}
}.call(this$));
this$.subscriptions = this$.subscriptions.concat(this$.session.routes);
this$.log.info("Remote route subscriptions: ");
for (i$ = 0, len$ = (ref3$ = flatten([this$.subscriptions])).length; i$ < len$; ++i$) {
x$ = ref3$[i$];
this$.log.info("-> " + x$);
}
this$.log.info("Emitting app.dcs.connect");
this$.send('app.dcs.connect', this$.session);
this$.trigger('logged-in', this$.session, function(){
var ref$;
return credentials = {
token: (ref$ = this$.session) != null ? ref$.token : void 8
};
});
} else {
this$.connected = false;
}
if ((res != null ? (ref3$ = res.auth) != null ? (ref4$ = ref3$.session) != null ? ref4$.logout : void 8 : void 8 : void 8) === 'yes') {
this$.trigger('kicked-out');
}
return callback(error, res);
});
});
if (this.connected) {
return this.trigger('_login');
}
};
ProxyClient.prototype.logout = function(callback){
var this$ = this;
return this.auth.logout(function(err, res){
var reason, ref$;
this$.log.info("Logged out; err, res: ", err, res);
reason = res != null ? (ref$ = res.auth) != null ? ref$.error : void 8 : void 8;
this$.trigger('logged-out', reason);
return callback(err, res);
});
};
return ProxyClient;
}(Actor));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
/**
* Helpers.
*/
var s = 1000;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
/**
* Parse or format the given `val`.
*
* Options:
*
* - `long` verbose formatting [false]
*
* @param {String|Number} val
* @param {Object} [options]
* @throws {Error} throw an error if val is not a non-empty string or a number
* @return {String|Number}
* @api public
*/
var ms = function(val, options) {
options = options || {};
var type = typeof val;
if (type === 'string' && val.length > 0) {
return parse(val);
} else if (type === 'number' && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
'val is not a non-empty string or a valid number. val=' +
JSON.stringify(val)
);
};
/**
* Parse the given `str` and return milliseconds.
*
* @param {String} str
* @return {Number}
* @api private
*/
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || 'ms').toLowerCase();
switch (type) {
case 'years':
case 'year':
case 'yrs':
case 'yr':
case 'y':
return n * y;
case 'weeks':
case 'week':
case 'w':
return n * w;
case 'days':
case 'day':
case 'd':
return n * d;
case 'hours':
case 'hour':
case 'hrs':
case 'hr':
case 'h':
return n * h;
case 'minutes':
case 'minute':
case 'mins':
case 'min':
case 'm':
return n * m;
case 'seconds':
case 'second':
case 'secs':
case 'sec':
case 's':
return n * s;
case 'milliseconds':
case 'millisecond':
case 'msecs':
case 'msec':
case 'ms':
return n;
default:
return undefined;
}
}
/**
* Short format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function fmtShort(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return Math.round(ms / d) + 'd';
}
if (msAbs >= h) {
return Math.round(ms / h) + 'h';
}
if (msAbs >= m) {
return Math.round(ms / m) + 'm';
}
if (msAbs >= s) {
return Math.round(ms / s) + 's';
}
return ms + 'ms';
}
/**
* Long format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function fmtLong(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return plural(ms, msAbs, d, 'day');
}
if (msAbs >= h) {
return plural(ms, msAbs, h, 'hour');
}
if (msAbs >= m) {
return plural(ms, msAbs, m, 'minute');
}
if (msAbs >= s) {
return plural(ms, msAbs, s, 'second');
}
return ms + ' ms';
}
/**
* Pluralization helper.
*/
function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
}
var debug = createCommonjsModule(function (module, exports) {
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
exports.humanize = ms;
/**
* The currently active debug mode names, and names to skip.
*/
exports.names = [];
exports.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
*/
exports.formatters = {};
/**
* Previous log timestamp.
*/
var prevTime;
/**
* Select a color.
* @param {String} namespace
* @return {Number}
* @api private
*/
function selectColor(namespace) {
var hash = 0, i;
for (i in namespace) {
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
hash |= 0; // Convert to 32bit integer
}
return exports.colors[Math.abs(hash) % exports.colors.length];
}
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function createDebug(namespace) {
function debug() {
// disabled?
if (!debug.enabled) return;
var self = debug;
// set `diff` timestamp
var curr = +new Date();
var ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
// turn the `arguments` into a proper Array
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
args[0] = exports.coerce(args[0]);
if ('string' !== typeof args[0]) {
// anything else let's inspect with %O
args.unshift('%O');
}
// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
// if we encounter an escaped % then don't increase the array index
if (match === '%%') return match;
index++;
var formatter = exports.formatters[format];
if ('function' === typeof formatter) {
var val = args[index];
match = formatter.call(self, val);
// now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// apply env-specific formatting (colors, etc.)
exports.formatArgs.call(self, args);
var logFn = debug.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.enabled = exports.enabled(namespace);
debug.useColors = exports.useColors();
debug.color = selectColor(namespace);
// env-specific initialization logic for debug instances
if ('function' === typeof exports.init) {
exports.init(debug);
}
return debug;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
exports.save(namespaces);
exports.names = [];
exports.skips = [];
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
var len = split.length;
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
namespaces = split[i].replace(/\*/g, '.*?');
if (namespaces[0] === '-') {
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
exports.names.push(new RegExp('^' + namespaces + '$'));
}
}
}
/**
* Disable debug output.
*
* @api public
*/
function disable() {
exports.enable('');
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
var i, len;
for (i = 0, len = exports.skips.length; i < len; i++) {
if (exports.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = exports.names.length; i < len; i++) {
if (exports.names[i].test(name)) {
return true;
}
}
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
});
var browser = createCommonjsModule(function (module, exports) {
/**
* This is the web browser implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = debug;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = 'undefined' != typeof chrome
&& 'undefined' != typeof chrome.storage
? chrome.storage.local
: localstorage();
/**
* Colors.
*/
exports.colors = [
'lightseagreen',
'forestgreen',
'goldenrod',
'dodgerblue',
'darkorchid',
'crimson'
];
/**
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
* and the Firebug extension (any Firefox version) are known
* to support "%c" CSS customizations.
*
* TODO: add a `localStorage` variable to explicitly enable/disable colors
*/
function useColors() {
// NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we're in Chrome, we'll just detect this case
// explicitly
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
return true;
}
// is webkit? http://stackoverflow.com/a/16459606/376773
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
// is firebug? http://stackoverflow.com/a/398120/376773
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
// is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
// double check webkit in userAgent just in case we are in a worker
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
}
/**
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
*/
exports.formatters.j = function(v) {
try {
return JSON.stringify(v);
} catch (err) {
return '[UnexpectedJSONParseError]: ' + err.message;
}
};
/**
* Colorize log arguments if enabled.
*
* @api public
*/
function formatArgs(args) {
var useColors = this.useColors;
args[0] = (useColors ? '%c' : '')
+ this.namespace
+ (useColors ? ' %c' : ' ')
+ args[0]
+ (useColors ? '%c ' : ' ')
+ '+' + exports.humanize(this.diff);
if (!useColors) return;
var c = 'color: ' + this.color;
args.splice(1, 0, c, 'color: inherit');
// the final "%c" is somewhat tricky, because there could be other
// arguments passed either before or after the %c, so we need to
// figure out the correct index to insert the CSS into
var index = 0;
var lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, function(match) {
if ('%%' === match) return;
index++;
if ('%c' === match) {
// we only are interested in the *last* %c
// (the user may have provided their own)
lastC = index;
}
});
args.splice(lastC, 0, c);
}
/**
* Invokes `console.log()` when available.
* No-op when `console.log` is not a "function".
*
* @api public
*/
function log() {
// this hackery is required for IE8/9, where
// the `console.log` function doesn't have 'apply'
return 'object' === typeof console
&& console.log
&& Function.prototype.apply.call(console.log, console, arguments);
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
try {
if (null == namespaces) {
exports.storage.removeItem('debug');
} else {
exports.storage.debug = namespaces;
}
} catch(e) {}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
var r;
try {
r = exports.storage.debug;
} catch(e) {}
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
if (!r && typeof process !== 'undefined' && 'env' in process) {
r = process.env.DEBUG;
}
return r;
}
/**
* Enable namespaces listed in `localStorage.debug` initially.
*/
exports.enable(load());
/**
* Localstorage attempts to return the localstorage.
*
* This is necessary because safari throws
* when a user disables cookies/localstorage
* and you attempt to access it.
*
* @return {LocalStorage}
* @api private
*/
function localstorage() {
try {
return window.localStorage;
} catch (e) {}
}
});
var node = createCommonjsModule(function (module, exports) {
/**
* Module dependencies.
*/
/**
* This is the Node.js implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = debug;
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
/**
* Colors.
*/
exports.colors = [6, 2, 3, 4, 5, 1];
/**
* Build up the default `inspectOpts` object from the environment variables.
*
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
*/
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
return /^debug_/i.test(key);
}).reduce(function (obj, key) {
// camel-case
var prop = key
.substring(6)
.toLowerCase()
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
// coerce string value into JS value
var val = process.env[key];
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
else if (val === 'null') val = null;
else val = Number(val);
obj[prop] = val;
return obj;
}, {});
/**
* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
if (1 !== fd && 2 !== fd) {
util__default['default'].deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
}
var stream = 1 === fd ? process.stdout :
2 === fd ? process.stderr :
createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
return 'colors' in exports.inspectOpts
? Boolean(exports.inspectOpts.colors)
: tty__default['default'].isatty(fd);
}
/**
* Map %o to `util.inspect()`, all on a single line.
*/
exports.formatters.o = function(v) {
this.inspectOpts.colors = this.useColors;
return util__default['default'].inspect(v, this.inspectOpts)
.split('\n').map(function(str) {
return str.trim()
}).join(' ');
};
/**
* Map %o to `util.inspect()`, allowing multiple lines if needed.
*/
exports.formatters.O = function(v) {
this.inspectOpts.colors = this.useColors;
return util__default['default'].inspect(v, this.inspectOpts);
};
/**
* Adds ANSI color escape codes if enabled.
*
* @api public
*/
function formatArgs(args) {
var name = this.namespace;
var useColors = this.useColors;
if (useColors) {
var c = this.color;
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
} else {
args[0] = new Date().toUTCString()
+ ' ' + name + ' ' + args[0];
}
}
/**
* Invokes `util.format()` with the specified arguments and writes to `stream`.
*/
function log() {
return stream.write(util__default['default'].format.apply(util__default['default'], arguments) + '\n');
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
if (null == namespaces) {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete process.env.DEBUG;
} else {
process.env.DEBUG = namespaces;
}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
return process.env.DEBUG;
}
/**
* Copied from `node/src/node.js`.
*
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
*/
function createWritableStdioStream (fd) {
var stream;
var tty_wrap = process.binding('tty_wrap');
// Note stream._type is used for test-module-load-list.js
switch (tty_wrap.guessHandleType(fd)) {
case 'TTY':
stream = new tty__default['default'].WriteStream(fd);
stream._type = 'tty';
// Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
case 'FILE':
var fs = fs__default['default'];
stream = new fs.SyncWriteStream(fd, { autoClose: false });
stream._type = 'fs';
break;
case 'PIPE':
case 'TCP':
var net = net__default['default'];
stream = new net.Socket({
fd: fd,
readable: false,
writable: true
});
// FIXME Should probably have an option in net.Socket to create a
// stream from an existing fd which is writable only. But for now
// we'll just add this hack and set the `readable` member to false.
// Test: ./node test/fixtures/echo.js < /etc/passwd
stream.readable = false;
stream.read = null;
stream._type = 'pipe';
// FIXME Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
default:
// Probably an error on in uv_guess_handle()
throw new Error('Implement me. Unknown stream file type!');
}
// For supporting legacy API we put the FD here.
stream.fd = fd;
stream._isStdio = true;
return stream;
}
/**
* Init logic for `debug` instances.
*
* Create a new `inspectOpts` object in case `useColors` is set
* differently for a particular `debug` instance.
*/
function init (debug) {
debug.inspectOpts = {};
var keys = Object.keys(exports.inspectOpts);
for (var i = 0; i < keys.length; i++) {
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
}
}
/**
* Enable namespaces listed in `process.env.DEBUG` initially.
*/
exports.enable(load());
});
var src = createCommonjsModule(function (module) {
/**
* Detect Electron renderer process, which is node, but we should
* treat as a browser.
*/
if (typeof process !== 'undefined' && process.type === 'renderer') {
module.exports = browser;
} else {
module.exports = node;
}
});
let debug$1 = src('net-reconnect');
class NetReconnect {
constructor (socket, options) {
this._socket = socket;
this._options = options;
this._retryTime = options.retryTime || 1000;
this._retryAlways = options.retryAlways || false;
this._keepAliveDelay = Math.max(options.keepAliveDelay, 1000) || 1000;
this._keepAliveInterval = Math.max(options.keepAliveInterval, 1000) || 1000;
this._keepAliveProbes = Math.max(Math.min(options.keepAliveProbes, 1), 20) || 1;
this._closing = false;
this._socket.on('connect', this._onConnect.bind(this));
this._socket.on('close', this._onClose.bind(this));
this._socket.on('error', this._onError.bind(this));
}
static apply (socket, options) {
return new NetReconnect(socket, options)
}
_reconnect () {
debug$1('reconnecting in %d', this._retryTime);
setTimeout(function () {
this._socket.connect(this._options);
}.bind(this), this._retryTime);
}
_onConnect () {
if (this._closing) {
return
}
this._socket.setKeepAlive(true, this._keepAliveDelay);
debug$1('online');
}
_onClose (hadError) {
if (this._closing) {
return
}
debug$1('offline');
this._state = 'offline';
if (!hadError) {
debug$1('connection closed on purpose');
if (this._retryAlways) {
debug$1('retryAlways flag active, reconnecting');
this._reconnect();
return
} else {
debug$1('not reconnecting');
return
}
}
debug$1('connection closed with errors, reconnecting');
this._reconnect();
}
_onError () {
if (this._closing) {
return
}
debug$1('error');
}
end () {
debug$1('closing socket permanently');
this._closing = true;
this._socket.removeListener('connect', this._onConnect);
this._socket.removeListener('close', this._onClose);
this._socket.removeListener('error', this._onError);
return this._socket.end.apply(this._socket, arguments)
}
}
var src$1 = NetReconnect;
var tcp = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var Reconnect, net, ref$, yellow, green, red, blue, bgGreen, bgRed, sleep, Logger, EventEmitter, TcpHandlerTransport, TcpTransport, logger, x$, transport, i, out$ = exports || commonjsGlobal, toString$ = {}.toString;
Reconnect = src$1;
net = net__default['default'];
ref$ = lib, yellow = ref$.yellow, green = ref$.green, red = ref$.red, blue = ref$.blue, bgGreen = ref$.bgGreen, bgRed = ref$.bgRed;
ref$ = lib$2, sleep = ref$.sleep, Logger = ref$.Logger, EventEmitter = ref$.EventEmitter;
out$.TcpHandlerTransport = TcpHandlerTransport = (function(superclass){
var prototype = extend$((import$(TcpHandlerTransport, superclass).displayName = 'TcpHandlerTransport', TcpHandlerTransport), superclass).prototype;
function TcpHandlerTransport(orig){
var x$, this$ = this;
this.orig = orig;
TcpHandlerTransport.superclass.call(this);
x$ = this.orig;
x$.on('end', function(){
return this$.trigger('disconnect');
});
x$.on('error', function(){
return this$.trigger('disconnect');
});
x$.on('data', function(data){
return this$.trigger('data', data);
});
}
TcpHandlerTransport.prototype.write = function(data){
return this.orig.write(data);
};
return TcpHandlerTransport;
}(EventEmitter));
out$.TcpTransport = TcpTransport = (function(superclass){
var prototype = extend$((import$(TcpTransport, superclass).displayName = 'TcpTransport', TcpTransport), superclass).prototype;
function TcpTransport(opts){
var x$, this$ = this;
opts == null && (opts = {});
TcpTransport.superclass.call(this);
this.opts = {
host: opts.host || "localhost",
port: opts.port || 5523,
retryAlways: true
};
this.log = new Logger('TCP_Transport');
this.socket = new net.Socket();
Reconnect.apply(this.socket, this.opts);
this.connected = false;
x$ = this.socket;
x$.setKeepAlive(true, 1000);
x$.setTimeout(1000);
x$.on('connect', function(){
return this$.connected = true;
});
x$.on('close', function(){
return this$.connected = false;
});
x$.on('data', function(data){
return this$.trigger('data', data);
});
x$.on('end', function(){
return this$.connected = false;
});
x$.on('error', function(err){
return this$.connected = false;
});
if (!opts.manualStart) {
this.start();
}
}
Object.defineProperty(TcpTransport.prototype, 'connected', {
get: function(){
return this._connected;
},
set: function(val){
var prev;
prev = this._connected;
this._connected = val;
if (!val && prev) {
this.trigger('disconnect');
}
if (val && !prev) {
this.trigger('connect');
}
},
configurable: true,
enumerable: true
});
TcpTransport.prototype.start = function(){
return this.socket.connect(this.opts);
};
TcpTransport.prototype.write = function(data, callback){
var e;
if (toString$.call(callback).slice(8, -1) !== 'Function') {
callback = function(){};
}
if (this.connected) {
try {
return this.socket.write(data, function(){
var err;
return callback(err = null);
});
} catch (e$) {
e = e$;
console.log("there is error again: ", e);
throw null;
}
} else {
return callback({
message: 'not connected'
/* disabling, because this will likely cause memory leak
* for long disconnections
resolved: (callback) ~>
@once \connect, callback
*/
});
}
};
return TcpTransport;
}(EventEmitter));
if (commonjsRequire.main === module) {
logger = new Logger('APP');
x$ = transport = new TcpTransport({
host: 'localhost',
port: 1234
});
x$.on('connect', function(){
return logger.log("transport connected");
});
x$.on('data', function(frame){
return logger.log("frame received:", frame.toString());
});
x$.on('disconnect', function(){
return logger.log("transport disconnected ");
});
i = 0;
(function lo(op){
var payload;
payload = "sending incremental data: " + i;
logger.log(payload);
return transport.write(payload + "\n", function(err){
if (err) {
logger.err("something went wrong while writing");
return sleep(1000, function(){
return lo(op);
});
} else {
if (++i > 10) {
return op();
}
return sleep(2000, function(){
return lo(op);
});
}
});
})(function(){
return logger.log("End of tests.");
});
}
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var client$1 = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ProxyClient, TcpTransport, sleep, DcsTcpClient, out$ = exports || commonjsGlobal;
ProxyClient = client.ProxyClient;
TcpTransport = tcp.TcpTransport;
sleep = deps$1.sleep;
out$.DcsTcpClient = DcsTcpClient = (function(superclass){
var prototype = extend$((import$(DcsTcpClient, superclass).displayName = 'DcsTcpClient', DcsTcpClient), superclass).prototype;
function DcsTcpClient(opts){
var transport, this$ = this;
this.opts = opts != null
? opts
: {};
this.opts.port || (function(){
throw "DcsTcpClient: Port is required.";
}());
transport = new TcpTransport({
host: this.opts.host || '127.0.0.1',
port: this.opts.port
});
DcsTcpClient.superclass.call(this, transport, {
name: 'TcpDcsClient',
forgetPassword: false
});
this.on('connect', function(){
return this$.log.info("Connected to server...");
});
this.onTopic('app.dcs.connect', function(msg){
return this$.log.info("Tcp Client is logged in into the DCS network.");
});
this.on('disconnect', function(){
this$.log.info("Disconnected.");
this$.log.info("ProxyClient will try to reconnect.");
return sleep(3000, function(){
return this$.trigger('_login');
});
});
}
return DcsTcpClient;
}(ProxyClient));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var ioProxyClient = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var Actor, sleep, FpsExec, topicMatch, _x, uuid4, IoProxyClient, out$ = exports || commonjsGlobal, toString$ = {}.toString;
Actor = actor.Actor;
sleep = sleep_1.sleep;
FpsExec = filters.FpsExec;
topicMatch = topicMatch_1.topicMatch;
_x = 0;
uuid4 = function(){
return "some-random-" + (_x++);
};
out$.IoProxyClient = IoProxyClient = (function(superclass){
var prototype = extend$((import$(IoProxyClient, superclass).displayName = 'IoProxyClient', IoProxyClient), superclass).prototype;
function IoProxyClient(opts){
var update, this$ = this;
opts == null && (opts = {});
this.route = opts.route || (function(){
throw "route is required.";
}());
this.timeout = opts.timeout || 1000;
IoProxyClient.superclass.call(this, this.route);
this.fps = new FpsExec(opts.fps || 20, this);
this.value = undefined;
this.lastUpdate = 0;
this.debug = opts.debug;
this.onTopic(this.route + "", function(msg){
var that, value;
if (that = msg.data.err) {
return this$.trigger('error', {
message: that
});
} else {
value = msg.data.val;
if (JSON.stringify(value) !== JSON.stringify(this$.value)) {
this$.trigger('change', value);
if (toString$.call(value).slice(8, -1) === 'Boolean') {
if (this$.value === false && value === true) {
this$.trigger('r-edge');
}
if (this$.value === true && value === false) {
this$.trigger('f-edge');
}
}
}
this$.lastUpdate = Date.now();
this$.value = value;
return this$.trigger('read', value, msg);
}
});
update = function(callback){
if (!callback) {
callback = function(){};
}
return this$.sendRequest({
route: this$.route + "",
timeout: this$.timeout
}, {
update: true
}, function(err, msg){
if (err || msg.err) {
this$.trigger('error', {
message: err
});
return callback(err);
} else {
this$.triggerTopic(this$.route + "", msg);
return callback(null);
}
});
};
this.onEveryLogin(function(msg){
var retryLimit;
retryLimit = 3;
return function lo(op){
return update(function(err){
if (err) {
retryLimit--;
if (retryLimit === 0) {
return op();
}
this$.log.warn("Update error, retrying... (left: " + retryLimit + ")");
return sleep(1000, function(){
return lo(op);
});
} else {
return op();
}
});
}(function(){});
});
}
IoProxyClient.prototype.rEdge = function(callback){
this.once('r-edge', callback);
};
IoProxyClient.prototype.fEdge = function(callback){
this.once('f-edge', callback);
};
IoProxyClient.prototype.when = function(filterFunc, callback){
var name, this$ = this;
name = uuid4();
this.on('change', name, function(value){
if (filterFunc(value)) {
return setImmediate(function(){
callback(value);
return this$.cancel(name);
});
}
});
};
IoProxyClient.prototype.write = function(value, callback){
var this$ = this;
this.fps.exec(function(){
this$.fps.pause();
return this$.filteredWrite(value, function(){
var args, res$, i$, to$, that;
res$ = [];
for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
res$.push(arguments[i$]);
}
args = res$;
this$.fps.resume();
if ((that = callback) != null) {
return that.apply(null, args);
}
});
});
};
IoProxyClient.prototype.read = function(callback){
this.sendRequest({
route: this.route,
timeout: this.timeout,
debug: this.debug
}, {
read: true
}, function(err, msg){
return callback(err, msg);
});
};
IoProxyClient.prototype.filteredWrite = function(value, callback){
var this$ = this;
this.sendRequest({
route: this.route,
timeout: this.timeout,
debug: this.debug
}, {
val: value
}, function(err, msg){
var error;
error = err || (msg != null ? msg.data.err : void 8);
if (!err) {
this$.value = msg.data.res;
}
if (toString$.call(callback).slice(8, -1) === 'Function') {
return callback(error);
}
});
};
return IoProxyClient;
}(Actor));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var keypath = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var getKeypath, setKeypath, deleteKeypath, out$ = exports || commonjsGlobal;
out$.getKeypath = getKeypath = function(obj, keypath){
var res, i$, ref$, len$, k;
res = obj;
if (keypath) {
for (i$ = 0, len$ = (ref$ = keypath.split('.')).length; i$ < len$; ++i$) {
k = ref$[i$];
res = (fn$());
}
}
return res;
function fn$(){
try {
return res[k];
} catch (e$) {
return null;
}
}
};
out$.setKeypath = setKeypath = function(obj, keypath, value){
var _set, path;
_set = function(_obj, _keypath){
var k;
if (_keypath.length === 0) {
return _obj;
}
k = _keypath.shift();
if (_keypath.length === 0) {
return _obj[k] = value;
} else {
if (!_obj[k]) {
_obj[k] = {};
}
_set(_obj[k], _keypath);
}
return _obj;
};
path = (keypath != null ? keypath.split('.') : void 8) || [];
return _set(obj, path);
};
out$.deleteKeypath = deleteKeypath = function(obj, keypath){
var _keypath, firstProp, lastProp, tmp, i$, x$, len$, ref$, key, results$ = [];
if (keypath) {
_keypath = keypath.split('.');
firstProp = _keypath.shift();
lastProp = _keypath.pop();
tmp = obj[firstProp];
for (i$ = 0, len$ = _keypath.length; i$ < len$; ++i$) {
x$ = _keypath[i$];
tmp = tmp[x$];
}
if (lastProp in tmp) {
return ref$ = tmp[lastProp], delete tmp[lastProp], ref$;
} else {
throw "no such key";
}
} else {
for (key in obj) {
results$.push((ref$ = obj[key], delete obj[key], ref$));
}
return results$;
}
};
});
var memoryMap = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var ref$, split, keys, map, getKeypath, CodingError, bitTest, bitWrite, dec2bin, splitBits, dataTypes, IoHandle, parseIoAddr, makeIoAddr, BlockRead, out$ = exports || commonjsGlobal, toString$ = {}.toString;
ref$ = lib$1, split = ref$.split, keys = ref$.keys, map = ref$.map;
getKeypath = keypath.getKeypath;
CodingError = errors.CodingError;
function hex2float (a) {return (a & 0x7fffff | 0x800000) * 1.0 / Math.pow(2,23) * Math.pow(2, ((a>>23 & 0xff) - 127))}
function bit_test(num, bit){
return ((num>>bit) % 2 != 0)
}
function bit_set(num, bit){
return num | 1<<bit;
}
function bit_clear(num, bit){
return num & ~(1<<bit);
}
out$.bitTest = bitTest = bit_test;
out$.bitWrite = bitWrite = function(source, bitNum, value){
if (value) {
return bit_set(source, bitNum);
} else {
return bit_clear(source, bitNum);
}
};
out$.dec2bin = dec2bin = function(dec){
'dec2bin(1); // 1\ndec2bin(-1); // 11111111111111111111111111111111\ndec2bin(256); // 100000000\ndec2bin(-256); // 11111111111111111111111100000000';
return dec >>> 0 .toString(2);
};
// taken from https://stackoverflow.com/a/1268377/1952991
function zeroPad(num, numZeros) {
var n = Math.abs(num);
var zeros = Math.max(0, numZeros - Math.floor(n).toString().length );
var zeroString = Math.pow(10,zeros).toString().substr(1);
if( num < 0 ) {
zeroString = '-' + zeroString;
}
return zeroString+n;
}
out$.zeroPad = zeroPad;
out$.splitBits = splitBits = function(input){
var bin, zpad8;
bin = (+input).toString(2);
zpad8 = function(it){
return ("00000000" + it).slice(-8);
};
return function(it){
return it.split("").reverse().map(function(it){
return parseInt(
it.trim());
});
}(
zpad8(
bin));
};
dataTypes = {
int: function(x){
return parseInt(x);
},
hex: function(x){
return x.toString(16).toUpperCase();
},
hexf: hex2float,
mili: (function(it){
return it / 1000;
}),
bool: Boolean
};
out$.IoHandle = IoHandle = (function(){
'This class adds some useful methods to an IO object, such as: \n\n .get-meaningful(raw-value): Returns meaningful value\n regarding to the @type. ';
IoHandle.displayName = 'IoHandle';
function IoHandle(opts, route){
var k, v;
opts == null && (opts = {});
for (k in opts) {
v = opts[k];
this[k] = v;
}
this.route = route;
this.id = this.route;
}
IoHandle.prototype.getMeaningful = function(value){
if (toString$.call(this.converter).slice(8, -1)) {
return this.converter(value);
} else {
if (!this.type) {
throw Error('unimplemented');
}
return dataTypes[this.type](value);
}
};
IoHandle.prototype.registerConverter = function(converter){
return this.converter = converter;
};
return IoHandle;
}());
out$.parseIoAddr = parseIoAddr = function(fullName){
var ref$, prefix, byte, bitSep, bit, parsed;
ref$ = fullName.split(/(\d+)/), prefix = ref$[0], byte = ref$[1], bitSep = ref$[2], bit = ref$[3];
parsed = {
prefix: prefix,
byte: parseInt(byte),
bit: bitSep ? parseInt(bit) : null,
bool: bitSep ? true : false
};
return parsed;
};
out$.makeIoAddr = makeIoAddr = function(prefix, byte, bit){
return prefix + "" + byte + (bit ? "." + bit : void 8);
};
out$.BlockRead = BlockRead = (function(){
BlockRead.displayName = 'BlockRead';
function BlockRead(opts){
this.prefix = opts.prefix;
this.from = opts.from;
this.count = opts.count;
this.bits0 = [];
this.bits = [];
this.handlers = {};
}
Object.defineProperty(BlockRead.prototype, 'readParams', {
get: function(){
return [this.prefix, this.from, this.count];
},
configurable: true,
enumerable: true
});
BlockRead.prototype.addHandler = function(name, handler){
if (name in this.handlers) {
return console.error(name + " is already registered, not registering again.");
} else {
return this.handlers[name] = handler;
}
};
BlockRead.prototype.distribute = function(arr){
var i$, x$, len$, i, j, ref$, addr, ref1$, err;
this.bits.length = 0;
for (i$ = 0, len$ = arr.length; i$ < len$; ++i$) {
x$ = arr[i$];
this.bits.push(splitBits(x$));
}
for (i in this.bits) {
for (j in this.bits[i]) {
if (this.bits[i][j] !== ((ref$ = this.bits0[i]) != null ? ref$[j] : void 8)) {
addr = makeIoAddr(this.prefix, i, j);
if (typeof (ref1$ = this.handlers)[addr] == 'function') {
ref1$[addr](err = null, this.bits[i][j]);
}
}
}
}
this.bits0 = JSON.parse(JSON.stringify(this.bits));
};
return BlockRead;
}());
});
var ioProxyHandler = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var Actor, EventEmitter, sleep, Logger, CodingError, IoHandle, IoProxyHandler, out$ = exports || commonjsGlobal;
Actor = actor.Actor;
EventEmitter = eventEmitter.EventEmitter;
sleep = sleep_1.sleep;
Logger = logger.Logger;
CodingError = errors.CodingError;
IoHandle = memoryMap.IoHandle;
out$.IoProxyHandler = IoProxyHandler = (function(superclass){
var prototype = extend$((import$(IoProxyHandler, superclass).displayName = 'IoProxyHandler', IoProxyHandler), superclass).prototype;
function IoProxyHandler(handle, _route, driver){
var ref$, route, prev, age, broadcastValue, responseValue, this$ = this;
if (!driver) {
driver = _route;
_route = null;
if ((handle != null ? (ref$ = handle.constructor) != null ? ref$.name : void 8 : void 8) !== 'IoHandle') {
throw new CodingError("handle should be an instance of IoHandle class");
}
} else {
handle = new IoHandle(handle, _route);
}
if (!driver) {
throw new CodingError("Driver must be provided");
}
if (!(route = handle.route)) {
throw new CodingError("A route MUST be provided to IoProxyHandler.");
}
IoProxyHandler.superclass.call(this, route);
prev = null;
age = 0;
broadcastValue = function(err, value){
this$.send(this$.name + "", {
err: err,
val: value
});
if (!err && value !== prev) {
prev = value;
return age = Date.now();
}
};
responseValue = function(msg){
return function(err, value){
this$.sendResponse(msg, {
err: err,
val: value
});
if (!err && value !== prev) {
prev = value;
return age = Date.now();
}
};
};
this.on('read', function(handle, respond){
return driver.read(handle, function(err, value){
return respond(err, value);
});
});
this.on('write', function(handle, value, respond){
return driver.write(handle, value, function(err){
return respond(err);
});
});
driver.initHandle(handle, broadcastValue);
this.onTopic(route, function(msg){
var newValue, maxAge, err, value;
if ('val' in msg.data) {
newValue = msg.data.val;
return this$.trigger('write', handle, newValue, function(err){
var meta, data;
meta = {
cc: this$.name + ""
};
data = {
err: err
};
if (!err) {
data.val = newValue;
prev = newValue;
}
return this$.sendResponse(msg, meta, data);
});
} else if ('update' in msg.data) {
maxAge = 10 * 60000;
if (maxAge + age < Date.now()) {
return this$.trigger('read', handle, responseValue(msg));
} else {
return responseValue(msg)(err = null, value = prev);
}
} else {
return this$.trigger('read', handle, responseValue(msg));
}
});
this.onEveryLogin(function(msg){
return this$.trigger('_try_broadcast_state');
});
driver.on('connect', function(){
return this$.trigger('_try_broadcast_state');
});
driver.on('disconnect', function(){
var err;
return broadcastValue(err = "Target is disconnected.");
});
driver.on('data', function(table){
var value, err;
if (handle.id in table) {
value = table[handle.id];
if (value !== prev) {
return broadcastValue(err = null, value);
}
}
});
this.on('_try_broadcast_state', function(){
if (driver.connected) {
return this$.trigger('read', handle, broadcastValue);
} else {
return this$.log.info("Driver is not connected, skipping broadcasting.");
}
});
if (!driver.starting || !driver.started) {
driver.start();
}
}
return IoProxyHandler;
}(Actor));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
var driverAbstract = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var EventEmitter, Logger, DriverAbstract, out$ = exports || commonjsGlobal;
EventEmitter = eventEmitter.EventEmitter;
Logger = logger.Logger;
out$.DriverAbstract = DriverAbstract = (function(superclass){
var prototype = extend$((import$(DriverAbstract, superclass).displayName = 'DriverAbstract', DriverAbstract), superclass).prototype;
function DriverAbstract(){
var implementedBy;
DriverAbstract.superclass.call(this);
this._queue = [];
this.io = {};
this.logger = new Logger(implementedBy = this.constructor.name);
}
DriverAbstract.prototype.initHandle = function(handle, broadcast){
throw Error('unimplemented');
};
DriverAbstract.prototype.write = function(handle, value, respond){
throw Error('unimplemented');
};
DriverAbstract.prototype._exec_sequential = function(func){
var i$, res$, j$;
res$ = [];
for (j$ = 1 < (i$ = arguments.length - 1) ? 1 : (i$ = 1); j$ < i$; ++j$) {
res$.push(arguments[j$]);
}
this._queue.push(arguments);
throw Error('unimplemented');
};
DriverAbstract.prototype.read = function(handle, respond){
throw Error('unimplemented');
};
DriverAbstract.prototype.start = function(){
this.starting = true;
this.logger.log("Driver immediately started.");
return this.connected = true;
};
Object.defineProperty(DriverAbstract.prototype, 'connected', {
get: function(){
return this._connected;
},
set: function(val){
if (val === true) {
this._connected = true;
this.started = true;
this.trigger('connect');
} else {
this._connected = false;
this.started = false;
this.starting = false;
this.trigger('disconnect');
}
},
configurable: true,
enumerable: true
});
return DriverAbstract;
}(EventEmitter));
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
});
// Generated by LiveScript 1.6.0
var Actor$1, FpsExec, ref$$3, Signal$3, SignalBranch$1, DcsTcpClient, EventEmitter$1, Logger$3, sleep$3, merge$1, pack$2, unpack$2, clone$3, diff$2, topicMatch$1, IoProxyClient, IoProxyHandler, DriverAbstract;
Actor$1 = actor.Actor;
FpsExec = filters.FpsExec;
ref$$3 = signal$1, Signal$3 = ref$$3.Signal, SignalBranch$1 = ref$$3.SignalBranch;
/* if dependencies of the followings are optionally installed,
then they shouldn't be included by default.
require! './services/couch-dcs/client': {CouchDcsClient}
require! './services/couch-dcs/server': {CouchDcsServer}
*/
DcsTcpClient = client$1.DcsTcpClient;
ref$$3 = lib$2, EventEmitter$1 = ref$$3.EventEmitter, Logger$3 = ref$$3.Logger, sleep$3 = ref$$3.sleep, merge$1 = ref$$3.merge, pack$2 = ref$$3.pack, unpack$2 = ref$$3.unpack, clone$3 = ref$$3.clone, diff$2 = ref$$3.diff;
topicMatch$1 = topicMatch_1.topicMatch;
IoProxyClient = ioProxyClient.IoProxyClient;
IoProxyHandler = ioProxyHandler.IoProxyHandler;
DriverAbstract = driverAbstract.DriverAbstract;
var dcs = {
Actor: Actor$1,
FpsExec: FpsExec,
Signal: Signal$3,
SignalBranch: SignalBranch$1,
DcsTcpClient: DcsTcpClient,
EventEmitter: EventEmitter$1,
Logger: Logger$3,
sleep: sleep$3,
merge: merge$1,
pack: pack$2,
unpack: unpack$2,
clone: clone$3,
diff: diff$2,
IoProxyClient: IoProxyClient,
IoProxyHandler: IoProxyHandler,
DriverAbstract: DriverAbstract,
topicMatch: topicMatch$1
};
var config = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var webserverPort, dcsPort, defaultPassword, out$ = exports || commonjsGlobal;
out$.webserverPort = webserverPort = 4013;
out$.dcsPort = dcsPort = 4014;
out$.defaultPassword = defaultPassword = "nCEqCyoyreg05ts4WmsVrPmPpw0dwt93";
});
var ractiveTemplate = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var Ractive, compile, ractiveCompile, out$ = exports || commonjsGlobal;
Ractive = ractive__default['default'];
Ractive.DEBUG = false;
compile = function(template, data){
var instance;
template == null && (template = "");
data == null && (data = {});
instance = new Ractive({
template: Ractive.parse(template, {
textOnlyMode: true,
preserveWhitespace: true
}),
data: data
});
return instance.toHTML();
};
/*
compile2 = (template="", data={}) ->
[prefix, postfix] = <[ <pre> </pre> ]>
instance = new Ractive do
template: prefix + template + postfix
data: data
return instance.toHTML!.slice(prefix.length, -postfix.length)
*/
out$.ractiveCompile = ractiveCompile = compile;
});
var readdirSyncRecursive_1 = createCommonjsModule(function (module, exports) {
// Generated by LiveScript 1.6.0
var fs, path, out$ = exports || commonjsGlobal;
fs = fs__default['default'];
path = path__default['default'];
out$.readdirSyncRecursive = readdirSyncRecursive;
function readdirSyncRecursive(dir, files, arg$){
var sub, f, i$, len$, file;
files == null && (files = []);
sub = (arg$ != null
? arg$
: {}).sub;
f = fs.readdirSync(dir);
for (i$ = 0, len$ = f.length; i$ < len$; ++i$) {
file = f[i$];
if (fs.statSync(dir + "/" + file).isDirectory()) {
files = readdirSyncRecursive(dir + "/" + file, files, {
sub: path.join(sub || '', file)
});
} else {
files.push(path.join(sub || '', file));
}
}
return files;
}
});
var supportedMcus = [
{
chibiDef: "STM32F030x6",
mcuCode: "STM32F030C6Tx",
stmGlob: "STM32F030C6Tx"
},
{
chibiDef: "STM32F030x8",
mcuCode: "STM32F030C8Tx",
stmGlob: "STM32F030C8Tx"
},
{
chibiDef: "STM32F030xC",
mcuCode: "STM32F030CCTx",
stmGlob: "STM32F030CCTx"
},
{
chibiDef: "STM32F030x4",
mcuCode: "STM32F030F4Px",
stmGlob: "STM32F030F4Px"
},
{
chibiDef: "STM32F030x6",
mcuCode: "STM32F030K6Tx",
stmGlob: "STM32F030K6Tx"
},
{
chibiDef: "STM32F030x8",
mcuCode: "STM32F030R8Tx",
stmGlob: "STM32F030R8Tx"
},
{
chibiDef: "STM32F030xC",
mcuCode: "STM32F030RCTx",
stmGlob: "STM32F030RCTx"
},
{
chibiDef: "STM32F031x6",
mcuCode: "STM32F031C6Tx",
stmGlob: "STM32F031C(4-6)Tx"
},
{
chibiDef: "STM32F031x6",
mcuCode: "STM32F031E6Yx",
stmGlob: "STM32F031E6Yx"
},
{
chibiDef: "STM32F031x6",
mcuCode: "STM32F031F6Px",
stmGlob: "STM32F031F(4-6)Px"
},
{
chibiDef: "STM32F031x6",
mcuCode: "STM32F031G6Ux",
stmGlob: "STM32F031G(4-6)Ux"
},
{
chibiDef: "STM32F031x6",
mcuCode: "STM32F031K6Ux",
stmGlob: "STM32F031K(4-6)Ux"
},
{
chibiDef: "STM32F031x6",
mcuCode: "STM32F031K6Tx",
stmGlob: "STM32F031K6Tx"
},
{
chibiDef: "STM32F038xx",
mcuCode: "STM32F038C6Tx",
stmGlob: "STM32F038C6Tx"
},
{
chibiDef: "STM32F038xx",
mcuCode: "STM32F038E6Yx",
stmGlob: "STM32F038E6Yx"
},
{
chibiDef: "STM32F038xx",
mcuCode: "STM32F038F6Px",
stmGlob: "STM32F038F6Px"
},
{
chibiDef: "STM32F038xx",
mcuCode: "STM32F038G6Ux",
stmGlob: "STM32F038G6Ux"
},
{
chibiDef: "STM32F038xx",
mcuCode: "STM32F038K6Ux",
stmGlob: "STM32F038K6Ux"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042C6Tx",
stmGlob: "STM32F042C(4-6)Tx"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042C6Ux",
stmGlob: "STM32F042C(4-6)Ux"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042F6Px",
stmGlob: "STM32F042F6Px"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042G6Ux",
stmGlob: "STM32F042G(4-6)Ux"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042K6Tx",
stmGlob: "STM32F042K(4-6)Tx"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042K6Ux",
stmGlob: "STM32F042K(4-6)Ux"
},
{
chibiDef: "STM32F042x6",
mcuCode: "STM32F042T6Yx",
stmGlob: "STM32F042T6Yx"
},
{
chibiDef: "STM32F048xx",
mcuCode: "STM32F048C6Ux",
stmGlob: "STM32F048C6Ux"
},
{
chibiDef: "STM32F048xx",
mcuCode: "STM32F048G6Ux",
stmGlob: "STM32F048G6Ux"
},
{
chibiDef: "STM32F048xx",
mcuCode: "STM32F048T6Yx",
stmGlob: "STM32F048T6Yx"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051C8Tx",
stmGlob: "STM32F051C8Tx"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051C8Ux",
stmGlob: "STM32F051C8Ux"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051K8Tx",
stmGlob: "STM32F051K8Tx"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051K8Ux",
stmGlob: "STM32F051K8Ux"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051R8Hx",
stmGlob: "STM32F051R8Hx"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051R8Tx",
stmGlob: "STM32F051R8Tx"
},
{
chibiDef: "STM32F051x8",
mcuCode: "STM32F051T8Yx",
stmGlob: "STM32F051T8Yx"
},
{
chibiDef: "STM32F058xx",
mcuCode: "STM32F058C8Ux",
stmGlob: "STM32F058C8Ux"
},
{
chibiDef: "STM32F058xx",
mcuCode: "STM32F058R8Hx",
stmGlob: "STM32F058R8Hx"
},
{
chibiDef: "STM32F058xx",
mcuCode: "STM32F058R8Tx",
stmGlob: "STM32F058R8Tx"
},
{
chibiDef: "STM32F058xx",
mcuCode: "STM32F058T8Yx",
stmGlob: "STM32F058T8Yx"
},
{
chibiDef: "STM32F070x6",
mcuCode: "STM32F070C6Tx",
stmGlob: "STM32F070C6Tx"
},
{
chibiDef: "STM32F070xB",
mcuCode: "STM32F070CBTx",
stmGlob: "STM32F070CBTx"
},
{
chibiDef: "STM32F070x6",
mcuCode: "STM32F070F6Px",
stmGlob: "STM32F070F6Px"
},
{
chibiDef: "STM32F070xB",
mcuCode: "STM32F070RBTx",
stmGlob: "STM32F070RBTx"
},
{
chibiDef: "STM32F071xB",
mcuCode: "STM32F071CBTx",
stmGlob: "STM32F071C(8-B)Tx"
},
{
chibiDef: "STM32F071xB",
mcuCode: "STM32F071CBUx",
stmGlob: "STM32F071C(8-B)Ux"
},
{
chibiDef: "STM32F071xB",
mcuCode: "STM32F071CBYx",
stmGlob: "STM32F071CBYx"
},
{
chibiDef: "STM32F071xB",
mcuCode: "STM32F071RBTx",
stmGlob: "STM32F071RBTx"
},
{
chibiDef: "STM32F071xB",
mcuCode: "STM32F071VBHx",
stmGlob: "STM32F071V(8-B)Hx"
},
{
chibiDef: "STM32F071xB",
mcuCode: "STM32F071VBTx",
stmGlob: "STM32F071V(8-B)Tx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072CBTx",
stmGlob: "STM32F072C(8-B)Tx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072CBUx",
stmGlob: "STM32F072C(8-B)Ux"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072CBYx",
stmGlob: "STM32F072CBYx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072RBTx",
stmGlob: "STM32F072R(8-B)Tx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072RBHx",
stmGlob: "STM32F072RBHx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072RBIx",
stmGlob: "STM32F072RBIx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072VBHx",
stmGlob: "STM32F072V(8-B)Hx"
},
{
chibiDef: "STM32F072xB",
mcuCode: "STM32F072VBTx",
stmGlob: "STM32F072V(8-B)Tx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078CBTx",
stmGlob: "STM32F078CBTx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078CBUx",
stmGlob: "STM32F078CBUx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078CBYx",
stmGlob: "STM32F078CBYx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078RBHx",
stmGlob: "STM32F078RBHx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078RBTx",
stmGlob: "STM32F078RBTx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078VBHx",
stmGlob: "STM32F078VBHx"
},
{
chibiDef: "STM32F078xx",
mcuCode: "STM32F078VBTx",
stmGlob: "STM32F078VBTx"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091CCTx",
stmGlob: "STM32F091C(B-C)Tx"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091CCUx",
stmGlob: "STM32F091C(B-C)Ux"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091RCTx",
stmGlob: "STM32F091R(B-C)Tx"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091RCHx",
stmGlob: "STM32F091RCHx"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091RCYx",
stmGlob: "STM32F091RCYx"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091VCTx",
stmGlob: "STM32F091V(B-C)Tx"
},
{
chibiDef: "STM32F091xC",
mcuCode: "STM32F091VCHx",
stmGlob: "STM32F091VCHx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098CCTx",
stmGlob: "STM32F098CCTx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098CCUx",
stmGlob: "STM32F098CCUx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098RCHx",
stmGlob: "STM32F098RCHx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098RCTx",
stmGlob: "STM32F098RCTx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098RCYx",
stmGlob: "STM32F098RCYx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098VCHx",
stmGlob: "STM32F098VCHx"
},
{
chibiDef: "STM32F098xx",
mcuCode: "STM32F098VCTx",
stmGlob: "STM32F098VCTx"
},
{
chibiDef: "STM32F100xB",
mcuCode: "STM32F100CBTx",
stmGlob: "STM32F100C(8-B)Tx"
},
{
chibiDef: "STM32F100xB",
mcuCode: "STM32F100RBHx",
stmGlob: "STM32F100R(8-B)Hx"
},
{
chibiDef: "STM32F100xB",
mcuCode: "STM32F100RBTx",
stmGlob: "STM32F100R(8-B)Tx"
},
{
chibiDef: "STM32F100xE",
mcuCode: "STM32F100RETx",
stmGlob: "STM32F100R(C-D-E)Tx"
},
{
chibiDef: "STM32F100xB",
mcuCode: "STM32F100VBTx",
stmGlob: "STM32F100V(8-B)Tx"
},
{
chibiDef: "STM32F100xE",
mcuCode: "STM32F100VETx",
stmGlob: "STM32F100V(C-D-E)Tx"
},
{
chibiDef: "STM32F100xE",
mcuCode: "STM32F100ZETx",
stmGlob: "STM32F100Z(C-D-E)Tx"
},
{
chibiDef: "STM32F101x6",
mcuCode: "STM32F101C6Tx",
stmGlob: "STM32F101C(4-6)Tx"
},
{
chibiDef: "STM32F101xB",
mcuCode: "STM32F101CBTx",
stmGlob: "STM32F101C(8-B)Tx"
},
{
chibiDef: "STM32F101xB",
mcuCode: "STM32F101CBUx",
stmGlob: "STM32F101C(8-B)Ux"
},
{
chibiDef: "STM32F101x6",
mcuCode: "STM32F101R6Tx",
stmGlob: "STM32F101R(4-6)Tx"
},
{
chibiDef: "STM32F101xB",
mcuCode: "STM32F101RBTx",
stmGlob: "STM32F101R(8-B)Tx"
},
{
chibiDef: "STM32F101xB",
mcuCode: "STM32F101RBHx",
stmGlob: "STM32F101RBHx"
},
{
chibiDef: "STM32F101xE",
mcuCode: "STM32F101RETx",
stmGlob: "STM32F101R(C-D-E)Tx"
},
{
chibiDef: "STM32F101xG",
mcuCode: "STM32F101RGTx",
stmGlob: "STM32F101R(F-G)Tx"
},
{
chibiDef: "STM32F101x6",
mcuCode: "STM32F101T6Ux",
stmGlob: "STM32F101T(4-6)Ux"
},
{
chibiDef: "STM32F101xB",
mcuCode: "STM32F101TBUx",
stmGlob: "STM32F101T(8-B)Ux"
},
{
chibiDef: "STM32F101xB",
mcuCode: "STM32F101VBTx",
stmGlob: "STM32F101V(8-B)Tx"
},
{
chibiDef: "STM32F101xE",
mcuCode: "STM32F101VETx",
stmGlob: "STM32F101V(C-D-E)Tx"
},
{
chibiDef: "STM32F101xG",
mcuCode: "STM32F101VGTx",
stmGlob: "STM32F101V(F-G)Tx"
},
{
chibiDef: "STM32F101xE",
mcuCode: "STM32F101ZETx",
stmGlob: "STM32F101Z(C-D-E)Tx"
},
{
chibiDef: "STM32F101xG",
mcuCode: "STM32F101ZGTx",
stmGlob: "STM32F101Z(F-G)Tx"
},
{
chibiDef: "STM32F102x6",
mcuCode: "STM32F102C6Tx",
stmGlob: "STM32F102C(4-6)Tx"
},
{
chibiDef: "STM32F102xB",
mcuCode: "STM32F102CBTx",
stmGlob: "STM32F102C(8-B)Tx"
},
{
chibiDef: "STM32F102x6",
mcuCode: "STM32F102R6Tx",
stmGlob: "STM32F102R(4-6)Tx"
},
{
chibiDef: "STM32F102xB",
mcuCode: "STM32F102RBTx",
stmGlob: "STM32F102R(8-B)Tx"
},
{
chibiDef: "STM32F103x6",
mcuCode: "STM32F103C6Tx",
stmGlob: "STM32F103C(4-6)Tx"
},
{
chibiDef: "STM32F103x6",
mcuCode: "STM32F103C6Ux",
stmGlob: "STM32F103C6Ux"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103CBTx",
stmGlob: "STM32F103C(8-B)Tx"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103CBUx",
stmGlob: "STM32F103CBUx"
},
{
chibiDef: "STM32F103x6",
mcuCode: "STM32F103R6Hx",
stmGlob: "STM32F103R(4-6)Hx"
},
{
chibiDef: "STM32F103x6",
mcuCode: "STM32F103R6Tx",
stmGlob: "STM32F103R(4-6)Tx"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103RBHx",
stmGlob: "STM32F103R(8-B)Hx"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103RBTx",
stmGlob: "STM32F103R(8-B)Tx"
},
{
chibiDef: "STM32F103xE",
mcuCode: "STM32F103RETx",
stmGlob: "STM32F103R(C-D-E)Tx"
},
{
chibiDef: "STM32F103xE",
mcuCode: "STM32F103REYx",
stmGlob: "STM32F103R(C-D-E)Yx"
},
{
chibiDef: "STM32F103xG",
mcuCode: "STM32F103RGTx",
stmGlob: "STM32F103R(F-G)Tx"
},
{
chibiDef: "STM32F103x6",
mcuCode: "STM32F103T6Ux",
stmGlob: "STM32F103T(4-6)Ux"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103TBUx",
stmGlob: "STM32F103T(8-B)Ux"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103VBHx",
stmGlob: "STM32F103V(8-B)Hx"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103VBTx",
stmGlob: "STM32F103V(8-B)Tx"
},
{
chibiDef: "STM32F103xB",
mcuCode: "STM32F103VBIx",
stmGlob: "STM32F103VBIx"
},
{
chibiDef: "STM32F103xE",
mcuCode: "STM32F103VEHx",
stmGlob: "STM32F103V(C-D-E)Hx"
},
{
chibiDef: "STM32F103xE",
mcuCode: "STM32F103VETx",
stmGlob: "STM32F103V(C-D-E)Tx"
},
{
chibiDef: "STM32F103xG",
mcuCode: "STM32F103VGTx",
stmGlob: "STM32F103V(F-G)Tx"
},
{
chibiDef: "STM32F103xE",
mcuCode: "STM32F103ZEHx",
stmGlob: "STM32F103Z(C-D-E)Hx"
},
{
chibiDef: "STM32F103xE",
mcuCode: "STM32F103ZETx",
stmGlob: "STM32F103Z(C-D-E)Tx"
},
{
chibiDef: "STM32F103xG",
mcuCode: "STM32F103ZGHx",
stmGlob: "STM32F103Z(F-G)Hx"
},
{
chibiDef: "STM32F103xG",
mcuCode: "STM32F103ZGTx",
stmGlob: "STM32F103Z(F-G)Tx"
},
{
chibiDef: "STM32F105xC",
mcuCode: "STM32F105RCTx",
stmGlob: "STM32F105R(8-B-C)Tx"
},
{
chibiDef: "STM32F105xC",
mcuCode: "STM32F105VCTx",
stmGlob: "STM32F105V(8-B-C)Tx"
},
{
chibiDef: "STM32F107xC",
mcuCode: "STM32F107RCTx",
stmGlob: "STM32F107R(B-C)Tx"
},
{
chibiDef: "STM32F107xC",
mcuCode: "STM32F107VCTx",
stmGlob: "STM32F107V(B-C)Tx"
},
{
chibiDef: "STM32F107xC",
mcuCode: "STM32F107VCHx",
stmGlob: "STM32F107VCHx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RBTx",
stmGlob: "STM32F205R(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RCTx",
stmGlob: "STM32F205R(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RETx",
stmGlob: "STM32F205R(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RFTx",
stmGlob: "STM32F205R(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RGTx",
stmGlob: "STM32F205R(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205REYx",
stmGlob: "STM32F205R(E-G)Yx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RGYx",
stmGlob: "STM32F205R(E-G)Yx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205RGEx",
stmGlob: "STM32F205RGEx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205VBTx",
stmGlob: "STM32F205V(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205VCTx",
stmGlob: "STM32F205V(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205VETx",
stmGlob: "STM32F205V(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205VFTx",
stmGlob: "STM32F205V(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205VGTx",
stmGlob: "STM32F205V(B-C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205ZCTx",
stmGlob: "STM32F205Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205ZETx",
stmGlob: "STM32F205Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205ZFTx",
stmGlob: "STM32F205Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F205xx",
mcuCode: "STM32F205ZGTx",
stmGlob: "STM32F205Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207ICHx",
stmGlob: "STM32F207I(C-E-F-G)Hx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207IEHx",
stmGlob: "STM32F207I(C-E-F-G)Hx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207IFHx",
stmGlob: "STM32F207I(C-E-F-G)Hx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207IGHx",
stmGlob: "STM32F207I(C-E-F-G)Hx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207ICTx",
stmGlob: "STM32F207I(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207IETx",
stmGlob: "STM32F207I(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207IFTx",
stmGlob: "STM32F207I(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207IGTx",
stmGlob: "STM32F207I(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207VCTx",
stmGlob: "STM32F207V(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207VETx",
stmGlob: "STM32F207V(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207VFTx",
stmGlob: "STM32F207V(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207VGTx",
stmGlob: "STM32F207V(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207ZCTx",
stmGlob: "STM32F207Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207ZETx",
stmGlob: "STM32F207Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207ZFTx",
stmGlob: "STM32F207Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F207xx",
mcuCode: "STM32F207ZGTx",
stmGlob: "STM32F207Z(C-E-F-G)Tx"
},
{
chibiDef: "STM32F215xx",
mcuCode: "STM32F215RETx",
stmGlob: "STM32F215R(E-G)Tx"
},
{
chibiDef: "STM32F215xx",
mcuCode: "STM32F215RGTx",
stmGlob: "STM32F215R(E-G)Tx"
},
{
chibiDef: "STM32F215xx",
mcuCode: "STM32F215VETx",
stmGlob: "STM32F215V(E-G)Tx"
},
{
chibiDef: "STM32F215xx",
mcuCode: "STM32F215VGTx",
stmGlob: "STM32F215V(E-G)Tx"
},
{
chibiDef: "STM32F215xx",
mcuCode: "STM32F215ZETx",
stmGlob: "STM32F215Z(E-G)Tx"
},
{
chibiDef: "STM32F215xx",
mcuCode: "STM32F215ZGTx",
stmGlob: "STM32F215Z(E-G)Tx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217IEHx",
stmGlob: "STM32F217I(E-G)Hx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217IGHx",
stmGlob: "STM32F217I(E-G)Hx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217IETx",
stmGlob: "STM32F217I(E-G)Tx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217IGTx",
stmGlob: "STM32F217I(E-G)Tx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217VETx",
stmGlob: "STM32F217V(E-G)Tx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217VGTx",
stmGlob: "STM32F217V(E-G)Tx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217ZETx",
stmGlob: "STM32F217Z(E-G)Tx"
},
{
chibiDef: "STM32F217xx",
mcuCode: "STM32F217ZGTx",
stmGlob: "STM32F217Z(E-G)Tx"
},
{
chibiDef: "STM32F301x8",
mcuCode: "STM32F301C8Tx",
stmGlob: "STM32F301C(6-8)Tx"
},
{
chibiDef: "STM32F301x8",
mcuCode: "STM32F301C8Yx",
stmGlob: "STM32F301C8Yx"
},
{
chibiDef: "STM32F301x8",
mcuCode: "STM32F301K8Tx",
stmGlob: "STM32F301K(6-8)Tx"
},
{
chibiDef: "STM32F301x8",
mcuCode: "STM32F301K8Ux",
stmGlob: "STM32F301K(6-8)Ux"
},
{
chibiDef: "STM32F301x8",
mcuCode: "STM32F301R8Tx",
stmGlob: "STM32F301R(6-8)Tx"
},
{
chibiDef: "STM32F302x8",
mcuCode: "STM32F302C8Tx",
stmGlob: "STM32F302C(6-8)Tx"
},
{
chibiDef: "STM32F302x8",
mcuCode: "STM32F302C8Yx",
stmGlob: "STM32F302C8Yx"
},
{
chibiDef: "STM32F302xC",
mcuCode: "STM32F302CCTx",
stmGlob: "STM32F302C(B-C)Tx"
},
{
chibiDef: "STM32F302x8",
mcuCode: "STM32F302K8Ux",
stmGlob: "STM32F302K(6-8)Ux"
},
{
chibiDef: "STM32F302x8",
mcuCode: "STM32F302R8Tx",
stmGlob: "STM32F302R(6-8)Tx"
},
{
chibiDef: "STM32F302xC",
mcuCode: "STM32F302RCTx",
stmGlob: "STM32F302R(B-C)Tx"
},
{
chibiDef: "STM32F302xE",
mcuCode: "STM32F302RETx",
stmGlob: "STM32F302R(D-E)Tx"
},
{
chibiDef: "STM32F302xC",
mcuCode: "STM32F302VCTx",
stmGlob: "STM32F302V(B-C)Tx"
},
{
chibiDef: "STM32F302xC",
mcuCode: "STM32F302VCYx",
stmGlob: "STM32F302VCYx"
},
{
chibiDef: "STM32F302xE",
mcuCode: "STM32F302VEHx",
stmGlob: "STM32F302V(D-E)Hx"
},
{
chibiDef: "STM32F302xE",
mcuCode: "STM32F302VETx",
stmGlob: "STM32F302V(D-E)Tx"
},
{
chibiDef: "STM32F302xE",
mcuCode: "STM32F302ZETx",
stmGlob: "STM32F302Z(D-E)Tx"
},
{
chibiDef: "STM32F303x8",
mcuCode: "STM32F303C8Tx",
stmGlob: "STM32F303C(6-8)Tx"
},
{
chibiDef: "STM32F303x8",
mcuCode: "STM32F303C8Yx",
stmGlob: "STM32F303C8Yx"
},
{
chibiDef: "STM32F303xC",
mcuCode: "STM32F303CCTx",
stmGlob: "STM32F303C(B-C)Tx"
},
{
chibiDef: "STM32F303x8",
mcuCode: "STM32F303K8Tx",
stmGlob: "STM32F303K(6-8)Tx"
},
{
chibiDef: "STM32F303x8",
mcuCode: "STM32F303K8Ux",
stmGlob: "STM32F303K(6-8)Ux"
},
{
chibiDef: "STM32F303x8",
mcuCode: "STM32F303R8Tx",
stmGlob: "STM32F303R(6-8)Tx"
},
{
chibiDef: "STM32F303xC",
mcuCode: "STM32F303RCTx",
stmGlob: "STM32F303R(B-C)Tx"
},
{
chibiDef: "STM32F303xE",
mcuCode: "STM32F303RETx",
stmGlob: "STM32F303R(D-E)Tx"
},
{
chibiDef: "STM32F303xC",
mcuCode: "STM32F303VCTx",
stmGlob: "STM32F303V(B-C)Tx"
},
{
chibiDef: "STM32F303xC",
mcuCode: "STM32F303VCYx",
stmGlob: "STM32F303VCYx"
},
{
chibiDef: "STM32F303xE",
mcuCode: "STM32F303VEHx",
stmGlob: "STM32F303V(D-E)Hx"
},
{
chibiDef: "STM32F303xE",
mcuCode: "STM32F303VETx",
stmGlob: "STM32F303V(D-E)Tx"
},
{
chibiDef: "STM32F303xE",
mcuCode: "STM32F303VEYx",
stmGlob: "STM32F303VEYx"
},
{
chibiDef: "STM32F303xE",
mcuCode: "STM32F303ZETx",
stmGlob: "STM32F303Z(D-E)Tx"
},
{
chibiDef: "STM32F318x8",
mcuCode: "STM32F318C8Tx",
stmGlob: "STM32F318C8Tx"
},
{
chibiDef: "STM32F318x8",
mcuCode: "STM32F318C8Yx",
stmGlob: "STM32F318C8Yx"
},
{
chibiDef: "STM32F318x8",
mcuCode: "STM32F318K8Ux",
stmGlob: "STM32F318K8Ux"
},
{
chibiDef: "STM32F328x8",
mcuCode: "STM32F328C8Tx",
stmGlob: "STM32F328C8Tx"
},
{
chibiDef: "STM32F334x8",
mcuCode: "STM32F334C8Tx",
stmGlob: "STM32F334C(4-6-8)Tx"
},
{
chibiDef: "STM32F334x8",
mcuCode: "STM32F334C8Yx",
stmGlob: "STM32F334C8Yx"
},
{
chibiDef: "STM32F334x8",
mcuCode: "STM32F334K8Tx",
stmGlob: "STM32F334K(4-6-8)Tx"
},
{
chibiDef: "STM32F334x8",
mcuCode: "STM32F334K8Ux",
stmGlob: "STM32F334K(4-6-8)Ux"
},
{
chibiDef: "STM32F334x8",
mcuCode: "STM32F334R8Tx",
stmGlob: "STM32F334R(6-8)Tx"
},
{
chibiDef: "STM32F358xC",
mcuCode: "STM32F358CCTx",
stmGlob: "STM32F358CCTx"
},
{
chibiDef: "STM32F358xC",
mcuCode: "STM32F358RCTx",
stmGlob: "STM32F358RCTx"
},
{
chibiDef: "STM32F358xC",
mcuCode: "STM32F358VCTx",
stmGlob: "STM32F358VCTx"
},
{
chibiDef: "STM32F373xC",
mcuCode: "STM32F373CCTx",
stmGlob: "STM32F373C(8-B-C)Tx"
},
{
chibiDef: "STM32F373xC",
mcuCode: "STM32F373RCTx",
stmGlob: "STM32F373R(8-B-C)Tx"
},
{
chibiDef: "STM32F373xC",
mcuCode: "STM32F373VCHx",
stmGlob: "STM32F373V(8-B-C)Hx"
},
{
chibiDef: "STM32F373xC",
mcuCode: "STM32F373VCTx",
stmGlob: "STM32F373V(8-B-C)Tx"
},
{
chibiDef: "STM32F378xx",
mcuCode: "STM32F378CCTx",
stmGlob: "STM32F378CCTx"
},
{
chibiDef: "STM32F378xx",
mcuCode: "STM32F378RCTx",
stmGlob: "STM32F378RCTx"
},
{
chibiDef: "STM32F378xx",
mcuCode: "STM32F378RCYx",
stmGlob: "STM32F378RCYx"
},
{
chibiDef: "STM32F378xx",
mcuCode: "STM32F378VCHx",
stmGlob: "STM32F378VCHx"
},
{
chibiDef: "STM32F378xx",
mcuCode: "STM32F378VCTx",
stmGlob: "STM32F378VCTx"
},
{
chibiDef: "STM32F398xx",
mcuCode: "STM32F398VETx",
stmGlob: "STM32F398VETx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401CBUx",
stmGlob: "STM32F401C(B-C)Ux"
},
{
chibiDef: "STM32F401xC",
mcuCode: "STM32F401CCUx",
stmGlob: "STM32F401C(B-C)Ux"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401CBYx",
stmGlob: "STM32F401C(B-C)Yx"
},
{
chibiDef: "STM32F401xC",
mcuCode: "STM32F401CCYx",
stmGlob: "STM32F401C(B-C)Yx"
},
{
chibiDef: "STM32F401xC",
mcuCode: "STM32F401CCFx",
stmGlob: "STM32F401CCFx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401CDUx",
stmGlob: "STM32F401C(D-E)Ux"
},
{
chibiDef: "STM32F401xE",
mcuCode: "STM32F401CEUx",
stmGlob: "STM32F401C(D-E)Ux"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401CDYx",
stmGlob: "STM32F401C(D-E)Yx"
},
{
chibiDef: "STM32F401xE",
mcuCode: "STM32F401CEYx",
stmGlob: "STM32F401C(D-E)Yx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401RBTx",
stmGlob: "STM32F401R(B-C)Tx"
},
{
chibiDef: "STM32F401xC",
mcuCode: "STM32F401RCTx",
stmGlob: "STM32F401R(B-C)Tx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401RDTx",
stmGlob: "STM32F401R(D-E)Tx"
},
{
chibiDef: "STM32F401xE",
mcuCode: "STM32F401RETx",
stmGlob: "STM32F401R(D-E)Tx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401VBHx",
stmGlob: "STM32F401V(B-C)Hx"
},
{
chibiDef: "STM32F401xC",
mcuCode: "STM32F401VCHx",
stmGlob: "STM32F401V(B-C)Hx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401VBTx",
stmGlob: "STM32F401V(B-C)Tx"
},
{
chibiDef: "STM32F401xC",
mcuCode: "STM32F401VCTx",
stmGlob: "STM32F401V(B-C)Tx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401VDHx",
stmGlob: "STM32F401V(D-E)Hx"
},
{
chibiDef: "STM32F401xE",
mcuCode: "STM32F401VEHx",
stmGlob: "STM32F401V(D-E)Hx"
},
{
chibiDef: "STM32F401xx",
mcuCode: "STM32F401VDTx",
stmGlob: "STM32F401V(D-E)Tx"
},
{
chibiDef: "STM32F401xE",
mcuCode: "STM32F401VETx",
stmGlob: "STM32F401V(D-E)Tx"
},
{
chibiDef: "STM32F405xx",
mcuCode: "STM32F405OEYx",
stmGlob: "STM32F405O(E-G)Yx"
},
{
chibiDef: "STM32F405xx",
mcuCode: "STM32F405OGYx",
stmGlob: "STM32F405O(E-G)Yx"
},
{
chibiDef: "STM32F405xx",
mcuCode: "STM32F405RGTx",
stmGlob: "STM32F405RGTx"
},
{
chibiDef: "STM32F405xx",
mcuCode: "STM32F405VGTx",
stmGlob: "STM32F405VGTx"
},
{
chibiDef: "STM32F405xx",
mcuCode: "STM32F405ZGTx",
stmGlob: "STM32F405ZGTx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407IEHx",
stmGlob: "STM32F407I(E-G)Hx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407IGHx",
stmGlob: "STM32F407I(E-G)Hx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407IETx",
stmGlob: "STM32F407I(E-G)Tx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407IGTx",
stmGlob: "STM32F407I(E-G)Tx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407VETx",
stmGlob: "STM32F407V(E-G)Tx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407VGTx",
stmGlob: "STM32F407V(E-G)Tx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407ZETx",
stmGlob: "STM32F407Z(E-G)Tx"
},
{
chibiDef: "STM32F407xx",
mcuCode: "STM32F407ZGTx",
stmGlob: "STM32F407Z(E-G)Tx"
},
{
chibiDef: "STM32F410Cx",
mcuCode: "STM32F410C8Tx",
stmGlob: "STM32F410C(8-B)Tx"
},
{
chibiDef: "STM32F410Cx",
mcuCode: "STM32F410CBTx",
stmGlob: "STM32F410C(8-B)Tx"
},
{
chibiDef: "STM32F410Cx",
mcuCode: "STM32F410C8Ux",
stmGlob: "STM32F410C(8-B)Ux"
},
{
chibiDef: "STM32F410Cx",
mcuCode: "STM32F410CBUx",
stmGlob: "STM32F410C(8-B)Ux"
},
{
chibiDef: "STM32F410Rx",
mcuCode: "STM32F410R8Ix",
stmGlob: "STM32F410R(8-B)Ix"
},
{
chibiDef: "STM32F410Rx",
mcuCode: "STM32F410RBIx",
stmGlob: "STM32F410R(8-B)Ix"
},
{
chibiDef: "STM32F410Rx",
mcuCode: "STM32F410R8Tx",
stmGlob: "STM32F410R(8-B)Tx"
},
{
chibiDef: "STM32F410Rx",
mcuCode: "STM32F410RBTx",
stmGlob: "STM32F410R(8-B)Tx"
},
{
chibiDef: "STM32F410Tx",
mcuCode: "STM32F410T8Yx",
stmGlob: "STM32F410T(8-B)Yx"
},
{
chibiDef: "STM32F410Tx",
mcuCode: "STM32F410TBYx",
stmGlob: "STM32F410T(8-B)Yx"
},
{
chibiDef: "STM32F411xx",
mcuCode: "STM32F411CCUx",
stmGlob: "STM32F411C(C-E)Ux"
},
{
chibiDef: "STM32F411xE",
mcuCode: "STM32F411CEUx",
stmGlob: "STM32F411C(C-E)Ux"
},
{
chibiDef: "STM32F411xx",
mcuCode: "STM32F411CCYx",
stmGlob: "STM32F411C(C-E)Yx"
},
{
chibiDef: "STM32F411xE",
mcuCode: "STM32F411CEYx",
stmGlob: "STM32F411C(C-E)Yx"
},
{
chibiDef: "STM32F411xx",
mcuCode: "STM32F411RCTx",
stmGlob: "STM32F411R(C-E)Tx"
},
{
chibiDef: "STM32F411xE",
mcuCode: "STM32F411RETx",
stmGlob: "STM32F411R(C-E)Tx"
},
{
chibiDef: "STM32F411xx",
mcuCode: "STM32F411VCHx",
stmGlob: "STM32F411V(C-E)Hx"
},
{
chibiDef: "STM32F411xE",
mcuCode: "STM32F411VEHx",
stmGlob: "STM32F411V(C-E)Hx"
},
{
chibiDef: "STM32F411xx",
mcuCode: "STM32F411VCTx",
stmGlob: "STM32F411V(C-E)Tx"
},
{
chibiDef: "STM32F411xE",
mcuCode: "STM32F411VETx",
stmGlob: "STM32F411V(C-E)Tx"
},
{
chibiDef: "STM32F412Cx",
mcuCode: "STM32F412CEUx",
stmGlob: "STM32F412C(E-G)Ux"
},
{
chibiDef: "STM32F412Cx",
mcuCode: "STM32F412CGUx",
stmGlob: "STM32F412C(E-G)Ux"
},
{
chibiDef: "STM32F412Rx",
mcuCode: "STM32F412RETx",
stmGlob: "STM32F412R(E-G)Tx"
},
{
chibiDef: "STM32F412Rx",
mcuCode: "STM32F412RGTx",
stmGlob: "STM32F412R(E-G)Tx"
},
{
chibiDef: "STM32F412Rx",
mcuCode: "STM32F412REYxP",
stmGlob: "STM32F412R(E-G)YxP"
},
{
chibiDef: "STM32F412Rx",
mcuCode: "STM32F412RGYxP",
stmGlob: "STM32F412R(E-G)YxP"
},
{
chibiDef: "STM32F412Rx",
mcuCode: "STM32F412REYx",
stmGlob: "STM32F412R(E-G)Yx"
},
{
chibiDef: "STM32F412Rx",
mcuCode: "STM32F412RGYx",
stmGlob: "STM32F412R(E-G)Yx"
},
{
chibiDef: "STM32F412Vx",
mcuCode: "STM32F412VEHx",
stmGlob: "STM32F412V(E-G)Hx"
},
{
chibiDef: "STM32F412Vx",
mcuCode: "STM32F412VGHx",
stmGlob: "STM32F412V(E-G)Hx"
},
{
chibiDef: "STM32F412Vx",
mcuCode: "STM32F412VETx",
stmGlob: "STM32F412V(E-G)Tx"
},
{
chibiDef: "STM32F412Vx",
mcuCode: "STM32F412VGTx",
stmGlob: "STM32F412V(E-G)Tx"
},
{
chibiDef: "STM32F412Zx",
mcuCode: "STM32F412ZEJx",
stmGlob: "STM32F412Z(E-G)Jx"
},
{
chibiDef: "STM32F412Zx",
mcuCode: "STM32F412ZGJx",
stmGlob: "STM32F412Z(E-G)Jx"
},
{
chibiDef: "STM32F412Zx",
mcuCode: "STM32F412ZETx",
stmGlob: "STM32F412Z(E-G)Tx"
},
{
chibiDef: "STM32F412Zx",
mcuCode: "STM32F412ZGTx",
stmGlob: "STM32F412Z(E-G)Tx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413CGUx",
stmGlob: "STM32F413C(G-H)Ux"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413CHUx",
stmGlob: "STM32F413C(G-H)Ux"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413MGYx",
stmGlob: "STM32F413M(G-H)Yx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413MHYx",
stmGlob: "STM32F413M(G-H)Yx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413RGTx",
stmGlob: "STM32F413R(G-H)Tx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413RHTx",
stmGlob: "STM32F413R(G-H)Tx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413VGHx",
stmGlob: "STM32F413V(G-H)Hx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413VHHx",
stmGlob: "STM32F413V(G-H)Hx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413VGTx",
stmGlob: "STM32F413V(G-H)Tx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413VHTx",
stmGlob: "STM32F413V(G-H)Tx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413ZGJx",
stmGlob: "STM32F413Z(G-H)Jx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413ZHJx",
stmGlob: "STM32F413Z(G-H)Jx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413ZGTx",
stmGlob: "STM32F413Z(G-H)Tx"
},
{
chibiDef: "STM32F40_41xxx",
mcuCode: "STM32F413ZHTx",
stmGlob: "STM32F413Z(G-H)Tx"
},
{
chibiDef: "STM32F415xx",
mcuCode: "STM32F415OGYx",
stmGlob: "STM32F415OGYx"
},
{
chibiDef: "STM32F415xx",
mcuCode: "STM32F415RGTx",
stmGlob: "STM32F415RGTx"
},
{
chibiDef: "STM32F415xx",
mcuCode: "STM32F415VGTx",
stmGlob: "STM32F415VGTx"
},
{
chibiDef: "STM32F415xx",
mcuCode: "STM32F415ZGTx",
stmGlob: "STM32F415ZGTx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417IEHx",
stmGlob: "STM32F417I(E-G)Hx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417IGHx",
stmGlob: "STM32F417I(E-G)Hx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417IETx",
stmGlob: "STM32F417I(E-G)Tx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417IGTx",
stmGlob: "STM32F417I(E-G)Tx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417VETx",
stmGlob: "STM32F417V(E-G)Tx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417VGTx",
stmGlob: "STM32F417V(E-G)Tx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417ZETx",
stmGlob: "STM32F417Z(E-G)Tx"
},
{
chibiDef: "STM32F417xx",
mcuCode: "STM32F417ZGTx",
stmGlob: "STM32F417Z(E-G)Tx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427AGHx",
stmGlob: "STM32F427A(G-I)Hx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427AIHx",
stmGlob: "STM32F427A(G-I)Hx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427IGHx",
stmGlob: "STM32F427I(G-I)Hx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427IIHx",
stmGlob: "STM32F427I(G-I)Hx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427IGTx",
stmGlob: "STM32F427I(G-I)Tx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427IITx",
stmGlob: "STM32F427I(G-I)Tx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427VGTx",
stmGlob: "STM32F427V(G-I)Tx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427VITx",
stmGlob: "STM32F427V(G-I)Tx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427ZGTx",
stmGlob: "STM32F427Z(G-I)Tx"
},
{
chibiDef: "STM32F427xx",
mcuCode: "STM32F427ZITx",
stmGlob: "STM32F427Z(G-I)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429AGHx",
stmGlob: "STM32F429A(G-I)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429AIHx",
stmGlob: "STM32F429A(G-I)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429BETx",
stmGlob: "STM32F429B(E-G-I)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429BGTx",
stmGlob: "STM32F429B(E-G-I)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429BITx",
stmGlob: "STM32F429B(E-G-I)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429IEHx",
stmGlob: "STM32F429I(E-G-I)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429IGHx",
stmGlob: "STM32F429I(E-G-I)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429IIHx",
stmGlob: "STM32F429I(E-G-I)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429IETx",
stmGlob: "STM32F429I(E-G)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429IGTx",
stmGlob: "STM32F429I(E-G)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429IITx",
stmGlob: "STM32F429IITx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429NEHx",
stmGlob: "STM32F429N(E-G)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429NGHx",
stmGlob: "STM32F429N(E-G)Hx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429NIHx",
stmGlob: "STM32F429NIHx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429VETx",
stmGlob: "STM32F429V(E-G)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429VGTx",
stmGlob: "STM32F429V(E-G)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429VITx",
stmGlob: "STM32F429VITx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429ZETx",
stmGlob: "STM32F429Z(E-G)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429ZGTx",
stmGlob: "STM32F429Z(E-G)Tx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429ZGYx",
stmGlob: "STM32F429ZGYx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429ZITx",
stmGlob: "STM32F429ZITx"
},
{
chibiDef: "STM32F429xx",
mcuCode: "STM32F429ZIYx",
stmGlob: "STM32F429ZIYx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437AIHx",
stmGlob: "STM32F437AIHx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437IGHx",
stmGlob: "STM32F437I(G-I)Hx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437IIHx",
stmGlob: "STM32F437I(G-I)Hx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437IGTx",
stmGlob: "STM32F437I(G-I)Tx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437IITx",
stmGlob: "STM32F437I(G-I)Tx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437VGTx",
stmGlob: "STM32F437V(G-I)Tx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437VITx",
stmGlob: "STM32F437V(G-I)Tx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437ZGTx",
stmGlob: "STM32F437Z(G-I)Tx"
},
{
chibiDef: "STM32F437xx",
mcuCode: "STM32F437ZITx",
stmGlob: "STM32F437Z(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439AIHx",
stmGlob: "STM32F439AIHx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439BGTx",
stmGlob: "STM32F439B(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439BITx",
stmGlob: "STM32F439B(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439IGHx",
stmGlob: "STM32F439I(G-I)Hx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439IIHx",
stmGlob: "STM32F439I(G-I)Hx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439IGTx",
stmGlob: "STM32F439I(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439IITx",
stmGlob: "STM32F439I(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439NGHx",
stmGlob: "STM32F439N(G-I)Hx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439NIHx",
stmGlob: "STM32F439N(G-I)Hx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439VGTx",
stmGlob: "STM32F439V(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439VITx",
stmGlob: "STM32F439V(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439ZGTx",
stmGlob: "STM32F439Z(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439ZITx",
stmGlob: "STM32F439Z(G-I)Tx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439ZGYx",
stmGlob: "STM32F439Z(G-I)Yx"
},
{
chibiDef: "STM32F439xx",
mcuCode: "STM32F439ZIYx",
stmGlob: "STM32F439Z(G-I)Yx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446MCYx",
stmGlob: "STM32F446M(C-E)Yx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446MEYx",
stmGlob: "STM32F446M(C-E)Yx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446RCTx",
stmGlob: "STM32F446R(C-E)Tx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446RETx",
stmGlob: "STM32F446R(C-E)Tx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446VCTx",
stmGlob: "STM32F446V(C-E)Tx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446VETx",
stmGlob: "STM32F446V(C-E)Tx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446ZCHx",
stmGlob: "STM32F446Z(C-E)Hx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446ZEHx",
stmGlob: "STM32F446Z(C-E)Hx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446ZCJx",
stmGlob: "STM32F446Z(C-E)Jx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446ZEJx",
stmGlob: "STM32F446Z(C-E)Jx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446ZCTx",
stmGlob: "STM32F446Z(C-E)Tx"
},
{
chibiDef: "STM32F446xx",
mcuCode: "STM32F446ZETx",
stmGlob: "STM32F446Z(C-E)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469AEHx",
stmGlob: "STM32F469A(E-G-I)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469AGHx",
stmGlob: "STM32F469A(E-G-I)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469AIHx",
stmGlob: "STM32F469A(E-G-I)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469AEYx",
stmGlob: "STM32F469A(E-G-I)Yx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469AGYx",
stmGlob: "STM32F469A(E-G-I)Yx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469AIYx",
stmGlob: "STM32F469A(E-G-I)Yx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469BETx",
stmGlob: "STM32F469B(E-G-I)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469BGTx",
stmGlob: "STM32F469B(E-G-I)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469BITx",
stmGlob: "STM32F469B(E-G-I)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469IEHx",
stmGlob: "STM32F469I(E-G-I)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469IGHx",
stmGlob: "STM32F469I(E-G-I)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469IIHx",
stmGlob: "STM32F469I(E-G-I)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469IETx",
stmGlob: "STM32F469I(E-G)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469IGTx",
stmGlob: "STM32F469I(E-G)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469IITx",
stmGlob: "STM32F469IITx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469NEHx",
stmGlob: "STM32F469N(E-G)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469NGHx",
stmGlob: "STM32F469N(E-G)Hx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469NIHx",
stmGlob: "STM32F469NIHx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469VETx",
stmGlob: "STM32F469V(E-G)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469VGTx",
stmGlob: "STM32F469V(E-G)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469VITx",
stmGlob: "STM32F469VITx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469ZETx",
stmGlob: "STM32F469Z(E-G)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469ZGTx",
stmGlob: "STM32F469Z(E-G)Tx"
},
{
chibiDef: "STM32F469xx",
mcuCode: "STM32F469ZITx",
stmGlob: "STM32F469ZITx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479AGHx",
stmGlob: "STM32F479A(G-I)Hx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479AIHx",
stmGlob: "STM32F479A(G-I)Hx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479AGYx",
stmGlob: "STM32F479A(G-I)Yx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479AIYx",
stmGlob: "STM32F479A(G-I)Yx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479BGTx",
stmGlob: "STM32F479B(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479BITx",
stmGlob: "STM32F479B(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479IGHx",
stmGlob: "STM32F479I(G-I)Hx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479IIHx",
stmGlob: "STM32F479I(G-I)Hx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479IGTx",
stmGlob: "STM32F479I(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479IITx",
stmGlob: "STM32F479I(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479NGHx",
stmGlob: "STM32F479N(G-I)Hx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479NIHx",
stmGlob: "STM32F479N(G-I)Hx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479VGTx",
stmGlob: "STM32F479V(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479VITx",
stmGlob: "STM32F479V(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479ZGTx",
stmGlob: "STM32F479Z(G-I)Tx"
},
{
chibiDef: "STM32F479xx",
mcuCode: "STM32F479ZITx",
stmGlob: "STM32F479Z(G-I)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722ICKx",
stmGlob: "STM32F722I(C-E)Kx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722IEKx",
stmGlob: "STM32F722I(C-E)Kx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722ICTx",
stmGlob: "STM32F722I(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722IETx",
stmGlob: "STM32F722I(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722RCTx",
stmGlob: "STM32F722R(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722RETx",
stmGlob: "STM32F722R(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722VCTx",
stmGlob: "STM32F722V(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722VETx",
stmGlob: "STM32F722V(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722ZCTx",
stmGlob: "STM32F722Z(C-E)Tx"
},
{
chibiDef: "STM32F722xx",
mcuCode: "STM32F722ZETx",
stmGlob: "STM32F722Z(C-E)Tx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723ICKx",
stmGlob: "STM32F723I(C-E)Kx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723IEKx",
stmGlob: "STM32F723I(C-E)Kx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723ICTx",
stmGlob: "STM32F723I(C-E)Tx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723IETx",
stmGlob: "STM32F723I(C-E)Tx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723VCTx",
stmGlob: "STM32F723V(C-E)Tx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723VETx",
stmGlob: "STM32F723V(C-E)Tx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723VCYx",
stmGlob: "STM32F723V(C-E)Yx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723VEYx",
stmGlob: "STM32F723V(C-E)Yx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723ZCIx",
stmGlob: "STM32F723Z(C-E)Ix"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723ZEIx",
stmGlob: "STM32F723Z(C-E)Ix"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723ZCTx",
stmGlob: "STM32F723Z(C-E)Tx"
},
{
chibiDef: "STM32F723xx",
mcuCode: "STM32F723ZETx",
stmGlob: "STM32F723Z(C-E)Tx"
},
{
chibiDef: "STM32F732xx",
mcuCode: "STM32F732IEKx",
stmGlob: "STM32F732IEKx"
},
{
chibiDef: "STM32F732xx",
mcuCode: "STM32F732IETx",
stmGlob: "STM32F732IETx"
},
{
chibiDef: "STM32F732xx",
mcuCode: "STM32F732RETx",
stmGlob: "STM32F732RETx"
},
{
chibiDef: "STM32F732xx",
mcuCode: "STM32F732VETx",
stmGlob: "STM32F732VETx"
},
{
chibiDef: "STM32F732xx",
mcuCode: "STM32F732ZETx",
stmGlob: "STM32F732ZETx"
},
{
chibiDef: "STM32F733xx",
mcuCode: "STM32F733IEKx",
stmGlob: "STM32F733IEKx"
},
{
chibiDef: "STM32F733xx",
mcuCode: "STM32F733IETx",
stmGlob: "STM32F733IETx"
},
{
chibiDef: "STM32F733xx",
mcuCode: "STM32F733VETx",
stmGlob: "STM32F733VETx"
},
{
chibiDef: "STM32F733xx",
mcuCode: "STM32F733VEYx",
stmGlob: "STM32F733VEYx"
},
{
chibiDef: "STM32F733xx",
mcuCode: "STM32F733ZEIx",
stmGlob: "STM32F733ZEIx"
},
{
chibiDef: "STM32F733xx",
mcuCode: "STM32F733ZETx",
stmGlob: "STM32F733ZETx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745IEKx",
stmGlob: "STM32F745I(E-G)Kx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745IGKx",
stmGlob: "STM32F745I(E-G)Kx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745IETx",
stmGlob: "STM32F745I(E-G)Tx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745IGTx",
stmGlob: "STM32F745I(E-G)Tx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745VEHx",
stmGlob: "STM32F745V(E-G)Hx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745VGHx",
stmGlob: "STM32F745V(E-G)Hx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745VETx",
stmGlob: "STM32F745V(E-G)Tx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745VGTx",
stmGlob: "STM32F745V(E-G)Tx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745ZETx",
stmGlob: "STM32F745Z(E-G)Tx"
},
{
chibiDef: "STM32F745xx",
mcuCode: "STM32F745ZGTx",
stmGlob: "STM32F745Z(E-G)Tx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746BETx",
stmGlob: "STM32F746B(E-G)Tx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746BGTx",
stmGlob: "STM32F746B(E-G)Tx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746IEKx",
stmGlob: "STM32F746I(E-G)Kx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746IGKx",
stmGlob: "STM32F746I(E-G)Kx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746IETx",
stmGlob: "STM32F746IETx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746IGTx",
stmGlob: "STM32F746IGTx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746NEHx",
stmGlob: "STM32F746NEHx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746NGHx",
stmGlob: "STM32F746NGHx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746VEHx",
stmGlob: "STM32F746V(E-G)Hx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746VGHx",
stmGlob: "STM32F746V(E-G)Hx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746VETx",
stmGlob: "STM32F746VETx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746VGTx",
stmGlob: "STM32F746VGTx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746ZEYx",
stmGlob: "STM32F746Z(E-G)Yx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746ZGYx",
stmGlob: "STM32F746Z(E-G)Yx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746ZETx",
stmGlob: "STM32F746ZETx"
},
{
chibiDef: "STM32F746xx",
mcuCode: "STM32F746ZGTx",
stmGlob: "STM32F746ZGTx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756BGTx",
stmGlob: "STM32F756BGTx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756IGKx",
stmGlob: "STM32F756IGKx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756IGTx",
stmGlob: "STM32F756IGTx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756NGHx",
stmGlob: "STM32F756NGHx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756VGHx",
stmGlob: "STM32F756VGHx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756VGTx",
stmGlob: "STM32F756VGTx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756ZGTx",
stmGlob: "STM32F756ZGTx"
},
{
chibiDef: "STM32F756xx",
mcuCode: "STM32F756ZGYx",
stmGlob: "STM32F756ZGYx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767BGTx",
stmGlob: "STM32F767B(G-I)Tx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767BITx",
stmGlob: "STM32F767B(G-I)Tx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767IGKx",
stmGlob: "STM32F767I(G-I)Kx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767IIKx",
stmGlob: "STM32F767I(G-I)Kx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767IGTx",
stmGlob: "STM32F767I(G-I)Tx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767IITx",
stmGlob: "STM32F767I(G-I)Tx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767NGHx",
stmGlob: "STM32F767N(G-I)Hx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767NIHx",
stmGlob: "STM32F767N(G-I)Hx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767VGHx",
stmGlob: "STM32F767VGHx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767VGTx",
stmGlob: "STM32F767VGTx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767VIHx",
stmGlob: "STM32F767VIHx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767VITx",
stmGlob: "STM32F767VITx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767ZGTx",
stmGlob: "STM32F767ZGTx"
},
{
chibiDef: "STM32F767xx",
mcuCode: "STM32F767ZITx",
stmGlob: "STM32F767ZITx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769AGYx",
stmGlob: "STM32F769A(G-I)Yx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769AIYx",
stmGlob: "STM32F769A(G-I)Yx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769BGTx",
stmGlob: "STM32F769B(G-I)Tx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769BITx",
stmGlob: "STM32F769B(G-I)Tx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769IGTx",
stmGlob: "STM32F769IGTx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769IITx",
stmGlob: "STM32F769IITx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769NGHx",
stmGlob: "STM32F769NGHx"
},
{
chibiDef: "STM32F769xx",
mcuCode: "STM32F769NIHx",
stmGlob: "STM32F769NIHx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777BITx",
stmGlob: "STM32F777BITx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777IIKx",
stmGlob: "STM32F777IIKx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777IITx",
stmGlob: "STM32F777IITx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777NIHx",
stmGlob: "STM32F777NIHx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777VIHx",
stmGlob: "STM32F777VIHx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777VITx",
stmGlob: "STM32F777VITx"
},
{
chibiDef: "STM32F777xx",
mcuCode: "STM32F777ZITx",
stmGlob: "STM32F777ZITx"
},
{
chibiDef: "STM32F779xx",
mcuCode: "STM32F779AIYx",
stmGlob: "STM32F779AIYx"
},
{
chibiDef: "STM32F779xx",
mcuCode: "STM32F779BITx",
stmGlob: "STM32F779BITx"
},
{
chibiDef: "STM32F779xx",
mcuCode: "STM32F779IITx",
stmGlob: "STM32F779IITx"
},
{
chibiDef: "STM32F779xx",
mcuCode: "STM32F779NIHx",
stmGlob: "STM32F779NIHx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743AGIx",
stmGlob: "STM32H743A(G-I)Ix"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743AIIx",
stmGlob: "STM32H743A(G-I)Ix"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743BGTx",
stmGlob: "STM32H743BGTx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743BITx",
stmGlob: "STM32H743BITx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743IGKx",
stmGlob: "STM32H743IGKx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743IGTx",
stmGlob: "STM32H743IGTx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743IIKx",
stmGlob: "STM32H743IIKx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743IITx",
stmGlob: "STM32H743IITx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743VGHx",
stmGlob: "STM32H743V(G-I)Hx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743VIHx",
stmGlob: "STM32H743V(G-I)Hx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743VGTx",
stmGlob: "STM32H743VGTx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743VITx",
stmGlob: "STM32H743VITx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743XGHx",
stmGlob: "STM32H743XGHx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743XIHx",
stmGlob: "STM32H743XIHx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743ZGTx",
stmGlob: "STM32H743ZGTx"
},
{
chibiDef: "STM32H743xx",
mcuCode: "STM32H743ZITx",
stmGlob: "STM32H743ZITx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753AIIx",
stmGlob: "STM32H753AIIx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753BITx",
stmGlob: "STM32H753BITx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753IIKx",
stmGlob: "STM32H753IIKx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753IITx",
stmGlob: "STM32H753IITx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753VIHx",
stmGlob: "STM32H753VIHx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753VITx",
stmGlob: "STM32H753VITx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753XIHx",
stmGlob: "STM32H753XIHx"
},
{
chibiDef: "STM32H753xx",
mcuCode: "STM32H753ZITx",
stmGlob: "STM32H753ZITx"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011D3Px",
stmGlob: "STM32L011D(3-4)Px"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011D4Px",
stmGlob: "STM32L011D(3-4)Px"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011E3Yx",
stmGlob: "STM32L011E(3-4)Yx"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011E4Yx",
stmGlob: "STM32L011E(3-4)Yx"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011F3Px",
stmGlob: "STM32L011F(3-4)Px"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011F4Px",
stmGlob: "STM32L011F(3-4)Px"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011F3Ux",
stmGlob: "STM32L011F(3-4)Ux"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011F4Ux",
stmGlob: "STM32L011F(3-4)Ux"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011G3Ux",
stmGlob: "STM32L011G(3-4)Ux"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011G4Ux",
stmGlob: "STM32L011G(3-4)Ux"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011K3Tx",
stmGlob: "STM32L011K(3-4)Tx"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011K4Tx",
stmGlob: "STM32L011K(3-4)Tx"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011K3Ux",
stmGlob: "STM32L011K(3-4)Ux"
},
{
chibiDef: "STM32L011xx",
mcuCode: "STM32L011K4Ux",
stmGlob: "STM32L011K(3-4)Ux"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031C4Tx",
stmGlob: "STM32L031C(4-6)Tx"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031C6Tx",
stmGlob: "STM32L031C(4-6)Tx"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031C4Ux",
stmGlob: "STM32L031C(4-6)Ux"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031C6Ux",
stmGlob: "STM32L031C(4-6)Ux"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031E4Yx",
stmGlob: "STM32L031E(4-6)Yx"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031E6Yx",
stmGlob: "STM32L031E(4-6)Yx"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031F4Px",
stmGlob: "STM32L031F(4-6)Px"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031F6Px",
stmGlob: "STM32L031F(4-6)Px"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031G4Ux",
stmGlob: "STM32L031G(4-6)Ux"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031G6Ux",
stmGlob: "STM32L031G(4-6)Ux"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031G6UxS",
stmGlob: "STM32L031G6UxS"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031K4Tx",
stmGlob: "STM32L031K(4-6)Tx"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031K6Tx",
stmGlob: "STM32L031K(4-6)Tx"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031K4Ux",
stmGlob: "STM32L031K(4-6)Ux"
},
{
chibiDef: "STM32L031xx",
mcuCode: "STM32L031K6Ux",
stmGlob: "STM32L031K(4-6)Ux"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051C6Tx",
stmGlob: "STM32L051C(6-8)Tx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051C8Tx",
stmGlob: "STM32L051C(6-8)Tx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051C6Ux",
stmGlob: "STM32L051C(6-8)Ux"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051C8Ux",
stmGlob: "STM32L051C(6-8)Ux"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051K6Tx",
stmGlob: "STM32L051K(6-8)Tx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051K8Tx",
stmGlob: "STM32L051K(6-8)Tx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051K6Ux",
stmGlob: "STM32L051K(6-8)Ux"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051K8Ux",
stmGlob: "STM32L051K(6-8)Ux"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051R6Hx",
stmGlob: "STM32L051R(6-8)Hx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051R8Hx",
stmGlob: "STM32L051R(6-8)Hx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051R6Tx",
stmGlob: "STM32L051R(6-8)Tx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051R8Tx",
stmGlob: "STM32L051R(6-8)Tx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051T6Yx",
stmGlob: "STM32L051T(6-8)Yx"
},
{
chibiDef: "STM32L051xx",
mcuCode: "STM32L051T8Yx",
stmGlob: "STM32L051T(6-8)Yx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052C6Tx",
stmGlob: "STM32L052C(6-8)Tx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052C8Tx",
stmGlob: "STM32L052C(6-8)Tx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052C6Ux",
stmGlob: "STM32L052C(6-8)Ux"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052C8Ux",
stmGlob: "STM32L052C(6-8)Ux"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052K6Tx",
stmGlob: "STM32L052K(6-8)Tx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052K8Tx",
stmGlob: "STM32L052K(6-8)Tx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052K6Ux",
stmGlob: "STM32L052K(6-8)Ux"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052K8Ux",
stmGlob: "STM32L052K(6-8)Ux"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052R6Hx",
stmGlob: "STM32L052R(6-8)Hx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052R8Hx",
stmGlob: "STM32L052R(6-8)Hx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052R6Tx",
stmGlob: "STM32L052R(6-8)Tx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052R8Tx",
stmGlob: "STM32L052R(6-8)Tx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052T6Yx",
stmGlob: "STM32L052T(6-8)Yx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052T8Yx",
stmGlob: "STM32L052T(6-8)Yx"
},
{
chibiDef: "STM32L052xx",
mcuCode: "STM32L052T8Fx",
stmGlob: "STM32L052T8Fx"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053C6Tx",
stmGlob: "STM32L053C(6-8)Tx"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053C8Tx",
stmGlob: "STM32L053C(6-8)Tx"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053C6Ux",
stmGlob: "STM32L053C(6-8)Ux"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053C8Ux",
stmGlob: "STM32L053C(6-8)Ux"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053R6Hx",
stmGlob: "STM32L053R(6-8)Hx"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053R8Hx",
stmGlob: "STM32L053R(6-8)Hx"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053R6Tx",
stmGlob: "STM32L053R(6-8)Tx"
},
{
chibiDef: "STM32L053xx",
mcuCode: "STM32L053R8Tx",
stmGlob: "STM32L053R(6-8)Tx"
},
{
chibiDef: "STM32L062xx",
mcuCode: "STM32L062C8Ux",
stmGlob: "STM32L062C8Ux"
},
{
chibiDef: "STM32L062xx",
mcuCode: "STM32L062K8Tx",
stmGlob: "STM32L062K8Tx"
},
{
chibiDef: "STM32L062xx",
mcuCode: "STM32L062K8Ux",
stmGlob: "STM32L062K8Ux"
},
{
chibiDef: "STM32L063xx",
mcuCode: "STM32L063C8Tx",
stmGlob: "STM32L063C8Tx"
},
{
chibiDef: "STM32L063xx",
mcuCode: "STM32L063C8Ux",
stmGlob: "STM32L063C8Ux"
},
{
chibiDef: "STM32L063xx",
mcuCode: "STM32L063R8Tx",
stmGlob: "STM32L063R8Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071C8Tx",
stmGlob: "STM32L071C8Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071C8Ux",
stmGlob: "STM32L071C8Ux"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071CBTx",
stmGlob: "STM32L071C(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071CZTx",
stmGlob: "STM32L071C(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071CBUx",
stmGlob: "STM32L071C(B-Z)Ux"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071CZUx",
stmGlob: "STM32L071C(B-Z)Ux"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071CBYx",
stmGlob: "STM32L071C(B-Z)Yx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071CZYx",
stmGlob: "STM32L071C(B-Z)Yx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071K8Ux",
stmGlob: "STM32L071K8Ux"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071KBTx",
stmGlob: "STM32L071K(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071KZTx",
stmGlob: "STM32L071K(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071KBUx",
stmGlob: "STM32L071K(B-Z)Ux"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071KZUx",
stmGlob: "STM32L071K(B-Z)Ux"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071RBHx",
stmGlob: "STM32L071R(B-Z)Hx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071RZHx",
stmGlob: "STM32L071R(B-Z)Hx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071RBTx",
stmGlob: "STM32L071R(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071RZTx",
stmGlob: "STM32L071R(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071V8Ix",
stmGlob: "STM32L071V8Ix"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071V8Tx",
stmGlob: "STM32L071V8Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071VBIx",
stmGlob: "STM32L071V(B-Z)Ix"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071VZIx",
stmGlob: "STM32L071V(B-Z)Ix"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071VBTx",
stmGlob: "STM32L071V(B-Z)Tx"
},
{
chibiDef: "STM32L071xx",
mcuCode: "STM32L071VZTx",
stmGlob: "STM32L071V(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CBTx",
stmGlob: "STM32L072C(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CZTx",
stmGlob: "STM32L072C(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CBUx",
stmGlob: "STM32L072C(B-Z)Ux"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CZUx",
stmGlob: "STM32L072C(B-Z)Ux"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CBYx",
stmGlob: "STM32L072C(B-Z)Yx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CZYx",
stmGlob: "STM32L072C(B-Z)Yx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072CZEx",
stmGlob: "STM32L072CZEx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072KBTx",
stmGlob: "STM32L072K(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072KZTx",
stmGlob: "STM32L072K(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072KBUx",
stmGlob: "STM32L072K(B-Z)Ux"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072KZUx",
stmGlob: "STM32L072K(B-Z)Ux"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072RBHx",
stmGlob: "STM32L072R(B-Z)Hx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072RZHx",
stmGlob: "STM32L072R(B-Z)Hx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072RBIx",
stmGlob: "STM32L072R(B-Z)Ix"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072RZIx",
stmGlob: "STM32L072R(B-Z)Ix"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072RBTx",
stmGlob: "STM32L072R(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072RZTx",
stmGlob: "STM32L072R(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072V8Ix",
stmGlob: "STM32L072V8Ix"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072V8Tx",
stmGlob: "STM32L072V8Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072VBIx",
stmGlob: "STM32L072V(B-Z)Ix"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072VZIx",
stmGlob: "STM32L072V(B-Z)Ix"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072VBTx",
stmGlob: "STM32L072V(B-Z)Tx"
},
{
chibiDef: "STM32L072xx",
mcuCode: "STM32L072VZTx",
stmGlob: "STM32L072V(B-Z)Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073CBTx",
stmGlob: "STM32L073C(B-Z)Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073CZTx",
stmGlob: "STM32L073C(B-Z)Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073CBUx",
stmGlob: "STM32L073C(B-Z)Ux"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073CZUx",
stmGlob: "STM32L073C(B-Z)Ux"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073RBHx",
stmGlob: "STM32L073R(B-Z)Hx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073RZHx",
stmGlob: "STM32L073R(B-Z)Hx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073RBTx",
stmGlob: "STM32L073R(B-Z)Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073RZTx",
stmGlob: "STM32L073R(B-Z)Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073RZIx",
stmGlob: "STM32L073RZIx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073V8Ix",
stmGlob: "STM32L073V8Ix"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073V8Tx",
stmGlob: "STM32L073V8Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073VBIx",
stmGlob: "STM32L073V(B-Z)Ix"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073VZIx",
stmGlob: "STM32L073V(B-Z)Ix"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073VBTx",
stmGlob: "STM32L073V(B-Z)Tx"
},
{
chibiDef: "STM32L073xx",
mcuCode: "STM32L073VZTx",
stmGlob: "STM32L073V(B-Z)Tx"
},
{
chibiDef: "STM32L100xB",
mcuCode: "STM32L100RBTxA",
stmGlob: "STM32L100R(8-B)TxA"
},
{
chibiDef: "STM32L100xB",
mcuCode: "STM32L100RBTx",
stmGlob: "STM32L100R(8-B)Tx"
},
{
chibiDef: "STM32L100xC",
mcuCode: "STM32L100RCTx",
stmGlob: "STM32L100RCTx"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151CBTxA",
stmGlob: "STM32L151C(6-8-B)TxA"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151CBTx",
stmGlob: "STM32L151C(6-8-B)Tx"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151CBUxA",
stmGlob: "STM32L151C(6-8-B)UxA"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151CBUx",
stmGlob: "STM32L151C(6-8-B)Ux"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151CCTx",
stmGlob: "STM32L151CCTx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151CCUx",
stmGlob: "STM32L151CCUx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151QCHx",
stmGlob: "STM32L151QCHx"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151QDHx",
stmGlob: "STM32L151QDHx"
},
{
chibiDef: "STM32L151xE",
mcuCode: "STM32L151QEHx",
stmGlob: "STM32L151QEHx"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151RBHxA",
stmGlob: "STM32L151R(6-8-B)HxA"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151RBHx",
stmGlob: "STM32L151R(6-8-B)Hx"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151RBTxA",
stmGlob: "STM32L151R(6-8-B)TxA"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151RBTx",
stmGlob: "STM32L151R(6-8-B)Tx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151RCTxA",
stmGlob: "STM32L151RCTxA"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151RCTx",
stmGlob: "STM32L151RCTx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151RCYx",
stmGlob: "STM32L151RCYx"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151RDTx",
stmGlob: "STM32L151RDTx"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151RDYx",
stmGlob: "STM32L151RDYx"
},
{
chibiDef: "STM32L151xE",
mcuCode: "STM32L151RETx",
stmGlob: "STM32L151RETx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151UCYx",
stmGlob: "STM32L151UCYx"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151VBHxA",
stmGlob: "STM32L151V(8-B)HxA"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151VBHx",
stmGlob: "STM32L151V(8-B)Hx"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151VBTxA",
stmGlob: "STM32L151V(8-B)TxA"
},
{
chibiDef: "STM32L151xB",
mcuCode: "STM32L151VBTx",
stmGlob: "STM32L151V(8-B)Tx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151VCHx",
stmGlob: "STM32L151VCHx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151VCTxA",
stmGlob: "STM32L151VCTxA"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151VCTx",
stmGlob: "STM32L151VCTx"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151VDTx",
stmGlob: "STM32L151VDTx"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151VDTxX",
stmGlob: "STM32L151VDTxX"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151VDYxX",
stmGlob: "STM32L151VDYxX"
},
{
chibiDef: "STM32L151xE",
mcuCode: "STM32L151VETx",
stmGlob: "STM32L151VETx"
},
{
chibiDef: "STM32L151xE",
mcuCode: "STM32L151VEYx",
stmGlob: "STM32L151VEYx"
},
{
chibiDef: "STM32L151xC",
mcuCode: "STM32L151ZCTx",
stmGlob: "STM32L151ZCTx"
},
{
chibiDef: "STM32L151xD",
mcuCode: "STM32L151ZDTx",
stmGlob: "STM32L151ZDTx"
},
{
chibiDef: "STM32L151xE",
mcuCode: "STM32L151ZETx",
stmGlob: "STM32L151ZETx"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152CBTxA",
stmGlob: "STM32L152C(6-8-B)TxA"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152CBTx",
stmGlob: "STM32L152C(6-8-B)Tx"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152CBUxA",
stmGlob: "STM32L152C(6-8-B)UxA"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152CBUx",
stmGlob: "STM32L152C(6-8-B)Ux"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152CCTx",
stmGlob: "STM32L152CCTx"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152CCUx",
stmGlob: "STM32L152CCUx"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152QCHx",
stmGlob: "STM32L152QCHx"
},
{
chibiDef: "STM32L152xD",
mcuCode: "STM32L152QDHx",
stmGlob: "STM32L152QDHx"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152RBHxA",
stmGlob: "STM32L152R(6-8-B)HxA"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152RBHx",
stmGlob: "STM32L152R(6-8-B)Hx"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152RBTxA",
stmGlob: "STM32L152R(6-8-B)TxA"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152RBTx",
stmGlob: "STM32L152R(6-8-B)Tx"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152RCTxA",
stmGlob: "STM32L152RCTxA"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152RCTx",
stmGlob: "STM32L152RCTx"
},
{
chibiDef: "STM32L152xD",
mcuCode: "STM32L152RDTx",
stmGlob: "STM32L152RDTx"
},
{
chibiDef: "STM32L152xD",
mcuCode: "STM32L152RDYx",
stmGlob: "STM32L152RDYx"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152UCYx",
stmGlob: "STM32L152UCYx"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152VBHxA",
stmGlob: "STM32L152V(8-B)HxA"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152VBHx",
stmGlob: "STM32L152V(8-B)Hx"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152VBTxA",
stmGlob: "STM32L152V(8-B)TxA"
},
{
chibiDef: "STM32L152xB",
mcuCode: "STM32L152VBTx",
stmGlob: "STM32L152V(8-B)Tx"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152VCHx",
stmGlob: "STM32L152VCHx"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152VCTxA",
stmGlob: "STM32L152VCTxA"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152VCTx",
stmGlob: "STM32L152VCTx"
},
{
chibiDef: "STM32L152xD",
mcuCode: "STM32L152VDTx",
stmGlob: "STM32L152VDTx"
},
{
chibiDef: "STM32L152xD",
mcuCode: "STM32L152VDTxX",
stmGlob: "STM32L152VDTxX"
},
{
chibiDef: "STM32L152xC",
mcuCode: "STM32L152ZCTx",
stmGlob: "STM32L152ZCTx"
},
{
chibiDef: "STM32L152xD",
mcuCode: "STM32L152ZDTx",
stmGlob: "STM32L152ZDTx"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162QCHx",
stmGlob: "STM32L162QCHx"
},
{
chibiDef: "STM32L162xD",
mcuCode: "STM32L162QDHx",
stmGlob: "STM32L162QDHx"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162RCTxA",
stmGlob: "STM32L162RCTxA"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162RCTx",
stmGlob: "STM32L162RCTx"
},
{
chibiDef: "STM32L162xD",
mcuCode: "STM32L162RDTx",
stmGlob: "STM32L162RDTx"
},
{
chibiDef: "STM32L162xD",
mcuCode: "STM32L162RDYx",
stmGlob: "STM32L162RDYx"
},
{
chibiDef: "STM32L162xE",
mcuCode: "STM32L162RETx",
stmGlob: "STM32L162RETx"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162VCHx",
stmGlob: "STM32L162VCHx"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162VCTxA",
stmGlob: "STM32L162VCTxA"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162VCTx",
stmGlob: "STM32L162VCTx"
},
{
chibiDef: "STM32L162xD",
mcuCode: "STM32L162VDTx",
stmGlob: "STM32L162VDTx"
},
{
chibiDef: "STM32L162xD",
mcuCode: "STM32L162VDYxX",
stmGlob: "STM32L162VDYxX"
},
{
chibiDef: "STM32L162xE",
mcuCode: "STM32L162VETx",
stmGlob: "STM32L162VETx"
},
{
chibiDef: "STM32L162xE",
mcuCode: "STM32L162VEYx",
stmGlob: "STM32L162VEYx"
},
{
chibiDef: "STM32L162xC",
mcuCode: "STM32L162ZCTx",
stmGlob: "STM32L162ZCTx"
},
{
chibiDef: "STM32L162xD",
mcuCode: "STM32L162ZDTx",
stmGlob: "STM32L162ZDTx"
},
{
chibiDef: "STM32L162xE",
mcuCode: "STM32L162ZETx",
stmGlob: "STM32L162ZETx"
},
{
chibiDef: "STM32L432xx",
mcuCode: "STM32L432KBUx",
stmGlob: "STM32L432K(B-C)Ux"
},
{
chibiDef: "STM32L432xx",
mcuCode: "STM32L432KCUx",
stmGlob: "STM32L432K(B-C)Ux"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443CCTx",
stmGlob: "STM32L443CCTx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443CCUx",
stmGlob: "STM32L443CCUx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443CCYx",
stmGlob: "STM32L443CCYx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443RCIx",
stmGlob: "STM32L443RCIx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443RCTx",
stmGlob: "STM32L443RCTx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443RCYx",
stmGlob: "STM32L443RCYx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443VCIx",
stmGlob: "STM32L443VCIx"
},
{
chibiDef: "STM32L443xx",
mcuCode: "STM32L443VCTx",
stmGlob: "STM32L443VCTx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476JEYx",
stmGlob: "STM32L476J(E-G)Yx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476JGYx",
stmGlob: "STM32L476J(E-G)Yx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476JGYxP",
stmGlob: "STM32L476JGYxP"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476MEYx",
stmGlob: "STM32L476M(E-G)Yx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476MGYx",
stmGlob: "STM32L476M(E-G)Yx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476QEIx",
stmGlob: "STM32L476Q(E-G)Ix"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476QGIx",
stmGlob: "STM32L476Q(E-G)Ix"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476RCTx",
stmGlob: "STM32L476R(C-E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476RETx",
stmGlob: "STM32L476R(C-E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476RGTx",
stmGlob: "STM32L476R(C-E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476VCTx",
stmGlob: "STM32L476V(C-E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476VETx",
stmGlob: "STM32L476V(C-E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476VGTx",
stmGlob: "STM32L476V(C-E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476ZETx",
stmGlob: "STM32L476Z(E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476ZGTx",
stmGlob: "STM32L476Z(E-G)Tx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476ZGJx",
stmGlob: "STM32L476ZGJx"
},
{
chibiDef: "STM32L476xx",
mcuCode: "STM32L476ZGTxP",
stmGlob: "STM32L476ZGTxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496AEIx",
stmGlob: "STM32L496A(E-G)Ix"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496AGIx",
stmGlob: "STM32L496A(E-G)Ix"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496AGIxP",
stmGlob: "STM32L496AGIxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496QEIx",
stmGlob: "STM32L496Q(E-G)Ix"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496QGIx",
stmGlob: "STM32L496Q(E-G)Ix"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496QGIxP",
stmGlob: "STM32L496QGIxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496RETx",
stmGlob: "STM32L496R(E-G)Tx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496RGTx",
stmGlob: "STM32L496R(E-G)Tx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496RGTxP",
stmGlob: "STM32L496RGTxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496VETx",
stmGlob: "STM32L496V(E-G)Tx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496VGTx",
stmGlob: "STM32L496V(E-G)Tx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496VGTxP",
stmGlob: "STM32L496VGTxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496VGYxP",
stmGlob: "STM32L496VGYxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496VGYx",
stmGlob: "STM32L496VGYx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496WGYxP",
stmGlob: "STM32L496WGYxP"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496ZETx",
stmGlob: "STM32L496Z(E-G)Tx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496ZGTx",
stmGlob: "STM32L496Z(E-G)Tx"
},
{
chibiDef: "STM32L496xx",
mcuCode: "STM32L496ZGTxP",
stmGlob: "STM32L496ZGTxP"
}
];
var supportedMcus$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
'default': supportedMcus
});
var require$$5 = getCjsExportFromNamespace(supportedMcus$1);
// Generated by LiveScript 1.6.0
var ref$$4, DcsTcpClient$1, Actor$2, SignalBranch$2, config$1, fs, ractiveCompile, readdirSyncRecursive, supportedMcus$2, find$2, map$2, pairsToObj$1, TemplateEngine;
ref$$4 = dcs, DcsTcpClient$1 = ref$$4.DcsTcpClient, Actor$2 = ref$$4.Actor, SignalBranch$2 = ref$$4.SignalBranch;
config$1 = config;
fs = fs__default['default'];
ractiveCompile = ractiveTemplate.ractiveCompile;
readdirSyncRecursive = readdirSyncRecursive_1.readdirSyncRecursive;
supportedMcus$2 = require$$5;
ref$$4 = preludeLs__default['default'], find$2 = ref$$4.find, map$2 = ref$$4.map, pairsToObj$1 = ref$$4.pairsToObj;
new (TemplateEngine = (function(superclass){
var prototype = extend$((import$(TemplateEngine, superclass).displayName = 'TemplateEngine', TemplateEngine), superclass).prototype;
TemplateEngine.prototype.action = function(){
var this$ = this;
return this.onTopic('@templating.get', function(msg){
var configOrig, data, mcu, ref$, pinout, response, b, s, dir, templates;
configOrig = JSON.stringify(msg.data.config, null, 2);
data = {};
for (mcu in ref$ = msg.data.config) {
pinout = ref$[mcu];
data["mcu"] = find$2(fn$, supportedMcus$2);
data["pinout"] = pinout;
}
response = {};
b = new SignalBranch$2;
if (data.mcu) {
s = b.add();
dir = "./hw-template";
templates = readdirSyncRecursive(dir);
this$.sendRequest("@datasheet.mcu-info", {
id: mcu
}, function(err, res){
var e, pinNames, pin, ref$, pinout, ref1$, i$, len$, template, file, compiled;
if (e = err || res.error) {
return s.go(e);
}
pinNames = pairsToObj$1(
map$2(function(it){
return [it.Position, it.Name.replace(/-.+/, '')];
})(
map$2(function(it){
return it._attributes;
})(
res.data.info.Pin)));
for (pin in ref$ = data.pinout) {
pinout = ref$[pin];
pinout.pinName = pinNames[pin];
pinout.ioName = pinNames[pin] + "_" + pinout.peripheral.type.toUpperCase();
pinout.af = (ref1$ = pinout.peripheral.type) !== 'din' && ref1$ !== 'dout';
pinout.gpioPort = "GPIO" + pinNames[pin][1].toUpperCase();
}
/*********************************************************
data.pinout = {
pin-number:
peripheral: # Object
id: String, peripheral id, eg. "din" or "pwm-1.3", see webapps/main/stm/peripheral-defs.ls
name: String, Human readable name
stm: String, STM type, eg. GPIO
type: String, peripheral type, eg. din for Digital Input
config: # Object, Configuration regarding to @peripheral.type
pin-name: eg. PA1
io-name: eg. PA1_PWM
gpio-port: eg. GPIOA
*********************************************************/
for (i$ = 0, len$ = (ref$ = templates).length; i$ < len$; ++i$) {
template = ref$[i$];
file = fs.readFileSync(dir + "/" + template, "utf-8");
compiled = ractiveCompile(file, data);
response[template] = compiled;
}
response["config.json"] = configOrig;
return s.go();
});
} else {
response["error"] = "Unknown MCU: " + mcu;
}
return b.joined(function(){
this$.log.log("Requested hardware definition.");
return this$.sendResponse(msg, response);
});
function fn$(it){
return it.stmGlob === mcu;
}
});
};
function TemplateEngine(){
TemplateEngine.superclass.apply(this, arguments);
}
return TemplateEngine;
}(Actor$2)));
new DcsTcpClient$1({
port: config$1.dcsPort
}).login({
user: "templating",
password: "1234"
});
function extend$(sub, sup){
function fun(){} fun.prototype = (sub.superclass = sup).prototype;
(sub.prototype = new fun).constructor = sub;
if (typeof sup.extended == 'function') sup.extended(sub);
return sub;
}
function import$(obj, src){
var own = {}.hasOwnProperty;
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment