UNPKG

avitext-parser

Version:
1,585 lines (1,576 loc) 177 kB
!function(e){function r(e,r,o){return 4===arguments.length?t.apply(this,arguments):void n(e,{declarative:!0,deps:r,declare:o})}function t(e,r,t,o){n(e,{declarative:!1,deps:r,executingRequire:t,execute:o})}function n(e,r){r.name=e,e in g||(g[e]=r),r.normalizedDeps=r.deps}function o(e,r){if(r[e.groupIndex]=r[e.groupIndex]||[],-1==m.call(r[e.groupIndex],e)){r[e.groupIndex].push(e);for(var t=0,n=e.normalizedDeps.length;n>t;t++){var a=e.normalizedDeps[t],u=g[a];if(u&&!u.evaluated){var d=e.groupIndex+(u.declarative!=e.declarative);if(void 0===u.groupIndex||u.groupIndex<d){if(void 0!==u.groupIndex&&(r[u.groupIndex].splice(m.call(r[u.groupIndex],u),1),0==r[u.groupIndex].length))throw new TypeError("Mixed dependency cycle detected");u.groupIndex=d}o(u,r)}}}}function a(e){var r=g[e];r.groupIndex=0;var t=[];o(r,t);for(var n=!!r.declarative==t.length%2,a=t.length-1;a>=0;a--){for(var u=t[a],i=0;i<u.length;i++){var s=u[i];n?d(s):l(s)}n=!n}}function u(e){return D[e]||(D[e]={name:e,dependencies:[],exports:{},importers:[]})}function d(r){if(!r.module){var t=r.module=u(r.name),n=r.module.exports,o=r.declare.call(e,function(e,r){if(t.locked=!0,"object"==typeof e)for(var o in e)n[o]=e[o];else n[e]=r;for(var a=0,u=t.importers.length;u>a;a++){var d=t.importers[a];if(!d.locked)for(var i=0;i<d.dependencies.length;++i)d.dependencies[i]===t&&d.setters[i](n)}return t.locked=!1,r},r.name);t.setters=o.setters,t.execute=o.execute;for(var a=0,i=r.normalizedDeps.length;i>a;a++){var l,s=r.normalizedDeps[a],c=g[s],f=D[s];f?l=f.exports:c&&!c.declarative?l=c.esModule:c?(d(c),f=c.module,l=f.exports):l=v(s),f&&f.importers?(f.importers.push(t),t.dependencies.push(f)):t.dependencies.push(null),t.setters[a]&&t.setters[a](l)}}}function i(e){var r,t=g[e];if(t)t.declarative?p(e,[]):t.evaluated||l(t),r=t.module.exports;else if(r=v(e),!r)throw new Error("Unable to load dependency "+e+".");return(!t||t.declarative)&&r&&r.__useDefault?r["default"]:r}function l(r){if(!r.module){var t={},n=r.module={exports:t,id:r.name};if(!r.executingRequire)for(var o=0,a=r.normalizedDeps.length;a>o;o++){var u=r.normalizedDeps[o],d=g[u];d&&l(d)}r.evaluated=!0;var c=r.execute.call(e,function(e){for(var t=0,n=r.deps.length;n>t;t++)if(r.deps[t]==e)return i(r.normalizedDeps[t]);throw new TypeError("Module "+e+" not declared as a dependency.")},t,n);c&&(n.exports=c),t=n.exports,t&&t.__esModule?r.esModule=t:r.esModule=s(t)}}function s(e){var r={};if("object"==typeof e||"function"==typeof e){var t=e&&e.hasOwnProperty;if(h)for(var n in e)f(r,e,n)||c(r,e,n,t);else for(var n in e)c(r,e,n,t)}return r["default"]=e,y(r,"__useDefault",{value:!0}),r}function c(e,r,t,n){(!n||r.hasOwnProperty(t))&&(e[t]=r[t])}function f(e,r,t){try{var n;return(n=Object.getOwnPropertyDescriptor(r,t))&&y(e,t,n),!0}catch(o){return!1}}function p(r,t){var n=g[r];if(n&&!n.evaluated&&n.declarative){t.push(r);for(var o=0,a=n.normalizedDeps.length;a>o;o++){var u=n.normalizedDeps[o];-1==m.call(t,u)&&(g[u]?p(u,t):v(u))}n.evaluated||(n.evaluated=!0,n.module.execute.call(e))}}function v(e){if(I[e])return I[e];if("@node/"==e.substr(0,6))return _(e.substr(6));var r=g[e];if(!r)throw"Module "+e+" not present.";return a(e),p(e,[]),g[e]=void 0,r.declarative&&y(r.module.exports,"__esModule",{value:!0}),I[e]=r.declarative?r.module.exports:r.esModule}var g={},m=Array.prototype.indexOf||function(e){for(var r=0,t=this.length;t>r;r++)if(this[r]===e)return r;return-1},h=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(x){h=!1}var y;!function(){try{Object.defineProperty({},"a",{})&&(y=Object.defineProperty)}catch(e){y=function(e,r,t){try{e[r]=t.value||t.get.call(e)}catch(n){}}}}();var D={},_="undefined"!=typeof System&&System._nodeRequire||"undefined"!=typeof require&&require.resolve&&"undefined"!=typeof process&&require,I={"@empty":{}};return function(e,n,o){return function(a){a(function(a){for(var u={_nodeRequire:_,register:r,registerDynamic:t,get:v,set:function(e,r){I[e]=r},newModule:function(e){return e}},d=0;d<n.length;d++)(function(e,r){r&&r.__esModule?I[e]=r:I[e]=s(r)})(n[d],arguments[d]);o(u);var i=v(e[0]);if(e.length>1)for(var d=1;d<e.length;d++)v(e[d]);return i.__useDefault?i["default"]:i})}}}("undefined"!=typeof self?self:global) (["1"], [], function($__System) { var require = this.require, exports = this.exports, module = this.module; $__System.registerDynamic("2", ["3", "4"], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); exports.default = undefined; var _functional = $__require('3'); var _functional2 = _interopRequireDefault(_functional); var _Maybe = $__require('4'); var _Maybe2 = _interopRequireDefault(_Maybe); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {default: obj}; } var memoize = function memoize(fn) { var cache = {}; return function() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var stringifiedArgs = JSON.stringify(args); var result = cache[stringifiedArgs] = cache[stringifiedArgs] || fn.apply(undefined, args); return result; }; }; var convertToSlash = function convertToSlash(str) { return str.replace(/-/g, '/'); }; var appendYear = function appendYear(str) { return str.length === 8 ? str.slice(0, -3) + '-20' + str.slice(-2) : str + '-' + new Date().getFullYear(); }; var shouldAppendYear = function shouldAppendYear(str) { return str.length > 8 ? str : appendYear(str); }; var leadingZero = function leadingZero(str) { return str.startsWith('.') ? '0' + str : str; }; var convertKmToMiles = function convertKmToMiles(str) { return str.search(/km/i) !== -1 ? (Number(str.slice(0, -2)) * 0.6214).toFixed(2) : str; }; var convertKToMiles = function convertKToMiles(str) { return str.search(/k/i) !== -1 ? (Number(str.slice(0, -1)) * 0.6214).toFixed(2) : str; }; var strOrNull = function strOrNull(str) { return str && str !== '' ? str : null; }; var parseDistance = _functional2.default.compose(strOrNull, convertKToMiles, convertKmToMiles, leadingZero); var parseDate = _functional2.default.compose(convertToSlash, shouldAppendYear); var explodeString = memoize(function(str) { return str ? str.split(' ') : []; }); var parseEffortLine = function parseEffortLine(str) { return { date: _Maybe2.default.of(parseDate(explodeString(str)[0])), time: _Maybe2.default.of(explodeString(str)[1]), duration: _Maybe2.default.of(explodeString(str)[2] || null), distance: _Maybe2.default.of(parseDistance(explodeString(str)[3] || '')), observers: _Maybe2.default.of(1), comments: _Maybe2.default.of(''), get protocol() { if (this.duration.isNothing()) return _Maybe2.default.of('Casual'); if (this.distance.isNothing()) return _Maybe2.default.of('Stationary'); return _Maybe2.default.of('Traveling'); }, get complete() { return _Maybe2.default.of(this.protocol.join() !== 'Casual'); } }; }; exports.default = parseEffortLine; return module.exports; }); $__System.registerDynamic("5", ["4"], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); exports.default = undefined; var _Maybe = $__require('4'); var _Maybe2 = _interopRequireDefault(_Maybe); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {default: obj}; } var memoize = function memoize(fn) { var cache = {}; return function() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var stringifiedArgs = JSON.stringify(args); var result = cache[stringifiedArgs] = cache[stringifiedArgs] || fn.apply(undefined, args); return result; }; }; var explodeString = memoize(function(str) { return str ? str.split(' ') : []; }); var findRegionCode = memoize(function(str) { return explodeString(str)[0] === explodeString(str)[0].toUpperCase() ? explodeString(str)[0] : null; }); var parseCountryCode = function parseCountryCode(str) { return str.length === 4 ? str.substring(2, 4) : str.substring(0, 2); }; var parseSubnationalCode = memoize(function(str) { return str.length === 4 ? str.substring(0, 2) : str.substring(3, 6); }); var getSubnational = function getSubnational(str) { return findRegionCode(str) ? parseSubnationalCode(findRegionCode(str)) : null; }; var parseCountry = function parseCountry(str) { return findRegionCode(str) ? parseCountryCode(findRegionCode(str)) : null; }; var getLocation = function getLocation(str) { return findRegionCode(str) ? str.replace(findRegionCode(str), '').substring(1) : str; }; var parseLocationLine = function parseLocationLine(str) { return { location: _Maybe2.default.of(getLocation(str)), province: _Maybe2.default.of(getSubnational(str)), country: _Maybe2.default.of(parseCountry(str)) }; }; exports.default = parseLocationLine; return module.exports; }); $__System.registerDynamic("3", [], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { return typeof obj; } : function(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var fjs = function() { "use strict"; var fjs = {}, hardReturn = "hardReturn;"; var lambda = function lambda(exp) { if (!fjs.isString(exp)) { return; } var parts = exp.match(/(.*)\s*[=-]>\s*(.*)/); parts.shift(); var params = parts.shift().replace(/^\s*|\s(?=\s)|\s*$|,/g, "").split(" "); var body = parts.shift(); parts = (!/\s*return\s+/.test(body) ? "return " : "") + body; params.push(parts); return Function.apply({}, params); }; var sliceArgs = function sliceArgs(args) { return args.length > 0 ? [].slice.call(args, 0) : []; }; fjs.isFunction = function(obj) { return !!(obj && obj.constructor && obj.call && obj.apply); }; fjs.isObject = function(obj) { return fjs.isFunction(obj) || !!obj && (typeof obj === "undefined" ? "undefined" : _typeof(obj)) === "object"; }; fjs.isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }; var checkFunction = function checkFunction(func) { if (!fjs.isFunction(func)) { func = lambda(func); if (!fjs.isFunction(func)) { throw "fjs Error: Invalid function"; } } return func; }; fjs.curry = function(func) { func = checkFunction(func); return function inner() { var _args = sliceArgs(arguments); if (_args.length === func.length) { return func.apply(null, _args); } else if (_args.length > func.length) { var initial = func.apply(null, _args); return fjs.fold(func, initial, _args.slice(func.length)); } else { return function() { var args = sliceArgs(arguments); return inner.apply(null, _args.concat(args)); }; } }; }; fjs.each = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); if (!fjs.exists(items) || !fjs.isArray(items)) { return; } for (var i = 0, j = items.length; i < j; i += 1) { if (iterator.call(null, items[i], i) === hardReturn) { return; } } }); fjs.map = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var mapped = []; fjs.each(function() { mapped.push(iterator.apply(null, arguments)); }, items); return mapped; }); fjs.fold = fjs.foldl = fjs.curry(function(iterator, cumulate, items) { iterator = checkFunction(iterator); fjs.each(function(item, i) { cumulate = iterator.call(null, cumulate, item, i); }, items); return cumulate; }); fjs.reduce = fjs.reducel = fjs.foldll = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var cumulate = items[0]; items.shift(); return fjs.fold(iterator, cumulate, items); }); fjs.clone = function(items) { var clone = []; fjs.each(function(item) { clone.push(item); }, items); return clone; }; fjs.first = fjs.head = fjs.take = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var first; fjs.each(function(item) { if (iterator.call(null, item)) { first = item; return hardReturn; } }, items); return first; }); fjs.rest = fjs.tail = fjs.drop = fjs.curry(function(iterator, items) { var result = fjs.select(iterator, items); result.shift(); return result; }); fjs.last = fjs.curry(function(iterator, items) { var itemsClone = fjs.clone(items); return fjs.first(iterator, itemsClone.reverse()); }); fjs.every = fjs.all = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var isEvery = true; fjs.each(function(item) { if (!iterator.call(null, item)) { isEvery = false; return hardReturn; } }, items); return isEvery; }); fjs.any = fjs.contains = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var isAny = false; fjs.each(function(item) { if (iterator.call(null, item)) { isAny = true; return hardReturn; } }, items); return isAny; }); fjs.select = fjs.filter = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var filtered = []; fjs.each(function(item) { if (iterator.call(null, item)) { filtered.push(item); } }, items); return filtered; }); fjs.best = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var compare = function compare(arg1, arg2) { return iterator.call(this, arg1, arg2) ? arg1 : arg2; }; return fjs.reduce(compare, items); }); fjs.while = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var result = []; fjs.each(function(item) { if (iterator.call(null, item)) { result.push(item); } else { return hardReturn; } }, items); return result; }); fjs.compose = function(funcs) { var anyInvalid = fjs.any(function(func) { return !fjs.isFunction(func); }); funcs = sliceArgs(arguments).reverse(); if (anyInvalid(funcs)) { throw "fjs Error: Invalid function to compose"; } return function() { var args = arguments; var applyEach = fjs.each(function(func) { args = [func.apply(null, args)]; }); applyEach(funcs); return args[0]; }; }; fjs.partition = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var truthy = [], falsy = []; fjs.each(function(item) { (iterator.call(null, item) ? truthy : falsy).push(item); }, items); return [truthy, falsy]; }); fjs.group = fjs.curry(function(iterator, items) { iterator = checkFunction(iterator); var result = {}; var group; fjs.each(function(item) { group = iterator.call(null, item); result[group] = result[group] || []; result[group].push(item); }, items); return result; }); fjs.shuffle = function(items) { var j, t; fjs.each(function(item, i) { j = Math.floor(Math.random() * (i + 1)); t = items[i]; items[i] = items[j]; items[j] = t; }, items); return items; }; fjs.toArray = function(obj) { return fjs.map(function(key) { return [key, obj[key]]; }, Object.keys(obj)); }; fjs.apply = fjs.curry(function(func, items) { var args = []; if (fjs.isArray(func)) { args = [].slice.call(func, 1); func = func[0]; } return fjs.map(function(item) { return item[func].apply(item, args); }, items); }); fjs.assign = fjs.extend = fjs.curry(function(obj1, obj2) { fjs.each(function(key) { obj2[key] = obj1[key]; }, Object.keys(obj1)); return obj2; }); fjs.prop = function(prop) { return function(obj) { return obj[prop]; }; }; fjs.pluck = fjs.curry(function(prop, items) { return fjs.map(fjs.prop(prop), items); }); fjs.nub = fjs.unique = fjs.distinct = fjs.curry(function(comparator, items) { var unique = items.length > 0 ? [items[0]] : []; fjs.each(function(item) { if (!fjs.any(fjs.curry(comparator)(item), unique)) { unique[unique.length] = item; } }, items); return unique; }); fjs.exists = function(obj) { return obj != null; }; fjs.truthy = function(obj) { return fjs.exists(obj) && obj !== false; }; fjs.falsy = function(obj) { return !fjs.truthy(obj); }; fjs.each(function(type) { fjs["is" + type] = function(obj) { return Object.prototype.toString.call(obj) === "[object " + type + "]"; }; }, ["Arguments", "Date", "Number", "RegExp", "String"]); return fjs; }(); if (typeof exports !== "undefined") { if (typeof module !== "undefined" && module.exports) { exports = module.exports = fjs; } exports.fjs = fjs; } return module.exports; }); $__System.registerDynamic("6", [], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); var Count_ = function Count_(x) { return { map: function map(f) { return x ? Count_(f(x)) : Count_(null); }, isNothing: function isNothing() { return x === null || x === undefined; }, join: function join() { return x ? x : Count_(null); }, toInt: function toInt() { return x ? parseInt(x) : 0; }, emit: function emit() { return x; }, fold: function fold(f) { return f(x); } }; }; var Count = {of: function of(x) { return Count_(x); }}; exports.default = Count; return module.exports; }); $__System.registerDynamic("4", [], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); var Maybe_ = function Maybe_(x) { return { map: function map(f) { return x ? Maybe_(f(x)) : Maybe_(null); }, isNothing: function isNothing() { return x === null || x === undefined; }, join: function join() { return x ? x : Maybe_(null); }, emit: function emit() { return x; }, fold: function fold(f) { return f(x); } }; }; var Maybe = {of: function of(x) { return Maybe_(x); }}; exports.default = Maybe; return module.exports; }); $__System.registerDynamic("7", ["3", "6", "4", "8"], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); exports.default = undefined; var _functional = $__require('3'); var _functional2 = _interopRequireDefault(_functional); var _Count = $__require('6'); var _Count2 = _interopRequireDefault(_Count); var _Maybe = $__require('4'); var _Maybe2 = _interopRequireDefault(_Maybe); var _birdbrain = $__require('8'); var _birdbrain2 = _interopRequireDefault(_birdbrain); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {default: obj}; } var memoize = function memoize(fn) { var cache = {}; return function() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var stringifiedArgs = JSON.stringify(args); var result = cache[stringifiedArgs] = cache[stringifiedArgs] || fn.apply(undefined, args); return result; }; }; var countNumbers = function countNumbers(str) { return Number(str.replace(/\D/g, '') || 0); }; var countMales = function countMales(str) { return countMs(str) === 1 ? countNumbers(str) || 1 : countMs(str); }; var countMs = function countMs(str) { return Number((str.match(/m/g) || []).length); }; var countAllMales = function countAllMales(val) { return val.reduce(function(prev, current) { return Number(prev) + countMales(current); }, 0); }; var countFs = function countFs(str) { return Number((str.match(/f/g) || []).length); }; var countFemales = function countFemales(str) { return countFs(str) === 1 ? countNumbers(str) || 1 : countFs(str); }; var countAllFemales = function countAllFemales(val) { return val.reduce(function(prev, current) { return Number(prev) + countFemales(current); }, 0); }; var countJs = function countJs(str) { return Number((str.match(/j/g) || []).length); }; var countJuveniles = function countJuveniles(str) { return countJs(str) === 1 && countNonNumeric(str) === 1 ? countNumbers(str) || 1 : 0; }; var countAllJuveniles = function countAllJuveniles(val) { return val.reduce(function(prev, current) { return Number(prev) + countJuveniles(current); }, 0); }; var countIs = function countIs(str) { return Number((str.match(/i/g) || []).length); }; var countImmatures = function countImmatures(str) { return countIs(str) === 1 && countNonNumeric(str) === 1 ? countNumbers(str) || 1 : 0; }; var countUnspecifiedImmatures = function countUnspecifiedImmatures(val) { return val.reduce(function(prev, current) { return Number(prev) + countImmatures(current); }, 0); }; var countAs = function countAs(str) { return Number((str.match(/a/g) || []).length); }; var countAdults = function countAdults(str) { return countAs(str) === 1 && countNonNumeric(str) === 1 ? countNumbers(str) || 1 : 0; }; var countUnspecifiedAdults = function countUnspecifiedAdults(val) { return val.reduce(function(prev, current) { return Number(prev) + countAdults(current); }, 0); }; var countXs = function countXs(str) { return Number((str.match(/x/g) || []).length); }; var countChecks = function countChecks(val) { return val.reduce(function(prev, current) { return countXs(current) === 1 ? true : prev; }, false); }; var countNonNumeric = function countNonNumeric(str) { return Number((str.match(/\D/g) || []).length); }; var countValidCharacters = function countValidCharacters(str) { return Number((str.match(/a|i|j|f|m|x/g) || []).length); }; var countUnspecified = function countUnspecified(val) { return val.reduce(function(prev, current) { return Number(prev) + (/[^$,\.\d]/.test(current) ? 0 : countNumbers(current)); }, 0); }; function countCombo(val) { return val.reduce(function(prev, current) { if (countAs(current) === 1 && (countFs(current) === 1 || countMs(current) === 1)) { countMs(current) ? prev.male.adult += countNumbers(current) : null; countFs(current) ? prev.female.adult += countNumbers(current) : null; } else if (countIs(current) === 1 && (countFs(current) === 1 || countMs(current) === 1)) { countFs(current) ? prev.female.immature += countNumbers(current) : null; countMs(current) ? prev.male.immature += countNumbers(current) : null; } return prev; }, { female: { immature: 0, adult: 0 }, male: { immature: 0, adult: 0 } }); } var implodeString = function implodeString(arr) { return arr.length ? arr.join(' ') : []; }; var explodeString_ = function explodeString_(str) { return str ? str.split(' ') : []; }; var explodeString = memoize(explodeString_); var discardInvalid = function discardInvalid(arr) { return (arr || []).filter(function(str) { return countValidCharacters(str) === countNonNumeric(str) ? true : false; }); }; var extractQuotes = function extractQuotes(str) { return str.match(/\"(.[\s\S]*?)\"/gm) || []; }; var removeQuotes = function removeQuotes(str) { return str.replace(/(['"])((\\\1|.)*?)\1/gm, ''); }; function removeTaxon(str) { if (str.substring(0, 2) === '[]') return str.substring(2); return getCustomTaxon(str).length ? str.substring(getCustomTaxon(str)[0].length) : str.substring(4); } var convertHardLineBreaks = function convertHardLineBreaks(str) { return str ? str.replace(/(\r\n|\n|\r)/gm, '; ') : null; }; var gatherComments = function gatherComments(str) { return extractQuotes(str).map(convertHardLineBreaks).map(trimString); }; var gatherInvalid = function gatherInvalid(arr) { return (arr.slice(1) || []).reduce(function(prev, current) { return countValidCharacters(current) !== countNonNumeric(current) ? prev.concat(current) : prev; }, []); }; var getBand4Code = function getBand4Code(str) { return str.substring(0, 4); }; var trimString = function trimString(str) { return str ? str.substring(1, str.length - 1) : null; }; var getEmptyTaxon = function getEmptyTaxon(str) { return str.substring(0, 2) === '[]' ? ['[passerine sp.]'] : false; }; var getCustomTaxon = function getCustomTaxon(str) { return getEmptyTaxon(str) || str.match(/\[([^)]+)\]/g) || []; }; var getSpecies = function getSpecies(str) { return getCustomTaxon(str).length ? trimString(getCustomTaxon(str)[0]) : getBand4Code(str); }; var breakOutInvalid = _functional2.default.compose(implodeString, gatherInvalid, explodeString, removeQuotes, removeTaxon); var breakOutSpecies_ = _functional2.default.compose(discardInvalid, explodeString, removeQuotes, removeTaxon); var breakOutSpecies = memoize(breakOutSpecies_); var calcPhenotypes_ = function calcPhenotypes_(str) { return _Count2.default.of(breakOutSpecies(str)).map(countCombo); }; var calcPhenotypes = memoize(calcPhenotypes_); var getPhenotype = function getPhenotype(str) { return function(arr) { return calcPhenotypes(str).map(function(val) { return val[arr[0]][arr[1]]; }); }; }; function calculateTaxonLine(str) { return { identifier: _Maybe2.default.of(getSpecies(str)), check: _Maybe2.default.of(breakOutSpecies(str)).map(countChecks), comment: _Maybe2.default.of(gatherComments(str).concat(breakOutInvalid(str))), get commonName() { return _Maybe2.default.of(_birdbrain2.default[this.identifier.emit()] ? _birdbrain2.default[this.identifier.emit()].name : this.identifier.join()); }, get scientificName() { return _Maybe2.default.of(_birdbrain2.default[this.identifier.emit()] ? _birdbrain2.default[this.identifier.emit()].scientificName : this.identifier.join()); }, phenotype: { male: { total: _Count2.default.of(breakOutSpecies(str)).map(countAllMales), immature: getPhenotype(str)(['male', 'immature']), adult: getPhenotype(str)(['male', 'adult']), get unspecified() { return _Count2.default.of(this.total.toInt() - this.immature.toInt() - this.adult.toInt()); } }, female: { total: _Count2.default.of(breakOutSpecies(str)).map(countAllFemales), immature: getPhenotype(str)(['female', 'immature']), adult: getPhenotype(str)(['female', 'adult']), get unspecified() { return _Count2.default.of(this.total.toInt() - this.immature.toInt() - this.adult.toInt()); } }, juvenile: _Count2.default.of(breakOutSpecies(str)).map(countAllJuveniles), immature: _Count2.default.of(breakOutSpecies(str)).map(countUnspecifiedImmatures), adult: _Count2.default.of(breakOutSpecies(str)).map(countUnspecifiedAdults), unspecified: _Count2.default.of(breakOutSpecies(str)).map(countUnspecified) } }; } exports.default = calculateTaxonLine; return module.exports; }); $__System.registerDynamic("9", ["2", "5", "7"], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); exports.default = undefined; var _effortLine = $__require('2'); var _effortLine2 = _interopRequireDefault(_effortLine); var _locationLine = $__require('5'); var _locationLine2 = _interopRequireDefault(_locationLine); var _taxonLine = $__require('7'); var _taxonLine2 = _interopRequireDefault(_taxonLine); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {default: obj}; } var processLines = function processLines(arr) { return arr.reduce(function(prev, current, index) { switch (index) { case 0: { var location = (0, _locationLine2.default)(current); Object.assign(prev, location); break; } case 1: { var effort = (0, _effortLine2.default)(current); Object.assign(prev, effort); break; } default: { if (!current) return prev; var taxon = (0, _taxonLine2.default)(current); prev.species.push(taxon); break; } } return prev; }, {species: []}); }; var checklist = function checklist(str) { return processLines(str.split(/\n/)); }; exports.default = checklist; return module.exports; }); $__System.registerDynamic("a", [], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { return typeof obj; } : function(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; function toCsvValue(theValue, sDelimiter) { var t = typeof theValue === "undefined" ? "undefined" : _typeof(theValue); var output = void 0, stringDelimiter = void 0; if (typeof sDelimiter === "undefined" || sDelimiter === null) stringDelimiter = '"'; else stringDelimiter = sDelimiter; if (t === "undefined" || t === null) output = ''; else if (t === 'string') output = sDelimiter + theValue + sDelimiter; else output = String(theValue); return output; } function toCsv(objArray, sDelimiter, cDelimiter) { var i = void 0, l = void 0, names = [], name = void 0, value = void 0, obj = void 0, row = void 0, output = "", n = void 0, nl = void 0; if (typeof sDelimiter === "undefined" || sDelimiter === null) { sDelimiter = '"'; } if (typeof cDelimiter === "undefined" || cDelimiter === null) { cDelimiter = ","; } for (i = 0, l = objArray.length; i < l; i += 1) { obj = objArray[i]; row = ""; if (i === 0) { for (name in obj) { if (obj.hasOwnProperty(name)) { names.push(name); row += [sDelimiter, name, sDelimiter, cDelimiter].join(""); } } row = row.substring(0, row.length - 1); output += row; } output += "\n"; row = ""; for (n = 0, nl = names.length; n < nl; n += 1) { name = names[n]; value = obj[name]; if (n > 0) { row += ","; } row += toCsvValue(value, '"'); } output += row; } return output; } exports.default = toCsv; return module.exports; }); $__System.registerDynamic("8", [], true, function($__require, exports, module) { "use strict"; ; var define, global = this, GLOBAL = this; Object.defineProperty(exports, "__esModule", {value: true}); var birdBrain = { "ABDU": { "name": "American Black Duck", "scientificName": "Anas rubripes", "abaCode": 1 }, "ABDX": { "name": "American Black Duck Dominant x Mallard Hybrid", "scientificName": "Anas platyrhynchos", "abaCode": 1 }, "ABTO": { "name": "Abert's Towhee", "scientificName": "Melozone aberti", "abaCode": 1 }, "ACFL": { "name": "Acadian Flycatcher", "scientificName": "Empidonax virescens", "abaCode": 1 }, "ACGO": { "name": "Aleutian Cackling Goose", "scientificName": "Branta hutchinsii", "abaCode": 1 }, "ACHU": { "name": "Antillean Crested Hummingbird", "scientificName": "", "abaCode": 0 }, "ACWO": { "name": "Acorn Woodpecker", "scientificName": "Melanerpes formicivorus", "abaCode": 1 }, "ADPE": { "name": "Adélie Penguin", "scientificName": "", "abaCode": 0 }, "ADWA": { "name": "Adelaide's Warbler", "scientificName": "", "abaCode": 0 }, "AFCD": { "name": "African Collared-Dove", "scientificName": "", "abaCode": 0 }, "AFOW": { "name": "Ashy-faced Owl", "scientificName": "", "abaCode": 0 }, "AFPE": { "name": "African Penguin", "scientificName": "", "abaCode": 0 }, "AFSI": { "name": "African Silverbill", "scientificName": "", "abaCode": 0 }, "AGWT": { "name": "American Green-winged Teal", "scientificName": "Anas crecca", "abaCode": 1 }, "AKEK": { "name": "ʻAkekeʻe", "scientificName": "", "abaCode": 0 }, "AKEP": { "name": "ʻAkepa", "scientificName": "", "abaCode": 0 }, "AKIK": { "name": "ʻAkikiki", "scientificName": "", "abaCode": 0 }, "AKIP": { "name": "ʻAkiapōlāʻau", "scientificName": "", "abaCode": 0 }, "AKOH": { "name": "ʻAkohekohe", "scientificName": "", "abaCode": 0 }, "ALFL": { "name": "Alder Flycatcher", "scientificName": "Empidonax alnorum", "abaCode": 1 }, "ALHU": { "name": "Allen's Hummingbird", "scientificName": "Selasphorus sasin", "abaCode": 1 }, "ALOR": { "name": "Altamira Oriole", "scientificName": "Icterus gularis", "abaCode": 2 }, "ALTE": { "name": "Aleutian Tern", "scientificName": "Onychoprion aleuticus", "abaCode": 2 }, "AMAV": { "name": "American Avocet", "scientificName": "Recurvirostra americana", "abaCode": 1 }, "AMBI": { "name": "American Bittern", "scientificName": "Botaurus lentiginosus", "abaCode": 1 }, "AMCO": { "name": "American Coot", "scientificName": "Fulica americana", "abaCode": 1 }, "AMCR": { "name": "American Crow", "scientificName": "Corvus brachyrhynchos", "abaCode": 1 }, "AMDI": { "name": "American Dipper", "scientificName": "Cinclus mexicanus", "abaCode": 1 }, "AMFL": { "name": "American Flamingo", "scientificName": "Phoenicopterus ruber", "abaCode": 3 }, "AMGO": { "name": "American Goldfinch", "scientificName": "Spinus tristis", "abaCode": 1 }, "AMGP": { "name": "American Golden-Plover", "scientificName": "Pluvialis dominica", "abaCode": 1 }, "AMKE": { "name": "American Kestrel", "scientificName": "Falco sparverius", "abaCode": 1 }, "AMOY": { "name": "American Oystercatcher", "scientificName": "Haematopus palliatus", "abaCode": 1 }, "AMPI": { "name": "American Pipit", "scientificName": "Anthus rubescens", "abaCode": 1 }, "AMRE": { "name": "American Redstart", "scientificName": "Setophaga ruticilla", "abaCode": 1 }, "AMRO": { "name": "American Robin", "scientificName": "Turdus migratorius", "abaCode": 1 }, "AMWI": { "name": "American Wigeon", "scientificName": "Anas americana", "abaCode": 1 }, "AMWO": { "name": "American Woodcock", "scientificName": "Scolopax minor", "abaCode": 1 }, "ANEU": { "name": "Antillean Euphonia", "scientificName": "", "abaCode": 0 }, "ANHI": { "name": "Anhinga", "scientificName": "Anhinga anhinga", "abaCode": 1 }, "ANHU": { "name": "Anna's Hummingbird", "scientificName": "Calypte anna", "abaCode": 1 }, "ANIA": { "name": "ʻAnianiau", "scientificName": "", "abaCode": 0 }, "ANMA": { "name": "Antillean Mango", "scientificName": "", "abaCode": 0 }, "ANMU": { "name": "Ancient Murrelet", "scientificName": "Synthliboramphus antiquus", "abaCode": 2 }, "ANNI": { "name": "Antillean Nighthawk", "scientificName": "Chordeiles gundlachii", "abaCode": 2 }, "ANPE": { "name": "Antarctic Petrel", "scientificName": "", "abaCode": 0 }, "ANTE": { "name": "Antarctic Tern", "scientificName": "Sterna paradisaea", "abaCode": 1 }, "APAP": { "name": "ʻApapane", "scientificName": "", "abaCode": 0 }, "APFA": { "name": "Aplomado Falcon", "scientificName": "Falco femoralis", "abaCode": 3 }, "ARLO": { "name": "Arctic Loon", "scientificName": "Gavia arctica", "abaCode": 2 }, "ARRW": { "name": "Arrowhead Warbler", "scientificName": "", "abaCode": 0 }, "ARTE": { "name": "Arctic Tern", "scientificName": "Sterna paradisaea", "abaCode": 1 }, "ARWA": { "name": "Arctic Warbler", "scientificName": "Phylloscopus borealis", "abaCode": 2 }, "ASSP": { "name": "Ashy Storm-Petrel", "scientificName": "Oceanodroma homochroa", "abaCode": 2 }, "ATBR": { "name": "Atlantic Brant", "scientificName": "Branta bernicla", "abaCode": 1 }, "ATFL": { "name": "Ash-throated Flycatcher", "scientificName": "Myiarchus cinerascens", "abaCode": 1 }, "ATPU": { "name": "Atlantic Puffin", "scientificName": "Fratercula arctica", "abaCode": 1 }, "ATSP": { "name": "American Tree Sparrow", "scientificName": "Spizella arborea", "abaCode": 1 }, "ATTW": { "name": "American Three-toed Woodpecker", "scientificName": "Picoides dorsalis", "abaCode": 2 }, "AUOR": { "name": "Audubon's Oriole", "scientificName": "Icterus graduacauda", "abaCode": 2 }, "AUSH": { "name": "Audubon's Shearwater", "scientificName": "Puffinus lherminieri", "abaCode": 1 }, "AUWA": { "name": "Audubon's Warbler", "scientificName": "", "abaCode": 0 }, "AWPE": { "name": "American White Pelican", "scientificName": "Pelecanus erythrorhynchos", "abaCode": 1 }, "AZTH": { "name": "Aztec Thrush", "scientificName": "Ridgwayia pinicola", "abaCode": 4 }, "BABI": { "name": "Black x Atlantic Brant Intergrade", "scientificName": "", "abaCode": 0 }, "BACG": { "name": "Baja Gnatcatcher", "scientificName": "", "abaCode": 0 }, "BACS": { "name": "Bachman's Sparrow", "scientificName": "Peucaea aestivalis", "abaCode": 2 }, "BAEA": { "name": "Bald Eagle", "scientificName": "Haliaeetus leucocephalus", "abaCode": 1 }, "BAGO": { "name": "Barrow's Goldeneye", "scientificName": "Bucephala islandica", "abaCode": 1 }, "BAHS": { "name": "Bahama Swallow", "scientificName": "Tachycineta cyaneoviridis", "abaCode": 4 }, "BAIS": { "name": "Baird's Sparrow", "scientificName": "Ammodramus bairdii", "abaCode": 2 }, "BAMO": { "name": "Bahama Mockingbird", "scientificName": "Mimus gundlachii", "abaCode": 4 }, "BANA": { "name": "Bananaquit", "scientificName": "Coereba flaveola", "abaCode": 4 }, "BANP": { "name": "Band-rumped Storm-Petrel", "scientificName": "Oceanodroma castro", "abaCode": 2 }, "BANS": { "name": "Bank Swallow", "scientificName": "Riparia riparia", "abaCode": 1 }, "BAOR": { "name": "Baltimore Oriole", "scientificName": "Icterus galbula", "abaCode": 1 }, "BARG": { "name": "Bar-tailed Godwit", "scientificName": "Limosa lapponica", "abaCode": 2 }, "BARS": { "name": "Barn Swallow", "scientificName": "Hirundo rustica", "abaCode": 1 }, "BASA": { "name": "Baird's Sandpiper", "scientificName": "Calidris bairdii", "abaCode": 1 }, "BATE": { "name": "Baikal Teal", "scientificName": "Anas formosa", "abaCode": 4 }, "BAWO": { "name": "Bahama Woodstar", "scientificName": "Calliphlox evelynae", "abaCode": 5 }, "BAWW": { "name": "Black-and-white Warbler", "scientificName": "Mniotilta varia", "abaCode": 1 }, "BAYE": { "name": "Bahama Yellowthroat", "scientificName": "", "abaCode": 0 }, "BBAL": { "name": "Black-browed Albatross", "scientificName": "Thalassarche melanophris", "abaCode": 5 }, "BBCU": { "name": "Black-billed Cuckoo", "scientificName": "Coccyzus erythropthalmus", "abaCode": 1 }, "BBFL": { "name": "Buff-breasted Flycatcher", "scientificName": "Empidonax fulvifrons", "abaCode": 2 }, "BBGR": { "name": "Blue-black Grassquit", "scientificName": "", "abaCode": 0 }, "BBLH": { "name": "Broad-billed Hummingbird", "scientificName": "Cynanthus latirostris", "abaCode": 2 }, "BBMA": { "name": "Black-billed Magpie", "scientificName": "Pica hudsonia", "abaCode": 1 }, "BBOH": { "name": "Baltimore x Bullock's Oriole Hybrid", "scientificName": "Icterus bullockii", "abaCode": 1 }, "BBPL": { "name": "Black-bellied Plover", "scientificName": "Pluvialis squatarola", "abaCode": 1 }, "BBPR": { "name": "Broad-billed Prion", "scientificName": "", "abaCode": 0 }, "BBRA": { "name": "Buff-banded Rail", "scientificName": "", "abaCode": 0 }, "BBSA": { "name": "Buff-breasted Sandpiper", "scientificName": "Tryngites subruficollis", "abaCode": 1 }, "BBWA": { "name": "Bay-breasted Warbler", "scientificName": "Setophaga castanea", "abaCode": 1 }, "BBWD": { "name": "Black-bellied Whistling-Duck", "scientificName": "Dendrocygna autumnalis", "abaCode": 1 }, "BBWO": { "name": "Black-backed Woodpecker", "scientificName": "Picoides arcticus", "abaCode": 2 }, "BCCH": { "name": "Black-capped Chickadee", "scientificName": "Poecile atricapillus", "abaCode": 1 }, "BCFL": { "name": "Brown-crested Flycatcher", "scientificName": "Myiarchus tyrannulus", "abaCode": 1 }, "BCGN": { "name": "Black-capped Gnatcatcher", "scientificName": "Polioptila nigriceps", "abaCode": 3 }, "BCHU": { "name": "Black-chinned Hummingbird", "scientificName": "Archilochus alexandri", "abaCode": 1 }, "BCLO": { "name": "Blue-crowned Lorikeet", "scientificName": "", "abaCode": 0 }, "BCNH": { "name": "Black-crowned Night-Heron", "scientificName": "Nycticorax nycticorax", "abaCode": 1 }, "BCNI": { "name": "Buff-collared Nightjar", "scientificName": "Antrostomus ridgwayi", "abaCode": 3 }, "BCOR": { "name": "Black-cowled Oriole", "scientificName": "", "abaCode": 0 }, "BCPE": { "name": "Black-capped Petrel", "scientificName": "Pterodroma hasitata", "abaCode": 2 }, "BCRF": { "name": "Brown-capped Rosy Finch", "scientificName": "", "abaCode": 0 }, "BCSP": { "name": "Black-chinned Sparrow", "scientificName": "Spizella atrogularis", "abaCode": 1 }, "BCTI": { "name": "Black-crested Titmouse", "scientificName": "Baeolophus atricristatus", "abaCode": 2 }, "BCVI": { "name": "Black-capped Vireo", "scientificName": "Vireo atricapilla", "abaCode": 2 }, "BDOW": { "name": "Barred Owl", "scientificName": "Strix varia", "abaCode": 1 }, "BECO": { "name": "Blue-eyed Cormorant", "scientificName": "", "abaCode": 0 }, "BEHU": { "name": "Berylline Hummingbird", "scientificName": "Amazilia beryllina", "abaCode": 3 }, "BEKI": { "name": "Belted Kingfisher", "scientificName": "Megaceryle alcyon", "abaCode": 1 }, "BESW": { "name": "Bewick's Swan", "scientificName": "", "abaCode": 0 }, "BETH": { "name": "Bendire's Thrasher", "scientificName": "Toxostoma bendirei", "abaCode": 2 }, "BEVI": { "name": "Bell's Vireo", "scientificName": "Vireo bellii", "abaCode": 1 }, "BEWR": { "name": "Bewick's Wren", "scientificName": "Thryomanes bewickii", "abaCode": 1 }, "BFAL": { "name": "Black-footed Albatross", "scientificName": "Phoebastria nigripes", "abaCode": 1 }, "BFBO": { "name": "Blue-footed Booby", "scientificName": "Sula nebouxii", "abaCode": 4 }, "BFGR": { "name": "Black-faced Grassquit", "scientificName": "Tiaris bicolor", "abaCode": 4 }, "BGGN": { "name": "Blue-gray Gnatcatcher", "scientificName": "Polioptila caerulea", "abaCode": 1 }, "BGNO": { "name": "Blue-gray Noddy", "scientificName": "", "abaCode": 0 }, "BGSE": { "name": "Blue Grouse", "scientificName": "", "abaCode": 0 }, "BGSG": { "name": "Blue Greater Snow Goose", "scientificName": "Chen caerulescens", "abaCode": 1 }, "BHCO": { "name": "Brown-headed Cowbird", "scientificName": "Molothrus ater", "abaCode": 1 }, "BHGR": { "name": "Black-headed Grosbeak", "scientificName": "Pheucticus melanocephalus", "abaCode": 1 }, "BHGU": { "name": "Black-headed Gull", "scientificName": "Chroicocephalus ridibundus", "abaCode": 3 }, "BHNU": { "name": "Brown-headed Nuthatch", "scientificName": "Sitta pusilla", "abaCode": 1 }, "BHPA": { "name": "Black-headed Parakeet", "scientificName": "", "abaCode": 0 }, "BHVI": { "name": "Blue-headed Vireo", "scientificName": "Vireo solitarius", "abaCode": 1 }, "BIOO": { "name": "Bishop's Oo", "scientificName": "", "abaCode": 0 }, "BITH": { "name": "Bicknell's Thrush", "scientificName": "Catharus bicknelli", "abaCode": 2 }, "BLAG": { "name": "Black-tailed Godwit", "scientificName": "Limosa limosa", "abaCode": 3 }, "BLBR": { "name": "Black Brant", "scientificName": "", "abaCode": 0 }, "BLBU": { "name": "Blue Bunting", "scientificName": "Cyanocompsa parellina", "abaCode": 4 }, "BLBW": { "name": "Blackburnian Warbler", "scientificName": "Setophaga fusca", "abaCode": 1 }, "BLDR": { "name": "Black Drongo", "scientificName": "", "abaCode": 0 }, "BLGO": { "name": "Blue Goose", "scientificName": "", "abaCode": 0 }, "BLGR": { "name": "Blue Grosbeak", "scientificName": "Passerina caerulea", "abaCode": 1 }, "BLGU": { "name": "Black Guillemot", "scientificName": "Cepphus grylle", "abaCode": 1 }, "BLJA": { "name": "Blue Jay", "scientificName": "Cyanocitta cristata", "abaCode": 1 }, "BLKI": { "name": "Black-legged Kittiwake", "scientificName": "Rissa tridactyla", "abaCode": 1 }, "BLNO": { "name": "Black Noddy", "scientificName": "Anous minutus", "abaCode": 3 }, "BLOY": { "name": "B