/******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 1062:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
var __webpack_unused_export__;
__webpack_unused_export__ = ({
value: true
});
var key = {
fullscreenEnabled: 0,
fullscreenElement: 1,
requestFullscreen: 2,
exitFullscreen: 3,
fullscreenchange: 4,
fullscreenerror: 5,
fullscreen: 6
};
var webkit = ['webkitFullscreenEnabled', 'webkitFullscreenElement', 'webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitfullscreenchange', 'webkitfullscreenerror', '-webkit-full-screen'];
var moz = ['mozFullScreenEnabled', 'mozFullScreenElement', 'mozRequestFullScreen', 'mozCancelFullScreen', 'mozfullscreenchange', 'mozfullscreenerror', '-moz-full-screen'];
var ms = ['msFullscreenEnabled', 'msFullscreenElement', 'msRequestFullscreen', 'msExitFullscreen', 'MSFullscreenChange', 'MSFullscreenError', '-ms-fullscreen'];
// so it doesn't throw if no window or document
var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
var vendor = 'fullscreenEnabled' in document && Object.keys(key) || webkit[0] in document && webkit || moz[0] in document && moz || ms[0] in document && ms || [];
exports.A = {
requestFullscreen: function requestFullscreen(element) {
return element[vendor[key.requestFullscreen]]();
},
requestFullscreenFunction: function requestFullscreenFunction(element) {
return element[vendor[key.requestFullscreen]];
},
get exitFullscreen() {
return document[vendor[key.exitFullscreen]].bind(document);
},
get fullscreenPseudoClass() {
return ':' + vendor[key.fullscreen];
},
addEventListener: function addEventListener(type, handler, options) {
return document.addEventListener(vendor[key[type]], handler, options);
},
removeEventListener: function removeEventListener(type, handler, options) {
return document.removeEventListener(vendor[key[type]], handler, options);
},
get fullscreenEnabled() {
return Boolean(document[vendor[key.fullscreenEnabled]]);
},
set fullscreenEnabled(val) {},
get fullscreenElement() {
return document[vendor[key.fullscreenElement]];
},
set fullscreenElement(val) {},
get onfullscreenchange() {
return document[('on' + vendor[key.fullscreenchange]).toLowerCase()];
},
set onfullscreenchange(handler) {
return document[('on' + vendor[key.fullscreenchange]).toLowerCase()] = handler;
},
get onfullscreenerror() {
return document[('on' + vendor[key.fullscreenerror]).toLowerCase()];
},
set onfullscreenerror(handler) {
return document[('on' + vendor[key.fullscreenerror]).toLowerCase()] = handler;
}
};
/***/ }),
/***/ 6112:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
A: function() { return /* binding */ createCache; }
});
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/@emotion/sheet/dist/emotion-sheet.browser.esm.js
/*
Based off glamor's StyleSheet, thanks Sunil ❤️
high performance StyleSheet for css-in-js systems
- uses multiple style tags behind the scenes for millions of rules
- uses `insertRule` for appending in production for *much* faster performance
// usage
import { StyleSheet } from '@emotion/sheet'
let styleSheet = new StyleSheet({ key: '', container: document.head })
styleSheet.insert('#box { border: 1px solid red; }')
- appends a css rule into the stylesheet
styleSheet.flush()
- empties the stylesheet of all its contents
*/
// $FlowFixMe
function sheetForTag(tag) {
if (tag.sheet) {
// $FlowFixMe
return tag.sheet;
} // this weirdness brought to you by firefox
/* istanbul ignore next */
for (var i = 0; i < document.styleSheets.length; i++) {
if (document.styleSheets[i].ownerNode === tag) {
// $FlowFixMe
return document.styleSheets[i];
}
}
}
function createStyleElement(options) {
var tag = document.createElement('style');
tag.setAttribute('data-emotion', options.key);
if (options.nonce !== undefined) {
tag.setAttribute('nonce', options.nonce);
}
tag.appendChild(document.createTextNode(''));
tag.setAttribute('data-s', '');
return tag;
}
var StyleSheet = /*#__PURE__*/function () {
// Using Node instead of HTMLElement since container may be a ShadowRoot
function StyleSheet(options) {
var _this = this;
this._insertTag = function (tag) {
var before;
if (_this.tags.length === 0) {
if (_this.insertionPoint) {
before = _this.insertionPoint.nextSibling;
} else if (_this.prepend) {
before = _this.container.firstChild;
} else {
before = _this.before;
}
} else {
before = _this.tags[_this.tags.length - 1].nextSibling;
}
_this.container.insertBefore(tag, before);
_this.tags.push(tag);
};
this.isSpeedy = options.speedy === undefined ? "production" === 'production' : options.speedy;
this.tags = [];
this.ctr = 0;
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
this.key = options.key;
this.container = options.container;
this.prepend = options.prepend;
this.insertionPoint = options.insertionPoint;
this.before = null;
}
var _proto = StyleSheet.prototype;
_proto.hydrate = function hydrate(nodes) {
nodes.forEach(this._insertTag);
};
_proto.insert = function insert(rule) {
// the max length is how many rules we have per style tag, it's 65000 in speedy mode
// it's 1 in dev because we insert source maps that map a single rule to a location
// and you can only have one source map per style tag
if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {
this._insertTag(createStyleElement(this));
}
var tag = this.tags[this.tags.length - 1];
if (false) { var isImportRule; }
if (this.isSpeedy) {
var sheet = sheetForTag(tag);
try {
// this is the ultrafast version, works across browsers
// the big drawback is that the css won't be editable in devtools
sheet.insertRule(rule, sheet.cssRules.length);
} catch (e) {
if (false) {}
}
} else {
tag.appendChild(document.createTextNode(rule));
}
this.ctr++;
};
_proto.flush = function flush() {
// $FlowFixMe
this.tags.forEach(function (tag) {
return tag.parentNode && tag.parentNode.removeChild(tag);
});
this.tags = [];
this.ctr = 0;
if (false) {}
};
return StyleSheet;
}();
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/stylis/src/Utility.js
/**
* @param {number}
* @return {number}
*/
var abs = Math.abs
/**
* @param {number}
* @return {string}
*/
var Utility_from = String.fromCharCode
/**
* @param {object}
* @return {object}
*/
var Utility_assign = Object.assign
/**
* @param {string} value
* @param {number} length
* @return {number}
*/
function hash (value, length) {
return Utility_charat(value, 0) ^ 45 ? (((((((length << 2) ^ Utility_charat(value, 0)) << 2) ^ Utility_charat(value, 1)) << 2) ^ Utility_charat(value, 2)) << 2) ^ Utility_charat(value, 3) : 0
}
/**
* @param {string} value
* @return {string}
*/
function trim (value) {
return value.trim()
}
/**
* @param {string} value
* @param {RegExp} pattern
* @return {string?}
*/
function Utility_match (value, pattern) {
return (value = pattern.exec(value)) ? value[0] : value
}
/**
* @param {string} value
* @param {(string|RegExp)} pattern
* @param {string} replacement
* @return {string}
*/
function Utility_replace (value, pattern, replacement) {
return value.replace(pattern, replacement)
}
/**
* @param {string} value
* @param {string} search
* @return {number}
*/
function indexof (value, search) {
return value.indexOf(search)
}
/**
* @param {string} value
* @param {number} index
* @return {number}
*/
function Utility_charat (value, index) {
return value.charCodeAt(index) | 0
}
/**
* @param {string} value
* @param {number} begin
* @param {number} end
* @return {string}
*/
function Utility_substr (value, begin, end) {
return value.slice(begin, end)
}
/**
* @param {string} value
* @return {number}
*/
function Utility_strlen (value) {
return value.length
}
/**
* @param {any[]} value
* @return {number}
*/
function Utility_sizeof (value) {
return value.length
}
/**
* @param {any} value
* @param {any[]} array
* @return {any}
*/
function Utility_append (value, array) {
return array.push(value), value
}
/**
* @param {string[]} array
* @param {function} callback
* @return {string}
*/
function Utility_combine (array, callback) {
return array.map(callback).join('')
}
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/stylis/src/Tokenizer.js
var line = 1
var column = 1
var Tokenizer_length = 0
var position = 0
var character = 0
var characters = ''
/**
* @param {string} value
* @param {object | null} root
* @param {object | null} parent
* @param {string} type
* @param {string[] | string} props
* @param {object[] | string} children
* @param {number} length
*/
function node (value, root, parent, type, props, children, length) {
return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: ''}
}
/**
* @param {object} root
* @param {object} props
* @return {object}
*/
function Tokenizer_copy (root, props) {
return Utility_assign(node('', null, null, '', null, null, 0), root, {length: -root.length}, props)
}
/**
* @return {number}
*/
function Tokenizer_char () {
return character
}
/**
* @return {number}
*/
function prev () {
character = position > 0 ? Utility_charat(characters, --position) : 0
if (column--, character === 10)
column = 1, line--
return character
}
/**
* @return {number}
*/
function next () {
character = position < Tokenizer_length ? Utility_charat(characters, position++) : 0
if (column++, character === 10)
column = 1, line++
return character
}
/**
* @return {number}
*/
function peek () {
return Utility_charat(characters, position)
}
/**
* @return {number}
*/
function caret () {
return position
}
/**
* @param {number} begin
* @param {number} end
* @return {string}
*/
function slice (begin, end) {
return Utility_substr(characters, begin, end)
}
/**
* @param {number} type
* @return {number}
*/
function token (type) {
switch (type) {
// \0 \t \n \r \s whitespace token
case 0: case 9: case 10: case 13: case 32:
return 5
// ! + , / > @ ~ isolate token
case 33: case 43: case 44: case 47: case 62: case 64: case 126:
// ; { } breakpoint token
case 59: case 123: case 125:
return 4
// : accompanied token
case 58:
return 3
// " ' ( [ opening delimit token
case 34: case 39: case 40: case 91:
return 2
// ) ] closing delimit token
case 41: case 93:
return 1
}
return 0
}
/**
* @param {string} value
* @return {any[]}
*/
function alloc (value) {
return line = column = 1, Tokenizer_length = Utility_strlen(characters = value), position = 0, []
}
/**
* @param {any} value
* @return {any}
*/
function dealloc (value) {
return characters = '', value
}
/**
* @param {number} type
* @return {string}
*/
function delimit (type) {
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))
}
/**
* @param {string} value
* @return {string[]}
*/
function Tokenizer_tokenize (value) {
return dealloc(tokenizer(alloc(value)))
}
/**
* @param {number} type
* @return {string}
*/
function whitespace (type) {
while (character = peek())
if (character < 33)
next()
else
break
return token(type) > 2 || token(character) > 3 ? '' : ' '
}
/**
* @param {string[]} children
* @return {string[]}
*/
function tokenizer (children) {
while (next())
switch (token(character)) {
case 0: append(identifier(position - 1), children)
break
case 2: append(delimit(character), children)
break
default: append(from(character), children)
}
return children
}
/**
* @param {number} index
* @param {number} count
* @return {string}
*/
function escaping (index, count) {
while (--count && next())
// not 0-9 A-F a-f
if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))
break
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))
}
/**
* @param {number} type
* @return {number}
*/
function delimiter (type) {
while (next())
switch (character) {
// ] ) " '
case type:
return position
// " '
case 34: case 39:
if (type !== 34 && type !== 39)
delimiter(character)
break
// (
case 40:
if (type === 41)
delimiter(type)
break
// \
case 92:
next()
break
}
return position
}
/**
* @param {number} type
* @param {number} index
* @return {number}
*/
function commenter (type, index) {
while (next())
// //
if (type + character === 47 + 10)
break
// /*
else if (type + character === 42 + 42 && peek() === 47)
break
return '/*' + slice(index, position - 1) + '*' + Utility_from(type === 47 ? type : next())
}
/**
* @param {number} index
* @return {string}
*/
function identifier (index) {
while (!token(peek()))
next()
return slice(index, position)
}
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/stylis/src/Enum.js
var Enum_MS = '-ms-'
var Enum_MOZ = '-moz-'
var Enum_WEBKIT = '-webkit-'
var COMMENT = 'comm'
var Enum_RULESET = 'rule'
var Enum_DECLARATION = 'decl'
var PAGE = '@page'
var MEDIA = '@media'
var IMPORT = '@import'
var CHARSET = '@charset'
var VIEWPORT = '@viewport'
var SUPPORTS = '@supports'
var DOCUMENT = '@document'
var NAMESPACE = '@namespace'
var Enum_KEYFRAMES = '@keyframes'
var FONT_FACE = '@font-face'
var COUNTER_STYLE = '@counter-style'
var FONT_FEATURE_VALUES = '@font-feature-values'
var LAYER = '@layer'
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/stylis/src/Serializer.js
/**
* @param {object[]} children
* @param {function} callback
* @return {string}
*/
function Serializer_serialize (children, callback) {
var output = ''
var length = Utility_sizeof(children)
for (var i = 0; i < length; i++)
output += callback(children[i], i, children, callback) || ''
return output
}
/**
* @param {object} element
* @param {number} index
* @param {object[]} children
* @param {function} callback
* @return {string}
*/
function stringify (element, index, children, callback) {
switch (element.type) {
case LAYER: if (element.children.length) break
case IMPORT: case Enum_DECLARATION: return element.return = element.return || element.value
case COMMENT: return ''
case Enum_KEYFRAMES: return element.return = element.value + '{' + Serializer_serialize(element.children, callback) + '}'
case Enum_RULESET: element.value = element.props.join(',')
}
return Utility_strlen(children = Serializer_serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''
}
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/stylis/src/Middleware.js
/**
* @param {function[]} collection
* @return {function}
*/
function middleware (collection) {
var length = Utility_sizeof(collection)
return function (element, index, children, callback) {
var output = ''
for (var i = 0; i < length; i++)
output += collection[i](element, index, children, callback) || ''
return output
}
}
/**
* @param {function} callback
* @return {function}
*/
function rulesheet (callback) {
return function (element) {
if (!element.root)
if (element = element.return)
callback(element)
}
}
/**
* @param {object} element
* @param {number} index
* @param {object[]} children
* @param {function} callback
*/
function prefixer (element, index, children, callback) {
if (element.length > -1)
if (!element.return)
switch (element.type) {
case DECLARATION: element.return = prefix(element.value, element.length, children)
return
case KEYFRAMES:
return serialize([copy(element, {value: replace(element.value, '@', '@' + WEBKIT)})], callback)
case RULESET:
if (element.length)
return combine(element.props, function (value) {
switch (match(value, /(::plac\w+|:read-\w+)/)) {
// :read-(only|write)
case ':read-only': case ':read-write':
return serialize([copy(element, {props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]})], callback)
// :placeholder
case '::placeholder':
return serialize([
copy(element, {props: [replace(value, /:(plac\w+)/, ':' + WEBKIT + 'input-$1')]}),
copy(element, {props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]}),
copy(element, {props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]})
], callback)
}
return ''
})
}
}
/**
* @param {object} element
* @param {number} index
* @param {object[]} children
*/
function namespace (element) {
switch (element.type) {
case RULESET:
element.props = element.props.map(function (value) {
return combine(tokenize(value), function (value, index, children) {
switch (charat(value, 0)) {
// \f
case 12:
return substr(value, 1, strlen(value))
// \0 ( + > ~
case 0: case 40: case 43: case 62: case 126:
return value
// :
case 58:
if (children[++index] === 'global')
children[index] = '', children[++index] = '\f' + substr(children[index], index = 1, -1)
// \s
case 32:
return index === 1 ? '' : value
default:
switch (index) {
case 0: element = value
return sizeof(children) > 1 ? '' : value
case index = sizeof(children) - 1: case 2:
return index === 2 ? value + element + element : value + element
default:
return value
}
}
})
})
}
}
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/stylis/src/Parser.js
/**
* @param {string} value
* @return {object[]}
*/
function compile (value) {
return dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))
}
/**
* @param {string} value
* @param {object} root
* @param {object?} parent
* @param {string[]} rule
* @param {string[]} rules
* @param {string[]} rulesets
* @param {number[]} pseudo
* @param {number[]} points
* @param {string[]} declarations
* @return {object}
*/
function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
var index = 0
var offset = 0
var length = pseudo
var atrule = 0
var property = 0
var previous = 0
var variable = 1
var scanning = 1
var ampersand = 1
var character = 0
var type = ''
var props = rules
var children = rulesets
var reference = rule
var characters = type
while (scanning)
switch (previous = character, character = next()) {
// (
case 40:
if (previous != 108 && Utility_charat(characters, length - 1) == 58) {
if (indexof(characters += Utility_replace(delimit(character), '&', '&\f'), '&\f') != -1)
ampersand = -1
break
}
// " ' [
case 34: case 39: case 91:
characters += delimit(character)
break
// \t \n \r \s
case 9: case 10: case 13: case 32:
characters += whitespace(previous)
break
// \
case 92:
characters += escaping(caret() - 1, 7)
continue
// /
case 47:
switch (peek()) {
case 42: case 47:
Utility_append(comment(commenter(next(), caret()), root, parent), declarations)
break
default:
characters += '/'
}
break
// {
case 123 * variable:
points[index++] = Utility_strlen(characters) * ampersand
// } ; \0
case 125 * variable: case 59: case 0:
switch (character) {
// \0 }
case 0: case 125: scanning = 0
// ;
case 59 + offset: if (ampersand == -1) characters = Utility_replace(characters, /\f/g, '')
if (property > 0 && (Utility_strlen(characters) - length))
Utility_append(property > 32 ? declaration(characters + ';', rule, parent, length - 1) : declaration(Utility_replace(characters, ' ', '') + ';', rule, parent, length - 2), declarations)
break
// @ ;
case 59: characters += ';'
// { rule/at-rule
default:
Utility_append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets)
if (character === 123)
if (offset === 0)
parse(characters, root, reference, reference, props, rulesets, length, points, children)
else
switch (atrule === 99 && Utility_charat(characters, 3) === 110 ? 100 : atrule) {
// d l m s
case 100: case 108: case 109: case 115:
parse(value, reference, reference, rule && Utility_append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children)
break
default:
parse(characters, reference, reference, reference, [''], children, 0, points, children)
}
}
index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo
break
// :
case 58:
length = 1 + Utility_strlen(characters), property = previous
default:
if (variable < 1)
if (character == 123)
--variable
else if (character == 125 && variable++ == 0 && prev() == 125)
continue
switch (characters += Utility_from(character), character * variable) {
// &
case 38:
ampersand = offset > 0 ? 1 : (characters += '\f', -1)
break
// ,
case 44:
points[index++] = (Utility_strlen(characters) - 1) * ampersand, ampersand = 1
break
// @
case 64:
// -
if (peek() === 45)
characters += delimit(next())
atrule = peek(), offset = length = Utility_strlen(type = characters += identifier(caret())), character++
break
// -
case 45:
if (previous === 45 && Utility_strlen(characters) == 2)
variable = 0
}
}
return rulesets
}
/**
* @param {string} value
* @param {object} root
* @param {object?} parent
* @param {number} index
* @param {number} offset
* @param {string[]} rules
* @param {number[]} points
* @param {string} type
* @param {string[]} props
* @param {string[]} children
* @param {number} length
* @return {object}
*/
function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length) {
var post = offset - 1
var rule = offset === 0 ? rules : ['']
var size = Utility_sizeof(rule)
for (var i = 0, j = 0, k = 0; i < index; ++i)
for (var x = 0, y = Utility_substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)
if (z = trim(j > 0 ? rule[x] + ' ' + y : Utility_replace(y, /&\f/g, rule[x])))
props[k++] = z
return node(value, root, parent, offset === 0 ? Enum_RULESET : type, props, children, length)
}
/**
* @param {number} value
* @param {object} root
* @param {object?} parent
* @return {object}
*/
function comment (value, root, parent) {
return node(value, root, parent, COMMENT, Utility_from(Tokenizer_char()), Utility_substr(value, 2, -2), 0)
}
/**
* @param {string} value
* @param {object} root
* @param {object?} parent
* @param {number} length
* @return {object}
*/
function declaration (value, root, parent, length) {
return node(value, root, parent, Enum_DECLARATION, Utility_substr(value, 0, length), Utility_substr(value, length + 1, -1), length)
}
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
var previous = 0;
var character = 0;
while (true) {
previous = character;
character = peek(); // &\f
if (previous === 38 && character === 12) {
points[index] = 1;
}
if (token(character)) {
break;
}
next();
}
return slice(begin, position);
};
var toRules = function toRules(parsed, points) {
// pretend we've started with a comma
var index = -1;
var character = 44;
do {
switch (token(character)) {
case 0:
// &\f
if (character === 38 && peek() === 12) {
// this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
// stylis inserts \f after & to know when & where it should replace this sequence with the context selector
// and when it should just concatenate the outer and inner selectors
// it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
points[index] = 1;
}
parsed[index] += identifierWithPointTracking(position - 1, points, index);
break;
case 2:
parsed[index] += delimit(character);
break;
case 4:
// comma
if (character === 44) {
// colon
parsed[++index] = peek() === 58 ? '&\f' : '';
points[index] = parsed[index].length;
break;
}
// fallthrough
default:
parsed[index] += Utility_from(character);
}
} while (character = next());
return parsed;
};
var getRules = function getRules(value, points) {
return dealloc(toRules(alloc(value), points));
}; // WeakSet would be more appropriate, but only WeakMap is supported in IE11
var fixedElements = /* #__PURE__ */new WeakMap();
var compat = function compat(element) {
if (element.type !== 'rule' || !element.parent || // positive .length indicates that this rule contains pseudo
// negative .length indicates that this rule has been already prefixed
element.length < 1) {
return;
}
var value = element.value,
parent = element.parent;
var isImplicitRule = element.column === parent.column && element.line === parent.line;
while (parent.type !== 'rule') {
parent = parent.parent;
if (!parent) return;
} // short-circuit for the simplest case
if (element.props.length === 1 && value.charCodeAt(0) !== 58
/* colon */
&& !fixedElements.get(parent)) {
return;
} // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
// then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
if (isImplicitRule) {
return;
}
fixedElements.set(element, true);
var points = [];
var rules = getRules(value, points);
var parentRules = parent.props;
for (var i = 0, k = 0; i < rules.length; i++) {
for (var j = 0; j < parentRules.length; j++, k++) {
element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
}
}
};
var removeLabel = function removeLabel(element) {
if (element.type === 'decl') {
var value = element.value;
if ( // charcode for l
value.charCodeAt(0) === 108 && // charcode for b
value.charCodeAt(2) === 98) {
// this ignores label
element["return"] = '';
element.value = '';
}
}
};
var ignoreFlag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';
var isIgnoringComment = function isIgnoringComment(element) {
return element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
};
var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
return function (element, index, children) {
if (element.type !== 'rule' || cache.compat) return;
var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
if (unsafePseudoClasses) {
var isNested = !!element.parent; // in nested rules comments become children of the "auto-inserted" rule and that's always the `element.parent`
//
// considering this input:
// .a {
// .b /* comm */ {}
// color: hotpink;
// }
// we get output corresponding to this:
// .a {
// & {
// /* comm */
// color: hotpink;
// }
// .b {}
// }
var commentContainer = isNested ? element.parent.children : // global rule at the root level
children;
for (var i = commentContainer.length - 1; i >= 0; i--) {
var node = commentContainer[i];
if (node.line < element.line) {
break;
} // it is quite weird but comments are *usually* put at `column: element.column - 1`
// so we seek *from the end* for the node that is earlier than the rule's `element` and check that
// this will also match inputs like this:
// .a {
// /* comm */
// .b {}
// }
//
// but that is fine
//
// it would be the easiest to change the placement of the comment to be the first child of the rule:
// .a {
// .b { /* comm */ }
// }
// with such inputs we wouldn't have to search for the comment at all
// TODO: consider changing this comment placement in the next major version
if (node.column < element.column) {
if (isIgnoringComment(node)) {
return;
}
break;
}
}
unsafePseudoClasses.forEach(function (unsafePseudoClass) {
console.error("The pseudo class \"" + unsafePseudoClass + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + unsafePseudoClass.split('-child')[0] + "-of-type\".");
});
}
};
};
var isImportRule = function isImportRule(element) {
return element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64;
};
var isPrependedWithRegularRules = function isPrependedWithRegularRules(index, children) {
for (var i = index - 1; i >= 0; i--) {
if (!isImportRule(children[i])) {
return true;
}
}
return false;
}; // use this to remove incorrect elements from further processing
// so they don't get handed to the `sheet` (or anything else)
// as that could potentially lead to additional logs which in turn could be overhelming to the user
var nullifyElement = function nullifyElement(element) {
element.type = '';
element.value = '';
element["return"] = '';
element.children = '';
element.props = '';
};
var incorrectImportAlarm = function incorrectImportAlarm(element, index, children) {
if (!isImportRule(element)) {
return;
}
if (element.parent) {
console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles.");
nullifyElement(element);
} else if (isPrependedWithRegularRules(index, children)) {
console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.");
nullifyElement(element);
}
};
/* eslint-disable no-fallthrough */
function emotion_cache_browser_esm_prefix(value, length) {
switch (hash(value, length)) {
// color-adjust
case 5103:
return Enum_WEBKIT + 'print-' + value + value;
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
case 5737:
case 4201:
case 3177:
case 3433:
case 1641:
case 4457:
case 2921: // text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
case 5572:
case 6356:
case 5844:
case 3191:
case 6645:
case 3005: // mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
case 6391:
case 5879:
case 5623:
case 6135:
case 4599:
case 4855: // background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
case 4215:
case 6389:
case 5109:
case 5365:
case 5621:
case 3829:
return Enum_WEBKIT + value + value;
// appearance, user-select, transform, hyphens, text-size-adjust
case 5349:
case 4246:
case 4810:
case 6968:
case 2756:
return Enum_WEBKIT + value + Enum_MOZ + value + Enum_MS + value + value;
// flex, flex-direction
case 6828:
case 4268:
return Enum_WEBKIT + value + Enum_MS + value + value;
// order
case 6165:
return Enum_WEBKIT + value + Enum_MS + 'flex-' + value + value;
// align-items
case 5187:
return Enum_WEBKIT + value + Utility_replace(value, /(\w+).+(:[^]+)/, Enum_WEBKIT + 'box-$1$2' + Enum_MS + 'flex-$1$2') + value;
// align-self
case 5443:
return Enum_WEBKIT + value + Enum_MS + 'flex-item-' + Utility_replace(value, /flex-|-self/, '') + value;
// align-content
case 4675:
return Enum_WEBKIT + value + Enum_MS + 'flex-line-pack' + Utility_replace(value, /align-content|flex-|-self/, '') + value;
// flex-shrink
case 5548:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, 'shrink', 'negative') + value;
// flex-basis
case 5292:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, 'basis', 'preferred-size') + value;
// flex-grow
case 6060:
return Enum_WEBKIT + 'box-' + Utility_replace(value, '-grow', '') + Enum_WEBKIT + value + Enum_MS + Utility_replace(value, 'grow', 'positive') + value;
// transition
case 4554:
return Enum_WEBKIT + Utility_replace(value, /([^-])(transform)/g, '$1' + Enum_WEBKIT + '$2') + value;
// cursor
case 6187:
return Utility_replace(Utility_replace(Utility_replace(value, /(zoom-|grab)/, Enum_WEBKIT + '$1'), /(image-set)/, Enum_WEBKIT + '$1'), value, '') + value;
// background, background-image
case 5495:
case 3959:
return Utility_replace(value, /(image-set\([^]*)/, Enum_WEBKIT + '$1' + '$`$1');
// justify-content
case 4968:
return Utility_replace(Utility_replace(value, /(.+:)(flex-)?(.*)/, Enum_WEBKIT + 'box-pack:$3' + Enum_MS + 'flex-pack:$3'), /s.+-b[^;]+/, 'justify') + Enum_WEBKIT + value + value;
// (margin|padding)-inline-(start|end)
case 4095:
case 3583:
case 4068:
case 2532:
return Utility_replace(value, /(.+)-inline(.+)/, Enum_WEBKIT + '$1$2') + value;
// (min|max)?(width|height|inline-size|block-size)
case 8116:
case 7059:
case 5753:
case 5535:
case 5445:
case 5701:
case 4933:
case 4677:
case 5533:
case 5789:
case 5021:
case 4765:
// stretch, max-content, min-content, fill-available
if (Utility_strlen(value) - 1 - length > 6) switch (Utility_charat(value, length + 1)) {
// (m)ax-content, (m)in-content
case 109:
// -
if (Utility_charat(value, length + 4) !== 45) break;
// (f)ill-available, (f)it-content
case 102:
return Utility_replace(value, /(.+:)(.+)-([^]+)/, '$1' + Enum_WEBKIT + '$2-$3' + '$1' + Enum_MOZ + (Utility_charat(value, length + 3) == 108 ? '$3' : '$2-$3')) + value;
// (s)tretch
case 115:
return ~indexof(value, 'stretch') ? emotion_cache_browser_esm_prefix(Utility_replace(value, 'stretch', 'fill-available'), length) + value : value;
}
break;
// position: sticky
case 4949:
// (s)ticky?
if (Utility_charat(value, length + 1) !== 115) break;
// display: (flex|inline-flex)
case 6444:
switch (Utility_charat(value, Utility_strlen(value) - 3 - (~indexof(value, '!important') && 10))) {
// stic(k)y
case 107:
return Utility_replace(value, ':', ':' + Enum_WEBKIT) + value;
// (inline-)?fl(e)x
case 101:
return Utility_replace(value, /(.+:)([^;!]+)(;|!.+)?/, '$1' + Enum_WEBKIT + (Utility_charat(value, 14) === 45 ? 'inline-' : '') + 'box$3' + '$1' + Enum_WEBKIT + '$2$3' + '$1' + Enum_MS + '$2box$3') + value;
}
break;
// writing-mode
case 5936:
switch (Utility_charat(value, length + 11)) {
// vertical-l(r)
case 114:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, /[svh]\w+-[tblr]{2}/, 'tb') + value;
// vertical-r(l)
case 108:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') + value;
// horizontal(-)tb
case 45:
return Enum_WEBKIT + value + Enum_MS + Utility_replace(value, /[svh]\w+-[tblr]{2}/, 'lr') + value;
}
return Enum_WEBKIT + value + Enum_MS + value + value;
}
return value;
}
var emotion_cache_browser_esm_prefixer = function prefixer(element, index, children, callback) {
if (element.length > -1) if (!element["return"]) switch (element.type) {
case Enum_DECLARATION:
element["return"] = emotion_cache_browser_esm_prefix(element.value, element.length);
break;
case Enum_KEYFRAMES:
return Serializer_serialize([Tokenizer_copy(element, {
value: Utility_replace(element.value, '@', '@' + Enum_WEBKIT)
})], callback);
case Enum_RULESET:
if (element.length) return Utility_combine(element.props, function (value) {
switch (Utility_match(value, /(::plac\w+|:read-\w+)/)) {
// :read-(only|write)
case ':read-only':
case ':read-write':
return Serializer_serialize([Tokenizer_copy(element, {
props: [Utility_replace(value, /:(read-\w+)/, ':' + Enum_MOZ + '$1')]
})], callback);
// :placeholder
case '::placeholder':
return Serializer_serialize([Tokenizer_copy(element, {
props: [Utility_replace(value, /:(plac\w+)/, ':' + Enum_WEBKIT + 'input-$1')]
}), Tokenizer_copy(element, {
props: [Utility_replace(value, /:(plac\w+)/, ':' + Enum_MOZ + '$1')]
}), Tokenizer_copy(element, {
props: [Utility_replace(value, /:(plac\w+)/, Enum_MS + 'input-$1')]
})], callback);
}
return '';
});
}
};
var defaultStylisPlugins = [emotion_cache_browser_esm_prefixer];
var createCache = function createCache(options) {
var key = options.key;
if (false) {}
if (key === 'css') {
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
// note this very very intentionally targets all style elements regardless of the key to ensure
// that creating a cache works inside of render of a React component
Array.prototype.forEach.call(ssrStyles, function (node) {
// we want to only move elements which have a space in the data-emotion attribute value
// because that indicates that it is an Emotion 11 server-side rendered style elements
// while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
// Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
// so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
// will not result in the Emotion 10 styles being destroyed
var dataEmotionAttribute = node.getAttribute('data-emotion');
if (dataEmotionAttribute.indexOf(' ') === -1) {
return;
}
document.head.appendChild(node);
node.setAttribute('data-s', '');
});
}
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
if (false) {}
var inserted = {};
var container;
var nodesToHydrate = [];
{
container = options.container || document.head;
Array.prototype.forEach.call( // this means we will ignore elements which don't have a space in them which
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
var attrib = node.getAttribute("data-emotion").split(' '); // $FlowFixMe
for (var i = 1; i < attrib.length; i++) {
inserted[attrib[i]] = true;
}
nodesToHydrate.push(node);
});
}
var _insert;
var omnipresentPlugins = [compat, removeLabel];
if (false) {}
{
var currentSheet;
var finalizingPlugins = [stringify, false ? 0 : rulesheet(function (rule) {
currentSheet.insert(rule);
})];
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
var stylis = function stylis(styles) {
return Serializer_serialize(compile(styles), serializer);
};
_insert = function insert(selector, serialized, sheet, shouldCache) {
currentSheet = sheet;
if (false) {}
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
if (shouldCache) {
cache.inserted[serialized.name] = true;
}
};
}
var cache = {
key: key,
sheet: new StyleSheet({
key: key,
container: container,
nonce: options.nonce,
speedy: options.speedy,
prepend: options.prepend,
insertionPoint: options.insertionPoint
}),
nonce: options.nonce,
inserted: inserted,
registered: {},
insert: _insert
};
cache.sheet.hydrate(nodesToHydrate);
return cache;
};
/***/ }),
/***/ 7424:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ C: function() { return /* binding */ CacheProvider; },
/* harmony export */ T: function() { return /* binding */ ThemeContext; },
/* harmony export */ i: function() { return /* binding */ isBrowser; },
/* harmony export */ w: function() { return /* binding */ withEmotionCache; }
/* harmony export */ });
/* unused harmony exports E, _, a, b, c, h, u */
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6540);
/* harmony import */ var _emotion_cache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6112);
/* harmony import */ var _emotion_serialize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5018);
/* harmony import */ var _emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6243);
var isBrowser = "object" !== 'undefined';
var hasOwnProperty = {}.hasOwnProperty;
var EmotionCacheContext = /* #__PURE__ */react__WEBPACK_IMPORTED_MODULE_0__.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
// because this module is primarily intended for the browser and node
// but it's also required in react native and similar environments sometimes
// and we could have a special build just for that
// but this is much easier and the native packages
// might use a different theme context in the future anyway
typeof HTMLElement !== 'undefined' ? /* #__PURE__ */(0,_emotion_cache__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)({
key: 'css'
}) : null);
if (false) {}
var CacheProvider = EmotionCacheContext.Provider;
var __unsafe_useEmotionCache = function useEmotionCache() {
return useContext(EmotionCacheContext);
};
var withEmotionCache = function withEmotionCache(func) {
// $FlowFixMe
return /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (props, ref) {
// the cache will never be null in the browser
var cache = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(EmotionCacheContext);
return func(props, cache, ref);
});
};
if (!isBrowser) {
withEmotionCache = function withEmotionCache(func) {
return function (props) {
var cache = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(EmotionCacheContext);
if (cache === null) {
// yes, we're potentially creating this on every render
// it doesn't actually matter though since it's only on the server
// so there will only every be a single render
// that could change in the future because of suspense and etc. but for now,
// this works and i don't want to optimise for a future thing that we aren't sure about
cache = (0,_emotion_cache__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)({
key: 'css'
});
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EmotionCacheContext.Provider, {
value: cache
}, func(props, cache));
} else {
return func(props, cache);
}
};
};
}
var ThemeContext = /* #__PURE__ */react__WEBPACK_IMPORTED_MODULE_0__.createContext({});
if (false) {}
var useTheme = function useTheme() {
return React.useContext(ThemeContext);
};
var getTheme = function getTheme(outerTheme, theme) {
if (typeof theme === 'function') {
var mergedTheme = theme(outerTheme);
if (false) {}
return mergedTheme;
}
if (false) {}
return _extends({}, outerTheme, theme);
};
var createCacheWithTheme = /* #__PURE__ */(/* unused pure expression or super */ null && (weakMemoize(function (outerTheme) {
return weakMemoize(function (theme) {
return getTheme(outerTheme, theme);
});
})));
var ThemeProvider = function ThemeProvider(props) {
var theme = React.useContext(ThemeContext);
if (props.theme !== theme) {
theme = createCacheWithTheme(theme)(props.theme);
}
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
value: theme
}, props.children);
};
function withTheme(Component) {
var componentName = Component.displayName || Component.name || 'Component';
var render = function render(props, ref) {
var theme = React.useContext(ThemeContext);
return /*#__PURE__*/React.createElement(Component, _extends({
theme: theme,
ref: ref
}, props));
}; // $FlowFixMe
var WithTheme = /*#__PURE__*/React.forwardRef(render);
WithTheme.displayName = "WithTheme(" + componentName + ")";
return hoistNonReactStatics(WithTheme, Component);
}
var getLastPart = function getLastPart(functionName) {
// The match may be something like 'Object.createEmotionProps' or
// 'Loader.prototype.render'
var parts = functionName.split('.');
return parts[parts.length - 1];
};
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
// V8
var match = /^\s+at\s+([A-Za-z0-9$.]+)\s/.exec(line);
if (match) return getLastPart(match[1]); // Safari / Firefox
match = /^([A-Za-z0-9$.]+)@/.exec(line);
if (match) return getLastPart(match[1]);
return undefined;
};
var internalReactFunctionNames = /* #__PURE__ */new Set(['renderWithHooks', 'processChild', 'finishClassComponent', 'renderToString']); // These identifiers come from error stacks, so they have to be valid JS
// identifiers, thus we only need to replace what is a valid character for JS,
// but not for CSS.
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
return identifier.replace(/\$/g, '-');
};
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
if (!stackTrace) return undefined;
var lines = stackTrace.split('\n');
for (var i = 0; i < lines.length; i++) {
var functionName = getFunctionNameFromStackTraceLine(lines[i]); // The first line of V8 stack traces is just "Error"
if (!functionName) continue; // If we reach one of these, we have gone too far and should quit
if (internalReactFunctionNames.has(functionName)) break; // The component name is the first function in the stack that starts with an
// uppercase letter
if (/^[A-Z]/.test(functionName)) return sanitizeIdentifier(functionName);
}
return undefined;
};
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
var createEmotionProps = function createEmotionProps(type, props) {
if (false) {}
var newProps = {};
for (var key in props) {
if (hasOwnProperty.call(props, key)) {
newProps[key] = props[key];
}
}
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
// the label hasn't already been computed
if (false) { var label; }
return newProps;
};
var Insertion = function Insertion(_ref) {
var cache = _ref.cache,
serialized = _ref.serialized,
isStringTag = _ref.isStringTag;
registerStyles(cache, serialized, isStringTag);
useInsertionEffectAlwaysWithSyncFallback(function () {
return insertStyles(cache, serialized, isStringTag);
});
return null;
};
var Emotion = /* #__PURE__ */(/* unused pure expression or super */ null && (withEmotionCache(function (props, cache, ref) {
var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
// not passing the registered cache to serializeStyles because it would
// make certain babel optimisations not possible
if (typeof cssProp === 'string' && cache.registered[cssProp] !== undefined) {
cssProp = cache.registered[cssProp];
}
var WrappedComponent = props[typePropName];
var registeredStyles = [cssProp];
var className = '';
if (typeof props.className === 'string') {
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
} else if (props.className != null) {
className = props.className + " ";
}
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
if (false) { var labelFromStack; }
className += cache.key + "-" + serialized.name;
var newProps = {};
for (var key in props) {
if (hasOwnProperty.call(props, key) && key !== 'css' && key !== typePropName && ( true || 0)) {
newProps[key] = props[key];
}
}
newProps.ref = ref;
newProps.className = className;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
cache: cache,
serialized: serialized,
isStringTag: typeof WrappedComponent === 'string'
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
})));
if (false) {}
var Emotion$1 = (/* unused pure expression or super */ null && (Emotion));
/***/ }),
/***/ 8361:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ AH: function() { return /* binding */ css; },
/* harmony export */ i7: function() { return /* binding */ keyframes; },
/* harmony export */ mL: function() { return /* binding */ Global; }
/* harmony export */ });
/* unused harmony exports ClassNames, createElement, jsx */
/* harmony import */ var _emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7424);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6540);
/* harmony import */ var _emotion_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1957);
/* harmony import */ var _emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6243);
/* harmony import */ var _emotion_serialize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5018);
/* harmony import */ var _emotion_cache__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6112);
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4146);
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_4__);
var pkg = {
name: "@emotion/react",
version: "11.11.1",
main: "dist/emotion-react.cjs.js",
module: "dist/emotion-react.esm.js",
browser: {
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
},
exports: {
".": {
module: {
worker: "./dist/emotion-react.worker.esm.js",
browser: "./dist/emotion-react.browser.esm.js",
"default": "./dist/emotion-react.esm.js"
},
"import": "./dist/emotion-react.cjs.mjs",
"default": "./dist/emotion-react.cjs.js"
},
"./jsx-runtime": {
module: {
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
},
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
},
"./_isolated-hnrs": {
module: {
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
},
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
},
"./jsx-dev-runtime": {
module: {
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
},
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
},
"./package.json": "./package.json",
"./types/css-prop": "./types/css-prop.d.ts",
"./macro": {
types: {
"import": "./macro.d.mts",
"default": "./macro.d.ts"
},
"default": "./macro.js"
}
},
types: "types/index.d.ts",
files: [
"src",
"dist",
"jsx-runtime",
"jsx-dev-runtime",
"_isolated-hnrs",
"types/*.d.ts",
"macro.*"
],
sideEffects: false,
author: "Emotion Contributors",
license: "MIT",
scripts: {
"test:typescript": "dtslint types"
},
dependencies: {
"@babel/runtime": "^7.18.3",
"@emotion/babel-plugin": "^11.11.0",
"@emotion/cache": "^11.11.0",
"@emotion/serialize": "^1.1.2",
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
"@emotion/utils": "^1.2.1",
"@emotion/weak-memoize": "^0.3.1",
"hoist-non-react-statics": "^3.3.1"
},
peerDependencies: {
react: ">=16.8.0"
},
peerDependenciesMeta: {
"@types/react": {
optional: true
}
},
devDependencies: {
"@definitelytyped/dtslint": "0.0.112",
"@emotion/css": "11.11.0",
"@emotion/css-prettifier": "1.1.3",
"@emotion/server": "11.11.0",
"@emotion/styled": "11.11.0",
"html-tag-names": "^1.1.2",
react: "16.14.0",
"svg-tag-names": "^1.1.1",
typescript: "^4.5.5"
},
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
publishConfig: {
access: "public"
},
"umd:main": "dist/emotion-react.umd.min.js",
preconstruct: {
entrypoints: [
"./index.js",
"./jsx-runtime.js",
"./jsx-dev-runtime.js",
"./_isolated-hnrs.js"
],
umdName: "emotionReact",
exports: {
envConditions: [
"browser",
"worker"
],
extra: {
"./types/css-prop": "./types/css-prop.d.ts",
"./macro": {
types: {
"import": "./macro.d.mts",
"default": "./macro.d.ts"
},
"default": "./macro.js"
}
}
}
}
};
var jsx = function jsx(type, props) {
var args = arguments;
if (props == null || !hasOwnProperty.call(props, 'css')) {
// $FlowFixMe
return React.createElement.apply(undefined, args);
}
var argsLength = args.length;
var createElementArgArray = new Array(argsLength);
createElementArgArray[0] = Emotion;
createElementArgArray[1] = createEmotionProps(type, props);
for (var i = 2; i < argsLength; i++) {
createElementArgArray[i] = args[i];
} // $FlowFixMe
return React.createElement.apply(null, createElementArgArray);
};
var warnedAboutCssPropForGlobal = false; // maintain place over rerenders.
// initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
// initial client-side render from SSR, use place of hydrating tag
var Global = /* #__PURE__ */(0,_emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__.w)(function (props, cache) {
if (false) {}
var styles = props.styles;
var serialized = (0,_emotion_serialize__WEBPACK_IMPORTED_MODULE_2__/* .serializeStyles */ .J)([styles], undefined, react__WEBPACK_IMPORTED_MODULE_0__.useContext(_emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__.T));
if (!_emotion_element_c39617d8_browser_esm_js__WEBPACK_IMPORTED_MODULE_5__.i) {
var _ref;
var serializedNames = serialized.name;
var serializedStyles = serialized.styles;
var next = serialized.next;
while (next !== undefined) {
serializedNames += ' ' + next.name;
serializedStyles += next.styles;
next = next.next;
}
var shouldCache = cache.compat === true;
var rules = cache.insert("", {
name: serializedNames,
styles: serializedStyles
}, cache.sheet, shouldCache);
if (shouldCache) {
return null;
}
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
__html: rules
}, _ref.nonce = cache.sheet.nonce, _ref));
} // yes, i know these hooks are used conditionally
// but it is based on a constant that will never change at runtime
// it's effectively like having two implementations and switching them out
// so it's not actually breaking anything
var sheetRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef();
(0,_emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_1__/* .useInsertionEffectWithLayoutFallback */ .i)(function () {
var key = cache.key + "-global"; // use case of https://github.com/emotion-js/emotion/issues/2675
var sheet = new cache.sheet.constructor({
key: key,
nonce: cache.sheet.nonce,
container: cache.sheet.container,
speedy: cache.sheet.isSpeedy
});
var rehydrating = false; // $FlowFixMe
var node = document.querySelector("style[data-emotion=\"" + key + " " + serialized.name + "\"]");
if (cache.sheet.tags.length) {
sheet.before = cache.sheet.tags[0];
}
if (node !== null) {
rehydrating = true; // clear the hash so this node won't be recognizable as rehydratable by other s
node.setAttribute('data-emotion', key);
sheet.hydrate([node]);
}
sheetRef.current = [sheet, rehydrating];
return function () {
sheet.flush();
};
}, [cache]);
(0,_emotion_use_insertion_effect_with_fallbacks__WEBPACK_IMPORTED_MODULE_1__/* .useInsertionEffectWithLayoutFallback */ .i)(function () {
var sheetRefCurrent = sheetRef.current;
var sheet = sheetRefCurrent[0],
rehydrating = sheetRefCurrent[1];
if (rehydrating) {
sheetRefCurrent[1] = false;
return;
}
if (serialized.next !== undefined) {
// insert keyframes
(0,_emotion_utils__WEBPACK_IMPORTED_MODULE_6__/* .insertStyles */ .sk)(cache, serialized.next, true);
}
if (sheet.tags.length) {
// if this doesn't exist then it will be null so the style element will be appended
var element = sheet.tags[sheet.tags.length - 1].nextElementSibling;
sheet.before = element;
sheet.flush();
}
cache.insert("", serialized, sheet, false);
}, [cache, serialized.name]);
return null;
});
if (false) {}
function css() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return (0,_emotion_serialize__WEBPACK_IMPORTED_MODULE_2__/* .serializeStyles */ .J)(args);
}
var keyframes = function keyframes() {
var insertable = css.apply(void 0, arguments);
var name = "animation-" + insertable.name; // $FlowFixMe
return {
name: name,
styles: "@keyframes " + name + "{" + insertable.styles + "}",
anim: 1,
toString: function toString() {
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
}
};
};
var classnames = function classnames(args) {
var len = args.length;
var i = 0;
var cls = '';
for (; i < len; i++) {
var arg = args[i];
if (arg == null) continue;
var toAdd = void 0;
switch (typeof arg) {
case 'boolean':
break;
case 'object':
{
if (Array.isArray(arg)) {
toAdd = classnames(arg);
} else {
if (false) {}
toAdd = '';
for (var k in arg) {
if (arg[k] && k) {
toAdd && (toAdd += ' ');
toAdd += k;
}
}
}
break;
}
default:
{
toAdd = arg;
}
}
if (toAdd) {
cls && (cls += ' ');
cls += toAdd;
}
}
return cls;
};
function merge(registered, css, className) {
var registeredStyles = [];
var rawClassName = getRegisteredStyles(registered, registeredStyles, className);
if (registeredStyles.length < 2) {
return className;
}
return rawClassName + css(registeredStyles);
}
var Insertion = function Insertion(_ref) {
var cache = _ref.cache,
serializedArr = _ref.serializedArr;
useInsertionEffectAlwaysWithSyncFallback(function () {
for (var i = 0; i < serializedArr.length; i++) {
insertStyles(cache, serializedArr[i], false);
}
});
return null;
};
var ClassNames = /* #__PURE__ */(/* unused pure expression or super */ null && (withEmotionCache(function (props, cache) {
var hasRendered = false;
var serializedArr = [];
var css = function css() {
if (hasRendered && "production" !== 'production') {}
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var serialized = serializeStyles(args, cache.registered);
serializedArr.push(serialized); // registration has to happen here as the result of this might get consumed by `cx`
registerStyles(cache, serialized, false);
return cache.key + "-" + serialized.name;
};
var cx = function cx() {
if (hasRendered && "production" !== 'production') {}
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return merge(cache.registered, css, classnames(args));
};
var content = {
css: css,
cx: cx,
theme: React.useContext(ThemeContext)
};
var ele = props.children(content);
hasRendered = true;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
cache: cache,
serializedArr: serializedArr
}), ele);
})));
if (false) {}
if (false) { var globalKey, globalContext, isTestEnv, isBrowser; }
/***/ }),
/***/ 5018:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
J: function() { return /* binding */ serializeStyles; }
});
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/@emotion/hash/dist/emotion-hash.esm.js
/* eslint-disable */
// Inspired by https://github.com/garycourt/murmurhash-js
// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
function murmur2(str) {
// 'm' and 'r' are mixing constants generated offline.
// They're not really 'magic', they just happen to work well.
// const m = 0x5bd1e995;
// const r = 24;
// Initialize the hash
var h = 0; // Mix 4 bytes at a time into the hash
var k,
i = 0,
len = str.length;
for (; len >= 4; ++i, len -= 4) {
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
k =
/* Math.imul(k, m): */
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
k ^=
/* k >>> r: */
k >>> 24;
h =
/* Math.imul(k, m): */
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
/* Math.imul(h, m): */
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
} // Handle the last few bytes of the input array
switch (len) {
case 3:
h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
case 2:
h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
case 1:
h ^= str.charCodeAt(i) & 0xff;
h =
/* Math.imul(h, m): */
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
} // Do a few final mixes of the hash to ensure the last few
// bytes are well-incorporated.
h ^= h >>> 13;
h =
/* Math.imul(h, m): */
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
return ((h ^ h >>> 15) >>> 0).toString(36);
}
// EXTERNAL MODULE: ./node_modules/@emotion/unitless/dist/unitless.browser.esm.js
var unitless_browser_esm = __webpack_require__(7103);
// EXTERNAL MODULE: ./node_modules/@emotion/memoize/dist/memoize.browser.esm.js
var memoize_browser_esm = __webpack_require__(4903);
;// CONCATENATED MODULE: ../../modules/ui/code/core/node_modules/@emotion/serialize/dist/emotion-serialize.browser.esm.js
var ILLEGAL_ESCAPE_SEQUENCE_ERROR = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
var UNDEFINED_AS_OBJECT_KEY_ERROR = "You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key).";
var hyphenateRegex = /[A-Z]|^ms/g;
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
var isCustomProperty = function isCustomProperty(property) {
return property.charCodeAt(1) === 45;
};
var isProcessableValue = function isProcessableValue(value) {
return value != null && typeof value !== 'boolean';
};
var processStyleName = /* #__PURE__ */(0,memoize_browser_esm/* default */.A)(function (styleName) {
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, '-$&').toLowerCase();
});
var processStyleValue = function processStyleValue(key, value) {
switch (key) {
case 'animation':
case 'animationName':
{
if (typeof value === 'string') {
return value.replace(animationRegex, function (match, p1, p2) {
cursor = {
name: p1,
styles: p2,
next: cursor
};
return p1;
});
}
}
}
if (unitless_browser_esm/* default */.A[key] !== 1 && !isCustomProperty(key) && typeof value === 'number' && value !== 0) {
return value + 'px';
}
return value;
};
if (false) { var hyphenatedCache, hyphenPattern, msPattern, oldProcessStyleValue, contentValues, contentValuePattern; }
var noComponentSelectorMessage = (/* unused pure expression or super */ null && ('Component selectors can only be used in conjunction with ' + '@emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware ' + 'compiler transform.'));
function handleInterpolation(mergedProps, registered, interpolation) {
if (interpolation == null) {
return '';
}
if (interpolation.__emotion_styles !== undefined) {
if (false) {}
return interpolation;
}
switch (typeof interpolation) {
case 'boolean':
{
return '';
}
case 'object':
{
if (interpolation.anim === 1) {
cursor = {
name: interpolation.name,
styles: interpolation.styles,
next: cursor
};
return interpolation.name;
}
if (interpolation.styles !== undefined) {
var next = interpolation.next;
if (next !== undefined) {
// not the most efficient thing ever but this is a pretty rare case
// and there will be very few iterations of this generally
while (next !== undefined) {
cursor = {
name: next.name,
styles: next.styles,
next: cursor
};
next = next.next;
}
}
var styles = interpolation.styles + ";";
if (false) {}
return styles;
}
return createStringFromObject(mergedProps, registered, interpolation);
}
case 'function':
{
if (mergedProps !== undefined) {
var previousCursor = cursor;
var result = interpolation(mergedProps);
cursor = previousCursor;
return handleInterpolation(mergedProps, registered, result);
} else if (false) {}
break;
}
case 'string':
if (false) { var replaced, matched; }
break;
} // finalize string values (regular strings and functions interpolated into css calls)
if (registered == null) {
return interpolation;
}
var cached = registered[interpolation];
return cached !== undefined ? cached : interpolation;
}
function createStringFromObject(mergedProps, registered, obj) {
var string = '';
if (Array.isArray(obj)) {
for (var i = 0; i < obj.length; i++) {
string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
}
} else {
for (var _key in obj) {
var value = obj[_key];
if (typeof value !== 'object') {
if (registered != null && registered[value] !== undefined) {
string += _key + "{" + registered[value] + "}";
} else if (isProcessableValue(value)) {
string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
}
} else {
if (_key === 'NO_COMPONENT_SELECTOR' && "production" !== 'production') {}
if (Array.isArray(value) && typeof value[0] === 'string' && (registered == null || registered[value[0]] === undefined)) {
for (var _i = 0; _i < value.length; _i++) {
if (isProcessableValue(value[_i])) {
string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
}
}
} else {
var interpolated = handleInterpolation(mergedProps, registered, value);
switch (_key) {
case 'animation':
case 'animationName':
{
string += processStyleName(_key) + ":" + interpolated + ";";
break;
}
default:
{
if (false) {}
string += _key + "{" + interpolated + "}";
}
}
}
}
}
}
return string;
}
var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
var sourceMapPattern;
if (false) {} // this is the cursor for keyframes
// keyframes are stored on the SerializedStyles object as a linked list
var cursor;
var serializeStyles = function serializeStyles(args, registered, mergedProps) {
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) {
return args[0];
}
var stringMode = true;
var styles = '';
cursor = undefined;
var strings = args[0];
if (strings == null || strings.raw === undefined) {
stringMode = false;
styles += handleInterpolation(mergedProps, registered, strings);
} else {
if (false) {}
styles += strings[0];
} // we start at 1 since we've already handled the first arg
for (var i = 1; i < args.length; i++) {
styles += handleInterpolation(mergedProps, registered, args[i]);
if (stringMode) {
if (false) {}
styles += strings[i];
}
}
var sourceMap;
if (false) {} // using a global regex with .exec is stateful so lastIndex has to be reset each time
labelPattern.lastIndex = 0;
var identifierName = '';
var match; // https://esbench.com/bench/5b809c2cf2949800a0f61fb5
while ((match = labelPattern.exec(styles)) !== null) {
identifierName += '-' + // $FlowFixMe we know it's not null
match[1];
}
var name = murmur2(styles) + identifierName;
if (false) {}
return {
name: name,
styles: styles,
next: cursor
};
};
/***/ }),
/***/ 6243:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
var react__WEBPACK_IMPORTED_MODULE_0___namespace_cache;
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ i: function() { return /* binding */ useInsertionEffectWithLayoutFallback; },
/* harmony export */ s: function() { return /* binding */ useInsertionEffectAlwaysWithSyncFallback; }
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6540);
var syncFallback = function syncFallback(create) {
return create();
};
var useInsertionEffect = /*#__PURE__*/ (react__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (react__WEBPACK_IMPORTED_MODULE_0___namespace_cache = __webpack_require__.t(react__WEBPACK_IMPORTED_MODULE_0__, 2)))['useInsertion' + 'Effect'] ? /*#__PURE__*/ (react__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (react__WEBPACK_IMPORTED_MODULE_0___namespace_cache = __webpack_require__.t(react__WEBPACK_IMPORTED_MODULE_0__, 2)))['useInsertion' + 'Effect'] : false;
var useInsertionEffectAlwaysWithSyncFallback = useInsertionEffect || syncFallback;
var useInsertionEffectWithLayoutFallback = useInsertionEffect || react__WEBPACK_IMPORTED_MODULE_0__.useLayoutEffect;
/***/ }),
/***/ 1957:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ Rk: function() { return /* binding */ getRegisteredStyles; },
/* harmony export */ SF: function() { return /* binding */ registerStyles; },
/* harmony export */ sk: function() { return /* binding */ insertStyles; }
/* harmony export */ });
var isBrowser = "object" !== 'undefined';
function getRegisteredStyles(registered, registeredStyles, classNames) {
var rawClassName = '';
classNames.split(' ').forEach(function (className) {
if (registered[className] !== undefined) {
registeredStyles.push(registered[className] + ";");
} else {
rawClassName += className + " ";
}
});
return rawClassName;
}
var registerStyles = function registerStyles(cache, serialized, isStringTag) {
var className = cache.key + "-" + serialized.name;
if ( // we only need to add the styles to the registered cache if the
// class name could be used further down
// the tree but if it's a string tag, we know it won't
// so we don't have to add it to registered cache.
// this improves memory usage since we can avoid storing the whole style string
(isStringTag === false || // we need to always store it if we're in compat mode and
// in node since emotion-server relies on whether a style is in
// the registered cache to know whether a style is global or not
// also, note that this check will be dead code eliminated in the browser
isBrowser === false ) && cache.registered[className] === undefined) {
cache.registered[className] = serialized.styles;
}
};
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
registerStyles(cache, serialized, isStringTag);
var className = cache.key + "-" + serialized.name;
if (cache.inserted[serialized.name] === undefined) {
var current = serialized;
do {
cache.insert(serialized === current ? "." + className : '', current, cache.sheet, true);
current = current.next;
} while (current !== undefined);
}
};
/***/ }),
/***/ 1953:
/***/ (function(module, exports) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/* global define */
(function () {
'use strict';
var hasOwn = {}.hasOwnProperty;
function classNames () {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
var argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg) && arg.length) {
var inner = classNames.apply(null, arg);
if (inner) {
classes.push(inner);
}
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
if ( true && module.exports) {
classNames.default = classNames;
module.exports = classNames;
} else if (true) {
// register as 'classnames', consistent with npm package name
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
return classNames;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}());
/***/ }),
/***/ 4609:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export clsx */
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t
* MIT Expat Licence
*/
// ----------------------------------- EDITABLE DEFAULTS ------------------------------------ //
// The limit on the value of `precision`, and on the value of the first argument to
// `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`.
var MAX_DIGITS = 1e9, // 0 to 1e9
// The initial configuration properties of the Decimal constructor.
Decimal = {
// These values must be integers within the stated ranges (inclusive).
// Most of these values can be changed during run-time using `Decimal.config`.
// The maximum number of significant digits of the result of a calculation or base conversion.
// E.g. `Decimal.config({ precision: 20 });`
precision: 20, // 1 to MAX_DIGITS
// The rounding mode used by default by `toInteger`, `toDecimalPlaces`, `toExponential`,
// `toFixed`, `toPrecision` and `toSignificantDigits`.
//
// ROUND_UP 0 Away from zero.
// ROUND_DOWN 1 Towards zero.
// ROUND_CEIL 2 Towards +Infinity.
// ROUND_FLOOR 3 Towards -Infinity.
// ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
// ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
// ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
// ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
// ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
//
// E.g.
// `Decimal.rounding = 4;`
// `Decimal.rounding = Decimal.ROUND_HALF_UP;`
rounding: 4, // 0 to 8
// The exponent value at and beneath which `toString` returns exponential notation.
// JavaScript numbers: -7
toExpNeg: -7, // 0 to -MAX_E
// The exponent value at and above which `toString` returns exponential notation.
// JavaScript numbers: 21
toExpPos: 21, // 0 to MAX_E
// The natural logarithm of 10.
// 115 digits
LN10: '2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286'
},
// ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
external = true,
decimalError = '[DecimalError] ',
invalidArgument = decimalError + 'Invalid argument: ',
exponentOutOfRange = decimalError + 'Exponent out of range: ',
mathfloor = Math.floor,
mathpow = Math.pow,
isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
ONE,
BASE = 1e7,
LOG_BASE = 7,
MAX_SAFE_INTEGER = 9007199254740991,
MAX_E = mathfloor(MAX_SAFE_INTEGER / LOG_BASE), // 1286742750677284
// Decimal.prototype object
P = {};
// Decimal prototype methods
/*
* absoluteValue abs
* comparedTo cmp
* decimalPlaces dp
* dividedBy div
* dividedToIntegerBy idiv
* equals eq
* exponent
* greaterThan gt
* greaterThanOrEqualTo gte
* isInteger isint
* isNegative isneg
* isPositive ispos
* isZero
* lessThan lt
* lessThanOrEqualTo lte
* logarithm log
* minus sub
* modulo mod
* naturalExponential exp
* naturalLogarithm ln
* negated neg
* plus add
* precision sd
* squareRoot sqrt
* times mul
* toDecimalPlaces todp
* toExponential
* toFixed
* toInteger toint
* toNumber
* toPower pow
* toPrecision
* toSignificantDigits tosd
* toString
* valueOf val
*/
/*
* Return a new Decimal whose value is the absolute value of this Decimal.
*
*/
P.absoluteValue = P.abs = function () {
var x = new this.constructor(this);
if (x.s) x.s = 1;
return x;
};
/*
* Return
* 1 if the value of this Decimal is greater than the value of `y`,
* -1 if the value of this Decimal is less than the value of `y`,
* 0 if they have the same value
*
*/
P.comparedTo = P.cmp = function (y) {
var i, j, xdL, ydL,
x = this;
y = new x.constructor(y);
// Signs differ?
if (x.s !== y.s) return x.s || -y.s;
// Compare exponents.
if (x.e !== y.e) return x.e > y.e ^ x.s < 0 ? 1 : -1;
xdL = x.d.length;
ydL = y.d.length;
// Compare digit by digit.
for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
if (x.d[i] !== y.d[i]) return x.d[i] > y.d[i] ^ x.s < 0 ? 1 : -1;
}
// Compare lengths.
return xdL === ydL ? 0 : xdL > ydL ^ x.s < 0 ? 1 : -1;
};
/*
* Return the number of decimal places of the value of this Decimal.
*
*/
P.decimalPlaces = P.dp = function () {
var x = this,
w = x.d.length - 1,
dp = (w - x.e) * LOG_BASE;
// Subtract the number of trailing zeros of the last word.
w = x.d[w];
if (w) for (; w % 10 == 0; w /= 10) dp--;
return dp < 0 ? 0 : dp;
};
/*
* Return a new Decimal whose value is the value of this Decimal divided by `y`, truncated to
* `precision` significant digits.
*
*/
P.dividedBy = P.div = function (y) {
return divide(this, new this.constructor(y));
};
/*
* Return a new Decimal whose value is the integer part of dividing the value of this Decimal
* by the value of `y`, truncated to `precision` significant digits.
*
*/
P.dividedToIntegerBy = P.idiv = function (y) {
var x = this,
Ctor = x.constructor;
return round(divide(x, new Ctor(y), 0, 1), Ctor.precision);
};
/*
* Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
*
*/
P.equals = P.eq = function (y) {
return !this.cmp(y);
};
/*
* Return the (base 10) exponent value of this Decimal (this.e is the base 10000000 exponent).
*
*/
P.exponent = function () {
return getBase10Exponent(this);
};
/*
* Return true if the value of this Decimal is greater than the value of `y`, otherwise return
* false.
*
*/
P.greaterThan = P.gt = function (y) {
return this.cmp(y) > 0;
};
/*
* Return true if the value of this Decimal is greater than or equal to the value of `y`,
* otherwise return false.
*
*/
P.greaterThanOrEqualTo = P.gte = function (y) {
return this.cmp(y) >= 0;
};
/*
* Return true if the value of this Decimal is an integer, otherwise return false.
*
*/
P.isInteger = P.isint = function () {
return this.e > this.d.length - 2;
};
/*
* Return true if the value of this Decimal is negative, otherwise return false.
*
*/
P.isNegative = P.isneg = function () {
return this.s < 0;
};
/*
* Return true if the value of this Decimal is positive, otherwise return false.
*
*/
P.isPositive = P.ispos = function () {
return this.s > 0;
};
/*
* Return true if the value of this Decimal is 0, otherwise return false.
*
*/
P.isZero = function () {
return this.s === 0;
};
/*
* Return true if the value of this Decimal is less than `y`, otherwise return false.
*
*/
P.lessThan = P.lt = function (y) {
return this.cmp(y) < 0;
};
/*
* Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
*
*/
P.lessThanOrEqualTo = P.lte = function (y) {
return this.cmp(y) < 1;
};
/*
* Return the logarithm of the value of this Decimal to the specified base, truncated to
* `precision` significant digits.
*
* If no base is specified, return log[10](x).
*
* log[base](x) = ln(x) / ln(base)
*
* The maximum error of the result is 1 ulp (unit in the last place).
*
* [base] {number|string|Decimal} The base of the logarithm.
*
*/
P.logarithm = P.log = function (base) {
var r,
x = this,
Ctor = x.constructor,
pr = Ctor.precision,
wpr = pr + 5;
// Default base is 10.
if (base === void 0) {
base = new Ctor(10);
} else {
base = new Ctor(base);
// log[-b](x) = NaN
// log[0](x) = NaN
// log[1](x) = NaN
if (base.s < 1 || base.eq(ONE)) throw Error(decimalError + 'NaN');
}
// log[b](-x) = NaN
// log[b](0) = -Infinity
if (x.s < 1) throw Error(decimalError + (x.s ? 'NaN' : '-Infinity'));
// log[b](1) = 0
if (x.eq(ONE)) return new Ctor(0);
external = false;
r = divide(ln(x, wpr), ln(base, wpr), wpr);
external = true;
return round(r, pr);
};
/*
* Return a new Decimal whose value is the value of this Decimal minus `y`, truncated to
* `precision` significant digits.
*
*/
P.minus = P.sub = function (y) {
var x = this;
y = new x.constructor(y);
return x.s == y.s ? subtract(x, y) : add(x, (y.s = -y.s, y));
};
/*
* Return a new Decimal whose value is the value of this Decimal modulo `y`, truncated to
* `precision` significant digits.
*
*/
P.modulo = P.mod = function (y) {
var q,
x = this,
Ctor = x.constructor,
pr = Ctor.precision;
y = new Ctor(y);
// x % 0 = NaN
if (!y.s) throw Error(decimalError + 'NaN');
// Return x if x is 0.
if (!x.s) return round(new Ctor(x), pr);
// Prevent rounding of intermediate calculations.
external = false;
q = divide(x, y, 0, 1).times(y);
external = true;
return x.minus(q);
};
/*
* Return a new Decimal whose value is the natural exponential of the value of this Decimal,
* i.e. the base e raised to the power the value of this Decimal, truncated to `precision`
* significant digits.
*
*/
P.naturalExponential = P.exp = function () {
return exp(this);
};
/*
* Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
* truncated to `precision` significant digits.
*
*/
P.naturalLogarithm = P.ln = function () {
return ln(this);
};
/*
* Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
* -1.
*
*/
P.negated = P.neg = function () {
var x = new this.constructor(this);
x.s = -x.s || 0;
return x;
};
/*
* Return a new Decimal whose value is the value of this Decimal plus `y`, truncated to
* `precision` significant digits.
*
*/
P.plus = P.add = function (y) {
var x = this;
y = new x.constructor(y);
return x.s == y.s ? add(x, y) : subtract(x, (y.s = -y.s, y));
};
/*
* Return the number of significant digits of the value of this Decimal.
*
* [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
*
*/
P.precision = P.sd = function (z) {
var e, sd, w,
x = this;
if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
e = getBase10Exponent(x) + 1;
w = x.d.length - 1;
sd = w * LOG_BASE + 1;
w = x.d[w];
// If non-zero...
if (w) {
// Subtract the number of trailing zeros of the last word.
for (; w % 10 == 0; w /= 10) sd--;
// Add the number of digits of the first word.
for (w = x.d[0]; w >= 10; w /= 10) sd++;
}
return z && e > sd ? e : sd;
};
/*
* Return a new Decimal whose value is the square root of this Decimal, truncated to `precision`
* significant digits.
*
*/
P.squareRoot = P.sqrt = function () {
var e, n, pr, r, s, t, wpr,
x = this,
Ctor = x.constructor;
// Negative or zero?
if (x.s < 1) {
if (!x.s) return new Ctor(0);
// sqrt(-x) = NaN
throw Error(decimalError + 'NaN');
}
e = getBase10Exponent(x);
external = false;
// Initial estimate.
s = Math.sqrt(+x);
// Math.sqrt underflow/overflow?
// Pass x to Math.sqrt as integer, then adjust the exponent of the result.
if (s == 0 || s == 1 / 0) {
n = digitsToString(x.d);
if ((n.length + e) % 2 == 0) n += '0';
s = Math.sqrt(n);
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
if (s == 1 / 0) {
n = '5e' + e;
} else {
n = s.toExponential();
n = n.slice(0, n.indexOf('e') + 1) + e;
}
r = new Ctor(n);
} else {
r = new Ctor(s.toString());
}
pr = Ctor.precision;
s = wpr = pr + 3;
// Newton-Raphson iteration.
for (;;) {
t = r;
r = t.plus(divide(x, t, wpr + 2)).times(0.5);
if (digitsToString(t.d).slice(0, wpr) === (n = digitsToString(r.d)).slice(0, wpr)) {
n = n.slice(wpr - 3, wpr + 1);
// The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or
// 4999, i.e. approaching a rounding boundary, continue the iteration.
if (s == wpr && n == '4999') {
// On the first iteration only, check to see if rounding up gives the exact result as the
// nines may infinitely repeat.
round(t, pr + 1, 0);
if (t.times(t).eq(x)) {
r = t;
break;
}
} else if (n != '9999') {
break;
}
wpr += 4;
}
}
external = true;
return round(r, pr);
};
/*
* Return a new Decimal whose value is the value of this Decimal times `y`, truncated to
* `precision` significant digits.
*
*/
P.times = P.mul = function (y) {
var carry, e, i, k, r, rL, t, xdL, ydL,
x = this,
Ctor = x.constructor,
xd = x.d,
yd = (y = new Ctor(y)).d;
// Return 0 if either is 0.
if (!x.s || !y.s) return new Ctor(0);
y.s *= x.s;
e = x.e + y.e;
xdL = xd.length;
ydL = yd.length;
// Ensure xd points to the longer array.
if (xdL < ydL) {
r = xd;
xd = yd;
yd = r;
rL = xdL;
xdL = ydL;
ydL = rL;
}
// Initialise the result array with zeros.
r = [];
rL = xdL + ydL;
for (i = rL; i--;) r.push(0);
// Multiply!
for (i = ydL; --i >= 0;) {
carry = 0;
for (k = xdL + i; k > i;) {
t = r[k] + yd[i] * xd[k - i - 1] + carry;
r[k--] = t % BASE | 0;
carry = t / BASE | 0;
}
r[k] = (r[k] + carry) % BASE | 0;
}
// Remove trailing zeros.
for (; !r[--rL];) r.pop();
if (carry) ++e;
else r.shift();
y.d = r;
y.e = e;
return external ? round(y, Ctor.precision) : y;
};
/*
* Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
* decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
*
* If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
*
* [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
*/
P.toDecimalPlaces = P.todp = function (dp, rm) {
var x = this,
Ctor = x.constructor;
x = new Ctor(x);
if (dp === void 0) return x;
checkInt32(dp, 0, MAX_DIGITS);
if (rm === void 0) rm = Ctor.rounding;
else checkInt32(rm, 0, 8);
return round(x, dp + getBase10Exponent(x) + 1, rm);
};
/*
* Return a string representing the value of this Decimal in exponential notation rounded to
* `dp` fixed decimal places using rounding mode `rounding`.
*
* [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
*/
P.toExponential = function (dp, rm) {
var str,
x = this,
Ctor = x.constructor;
if (dp === void 0) {
str = toString(x, true);
} else {
checkInt32(dp, 0, MAX_DIGITS);
if (rm === void 0) rm = Ctor.rounding;
else checkInt32(rm, 0, 8);
x = round(new Ctor(x), dp + 1, rm);
str = toString(x, true, dp + 1);
}
return str;
};
/*
* Return a string representing the value of this Decimal in normal (fixed-point) notation to
* `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is
* omitted.
*
* As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
*
* [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
* (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
* (-0).toFixed(3) is '0.000'.
* (-0.5).toFixed(0) is '-0'.
*
*/
P.toFixed = function (dp, rm) {
var str, y,
x = this,
Ctor = x.constructor;
if (dp === void 0) return toString(x);
checkInt32(dp, 0, MAX_DIGITS);
if (rm === void 0) rm = Ctor.rounding;
else checkInt32(rm, 0, 8);
y = round(new Ctor(x), dp + getBase10Exponent(x) + 1, rm);
str = toString(y.abs(), false, dp + getBase10Exponent(y) + 1);
// To determine whether to add the minus sign look at the value before it was rounded,
// i.e. look at `x` rather than `y`.
return x.isneg() && !x.isZero() ? '-' + str : str;
};
/*
* Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
* rounding mode `rounding`.
*
*/
P.toInteger = P.toint = function () {
var x = this,
Ctor = x.constructor;
return round(new Ctor(x), getBase10Exponent(x) + 1, Ctor.rounding);
};
/*
* Return the value of this Decimal converted to a number primitive.
*
*/
P.toNumber = function () {
return +this;
};
/*
* Return a new Decimal whose value is the value of this Decimal raised to the power `y`,
* truncated to `precision` significant digits.
*
* For non-integer or very large exponents pow(x, y) is calculated using
*
* x^y = exp(y*ln(x))
*
* The maximum error is 1 ulp (unit in last place).
*
* y {number|string|Decimal} The power to which to raise this Decimal.
*
*/
P.toPower = P.pow = function (y) {
var e, k, pr, r, sign, yIsInt,
x = this,
Ctor = x.constructor,
guard = 12,
yn = +(y = new Ctor(y));
// pow(x, 0) = 1
if (!y.s) return new Ctor(ONE);
x = new Ctor(x);
// pow(0, y > 0) = 0
// pow(0, y < 0) = Infinity
if (!x.s) {
if (y.s < 1) throw Error(decimalError + 'Infinity');
return x;
}
// pow(1, y) = 1
if (x.eq(ONE)) return x;
pr = Ctor.precision;
// pow(x, 1) = x
if (y.eq(ONE)) return round(x, pr);
e = y.e;
k = y.d.length - 1;
yIsInt = e >= k;
sign = x.s;
if (!yIsInt) {
// pow(x < 0, y non-integer) = NaN
if (sign < 0) throw Error(decimalError + 'NaN');
// If y is a small integer use the 'exponentiation by squaring' algorithm.
} else if ((k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
r = new Ctor(ONE);
// Max k of 9007199254740991 takes 53 loop iterations.
// Maximum digits array length; leaves [28, 34] guard digits.
e = Math.ceil(pr / LOG_BASE + 4);
external = false;
for (;;) {
if (k % 2) {
r = r.times(x);
truncate(r.d, e);
}
k = mathfloor(k / 2);
if (k === 0) break;
x = x.times(x);
truncate(x.d, e);
}
external = true;
return y.s < 0 ? new Ctor(ONE).div(r) : round(r, pr);
}
// Result is negative if x is negative and the last digit of integer y is odd.
sign = sign < 0 && y.d[Math.max(e, k)] & 1 ? -1 : 1;
x.s = 1;
external = false;
r = y.times(ln(x, pr + guard));
external = true;
r = exp(r);
r.s = sign;
return r;
};
/*
* Return a string representing the value of this Decimal rounded to `sd` significant digits
* using rounding mode `rounding`.
*
* Return exponential notation if `sd` is less than the number of digits necessary to represent
* the integer part of the value in normal notation.
*
* [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
*/
P.toPrecision = function (sd, rm) {
var e, str,
x = this,
Ctor = x.constructor;
if (sd === void 0) {
e = getBase10Exponent(x);
str = toString(x, e <= Ctor.toExpNeg || e >= Ctor.toExpPos);
} else {
checkInt32(sd, 1, MAX_DIGITS);
if (rm === void 0) rm = Ctor.rounding;
else checkInt32(rm, 0, 8);
x = round(new Ctor(x), sd, rm);
e = getBase10Exponent(x);
str = toString(x, sd <= e || e <= Ctor.toExpNeg, sd);
}
return str;
};
/*
* Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
* significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
* omitted.
*
* [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
*/
P.toSignificantDigits = P.tosd = function (sd, rm) {
var x = this,
Ctor = x.constructor;
if (sd === void 0) {
sd = Ctor.precision;
rm = Ctor.rounding;
} else {
checkInt32(sd, 1, MAX_DIGITS);
if (rm === void 0) rm = Ctor.rounding;
else checkInt32(rm, 0, 8);
}
return round(new Ctor(x), sd, rm);
};
/*
* Return a string representing the value of this Decimal.
*
* Return exponential notation if this Decimal has a positive exponent equal to or greater than
* `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
*
*/
P.toString = P.valueOf = P.val = P.toJSON = function () {
var x = this,
e = getBase10Exponent(x),
Ctor = x.constructor;
return toString(x, e <= Ctor.toExpNeg || e >= Ctor.toExpPos);
};
// Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers.
/*
* add P.minus, P.plus
* checkInt32 P.todp, P.toExponential, P.toFixed, P.toPrecision, P.tosd
* digitsToString P.log, P.sqrt, P.pow, toString, exp, ln
* divide P.div, P.idiv, P.log, P.mod, P.sqrt, exp, ln
* exp P.exp, P.pow
* getBase10Exponent P.exponent, P.sd, P.toint, P.sqrt, P.todp, P.toFixed, P.toPrecision,
* P.toString, divide, round, toString, exp, ln
* getLn10 P.log, ln
* getZeroString digitsToString, toString
* ln P.log, P.ln, P.pow, exp
* parseDecimal Decimal
* round P.abs, P.idiv, P.log, P.minus, P.mod, P.neg, P.plus, P.toint, P.sqrt,
* P.times, P.todp, P.toExponential, P.toFixed, P.pow, P.toPrecision, P.tosd,
* divide, getLn10, exp, ln
* subtract P.minus, P.plus
* toString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf
* truncate P.pow
*
* Throws: P.log, P.mod, P.sd, P.sqrt, P.pow, checkInt32, divide, round,
* getLn10, exp, ln, parseDecimal, Decimal, config
*/
function add(x, y) {
var carry, d, e, i, k, len, xd, yd,
Ctor = x.constructor,
pr = Ctor.precision;
// If either is zero...
if (!x.s || !y.s) {
// Return x if y is zero.
// Return y if y is non-zero.
if (!y.s) y = new Ctor(x);
return external ? round(y, pr) : y;
}
xd = x.d;
yd = y.d;
// x and y are finite, non-zero numbers with the same sign.
k = x.e;
e = y.e;
xd = xd.slice();
i = k - e;
// If base 1e7 exponents differ...
if (i) {
if (i < 0) {
d = xd;
i = -i;
len = yd.length;
} else {
d = yd;
e = k;
len = xd.length;
}
// Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1.
k = Math.ceil(pr / LOG_BASE);
len = k > len ? k + 1 : len + 1;
if (i > len) {
i = len;
d.length = 1;
}
// Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts.
d.reverse();
for (; i--;) d.push(0);
d.reverse();
}
len = xd.length;
i = yd.length;
// If yd is longer than xd, swap xd and yd so xd points to the longer array.
if (len - i < 0) {
i = len;
d = yd;
yd = xd;
xd = d;
}
// Only start adding at yd.length - 1 as the further digits of xd can be left as they are.
for (carry = 0; i;) {
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
xd[i] %= BASE;
}
if (carry) {
xd.unshift(carry);
++e;
}
// Remove trailing zeros.
// No need to check for zero, as +x + +y != 0 && -x + -y != 0
for (len = xd.length; xd[--len] == 0;) xd.pop();
y.d = xd;
y.e = e;
return external ? round(y, pr) : y;
}
function checkInt32(i, min, max) {
if (i !== ~~i || i < min || i > max) {
throw Error(invalidArgument + i);
}
}
function digitsToString(d) {
var i, k, ws,
indexOfLastWord = d.length - 1,
str = '',
w = d[0];
if (indexOfLastWord > 0) {
str += w;
for (i = 1; i < indexOfLastWord; i++) {
ws = d[i] + '';
k = LOG_BASE - ws.length;
if (k) str += getZeroString(k);
str += ws;
}
w = d[i];
ws = w + '';
k = LOG_BASE - ws.length;
if (k) str += getZeroString(k);
} else if (w === 0) {
return '0';
}
// Remove trailing zeros of last w.
for (; w % 10 === 0;) w /= 10;
return str + w;
}
var divide = (function () {
// Assumes non-zero x and k, and hence non-zero result.
function multiplyInteger(x, k) {
var temp,
carry = 0,
i = x.length;
for (x = x.slice(); i--;) {
temp = x[i] * k + carry;
x[i] = temp % BASE | 0;
carry = temp / BASE | 0;
}
if (carry) x.unshift(carry);
return x;
}
function compare(a, b, aL, bL) {
var i, r;
if (aL != bL) {
r = aL > bL ? 1 : -1;
} else {
for (i = r = 0; i < aL; i++) {
if (a[i] != b[i]) {
r = a[i] > b[i] ? 1 : -1;
break;
}
}
}
return r;
}
function subtract(a, b, aL) {
var i = 0;
// Subtract b from a.
for (; aL--;) {
a[aL] -= i;
i = a[aL] < b[aL] ? 1 : 0;
a[aL] = i * BASE + a[aL] - b[aL];
}
// Remove leading zeros.
for (; !a[0] && a.length > 1;) a.shift();
}
return function (x, y, pr, dp) {
var cmp, e, i, k, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz,
Ctor = x.constructor,
sign = x.s == y.s ? 1 : -1,
xd = x.d,
yd = y.d;
// Either 0?
if (!x.s) return new Ctor(x);
if (!y.s) throw Error(decimalError + 'Division by zero');
e = x.e - y.e;
yL = yd.length;
xL = xd.length;
q = new Ctor(sign);
qd = q.d = [];
// Result exponent may be one less than e.
for (i = 0; yd[i] == (xd[i] || 0); ) ++i;
if (yd[i] > (xd[i] || 0)) --e;
if (pr == null) {
sd = pr = Ctor.precision;
} else if (dp) {
sd = pr + (getBase10Exponent(x) - getBase10Exponent(y)) + 1;
} else {
sd = pr;
}
if (sd < 0) return new Ctor(0);
// Convert precision in number of base 10 digits to base 1e7 digits.
sd = sd / LOG_BASE + 2 | 0;
i = 0;
// divisor < 1e7
if (yL == 1) {
k = 0;
yd = yd[0];
sd++;
// k is the carry.
for (; (i < xL || k) && sd--; i++) {
t = k * BASE + (xd[i] || 0);
qd[i] = t / yd | 0;
k = t % yd | 0;
}
// divisor >= 1e7
} else {
// Normalise xd and yd so highest order digit of yd is >= BASE/2
k = BASE / (yd[0] + 1) | 0;
if (k > 1) {
yd = multiplyInteger(yd, k);
xd = multiplyInteger(xd, k);
yL = yd.length;
xL = xd.length;
}
xi = yL;
rem = xd.slice(0, yL);
remL = rem.length;
// Add zeros to make remainder as long as divisor.
for (; remL < yL;) rem[remL++] = 0;
yz = yd.slice();
yz.unshift(0);
yd0 = yd[0];
if (yd[1] >= BASE / 2) ++yd0;
do {
k = 0;
// Compare divisor and remainder.
cmp = compare(yd, rem, yL, remL);
// If divisor < remainder.
if (cmp < 0) {
// Calculate trial digit, k.
rem0 = rem[0];
if (yL != remL) rem0 = rem0 * BASE + (rem[1] || 0);
// k will be how many times the divisor goes into the current remainder.
k = rem0 / yd0 | 0;
// Algorithm:
// 1. product = divisor * trial digit (k)
// 2. if product > remainder: product -= divisor, k--
// 3. remainder -= product
// 4. if product was < remainder at 2:
// 5. compare new remainder and divisor
// 6. If remainder > divisor: remainder -= divisor, k++
if (k > 1) {
if (k >= BASE) k = BASE - 1;
// product = divisor * trial digit.
prod = multiplyInteger(yd, k);
prodL = prod.length;
remL = rem.length;
// Compare product and remainder.
cmp = compare(prod, rem, prodL, remL);
// product > remainder.
if (cmp == 1) {
k--;
// Subtract divisor from product.
subtract(prod, yL < prodL ? yz : yd, prodL);
}
} else {
// cmp is -1.
// If k is 0, there is no need to compare yd and rem again below, so change cmp to 1
// to avoid it. If k is 1 there is a need to compare yd and rem again below.
if (k == 0) cmp = k = 1;
prod = yd.slice();
}
prodL = prod.length;
if (prodL < remL) prod.unshift(0);
// Subtract product from remainder.
subtract(rem, prod, remL);
// If product was < previous remainder.
if (cmp == -1) {
remL = rem.length;
// Compare divisor and new remainder.
cmp = compare(yd, rem, yL, remL);
// If divisor < new remainder, subtract divisor from remainder.
if (cmp < 1) {
k++;
// Subtract divisor from remainder.
subtract(rem, yL < remL ? yz : yd, remL);
}
}
remL = rem.length;
} else if (cmp === 0) {
k++;
rem = [0];
} // if cmp === 1, k will be 0
// Add the next digit, k, to the result array.
qd[i++] = k;
// Update the remainder.
if (cmp && rem[0]) {
rem[remL++] = xd[xi] || 0;
} else {
rem = [xd[xi]];
remL = 1;
}
} while ((xi++ < xL || rem[0] !== void 0) && sd--);
}
// Leading zero?
if (!qd[0]) qd.shift();
q.e = e;
return round(q, dp ? pr + getBase10Exponent(q) + 1 : pr);
};
})();
/*
* Return a new Decimal whose value is the natural exponential of `x` truncated to `sd`
* significant digits.
*
* Taylor/Maclaurin series.
*
* exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ...
*
* Argument reduction:
* Repeat x = x / 32, k += 5, until |x| < 0.1
* exp(x) = exp(x / 2^k)^(2^k)
*
* Previously, the argument was initially reduced by
* exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10)
* to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was
* found to be slower than just dividing repeatedly by 32 as above.
*
* (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324)
*
* exp(x) is non-terminating for any finite, non-zero x.
*
*/
function exp(x, sd) {
var denominator, guard, pow, sum, t, wpr,
i = 0,
k = 0,
Ctor = x.constructor,
pr = Ctor.precision;
if (getBase10Exponent(x) > 16) throw Error(exponentOutOfRange + getBase10Exponent(x));
// exp(0) = 1
if (!x.s) return new Ctor(ONE);
if (sd == null) {
external = false;
wpr = pr;
} else {
wpr = sd;
}
t = new Ctor(0.03125);
while (x.abs().gte(0.1)) {
x = x.times(t); // x = x / 2^5
k += 5;
}
// Estimate the precision increase necessary to ensure the first 4 rounding digits are correct.
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
wpr += guard;
denominator = pow = sum = new Ctor(ONE);
Ctor.precision = wpr;
for (;;) {
pow = round(pow.times(x), wpr);
denominator = denominator.times(++i);
t = sum.plus(divide(pow, denominator, wpr));
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
while (k--) sum = round(sum.times(sum), wpr);
Ctor.precision = pr;
return sd == null ? (external = true, round(sum, pr)) : sum;
}
sum = t;
}
}
// Calculate the base 10 exponent from the base 1e7 exponent.
function getBase10Exponent(x) {
var e = x.e * LOG_BASE,
w = x.d[0];
// Add the number of digits of the first word of the digits array.
for (; w >= 10; w /= 10) e++;
return e;
}
function getLn10(Ctor, sd, pr) {
if (sd > Ctor.LN10.sd()) {
// Reset global state in case the exception is caught.
external = true;
if (pr) Ctor.precision = pr;
throw Error(decimalError + 'LN10 precision limit exceeded');
}
return round(new Ctor(Ctor.LN10), sd);
}
function getZeroString(k) {
var zs = '';
for (; k--;) zs += '0';
return zs;
}
/*
* Return a new Decimal whose value is the natural logarithm of `x` truncated to `sd` significant
* digits.
*
* ln(n) is non-terminating (n != 1)
*
*/
function ln(y, sd) {
var c, c0, denominator, e, numerator, sum, t, wpr, x2,
n = 1,
guard = 10,
x = y,
xd = x.d,
Ctor = x.constructor,
pr = Ctor.precision;
// ln(-x) = NaN
// ln(0) = -Infinity
if (x.s < 1) throw Error(decimalError + (x.s ? 'NaN' : '-Infinity'));
// ln(1) = 0
if (x.eq(ONE)) return new Ctor(0);
if (sd == null) {
external = false;
wpr = pr;
} else {
wpr = sd;
}
if (x.eq(10)) {
if (sd == null) external = true;
return getLn10(Ctor, wpr);
}
wpr += guard;
Ctor.precision = wpr;
c = digitsToString(xd);
c0 = c.charAt(0);
e = getBase10Exponent(x);
if (Math.abs(e) < 1.5e15) {
// Argument reduction.
// The series converges faster the closer the argument is to 1, so using
// ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b
// multiply the argument by itself until the leading digits of the significand are 7, 8, 9,
// 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can
// later be divided by this number, then separate out the power of 10 using
// ln(a*10^b) = ln(a) + b*ln(10).
// max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14).
//while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) {
// max n is 6 (gives 0.7 - 1.3)
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
x = x.times(y);
c = digitsToString(x.d);
c0 = c.charAt(0);
n++;
}
e = getBase10Exponent(x);
if (c0 > 1) {
x = new Ctor('0.' + c);
e++;
} else {
x = new Ctor(c0 + '.' + c.slice(1));
}
} else {
// The argument reduction method above may result in overflow if the argument y is a massive
// number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this
// function using ln(x*10^e) = ln(x) + e*ln(10).
t = getLn10(Ctor, wpr + 2, pr).times(e + '');
x = ln(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t);
Ctor.precision = pr;
return sd == null ? (external = true, round(x, pr)) : x;
}
// x is reduced to a value near 1.
// Taylor series.
// ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...)
// where x = (y - 1)/(y + 1) (|x| < 1)
sum = numerator = x = divide(x.minus(ONE), x.plus(ONE), wpr);
x2 = round(x.times(x), wpr);
denominator = 3;
for (;;) {
numerator = round(numerator.times(x2), wpr);
t = sum.plus(divide(numerator, new Ctor(denominator), wpr));
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
sum = sum.times(2);
// Reverse the argument reduction.
if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ''));
sum = divide(sum, new Ctor(n), wpr);
Ctor.precision = pr;
return sd == null ? (external = true, round(sum, pr)) : sum;
}
sum = t;
denominator += 2;
}
}
/*
* Parse the value of a new Decimal `x` from string `str`.
*/
function parseDecimal(x, str) {
var e, i, len;
// Decimal point?
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
// Exponential form?
if ((i = str.search(/e/i)) > 0) {
// Determine exponent.
if (e < 0) e = i;
e += +str.slice(i + 1);
str = str.substring(0, i);
} else if (e < 0) {
// Integer.
e = str.length;
}
// Determine leading zeros.
for (i = 0; str.charCodeAt(i) === 48;) ++i;
// Determine trailing zeros.
for (len = str.length; str.charCodeAt(len - 1) === 48;) --len;
str = str.slice(i, len);
if (str) {
len -= i;
e = e - i - 1;
x.e = mathfloor(e / LOG_BASE);
x.d = [];
// Transform base
// e is the base 10 exponent.
// i is where to slice str to get the first word of the digits array.
i = (e + 1) % LOG_BASE;
if (e < 0) i += LOG_BASE;
if (i < len) {
if (i) x.d.push(+str.slice(0, i));
for (len -= LOG_BASE; i < len;) x.d.push(+str.slice(i, i += LOG_BASE));
str = str.slice(i);
i = LOG_BASE - str.length;
} else {
i -= len;
}
for (; i--;) str += '0';
x.d.push(+str);
if (external && (x.e > MAX_E || x.e < -MAX_E)) throw Error(exponentOutOfRange + e);
} else {
// Zero.
x.s = 0;
x.e = 0;
x.d = [0];
}
return x;
}
/*
* Round `x` to `sd` significant digits, using rounding mode `rm` if present (truncate otherwise).
*/
function round(x, sd, rm) {
var i, j, k, n, rd, doRound, w, xdi,
xd = x.d;
// rd: the rounding digit, i.e. the digit after the digit that may be rounded up.
// w: the word of xd which contains the rounding digit, a base 1e7 number.
// xdi: the index of w within xd.
// n: the number of digits of w.
// i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if
// they had leading zeros)
// j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
// Get the length of the first word of the digits array xd.
for (n = 1, k = xd[0]; k >= 10; k /= 10) n++;
i = sd - n;
// Is the rounding digit in the first word of xd?
if (i < 0) {
i += LOG_BASE;
j = sd;
w = xd[xdi = 0];
} else {
xdi = Math.ceil((i + 1) / LOG_BASE);
k = xd.length;
if (xdi >= k) return x;
w = k = xd[xdi];
// Get the number of digits of w.
for (n = 1; k >= 10; k /= 10) n++;
// Get the index of rd within w.
i %= LOG_BASE;
// Get the index of rd within w, adjusted for leading zeros.
// The number of leading zeros of w is given by LOG_BASE - n.
j = i - LOG_BASE + n;
}
if (rm !== void 0) {
k = mathpow(10, n - j - 1);
// Get the rounding digit at index j of w.
rd = w / k % 10 | 0;
// Are there any non-zero digits after the rounding digit?
doRound = sd < 0 || xd[xdi + 1] !== void 0 || w % k;
// The expression `w % mathpow(10, n - j - 1)` returns all the digits of w to the right of the
// digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression will give
// 714.
doRound = rm < 4
? (rd || doRound) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
: rd > 5 || rd == 5 && (rm == 4 || doRound || rm == 6 &&
// Check whether the digit to the left of the rounding digit is odd.
((i > 0 ? j > 0 ? w / mathpow(10, n - j) : 0 : xd[xdi - 1]) % 10) & 1 ||
rm == (x.s < 0 ? 8 : 7));
}
if (sd < 1 || !xd[0]) {
if (doRound) {
k = getBase10Exponent(x);
xd.length = 1;
// Convert sd to decimal places.
sd = sd - k - 1;
// 1, 0.1, 0.01, 0.001, 0.0001 etc.
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
x.e = mathfloor(-sd / LOG_BASE) || 0;
} else {
xd.length = 1;
// Zero.
xd[0] = x.e = x.s = 0;
}
return x;
}
// Remove excess digits.
if (i == 0) {
xd.length = xdi;
k = 1;
xdi--;
} else {
xd.length = xdi + 1;
k = mathpow(10, LOG_BASE - i);
// E.g. 56700 becomes 56000 if 7 is the rounding digit.
// j > 0 means i > number of leading zeros of w.
xd[xdi] = j > 0 ? (w / mathpow(10, n - j) % mathpow(10, j) | 0) * k : 0;
}
if (doRound) {
for (;;) {
// Is the digit to be rounded up in the first word of xd?
if (xdi == 0) {
if ((xd[0] += k) == BASE) {
xd[0] = 1;
++x.e;
}
break;
} else {
xd[xdi] += k;
if (xd[xdi] != BASE) break;
xd[xdi--] = 0;
k = 1;
}
}
}
// Remove trailing zeros.
for (i = xd.length; xd[--i] === 0;) xd.pop();
if (external && (x.e > MAX_E || x.e < -MAX_E)) {
throw Error(exponentOutOfRange + getBase10Exponent(x));
}
return x;
}
function subtract(x, y) {
var d, e, i, j, k, len, xd, xe, xLTy, yd,
Ctor = x.constructor,
pr = Ctor.precision;
// Return y negated if x is zero.
// Return x if y is zero and x is non-zero.
if (!x.s || !y.s) {
if (y.s) y.s = -y.s;
else y = new Ctor(x);
return external ? round(y, pr) : y;
}
xd = x.d;
yd = y.d;
// x and y are non-zero numbers with the same sign.
e = y.e;
xe = x.e;
xd = xd.slice();
k = xe - e;
// If exponents differ...
if (k) {
xLTy = k < 0;
if (xLTy) {
d = xd;
k = -k;
len = yd.length;
} else {
d = yd;
e = xe;
len = xd.length;
}
// Numbers with massively different exponents would result in a very high number of zeros
// needing to be prepended, but this can be avoided while still ensuring correct rounding by
// limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`.
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
if (k > i) {
k = i;
d.length = 1;
}
// Prepend zeros to equalise exponents.
d.reverse();
for (i = k; i--;) d.push(0);
d.reverse();
// Base 1e7 exponents equal.
} else {
// Check digits to determine which is the bigger number.
i = xd.length;
len = yd.length;
xLTy = i < len;
if (xLTy) len = i;
for (i = 0; i < len; i++) {
if (xd[i] != yd[i]) {
xLTy = xd[i] < yd[i];
break;
}
}
k = 0;
}
if (xLTy) {
d = xd;
xd = yd;
yd = d;
y.s = -y.s;
}
len = xd.length;
// Append zeros to xd if shorter.
// Don't add zeros to yd if shorter as subtraction only needs to start at yd length.
for (i = yd.length - len; i > 0; --i) xd[len++] = 0;
// Subtract yd from xd.
for (i = yd.length; i > k;) {
if (xd[--i] < yd[i]) {
for (j = i; j && xd[--j] === 0;) xd[j] = BASE - 1;
--xd[j];
xd[i] += BASE;
}
xd[i] -= yd[i];
}
// Remove trailing zeros.
for (; xd[--len] === 0;) xd.pop();
// Remove leading zeros and adjust exponent accordingly.
for (; xd[0] === 0; xd.shift()) --e;
// Zero?
if (!xd[0]) return new Ctor(0);
y.d = xd;
y.e = e;
//return external && xd.length >= pr / LOG_BASE ? round(y, pr) : y;
return external ? round(y, pr) : y;
}
function toString(x, isExp, sd) {
var k,
e = getBase10Exponent(x),
str = digitsToString(x.d),
len = str.length;
if (isExp) {
if (sd && (k = sd - len) > 0) {
str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k);
} else if (len > 1) {
str = str.charAt(0) + '.' + str.slice(1);
}
str = str + (e < 0 ? 'e' : 'e+') + e;
} else if (e < 0) {
str = '0.' + getZeroString(-e - 1) + str;
if (sd && (k = sd - len) > 0) str += getZeroString(k);
} else if (e >= len) {
str += getZeroString(e + 1 - len);
if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k);
} else {
if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k);
if (sd && (k = sd - len) > 0) {
if (e + 1 === len) str += '.';
str += getZeroString(k);
}
}
return x.s < 0 ? '-' + str : str;
}
// Does not strip trailing zeros.
function truncate(arr, len) {
if (arr.length > len) {
arr.length = len;
return true;
}
}
// Decimal methods
/*
* clone
* config/set
*/
/*
* Create and return a Decimal constructor with the same configuration properties as this Decimal
* constructor.
*
*/
function clone(obj) {
var i, p, ps;
/*
* The Decimal constructor and exported function.
* Return a new Decimal instance.
*
* value {number|string|Decimal} A numeric value.
*
*/
function Decimal(value) {
var x = this;
// Decimal called without new.
if (!(x instanceof Decimal)) return new Decimal(value);
// Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor
// which points to Object.
x.constructor = Decimal;
// Duplicate.
if (value instanceof Decimal) {
x.s = value.s;
x.e = value.e;
x.d = (value = value.d) ? value.slice() : value;
return;
}
if (typeof value === 'number') {
// Reject Infinity/NaN.
if (value * 0 !== 0) {
throw Error(invalidArgument + value);
}
if (value > 0) {
x.s = 1;
} else if (value < 0) {
value = -value;
x.s = -1;
} else {
x.s = 0;
x.e = 0;
x.d = [0];
return;
}
// Fast path for small integers.
if (value === ~~value && value < 1e7) {
x.e = 0;
x.d = [value];
return;
}
return parseDecimal(x, value.toString());
} else if (typeof value !== 'string') {
throw Error(invalidArgument + value);
}
// Minus sign?
if (value.charCodeAt(0) === 45) {
value = value.slice(1);
x.s = -1;
} else {
x.s = 1;
}
if (isDecimal.test(value)) parseDecimal(x, value);
else throw Error(invalidArgument + value);
}
Decimal.prototype = P;
Decimal.ROUND_UP = 0;
Decimal.ROUND_DOWN = 1;
Decimal.ROUND_CEIL = 2;
Decimal.ROUND_FLOOR = 3;
Decimal.ROUND_HALF_UP = 4;
Decimal.ROUND_HALF_DOWN = 5;
Decimal.ROUND_HALF_EVEN = 6;
Decimal.ROUND_HALF_CEIL = 7;
Decimal.ROUND_HALF_FLOOR = 8;
Decimal.clone = clone;
Decimal.config = Decimal.set = config;
if (obj === void 0) obj = {};
if (obj) {
ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'LN10'];
for (i = 0; i < ps.length;) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
}
Decimal.config(obj);
return Decimal;
}
/*
* Configure global settings for a Decimal constructor.
*
* `obj` is an object with one or more of the following properties,
*
* precision {number}
* rounding {number}
* toExpNeg {number}
* toExpPos {number}
*
* E.g. Decimal.config({ precision: 20, rounding: 4 })
*
*/
function config(obj) {
if (!obj || typeof obj !== 'object') {
throw Error(decimalError + 'Object expected');
}
var i, p, v,
ps = [
'precision', 1, MAX_DIGITS,
'rounding', 0, 8,
'toExpNeg', -1 / 0, 0,
'toExpPos', 0, 1 / 0
];
for (i = 0; i < ps.length; i += 3) {
if ((v = obj[p = ps[i]]) !== void 0) {
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;
else throw Error(invalidArgument + p + ': ' + v);
}
}
if ((v = obj[p = 'LN10']) !== void 0) {
if (v == Math.LN10) this[p] = new this(v);
else throw Error(invalidArgument + p + ': ' + v);
}
return this;
}
// Create and configure initial Decimal constructor.
Decimal = clone(Decimal);
Decimal['default'] = Decimal.Decimal = Decimal;
// Internal constant.
ONE = new Decimal(1);
// Export.
// AMD.
if (true) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
return Decimal;
}).call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
// Node and other environments that support module.exports.
} else {}
})(this);
/***/ }),
/***/ 1640:
/***/ (function(module) {
"use strict";
var has = Object.prototype.hasOwnProperty
, prefix = '~';
/**
* Constructor to create a storage for our `EE` objects.
* An `Events` instance is a plain object whose properties are event names.
*
* @constructor
* @private
*/
function Events() {}
//
// We try to not inherit from `Object.prototype`. In some engines creating an
// instance in this way is faster than calling `Object.create(null)` directly.
// If `Object.create(null)` is not supported we prefix the event names with a
// character to make sure that the built-in object properties are not
// overridden or used as an attack vector.
//
if (Object.create) {
Events.prototype = Object.create(null);
//
// This hack is needed because the `__proto__` property is still inherited in
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
//
if (!new Events().__proto__) prefix = false;
}
/**
* Representation of a single event listener.
*
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
* @constructor
* @private
*/
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
/**
* Add a listener for a given event.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} once Specify if the listener is a one-time listener.
* @returns {EventEmitter}
* @private
*/
function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once)
, evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
else emitter._events[evt] = [emitter._events[evt], listener];
return emitter;
}
/**
* Clear event by name.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} evt The Event name.
* @private
*/
function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
}
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*
* @constructor
* @public
*/
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*
* @returns {Array}
* @public
*/
EventEmitter.prototype.eventNames = function eventNames() {
var names = []
, events
, name;
if (this._eventsCount === 0) return names;
for (name in (events = this._events)) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
/**
* Return the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Array} The registered listeners.
* @public
*/
EventEmitter.prototype.listeners = function listeners(event) {
var evt = prefix ? prefix + event : event
, handlers = this._events[evt];
if (!handlers) return [];
if (handlers.fn) return [handlers.fn];
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
ee[i] = handlers[i].fn;
}
return ee;
};
/**
* Return the number of listeners listening to a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Number} The number of listeners.
* @public
*/
EventEmitter.prototype.listenerCount = function listenerCount(event) {
var evt = prefix ? prefix + event : event
, listeners = this._events[evt];
if (!listeners) return 0;
if (listeners.fn) return 1;
return listeners.length;
};
/**
* Calls each of the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Boolean} `true` if the event had listeners, else `false`.
* @public
*/
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt]
, len = arguments.length
, args
, i;
if (listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}
for (i = 1, args = new Array(len -1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1: listeners[i].fn.call(listeners[i].context); break;
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
default:
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
/**
* Add a listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.on = function on(event, fn, context) {
return addListener(this, event, fn, context, false);
};
/**
* Add a one-time listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.once = function once(event, fn, context) {
return addListener(this, event, fn, context, true);
};
/**
* Remove the listeners of a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn Only remove the listeners that match this function.
* @param {*} context Only remove the listeners that have this context.
* @param {Boolean} once Only remove one-time listeners.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
clearEvent(this, evt);
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (
listeners.fn === fn &&
(!once || listeners.once) &&
(!context || listeners.context === context)
) {
clearEvent(this, evt);
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (
listeners[i].fn !== fn ||
(once && !listeners[i].once) ||
(context && listeners[i].context !== context)
) {
events.push(listeners[i]);
}
}
//
// Reset the array, or remove it completely if we have no more listeners.
//
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
else clearEvent(this, evt);
}
return this;
};
/**
* Remove all listeners, or those of the specified event.
*
* @param {(String|Symbol)} [event] The event name.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) clearEvent(this, evt);
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
//
// Alias methods names because people roll like that.
//
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
//
// Expose the prefix.
//
EventEmitter.prefixed = prefix;
//
// Allow `EventEmitter` to be imported as module namespace.
//
EventEmitter.EventEmitter = EventEmitter;
//
// Expose the module.
//
if (true) {
module.exports = EventEmitter;
}
/***/ }),
/***/ 3096:
/***/ (function(module) {
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
(function (global, factory) {
true ? module.exports = factory() :
0;
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;
function createClass(ctor, superClass) {
if (superClass) {
ctor.prototype = Object.create(superClass.prototype);
}
ctor.prototype.constructor = ctor;
}
function Iterable(value) {
return isIterable(value) ? value : Seq(value);
}
createClass(KeyedIterable, Iterable);
function KeyedIterable(value) {
return isKeyed(value) ? value : KeyedSeq(value);
}
createClass(IndexedIterable, Iterable);
function IndexedIterable(value) {
return isIndexed(value) ? value : IndexedSeq(value);
}
createClass(SetIterable, Iterable);
function SetIterable(value) {
return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
}
function isIterable(maybeIterable) {
return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
}
function isKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
}
function isIndexed(maybeIndexed) {
return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
}
function isAssociative(maybeAssociative) {
return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
}
function isOrdered(maybeOrdered) {
return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
}
Iterable.isIterable = isIterable;
Iterable.isKeyed = isKeyed;
Iterable.isIndexed = isIndexed;
Iterable.isAssociative = isAssociative;
Iterable.isOrdered = isOrdered;
Iterable.Keyed = KeyedIterable;
Iterable.Indexed = IndexedIterable;
Iterable.Set = SetIterable;
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on.
var DELETE = 'delete';
// Constants describing the size of trie nodes.
var SHIFT = 5; // Resulted in best performance after ______?
var SIZE = 1 << SHIFT;
var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other
// than itself, and nothing that could be provided externally.
var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`.
var CHANGE_LENGTH = { value: false };
var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false;
return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes
// to tries. The return value will only ever equal itself, and will not equal
// the return of any subsequent call of this function.
function OwnerID() {}
// http://jsperf.com/copy-array-inline
function arrCopy(arr, offset) {
offset = offset || 0;
var len = Math.max(0, arr.length - offset);
var newArr = new Array(len);
for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
}
return newArr;
}
function ensureSize(iter) {
if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
}
return iter.size;
}
function wrapIndex(iter, index) {
// This implements "is array index" which the ECMAString spec defines as:
//
// A String property name P is an array index if and only if
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
// to 2^32−1.
//
// http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
if (typeof index !== 'number') {
var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
if ('' + uint32Index !== index || uint32Index === 4294967295) {
return NaN;
}
index = uint32Index;
}
return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() {
return true;
}
function wholeSlice(begin, end, size) {
return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) {
return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) {
return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) {
return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0;
var ITERATE_VALUES = 1;
var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
function Iterator(next) {
this.next = next;
}
Iterator.prototype.toString = function() {
return '[Iterator]';
};
Iterator.KEYS = ITERATE_KEYS;
Iterator.VALUES = ITERATE_VALUES;
Iterator.ENTRIES = ITERATE_ENTRIES;
Iterator.prototype.inspect =
Iterator.prototype.toSource = function () { return this.toString(); }
Iterator.prototype[ITERATOR_SYMBOL] = function () {
return this;
};
function iteratorValue(type, k, v, iteratorResult) {
var value = type === 0 ? k : type === 1 ? v : [k, v];
iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
value: value, done: false
});
return iteratorResult;
}
function iteratorDone() {
return { value: undefined, done: true };
}
function hasIterator(maybeIterable) {
return !!getIteratorFn(maybeIterable);
}
function isIterator(maybeIterator) {
return maybeIterator && typeof maybeIterator.next === 'function';
}
function getIterator(iterable) {
var iteratorFn = getIteratorFn(iterable);
return iteratorFn && iteratorFn.call(iterable);
}
function getIteratorFn(iterable) {
var iteratorFn = iterable && (
(REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
iterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
function isArrayLike(value) {
return value && typeof value.length === 'number';
}
createClass(Seq, Iterable);
function Seq(value) {
return value === null || value === undefined ? emptySequence() :
isIterable(value) ? value.toSeq() : seqFromValue(value);
}
Seq.of = function(/*...values*/) {
return Seq(arguments);
};
Seq.prototype.toSeq = function() {
return this;
};
Seq.prototype.toString = function() {
return this.__toString('Seq {', '}');
};
Seq.prototype.cacheResult = function() {
if (!this._cache && this.__iterateUncached) {
this._cache = this.entrySeq().toArray();
this.size = this._cache.length;
}
return this;
};
// abstract __iterateUncached(fn, reverse)
Seq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, true);
};
// abstract __iteratorUncached(type, reverse)
Seq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, true);
};
createClass(KeyedSeq, Seq);
function KeyedSeq(value) {
return value === null || value === undefined ?
emptySequence().toKeyedSeq() :
isIterable(value) ?
(isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
keyedSeqFromValue(value);
}
KeyedSeq.prototype.toKeyedSeq = function() {
return this;
};
createClass(IndexedSeq, Seq);
function IndexedSeq(value) {
return value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
}
IndexedSeq.of = function(/*...values*/) {
return IndexedSeq(arguments);
};
IndexedSeq.prototype.toIndexedSeq = function() {
return this;
};
IndexedSeq.prototype.toString = function() {
return this.__toString('Seq [', ']');
};
IndexedSeq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, false);
};
IndexedSeq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, false);
};
createClass(SetSeq, Seq);
function SetSeq(value) {
return (
value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value
).toSetSeq();
}
SetSeq.of = function(/*...values*/) {
return SetSeq(arguments);
};
SetSeq.prototype.toSetSeq = function() {
return this;
};
Seq.isSeq = isSeq;
Seq.Keyed = KeyedSeq;
Seq.Set = SetSeq;
Seq.Indexed = IndexedSeq;
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
Seq.prototype[IS_SEQ_SENTINEL] = true;
createClass(ArraySeq, IndexedSeq);
function ArraySeq(array) {
this._array = array;
this.size = array.length;
}
ArraySeq.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
};
ArraySeq.prototype.__iterate = function(fn, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
return ii + 1;
}
}
return ii;
};
ArraySeq.prototype.__iterator = function(type, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
var ii = 0;
return new Iterator(function()
{return ii > maxIndex ?
iteratorDone() :
iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
);
};
createClass(ObjectSeq, KeyedSeq);
function ObjectSeq(object) {
var keys = Object.keys(object);
this._object = object;
this._keys = keys;
this.size = keys.length;
}
ObjectSeq.prototype.get = function(key, notSetValue) {
if (notSetValue !== undefined && !this.has(key)) {
return notSetValue;
}
return this._object[key];
};
ObjectSeq.prototype.has = function(key) {
return this._object.hasOwnProperty(key);
};
ObjectSeq.prototype.__iterate = function(fn, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var key = keys[reverse ? maxIndex - ii : ii];
if (fn(object[key], key, this) === false) {
return ii + 1;
}
}
return ii;
};
ObjectSeq.prototype.__iterator = function(type, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
var ii = 0;
return new Iterator(function() {
var key = keys[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, key, object[key]);
});
};
ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
createClass(IterableSeq, IndexedSeq);
function IterableSeq(iterable) {
this._iterable = iterable;
this.size = iterable.length || iterable.size;
}
IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
var iterations = 0;
if (isIterator(iterator)) {
var step;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
}
return iterations;
};
IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
if (!isIterator(iterator)) {
return new Iterator(iteratorDone);
}
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step : iteratorValue(type, iterations++, step.value);
});
};
createClass(IteratorSeq, IndexedSeq);
function IteratorSeq(iterator) {
this._iterator = iterator;
this._iteratorCache = [];
}
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
while (iterations < cache.length) {
if (fn(cache[iterations], iterations++, this) === false) {
return iterations;
}
}
var step;
while (!(step = iterator.next()).done) {
var val = step.value;
cache[iterations] = val;
if (fn(val, iterations++, this) === false) {
break;
}
}
return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
return new Iterator(function() {
if (iterations >= cache.length) {
var step = iterator.next();
if (step.done) {
return step;
}
cache[iterations] = step.value;
}
return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) {
return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() {
return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) {
var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
typeof value === 'object' ? new ObjectSeq(value) :
undefined;
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of [k, v] entries, '+
'or keyed object: ' + value
);
}
return seq;
}
function indexedSeqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value);
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values: ' + value
);
}
return seq;
}
function seqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value));
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values, or keyed object: ' + value
);
}
return seq;
}
function maybeIndexedSeqFromValue(value) {
return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var entry = cache[reverse ? maxIndex - ii : ii];
if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
return ii + 1;
}
}
return ii;
}
return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
var ii = 0;
return new Iterator(function() {
var entry = cache[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
}
return seq.__iteratorUncached(type, reverse);
}
function fromJS(json, converter) {
return converter ?
fromJSWith(converter, json, '', {'': json}) :
fromJSDefault(json);
}
function fromJSWith(converter, json, key, parentJSON) {
if (Array.isArray(json)) {
return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
if (isPlainObj(json)) {
return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
return json;
}
function fromJSDefault(json) {
if (Array.isArray(json)) {
return IndexedSeq(json).map(fromJSDefault).toList();
}
if (isPlainObj(json)) {
return KeyedSeq(json).map(fromJSDefault).toMap();
}
return json;
}
function isPlainObj(value) {
return value && (value.constructor === Object || value.constructor === undefined);
}
/**
* An extension of the "same-value" algorithm as [described for use by ES6 Map
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
*
* NaN is considered the same as NaN, however -0 and 0 are considered the same
* value, which is different from the algorithm described by
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
*
* This is extended further to allow Objects to describe the values they
* represent, by way of `valueOf` or `equals` (and `hashCode`).
*
* Note: because of this extension, the key equality of Immutable.Map and the
* value equality of Immutable.Set will differ from ES6 Map and Set.
*
* ### Defining custom values
*
* The easiest way to describe the value an object represents is by implementing
* `valueOf`. For example, `Date` represents a value by returning a unix
* timestamp for `valueOf`:
*
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
* var date2 = new Date(1234567890000);
* date1.valueOf(); // 1234567890000
* assert( date1 !== date2 );
* assert( Immutable.is( date1, date2 ) );
*
* Note: overriding `valueOf` may have other implications if you use this object
* where JavaScript expects a primitive, such as implicit string coercion.
*
* For more complex types, especially collections, implementing `valueOf` may
* not be performant. An alternative is to implement `equals` and `hashCode`.
*
* `equals` takes another object, presumably of similar type, and returns true
* if the it is equal. Equality is symmetrical, so the same result should be
* returned if this and the argument are flipped.
*
* assert( a.equals(b) === b.equals(a) );
*
* `hashCode` returns a 32bit integer number representing the object which will
* be used to determine how to store the value object in a Map or Set. You must
* provide both or neither methods, one must not exist without the other.
*
* Also, an important relationship between these methods must be upheld: if two
* values are equal, they *must* return the same hashCode. If the values are not
* equal, they might have the same hashCode; this is called a hash collision,
* and while undesirable for performance reasons, it is acceptable.
*
* if (a.equals(b)) {
* assert( a.hashCode() === b.hashCode() );
* }
*
* All Immutable collections implement `equals` and `hashCode`.
*
*/
function is(valueA, valueB) {
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
if (typeof valueA.valueOf === 'function' &&
typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf();
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
}
if (typeof valueA.equals === 'function' &&
typeof valueB.equals === 'function' &&
valueA.equals(valueB)) {
return true;
}
return false;
}
function deepEqual(a, b) {
if (a === b) {
return true;
}
if (
!isIterable(b) ||
a.size !== undefined && b.size !== undefined && a.size !== b.size ||
a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
isKeyed(a) !== isKeyed(b) ||
isIndexed(a) !== isIndexed(b) ||
isOrdered(a) !== isOrdered(b)
) {
return false;
}
if (a.size === 0 && b.size === 0) {
return true;
}
var notAssociative = !isAssociative(a);
if (isOrdered(a)) {
var entries = a.entries();
return b.every(function(v, k) {
var entry = entries.next().value;
return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
}) && entries.next().done;
}
var flipped = false;
if (a.size === undefined) {
if (b.size === undefined) {
if (typeof a.cacheResult === 'function') {
a.cacheResult();
}
} else {
flipped = true;
var _ = a;
a = b;
b = _;
}
}
var allEqual = true;
var bSize = b.__iterate(function(v, k) {
if (notAssociative ? !a.has(v) :
flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
allEqual = false;
return false;
}
});
return allEqual && a.size === bSize;
}
createClass(Repeat, IndexedSeq);
function Repeat(value, times) {
if (!(this instanceof Repeat)) {
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
}
}
Repeat.prototype.toString = function() {
if (this.size === 0) {
return 'Repeat []';
}
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
};
Repeat.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._value : notSetValue;
};
Repeat.prototype.includes = function(searchValue) {
return is(this._value, searchValue);
};
Repeat.prototype.slice = function(begin, end) {
var size = this.size;
return wholeSlice(begin, end, size) ? this :
new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
};
Repeat.prototype.reverse = function() {
return this;
};
Repeat.prototype.indexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return 0;
}
return -1;
};
Repeat.prototype.lastIndexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return this.size;
}
return -1;
};
Repeat.prototype.__iterate = function(fn, reverse) {
for (var ii = 0; ii < this.size; ii++) {
if (fn(this._value, ii, this) === false) {
return ii + 1;
}
}
return ii;
};
Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
var ii = 0;
return new Iterator(function()
{return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
);
};
Repeat.prototype.equals = function(other) {
return other instanceof Repeat ?
is(this._value, other._value) :
deepEqual(other);
};
var EMPTY_REPEAT;
function invariant(condition, error) {
if (!condition) throw new Error(error);
}
createClass(Range, IndexedSeq);
function Range(start, end, step) {
if (!(this instanceof Range)) {
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
start = start || 0;
if (end === undefined) {
end = Infinity;
}
step = step === undefined ? 1 : Math.abs(step);
if (end < start) {
step = -step;
}
this._start = start;
this._end = end;
this._step = step;
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
}
}
Range.prototype.toString = function() {
if (this.size === 0) {
return 'Range []';
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step !== 1 ? ' by ' + this._step : '') +
' ]';
};
Range.prototype.get = function(index, notSetValue) {
return this.has(index) ?
this._start + wrapIndex(this, index) * this._step :
notSetValue;
};
Range.prototype.includes = function(searchValue) {
var possibleIndex = (searchValue - this._start) / this._step;
return possibleIndex >= 0 &&
possibleIndex < this.size &&
possibleIndex === Math.floor(possibleIndex);
};
Range.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
begin = resolveBegin(begin, this.size);
end = resolveEnd(end, this.size);
if (end <= begin) {
return new Range(0, 0);
}
return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
};
Range.prototype.indexOf = function(searchValue) {
var offsetValue = searchValue - this._start;
if (offsetValue % this._step === 0) {
var index = offsetValue / this._step;
if (index >= 0 && index < this.size) {
return index
}
}
return -1;
};
Range.prototype.lastIndexOf = function(searchValue) {
return this.indexOf(searchValue);
};
Range.prototype.__iterate = function(fn, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(value, ii, this) === false) {
return ii + 1;
}
value += reverse ? -step : step;
}
return ii;
};
Range.prototype.__iterator = function(type, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
var ii = 0;
return new Iterator(function() {
var v = value;
value += reverse ? -step : step;
return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
});
};
Range.prototype.equals = function(other) {
return other instanceof Range ?
this._start === other._start &&
this._end === other._end &&
this._step === other._step :
deepEqual(this, other);
};
var EMPTY_RANGE;
createClass(Collection, Iterable);
function Collection() {
throw TypeError('Abstract');
}
createClass(KeyedCollection, Collection);function KeyedCollection() {}
createClass(IndexedCollection, Collection);function IndexedCollection() {}
createClass(SetCollection, Collection);function SetCollection() {}
Collection.Keyed = KeyedCollection;
Collection.Indexed = IndexedCollection;
Collection.Set = SetCollection;
var imul =
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul :
function imul(a, b) {
a = a | 0; // int
b = b | 0; // int
var c = a & 0xffff;
var d = b & 0xffff;
// Shift by 0 fixes the sign on the high part.
return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers.
// Values which have either 00 or 11 as the high order bits qualify.
// This function drops the highest order bit in a signed number, maintaining
// the sign bit.
function smi(i32) {
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) {
if (o === false || o === null || o === undefined) {
return 0;
}
if (typeof o.valueOf === 'function') {
o = o.valueOf();
if (o === false || o === null || o === undefined) {
return 0;
}
}
if (o === true) {
return 1;
}
var type = typeof o;
if (type === 'number') {
if (o !== o || o === Infinity) {
return 0;
}
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
}
while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
}
return smi(h);
}
if (type === 'string') {
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
}
if (typeof o.hashCode === 'function') {
return o.hashCode();
}
if (type === 'object') {
return hashJSObj(o);
}
if (typeof o.toString === 'function') {
return hashString(o.toString());
}
throw new Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) {
var hash = stringHashCache[string];
if (hash === undefined) {
hash = hashString(string);
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
}
return hash;
}
// http://jsperf.com/hashing-strings
function hashString(string) {
// This is the hash from JVM
// The hash code for a string is computed as
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
// where s[i] is the ith character of the string and n is the length of
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
// (exclusive) by dropping high bits.
var hash = 0;
for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
}
return smi(hash);
}
function hashJSObj(obj) {
var hash;
if (usingWeakMap) {
hash = weakMap.get(obj);
if (hash !== undefined) {
return hash;
}
}
hash = obj[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
if (!canDefineProperty) {
hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
hash = getIENodeHash(obj);
if (hash !== undefined) {
return hash;
}
}
hash = ++objHashUID;
if (objHashUID & 0x40000000) {
objHashUID = 0;
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} else if (isExtensible !== undefined && isExtensible(obj) === false) {
throw new Error('Non-extensible objects are not allowed as keys.');
} else if (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, {
'enumerable': false,
'configurable': false,
'writable': false,
'value': hash
});
} else if (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
// Since we can't define a non-enumerable property on the object
// we'll hijack one of the less-used non-enumerable properties to
// save our hash on it. Since this is a function it will not show up in
// `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() {
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} else if (obj.nodeType !== undefined) {
// At this point we couldn't get the IE `uniqueID` to use as a hash
// and we couldn't use a non-enumerable property to exploit the
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
// itself.
obj[UID_HASH_KEY] = hash;
} else {
throw new Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods.
var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test.
var canDefineProperty = (function() {
try {
Object.defineProperty({}, '@', {});
return true;
} catch (e) {
return false;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
// and avoid memory leaks from the IE cloneNode bug.
function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap.
var usingWeakMap = typeof WeakMap === 'function';
var weakMap;
if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__';
if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16;
var STRING_HASH_CACHE_MAX_SIZE = 255;
var STRING_HASH_CACHE_SIZE = 0;
var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity,
'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) {
return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.of = function() {var keyValues = SLICE$0.call(arguments, 0);
return emptyMap().withMutations(function(map ) {
for (var i = 0; i < keyValues.length; i += 2) {
if (i + 1 >= keyValues.length) {
throw new Error('Missing value for key: ' + keyValues[i]);
}
map.set(keyValues[i], keyValues[i + 1]);
}
});
};
Map.prototype.toString = function() {
return this.__toString('Map {', '}');
};
// @pragma Access
Map.prototype.get = function(k, notSetValue) {
return this._root ?
this._root.get(0, undefined, k, notSetValue) :
notSetValue;
};
// @pragma Modification
Map.prototype.set = function(k, v) {
return updateMap(this, k, v);
};
Map.prototype.setIn = function(keyPath, v) {
return this.updateIn(keyPath, NOT_SET, function() {return v});
};
Map.prototype.remove = function(k) {
return updateMap(this, k, NOT_SET);
};
Map.prototype.deleteIn = function(keyPath) {
return this.updateIn(keyPath, function() {return NOT_SET});
};
Map.prototype.update = function(k, notSetValue, updater) {
return arguments.length === 1 ?
k(this) :
this.updateIn([k], notSetValue, updater);
};
Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
if (!updater) {
updater = notSetValue;
notSetValue = undefined;
}
var updatedValue = updateInDeepMap(
this,
forceIterator(keyPath),
notSetValue,
updater
);
return updatedValue === NOT_SET ? undefined : updatedValue;
};
Map.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._root = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyMap();
};
// @pragma Composition
Map.prototype.merge = function(/*...iters*/) {
return mergeIntoMapWith(this, undefined, arguments);
};
Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, merger, iters);
};
Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.merge === 'function' ?
m.merge.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoMapWith(this, deepMerger, arguments);
};
Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
};
Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.mergeDeep === 'function' ?
m.mergeDeep.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.sort = function(comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator));
};
Map.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator, mapper));
};
// @pragma Mutability
Map.prototype.withMutations = function(fn) {
var mutable = this.asMutable();
fn(mutable);
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
};
Map.prototype.asMutable = function() {
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
};
Map.prototype.asImmutable = function() {
return this.__ensureOwner();
};
Map.prototype.wasAltered = function() {
return this.__altered;
};
Map.prototype.__iterator = function(type, reverse) {
return new MapIterator(this, type, reverse);
};
Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
this._root && this._root.iterate(function(entry ) {
iterations++;
return fn(entry[1], entry[0], this$0);
}, reverse);
return iterations;
};
Map.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeMap(this.size, this._root, ownerID, this.__hash);
};
function isMap(maybeMap) {
return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
}
Map.isMap = isMap;
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
var MapPrototype = Map.prototype;
MapPrototype[IS_MAP_SENTINEL] = true;
MapPrototype[DELETE] = MapPrototype.remove;
MapPrototype.removeIn = MapPrototype.deleteIn;
// #pragma Trie Nodes
function ArrayMapNode(ownerID, entries) {
this.ownerID = ownerID;
this.entries = entries;
}
ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && entries.length === 1) {
return; // undefined
}
if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
return createNodes(ownerID, entries, key, value);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new ArrayMapNode(ownerID, newEntries);
};
function BitmapIndexedNode(ownerID, bitmap, nodes) {
this.ownerID = ownerID;
this.bitmap = bitmap;
this.nodes = nodes;
}
BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
var bitmap = this.bitmap;
return (bitmap & bit) === 0 ? notSetValue :
this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
};
BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var bit = 1 << keyHashFrag;
var bitmap = this.bitmap;
var exists = (bitmap & bit) !== 0;
if (!exists && value === NOT_SET) {
return this;
}
var idx = popCount(bitmap & (bit - 1));
var nodes = this.nodes;
var node = exists ? nodes[idx] : undefined;
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
}
if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
return nodes[idx ^ 1];
}
if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
return newNode;
}
var isEditable = ownerID && ownerID === this.ownerID;
var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
var newNodes = exists ? newNode ?
setIn(nodes, idx, newNode, isEditable) :
spliceOut(nodes, idx, isEditable) :
spliceIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.bitmap = newBitmap;
this.nodes = newNodes;
return this;
}
return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
};
function HashArrayMapNode(ownerID, count, nodes) {
this.ownerID = ownerID;
this.count = count;
this.nodes = nodes;
}
HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var node = this.nodes[idx];
return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
};
HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var removed = value === NOT_SET;
var nodes = this.nodes;
var node = nodes[idx];
if (removed && !node) {
return this;
}
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
var newCount = this.count;
if (!node) {
newCount++;
} else if (!newNode) {
newCount--;
if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
return packNodes(ownerID, nodes, newCount, idx);
}
}
var isEditable = ownerID && ownerID === this.ownerID;
var newNodes = setIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.count = newCount;
this.nodes = newNodes;
return this;
}
return new HashArrayMapNode(ownerID, newCount, newNodes);
};
function HashCollisionNode(ownerID, keyHash, entries) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entries = entries;
}
HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var removed = value === NOT_SET;
if (keyHash !== this.keyHash) {
if (removed) {
return this;
}
SetRef(didAlter);
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
}
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && len === 2) {
return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new HashCollisionNode(ownerID, this.keyHash, newEntries);
};
function ValueNode(ownerID, keyHash, entry) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entry = entry;
}
ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
};
ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var keyMatch = is(key, this.entry[0]);
if (keyMatch ? value === this.entry[1] : removed) {
return this;
}
SetRef(didAlter);
if (removed) {
SetRef(didChangeSize);
return; // undefined
}
if (keyMatch) {
if (ownerID && ownerID === this.ownerID) {
this.entry[1] = value;
return this;
}
return new ValueNode(ownerID, this.keyHash, [key, value]);
}
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
};
// #pragma Iterators
ArrayMapNode.prototype.iterate =
HashCollisionNode.prototype.iterate = function (fn, reverse) {
var entries = this.entries;
for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
return false;
}
}
}
BitmapIndexedNode.prototype.iterate =
HashArrayMapNode.prototype.iterate = function (fn, reverse) {
var nodes = this.nodes;
for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
var node = nodes[reverse ? maxIndex - ii : ii];
if (node && node.iterate(fn, reverse) === false) {
return false;
}
}
}
ValueNode.prototype.iterate = function (fn, reverse) {
return fn(this.entry);
}
createClass(MapIterator, Iterator);
function MapIterator(map, type, reverse) {
this._type = type;
this._reverse = reverse;
this._stack = map._root && mapIteratorFrame(map._root);
}
MapIterator.prototype.next = function() {
var type = this._type;
var stack = this._stack;
while (stack) {
var node = stack.node;
var index = stack.index++;
var maxIndex;
if (node.entry) {
if (index === 0) {
return mapIteratorValue(type, node.entry);
}
} else if (node.entries) {
maxIndex = node.entries.length - 1;
if (index <= maxIndex) {
return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
}
} else {
maxIndex = node.nodes.length - 1;
if (index <= maxIndex) {
var subNode = node.nodes[this._reverse ? maxIndex - index : index];
if (subNode) {
if (subNode.entry) {
return mapIteratorValue(type, subNode.entry);
}
stack = this._stack = mapIteratorFrame(subNode, stack);
}
continue;
}
}
stack = this._stack = this._stack.__prev;
}
return iteratorDone();
};
function mapIteratorValue(type, entry) {
return iteratorValue(type, entry[0], entry[1]);
}
function mapIteratorFrame(node, prev) {
return {
node: node,
index: 0,
__prev: prev
};
}
function makeMap(size, root, ownerID, hash) {
var map = Object.create(MapPrototype);
map.size = size;
map._root = root;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_MAP;
function emptyMap() {
return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
}
function updateMap(map, k, v) {
var newRoot;
var newSize;
if (!map._root) {
if (v === NOT_SET) {
return map;
}
newSize = 1;
newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
} else {
var didChangeSize = MakeRef(CHANGE_LENGTH);
var didAlter = MakeRef(DID_ALTER);
newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
if (!didAlter.value) {
return map;
}
newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
}
if (map.__ownerID) {
map.size = newSize;
map._root = newRoot;
map.__hash = undefined;
map.__altered = true;
return map;
}
return newRoot ? makeMap(newSize, newRoot) : emptyMap();
}
function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (!node) {
if (value === NOT_SET) {
return node;
}
SetRef(didAlter);
SetRef(didChangeSize);
return new ValueNode(ownerID, keyHash, [key, value]);
}
return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
}
function isLeafNode(node) {
return node.constructor === ValueNode || node.constructor === HashCollisionNode;
}
function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
if (node.keyHash === keyHash) {
return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
}
var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var newNode;
var nodes = idx1 === idx2 ?
[mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
}
function createNodes(ownerID, entries, key, value) {
if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]);
for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
}
return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count);
for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii];
if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
}
return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE);
for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node;
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = [];
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value);
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
return mergeIntoCollectionWith(map, merger, iters);
}
function deepMerger(existing, value, key) {
return existing && existing.mergeDeep && isIterable(value) ?
existing.mergeDeep(value) :
is(existing, value) ? existing : value;
}
function deepMergerWith(merger) {
return function(existing, value, key) {
if (existing && existing.mergeDeepWith && isIterable(value)) {
return existing.mergeDeepWith(merger, value);
}
var nextValue = merger(existing, value, key);
return is(existing, nextValue) ? existing : nextValue;
};
}
function mergeIntoCollectionWith(collection, merger, iters) {
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return collection;
}
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
return collection.constructor(iters[0]);
}
return collection.withMutations(function(collection ) {
var mergeIntoMap = merger ?
function(value, key) {
collection.update(key, NOT_SET, function(existing )
{return existing === NOT_SET ? value : merger(existing, value, key)}
);
} :
function(value, key) {
collection.set(key, value);
}
for (var ii = 0; ii < iters.length; ii++) {
iters[ii].forEach(mergeIntoMap);
}
});
}
function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
var isNotSet = existing === NOT_SET;
var step = keyPathIter.next();
if (step.done) {
var existingValue = isNotSet ? notSetValue : existing;
var newValue = updater(existingValue);
return newValue === existingValue ? existing : newValue;
}
invariant(
isNotSet || (existing && existing.set),
'invalid keyPath'
);
var key = step.value;
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
var nextUpdated = updateInDeepMap(
nextExisting,
keyPathIter,
notSetValue,
updater
);
return nextUpdated === nextExisting ? existing :
nextUpdated === NOT_SET ? existing.remove(key) :
(isNotSet ? emptyMap() : existing).set(key, nextUpdated);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val;
return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1;
if (canEdit && idx + 1 === newLen) {
array[idx] = val;
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
}
return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1;
if (canEdit && idx === newLen) {
array.pop();
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
}
return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList();
if (value === null || value === undefined) {
return empty;
}
if (isList(value)) {
return value;
}
var iter = IndexedIterable(value);
var size = iter.size;
if (size === 0) {
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.of = function(/*...values*/) {
return this(arguments);
};
List.prototype.toString = function() {
return this.__toString('List [', ']');
};
// @pragma Access
List.prototype.get = function(index, notSetValue) {
index = wrapIndex(this, index);
if (index >= 0 && index < this.size) {
index += this._origin;
var node = listNodeFor(this, index);
return node && node.array[index & MASK];
}
return notSetValue;
};
// @pragma Modification
List.prototype.set = function(index, value) {
return updateList(this, index, value);
};
List.prototype.remove = function(index) {
return !this.has(index) ? this :
index === 0 ? this.shift() :
index === this.size - 1 ? this.pop() :
this.splice(index, 1);
};
List.prototype.insert = function(index, value) {
return this.splice(index, 0, value);
};
List.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = this._origin = this._capacity = 0;
this._level = SHIFT;
this._root = this._tail = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyList();
};
List.prototype.push = function(/*...values*/) {
var values = arguments;
var oldSize = this.size;
return this.withMutations(function(list ) {
setListBounds(list, 0, oldSize + values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(oldSize + ii, values[ii]);
}
});
};
List.prototype.pop = function() {
return setListBounds(this, 0, -1);
};
List.prototype.unshift = function(/*...values*/) {
var values = arguments;
return this.withMutations(function(list ) {
setListBounds(list, -values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(ii, values[ii]);
}
});
};
List.prototype.shift = function() {
return setListBounds(this, 1);
};
// @pragma Composition
List.prototype.merge = function(/*...iters*/) {
return mergeIntoListWith(this, undefined, arguments);
};
List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, merger, iters);
};
List.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoListWith(this, deepMerger, arguments);
};
List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, deepMergerWith(merger), iters);
};
List.prototype.setSize = function(size) {
return setListBounds(this, 0, size);
};
// @pragma Iteration
List.prototype.slice = function(begin, end) {
var size = this.size;
if (wholeSlice(begin, end, size)) {
return this;
}
return setListBounds(
this,
resolveBegin(begin, size),
resolveEnd(end, size)
);
};
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse);
return new Iterator(function() {
var value = values();
return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value;
while ((value = values()) !== DONE) {
if (fn(value, index++, this) === false) {
break;
}
}
return index;
};
List.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
return this;
}
return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
};
function isList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
List.isList = isList;
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
var ListPrototype = List.prototype;
ListPrototype[IS_LIST_SENTINEL] = true;
ListPrototype[DELETE] = ListPrototype.remove;
ListPrototype.setIn = MapPrototype.setIn;
ListPrototype.deleteIn =
ListPrototype.removeIn = MapPrototype.removeIn;
ListPrototype.update = MapPrototype.update;
ListPrototype.updateIn = MapPrototype.updateIn;
ListPrototype.mergeIn = MapPrototype.mergeIn;
ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
ListPrototype.withMutations = MapPrototype.withMutations;
ListPrototype.asMutable = MapPrototype.asMutable;
ListPrototype.asImmutable = MapPrototype.asImmutable;
ListPrototype.wasAltered = MapPrototype.wasAltered;
function VNode(array, ownerID) {
this.array = array;
this.ownerID = ownerID;
}
// TODO: seems like these methods are very similar
VNode.prototype.removeBefore = function(ownerID, level, index) {
if (index === level ? 1 << level : false || this.array.length === 0) {
return this;
}
var originIndex = (index >>> level) & MASK;
if (originIndex >= this.array.length) {
return new VNode([], ownerID);
}
var removingFirst = originIndex === 0;
var newChild;
if (level > 0) {
var oldChild = this.array[originIndex];
newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
if (newChild === oldChild && removingFirst) {
return this;
}
}
if (removingFirst && !newChild) {
return this;
}
var editable = editableVNode(this, ownerID);
if (!removingFirst) {
for (var ii = 0; ii < originIndex; ii++) {
editable.array[ii] = undefined;
}
}
if (newChild) {
editable.array[originIndex] = newChild;
}
return editable;
};
VNode.prototype.removeAfter = function(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
return this;
}
var sizeIndex = ((index - 1) >>> level) & MASK;
if (sizeIndex >= this.array.length) {
return this;
}
var newChild;
if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1);
if (newChild) {
editable.array[sizeIndex] = newChild;
}
return editable;
};
var DONE = {};
function iterateList(list, reverse) {
var left = list._origin;
var right = list._capacity;
var tailPos = getTailOffset(right);
var tail = list._tail;
return iterateNodeOrLeaf(list._root, list._level, 0);
function iterateNodeOrLeaf(node, level, offset) {
return level === 0 ?
iterateLeaf(node, offset) :
iterateNode(node, level, offset);
}
function iterateLeaf(node, offset) {
var array = offset === tailPos ? tail && tail.array : node && node.array;
var from = offset > left ? 0 : left - offset;
var to = right - offset;
if (to > SIZE) {
to = SIZE;
}
return function() {
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
return array && array[idx];
};
}
function iterateNode(node, level, offset) {
var values;
var array = node && node.array;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
if (to > SIZE) {
to = SIZE;
}
return function() {
do {
if (values) {
var value = values();
if (value !== DONE) {
return value;
}
values = null;
}
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
values = iterateNodeOrLeaf(
array && array[idx], level - SHIFT, offset + (idx << level)
);
} while (true);
};
}
}
function makeList(origin, capacity, level, root, tail, ownerID, hash) {
var list = Object.create(ListPrototype);
list.size = capacity - origin;
list._origin = origin;
list._capacity = capacity;
list._level = level;
list._root = root;
list._tail = tail;
list.__ownerID = ownerID;
list.__hash = hash;
list.__altered = false;
return list;
}
var EMPTY_LIST;
function emptyList() {
return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
}
function updateList(list, index, value) {
index = wrapIndex(list, index);
if (index !== index) {
return list;
}
if (index >= list.size || index < 0) {
return list.withMutations(function(list ) {
index < 0 ?
setListBounds(list, index).set(0, value) :
setListBounds(list, 0, index + 1).set(index, value)
});
}
index += list._origin;
var newTail = list._tail;
var newRoot = list._root;
var didAlter = MakeRef(DID_ALTER);
if (index >= getTailOffset(list._capacity)) {
newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
} else {
newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
}
if (!didAlter.value) {
return list;
}
if (list.__ownerID) {
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
}
function updateVNode(node, ownerID, level, index, value, didAlter) {
var idx = (index >>> level) & MASK;
var nodeHas = node && idx < node.array.length;
if (!nodeHas && value === undefined) {
return node;
}
var newNode;
if (level > 0) {
var lowerNode = node && node.array[idx];
var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
if (newLowerNode === lowerNode) {
return node;
}
newNode = editableVNode(node, ownerID);
newNode.array[idx] = newLowerNode;
return newNode;
}
if (nodeHas && node.array[idx] === value) {
return node;
}
SetRef(didAlter);
newNode = editableVNode(node, ownerID);
if (value === undefined && idx === newNode.array.length - 1) {
newNode.array.pop();
} else {
newNode.array[idx] = value;
}
return newNode;
}
function editableVNode(node, ownerID) {
if (ownerID && node && ownerID === node.ownerID) {
return node;
}
return new VNode(node ? node.array.slice() : [], ownerID);
}
function listNodeFor(list, rawIndex) {
if (rawIndex >= getTailOffset(list._capacity)) {
return list._tail;
}
if (rawIndex < 1 << (list._level + SHIFT)) {
var node = list._root;
var level = list._level;
while (node && level > 0) {
node = node.array[(rawIndex >>> level) & MASK];
level -= SHIFT;
}
return node;
}
}
function setListBounds(list, begin, end) {
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
var owner = list.__ownerID || new OwnerID();
var oldOrigin = list._origin;
var oldCapacity = list._capacity;
var newOrigin = oldOrigin + begin;
var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
// If it's going to end after it starts, it's empty.
if (newOrigin >= newCapacity) {
return list.clear();
}
var newLevel = list._level;
var newRoot = list._root;
// New origin might need creating a higher root.
var offsetShift = 0;
while (newOrigin + offsetShift < 0) {
newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
newLevel += SHIFT;
offsetShift += 1 << newLevel;
}
if (offsetShift) {
newOrigin += offsetShift;
oldOrigin += offsetShift;
newCapacity += offsetShift;
oldCapacity += offsetShift;
}
var oldTailOffset = getTailOffset(oldCapacity);
var newTailOffset = getTailOffset(newCapacity);
// New size might need creating a higher root.
while (newTailOffset >= 1 << (newLevel + SHIFT)) {
newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
newLevel += SHIFT;
}
// Locate or create the new tail.
var oldTail = list._tail;
var newTail = newTailOffset < oldTailOffset ?
listNodeFor(list, newCapacity - 1) :
newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
// Merge Tail into tree.
if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
newRoot = editableVNode(newRoot, owner);
var node = newRoot;
for (var level = newLevel; level > SHIFT; level -= SHIFT) {
var idx = (oldTailOffset >>> level) & MASK;
node = node.array[idx] = editableVNode(node.array[idx], owner);
}
node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
}
// If the size has been reduced, there's a chance the tail needs to be trimmed.
if (newCapacity < oldCapacity) {
newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
}
// If the new origin is within the tail, then we do not need a root.
if (newOrigin >= newTailOffset) {
newOrigin -= newTailOffset;
newCapacity -= newTailOffset;
newLevel = SHIFT;
newRoot = null;
newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
// Otherwise, if the root has been trimmed, garbage collect.
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
offsetShift = 0;
// Identify the new top root node of the subtree of the old root.
while (newRoot) {
var beginIndex = (newOrigin >>> newLevel) & MASK;
if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
break;
}
if (beginIndex) {
offsetShift += (1 << newLevel) * beginIndex;
}
newLevel -= SHIFT;
newRoot = newRoot.array[beginIndex];
}
// Trim the new sides of the new root.
if (newRoot && newOrigin > oldOrigin) {
newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
}
if (newRoot && newTailOffset < oldTailOffset) {
newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
}
if (offsetShift) {
newOrigin -= offsetShift;
newCapacity -= offsetShift;
}
}
if (list.__ownerID) {
list.size = newCapacity - newOrigin;
list._origin = newOrigin;
list._capacity = newCapacity;
list._level = newLevel;
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
}
function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}
return mergeIntoCollectionWith(list, merger, iters);
}
function getTailOffset(size) {
return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
}
createClass(OrderedMap, Map);
// @pragma Construction
function OrderedMap(value) {
return value === null || value === undefined ? emptyOrderedMap() :
isOrderedMap(value) ? value :
emptyOrderedMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
OrderedMap.of = function(/*...values*/) {
return this(arguments);
};
OrderedMap.prototype.toString = function() {
return this.__toString('OrderedMap {', '}');
};
// @pragma Access
OrderedMap.prototype.get = function(k, notSetValue) {
var index = this._map.get(k);
return index !== undefined ? this._list.get(index)[1] : notSetValue;
};
// @pragma Modification
OrderedMap.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._map.clear();
this._list.clear();
return this;
}
return emptyOrderedMap();
};
OrderedMap.prototype.set = function(k, v) {
return updateOrderedMap(this, k, v);
};
OrderedMap.prototype.remove = function(k) {
return updateOrderedMap(this, k, NOT_SET);
};
OrderedMap.prototype.wasAltered = function() {
return this._map.wasAltered() || this._list.wasAltered();
};
OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._list.__iterate(
function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
reverse
);
};
OrderedMap.prototype.__iterator = function(type, reverse) {
return this._list.fromEntrySeq().__iterator(type, reverse);
};
OrderedMap.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
var newList = this._list.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
this._list = newList;
return this;
}
return makeOrderedMap(newMap, newList, ownerID, this.__hash);
};
function isOrderedMap(maybeOrderedMap) {
return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
}
OrderedMap.isOrderedMap = isOrderedMap;
OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
function makeOrderedMap(map, list, ownerID, hash) {
var omap = Object.create(OrderedMap.prototype);
omap.size = map ? map.size : 0;
omap._map = map;
omap._list = list;
omap.__ownerID = ownerID;
omap.__hash = hash;
return omap;
}
var EMPTY_ORDERED_MAP;
function emptyOrderedMap() {
return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
}
function updateOrderedMap(omap, k, v) {
var map = omap._map;
var list = omap._list;
var i = map.get(k);
var has = i !== undefined;
var newMap;
var newList;
if (v === NOT_SET) { // removed
if (!has) {
return omap;
}
if (list.size >= SIZE && list.size >= map.size * 2) {
newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
if (omap.__ownerID) {
newMap.__ownerID = newList.__ownerID = omap.__ownerID;
}
} else {
newMap = map.remove(k);
newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
}
} else {
if (has) {
if (v === list.get(i)[1]) {
return omap;
}
newMap = map;
newList = list.set(i, [k, v]);
} else {
newMap = map.set(k, list.size);
newList = list.set(list.size, [k, v]);
}
}
if (omap.__ownerID) {
omap.size = newMap.size;
omap._map = newMap;
omap._list = newList;
omap.__hash = undefined;
return omap;
}
return makeOrderedMap(newMap, newList);
}
createClass(ToKeyedSequence, KeyedSeq);
function ToKeyedSequence(indexed, useKeys) {
this._iter = indexed;
this._useKeys = useKeys;
this.size = indexed.size;
}
ToKeyedSequence.prototype.get = function(key, notSetValue) {
return this._iter.get(key, notSetValue);
};
ToKeyedSequence.prototype.has = function(key) {
return this._iter.has(key);
};
ToKeyedSequence.prototype.valueSeq = function() {
return this._iter.valueSeq();
};
ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
var reversedSequence = reverseFactory(this, true);
if (!this._useKeys) {
reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
}
return reversedSequence;
};
ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
var mappedSequence = mapFactory(this, mapper, context);
if (!this._useKeys) {
mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
}
return mappedSequence;
};
ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var ii;
return this._iter.__iterate(
this._useKeys ?
function(v, k) {return fn(v, k, this$0)} :
((ii = reverse ? resolveSize(this) : 0),
function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
reverse
);
};
ToKeyedSequence.prototype.__iterator = function(type, reverse) {
if (this._useKeys) {
return this._iter.__iterator(type, reverse);
}
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var ii = reverse ? resolveSize(this) : 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, reverse ? --ii : ii++, step.value, step);
});
};
ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
createClass(ToIndexedSequence, IndexedSeq);
function ToIndexedSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToIndexedSequence.prototype.includes = function(value) {
return this._iter.includes(value);
};
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
};
ToIndexedSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, iterations++, step.value, step)
});
};
createClass(ToSetSequence, SetSeq);
function ToSetSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToSetSequence.prototype.has = function(key) {
return this._iter.includes(key);
};
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
};
ToSetSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, step.value, step.value, step);
});
};
createClass(FromEntriesSequence, KeyedSeq);
function FromEntriesSequence(entries) {
this._iter = entries;
this.size = entries.size;
}
FromEntriesSequence.prototype.entrySeq = function() {
return this._iter.toSeq();
};
FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(entry ) {
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return fn(
indexedIterable ? entry.get(1) : entry[1],
indexedIterable ? entry.get(0) : entry[0],
this$0
);
}
}, reverse);
};
FromEntriesSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return iteratorValue(
type,
indexedIterable ? entry.get(0) : entry[0],
indexedIterable ? entry.get(1) : entry[1],
step
);
}
}
});
};
ToIndexedSequence.prototype.cacheResult =
ToKeyedSequence.prototype.cacheResult =
ToSetSequence.prototype.cacheResult =
FromEntriesSequence.prototype.cacheResult =
cacheResultThrough;
function flipFactory(iterable) {
var flipSequence = makeSequence(iterable);
flipSequence._iter = iterable;
flipSequence.size = iterable.size;
flipSequence.flip = function() {return iterable};
flipSequence.reverse = function () {
var reversedSequence = iterable.reverse.apply(this); // super.reverse()
reversedSequence.flip = function() {return iterable.reverse()};
return reversedSequence;
};
flipSequence.has = function(key ) {return iterable.includes(key)};
flipSequence.includes = function(key ) {return iterable.has(key)};
flipSequence.cacheResult = cacheResultThrough;
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
}
flipSequence.__iteratorUncached = function(type, reverse) {
if (type === ITERATE_ENTRIES) {
var iterator = iterable.__iterator(type, reverse);
return new Iterator(function() {
var step = iterator.next();
if (!step.done) {
var k = step.value[0];
step.value[0] = step.value[1];
step.value[1] = k;
}
return step;
});
}
return iterable.__iterator(
type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
reverse
);
}
return flipSequence;
}
function mapFactory(iterable, mapper, context) {
var mappedSequence = makeSequence(iterable);
mappedSequence.size = iterable.size;
mappedSequence.has = function(key ) {return iterable.has(key)};
mappedSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v === NOT_SET ?
notSetValue :
mapper.call(context, v, key, iterable);
};
mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(
function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
reverse
);
}
mappedSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
return new Iterator(function() {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
return iteratorValue(
type,
key,
mapper.call(context, entry[1], key, iterable),
step
);
});
}
return mappedSequence;
}
function reverseFactory(iterable, useKeys) {
var reversedSequence = makeSequence(iterable);
reversedSequence._iter = iterable;
reversedSequence.size = iterable.size;
reversedSequence.reverse = function() {return iterable};
if (iterable.flip) {
reversedSequence.flip = function () {
var flipSequence = flipFactory(iterable);
flipSequence.reverse = function() {return iterable.flip()};
return flipSequence;
};
}
reversedSequence.get = function(key, notSetValue)
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
reversedSequence.has = function(key )
{return iterable.has(useKeys ? key : -1 - key)};
reversedSequence.includes = function(value ) {return iterable.includes(value)};
reversedSequence.cacheResult = cacheResultThrough;
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
};
reversedSequence.__iterator =
function(type, reverse) {return iterable.__iterator(type, !reverse)};
return reversedSequence;
}
function filterFactory(iterable, predicate, context, useKeys) {
var filterSequence = makeSequence(iterable);
if (useKeys) {
filterSequence.has = function(key ) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
};
filterSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
v : notSetValue;
};
}
filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
}, reverse);
return iterations;
};
filterSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterations = 0;
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
var value = entry[1];
if (predicate.call(context, value, key, iterable)) {
return iteratorValue(type, useKeys ? key : iterations++, value, step);
}
}
});
}
return filterSequence;
}
function countByFactory(iterable, grouper, context) {
var groups = Map().asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
0,
function(a ) {return a + 1}
);
});
return groups.asImmutable();
}
function groupByFactory(iterable, grouper, context) {
var isKeyedIter = isKeyed(iterable);
var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
);
});
var coerce = iterableClass(iterable);
return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
}
function sliceFactory(iterable, begin, end, useKeys) {
var originalSize = iterable.size;
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
if (end === Infinity) {
end = originalSize;
} else {
end = end | 0;
}
}
if (wholeSlice(begin, end, originalSize)) {
return iterable;
}
var resolvedBegin = resolveBegin(begin, originalSize);
var resolvedEnd = resolveEnd(end, originalSize);
// begin or end will be NaN if they were provided as negative numbers and
// this iterable's size is unknown. In that case, cache first so there is
// a known size and these do not resolve to NaN.
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
}
// Note: resolvedEnd is undefined when the original sequence's length is
// unknown and this slice did not supply an end and should contain all
// elements after resolvedBegin.
// In that case, resolvedSize will be NaN and sliceSize will remain undefined.
var resolvedSize = resolvedEnd - resolvedBegin;
var sliceSize;
if (resolvedSize === resolvedSize) {
sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
}
var sliceSeq = makeSequence(iterable);
// If iterable.size is undefined, the size of the realized sliceSeq is
// unknown at this point unless the number of items to slice is 0
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
sliceSeq.get = function (index, notSetValue) {
index = wrapIndex(this, index);
return index >= 0 && index < sliceSize ?
iterable.get(index + resolvedBegin, notSetValue) :
notSetValue;
}
}
sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (sliceSize === 0) {
return 0;
}
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var skipped = 0;
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k) {
if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
iterations !== sliceSize;
}
});
return iterations;
};
sliceSeq.__iteratorUncached = function(type, reverse) {
if (sliceSize !== 0 && reverse) {
return this.cacheResult().__iterator(type, reverse);
}
// Don't bother instantiating parent iterator if taking 0.
var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
var skipped = 0;
var iterations = 0;
return new Iterator(function() {
while (skipped++ < resolvedBegin) {
iterator.next();
}
if (++iterations > sliceSize) {
return iteratorDone();
}
var step = iterator.next();
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations - 1, undefined, step);
} else {
return iteratorValue(type, iterations - 1, step.value[1], step);
}
});
}
return sliceSeq;
}
function takeWhileFactory(iterable, predicate, context) {
var takeSequence = makeSequence(iterable);
takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterations = 0;
iterable.__iterate(function(v, k, c)
{return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
);
return iterations;
};
takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterating = true;
return new Iterator(function() {
if (!iterating) {
return iteratorDone();
}
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var k = entry[0];
var v = entry[1];
if (!predicate.call(context, v, k, this$0)) {
iterating = false;
return iteratorDone();
}
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return takeSequence;
}
function skipWhileFactory(iterable, predicate, context, useKeys) {
var skipSequence = makeSequence(iterable);
skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
});
return iterations;
};
skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var skipping = true;
var iterations = 0;
return new Iterator(function() {
var step, k, v;
do {
step = iterator.next();
if (step.done) {
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations++, undefined, step);
} else {
return iteratorValue(type, iterations++, step.value[1], step);
}
}
var entry = step.value;
k = entry[0];
v = entry[1];
skipping && (skipping = predicate.call(context, v, k, this$0));
} while (skipping);
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return skipSequence;
}
function concatFactory(iterable, values) {
var isKeyedIterable = isKeyed(iterable);
var iters = [iterable].concat(values).map(function(v ) {
if (!isIterable(v)) {
v = isKeyedIterable ?
keyedSeqFromValue(v) :
indexedSeqFromValue(Array.isArray(v) ? v : [v]);
} else if (isKeyedIterable) {
v = KeyedIterable(v);
}
return v;
}).filter(function(v ) {return v.size !== 0});
if (iters.length === 0) {
return iterable;
}
if (iters.length === 1) {
var singleton = iters[0];
if (singleton === iterable ||
isKeyedIterable && isKeyed(singleton) ||
isIndexed(iterable) && isIndexed(singleton)) {
return singleton;
}
}
var concatSeq = new ArraySeq(iters);
if (isKeyedIterable) {
concatSeq = concatSeq.toKeyedSeq();
} else if (!isIndexed(iterable)) {
concatSeq = concatSeq.toSetSeq();
}
concatSeq = concatSeq.flatten(true);
concatSeq.size = iters.reduce(
function(sum, seq) {
if (sum !== undefined) {
var size = seq.size;
if (size !== undefined) {
return sum + size;
}
}
},
0
);
return concatSeq;
}
function flattenFactory(iterable, depth, useKeys) {
var flatSequence = makeSequence(iterable);
flatSequence.__iterateUncached = function(fn, reverse) {
var iterations = 0;
var stopped = false;
function flatDeep(iter, currentDepth) {var this$0 = this;
iter.__iterate(function(v, k) {
if ((!depth || currentDepth < depth) && isIterable(v)) {
flatDeep(v, currentDepth + 1);
} else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
stopped = true;
}
return !stopped;
}, reverse);
}
flatDeep(iterable, 0);
return iterations;
}
flatSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(type, reverse);
var stack = [];
var iterations = 0;
return new Iterator(function() {
while (iterator) {
var step = iterator.next();
if (step.done !== false) {
iterator = stack.pop();
continue;
}
var v = step.value;
if (type === ITERATE_ENTRIES) {
v = v[1];
}
if ((!depth || stack.length < depth) && isIterable(v)) {
stack.push(iterator);
iterator = v.__iterator(type, reverse);
} else {
return useKeys ? step : iteratorValue(type, iterations++, v, step);
}
}
return iteratorDone();
});
}
return flatSequence;
}
function flatMapFactory(iterable, mapper, context) {
var coerce = iterableClass(iterable);
return iterable.toSeq().map(
function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
).flatten(true);
}
function interposeFactory(iterable, separator) {
var interposedSequence = makeSequence(iterable);
interposedSequence.size = iterable.size && iterable.size * 2 -1;
interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k)
{return (!iterations || fn(separator, iterations++, this$0) !== false) &&
fn(v, iterations++, this$0) !== false},
reverse
);
return iterations;
};
interposedSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
var step;
return new Iterator(function() {
if (!step || iterations % 2) {
step = iterator.next();
if (step.done) {
return step;
}
}
return iterations % 2 ?
iteratorValue(type, iterations++, separator) :
iteratorValue(type, iterations++, step.value, step);
});
};
return interposedSequence;
}
function sortFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
var isKeyedIterable = isKeyed(iterable);
var index = 0;
var entries = iterable.toSeq().map(
function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
).toArray();
entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
isKeyedIterable ?
function(v, i) { entries[i].length = 2; } :
function(v, i) { entries[i] = v[1]; }
);
return isKeyedIterable ? KeyedSeq(entries) :
isIndexed(iterable) ? IndexedSeq(entries) :
SetSeq(entries);
}
function maxFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
if (mapper) {
var entry = iterable.toSeq()
.map(function(v, k) {return [v, mapper(v, k, iterable)]})
.reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
return entry && entry[0];
} else {
return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
}
}
function maxCompare(comparator, a, b) {
var comp = comparator(b, a);
// b is considered the new max if the comparator declares them equal, but
// they are not equal and b is in fact a nullish value.
return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
}
function zipWithFactory(keyIter, zipper, iters) {
var zipSequence = makeSequence(keyIter);
zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
// Note: this a generic base implementation of __iterate in terms of
// __iterator which may be more generically useful in the future.
zipSequence.__iterate = function(fn, reverse) {
/* generic:
var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
iterations++;
if (fn(step.value[1], step.value[0], this) === false) {
break;
}
}
return iterations;
*/
// indexed:
var iterator = this.__iterator(ITERATE_VALUES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
return iterations;
};
zipSequence.__iteratorUncached = function(type, reverse) {
var iterators = iters.map(function(i )
{return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
);
var iterations = 0;
var isDone = false;
return new Iterator(function() {
var steps;
if (!isDone) {
steps = iterators.map(function(i ) {return i.next()});
isDone = steps.some(function(s ) {return s.done});
}
if (isDone) {
return iteratorDone();
}
return iteratorValue(
type,
iterations++,
zipper.apply(null, steps.map(function(s ) {return s.value}))
);
});
};
return zipSequence
}
// #pragma Helper Functions
function reify(iter, seq) {
return isSeq(iter) ? seq : iter.constructor(seq);
}
function validateEntry(entry) {
if (entry !== Object(entry)) {
throw new TypeError('Expected [K, V] tuple: ' + entry);
}
}
function resolveSize(iter) {
assertNotInfinite(iter.size);
return ensureSize(iter);
}
function iterableClass(iterable) {
return isKeyed(iterable) ? KeyedIterable :
isIndexed(iterable) ? IndexedIterable :
SetIterable;
}
function makeSequence(iterable) {
return Object.create(
(
isKeyed(iterable) ? KeyedSeq :
isIndexed(iterable) ? IndexedSeq :
SetSeq
).prototype
);
}
function cacheResultThrough() {
if (this._iter.cacheResult) {
this._iter.cacheResult();
this.size = this._iter.size;
return this;
} else {
return Seq.prototype.cacheResult.call(this);
}
}
function defaultComparator(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
function forceIterator(keyPath) {
var iter = getIterator(keyPath);
if (!iter) {
// Array might not be iterable in this environment, so we need a fallback
// to our wrapped type.
if (!isArrayLike(keyPath)) {
throw new TypeError('Expected iterable or array-like: ' + keyPath);
}
iter = getIterator(Iterable(keyPath));
}
return iter;
}
createClass(Record, KeyedCollection);
function Record(defaultValues, name) {
var hasInitialized;
var RecordType = function Record(values) {
if (values instanceof RecordType) {
return values;
}
if (!(this instanceof RecordType)) {
return new RecordType(values);
}
if (!hasInitialized) {
hasInitialized = true;
var keys = Object.keys(defaultValues);
setProps(RecordTypePrototype, keys);
RecordTypePrototype.size = keys.length;
RecordTypePrototype._name = name;
RecordTypePrototype._keys = keys;
RecordTypePrototype._defaultValues = defaultValues;
}
this._map = Map(values);
};
var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
RecordTypePrototype.constructor = RecordType;
return RecordType;
}
Record.prototype.toString = function() {
return this.__toString(recordName(this) + ' {', '}');
};
// @pragma Access
Record.prototype.has = function(k) {
return this._defaultValues.hasOwnProperty(k);
};
Record.prototype.get = function(k, notSetValue) {
if (!this.has(k)) {
return notSetValue;
}
var defaultVal = this._defaultValues[k];
return this._map ? this._map.get(k, defaultVal) : defaultVal;
};
// @pragma Modification
Record.prototype.clear = function() {
if (this.__ownerID) {
this._map && this._map.clear();
return this;
}
var RecordType = this.constructor;
return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
};
Record.prototype.set = function(k, v) {
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
if (this._map && !this._map.has(k)) {
var defaultVal = this._defaultValues[k];
if (v === defaultVal) {
return this;
}
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.remove = function(k) {
if (!this.has(k)) {
return this;
}
var newMap = this._map && this._map.remove(k);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
};
Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
};
Record.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map && this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return makeRecord(this, newMap, ownerID);
};
var RecordPrototype = Record.prototype;
RecordPrototype[DELETE] = RecordPrototype.remove;
RecordPrototype.deleteIn =
RecordPrototype.removeIn = MapPrototype.removeIn;
RecordPrototype.merge = MapPrototype.merge;
RecordPrototype.mergeWith = MapPrototype.mergeWith;
RecordPrototype.mergeIn = MapPrototype.mergeIn;
RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
RecordPrototype.setIn = MapPrototype.setIn;
RecordPrototype.update = MapPrototype.update;
RecordPrototype.updateIn = MapPrototype.updateIn;
RecordPrototype.withMutations = MapPrototype.withMutations;
RecordPrototype.asMutable = MapPrototype.asMutable;
RecordPrototype.asImmutable = MapPrototype.asImmutable;
function makeRecord(likeRecord, map, ownerID) {
var record = Object.create(Object.getPrototypeOf(likeRecord));
record._map = map;
record.__ownerID = ownerID;
return record;
}
function recordName(record) {
return record._name || record.constructor.name || 'Record';
}
function setProps(prototype, names) {
try {
names.forEach(setProp.bind(undefined, prototype));
} catch (error) {
// Object.defineProperty failed. Probably IE8.
}
}
function setProp(prototype, name) {
Object.defineProperty(prototype, name, {
get: function() {
return this.get(name);
},
set: function(value) {
invariant(this.__ownerID, 'Cannot set on an immutable record.');
this.set(name, value);
}
});
}
createClass(Set, SetCollection);
// @pragma Construction
function Set(value) {
return value === null || value === undefined ? emptySet() :
isSet(value) && !isOrdered(value) ? value :
emptySet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
Set.of = function(/*...values*/) {
return this(arguments);
};
Set.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
Set.prototype.toString = function() {
return this.__toString('Set {', '}');
};
// @pragma Access
Set.prototype.has = function(value) {
return this._map.has(value);
};
// @pragma Modification
Set.prototype.add = function(value) {
return updateSet(this, this._map.set(value, true));
};
Set.prototype.remove = function(value) {
return updateSet(this, this._map.remove(value));
};
Set.prototype.clear = function() {
return updateSet(this, this._map.clear());
};
// @pragma Composition
Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return this;
}
if (this.size === 0 && !this.__ownerID && iters.length === 1) {
return this.constructor(iters[0]);
}
return this.withMutations(function(set ) {
for (var ii = 0; ii < iters.length; ii++) {
SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
}
});
};
Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (!iters.every(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (iters.some(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.merge = function() {
return this.union.apply(this, arguments);
};
Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return this.union.apply(this, iters);
};
Set.prototype.sort = function(comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator));
};
Set.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator, mapper));
};
Set.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
};
Set.prototype.__iterator = function(type, reverse) {
return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
};
Set.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return this.__make(newMap, ownerID);
};
function isSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
}
Set.isSet = isSet;
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
var SetPrototype = Set.prototype;
SetPrototype[IS_SET_SENTINEL] = true;
SetPrototype[DELETE] = SetPrototype.remove;
SetPrototype.mergeDeep = SetPrototype.merge;
SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
SetPrototype.withMutations = MapPrototype.withMutations;
SetPrototype.asMutable = MapPrototype.asMutable;
SetPrototype.asImmutable = MapPrototype.asImmutable;
SetPrototype.__empty = emptySet;
SetPrototype.__make = makeSet;
function updateSet(set, newMap) {
if (set.__ownerID) {
set.size = newMap.size;
set._map = newMap;
return set;
}
return newMap === set._map ? set :
newMap.size === 0 ? set.__empty() :
set.__make(newMap);
}
function makeSet(map, ownerID) {
var set = Object.create(SetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_SET;
function emptySet() {
return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
}
createClass(OrderedSet, Set);
// @pragma Construction
function OrderedSet(value) {
return value === null || value === undefined ? emptyOrderedSet() :
isOrderedSet(value) ? value :
emptyOrderedSet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
OrderedSet.of = function(/*...values*/) {
return this(arguments);
};
OrderedSet.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
OrderedSet.prototype.toString = function() {
return this.__toString('OrderedSet {', '}');
};
function isOrderedSet(maybeOrderedSet) {
return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
}
OrderedSet.isOrderedSet = isOrderedSet;
var OrderedSetPrototype = OrderedSet.prototype;
OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
OrderedSetPrototype.__empty = emptyOrderedSet;
OrderedSetPrototype.__make = makeOrderedSet;
function makeOrderedSet(map, ownerID) {
var set = Object.create(OrderedSetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_ORDERED_SET;
function emptyOrderedSet() {
return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
}
createClass(Stack, IndexedCollection);
// @pragma Construction
function Stack(value) {
return value === null || value === undefined ? emptyStack() :
isStack(value) ? value :
emptyStack().unshiftAll(value);
}
Stack.of = function(/*...values*/) {
return this(arguments);
};
Stack.prototype.toString = function() {
return this.__toString('Stack [', ']');
};
// @pragma Access
Stack.prototype.get = function(index, notSetValue) {
var head = this._head;
index = wrapIndex(this, index);
while (head && index--) {
head = head.next;
}
return head ? head.value : notSetValue;
};
Stack.prototype.peek = function() {
return this._head && this._head.value;
};
// @pragma Modification
Stack.prototype.push = function(/*...values*/) {
if (arguments.length === 0) {
return this;
}
var newSize = this.size + arguments.length;
var head = this._head;
for (var ii = arguments.length - 1; ii >= 0; ii--) {
head = {
value: arguments[ii],
next: head
};
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pushAll = function(iter) {
iter = IndexedIterable(iter);
if (iter.size === 0) {
return this;
}
assertNotInfinite(iter.size);
var newSize = this.size;
var head = this._head;
iter.reverse().forEach(function(value ) {
newSize++;
head = {
value: value,
next: head
};
});
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pop = function() {
return this.slice(1);
};
Stack.prototype.unshift = function(/*...values*/) {
return this.push.apply(this, arguments);
};
Stack.prototype.unshiftAll = function(iter) {
return this.pushAll(iter);
};
Stack.prototype.shift = function() {
return this.pop.apply(this, arguments);
};
Stack.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._head = undefined;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyStack();
};
Stack.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
var resolvedBegin = resolveBegin(begin, this.size);
var resolvedEnd = resolveEnd(end, this.size);
if (resolvedEnd !== this.size) {
// super.slice(begin, end);
return IndexedCollection.prototype.slice.call(this, begin, end);
}
var newSize = this.size - resolvedBegin;
var head = this._head;
while (resolvedBegin--) {
head = head.next;
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
// @pragma Mutability
Stack.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeStack(this.size, this._head, ownerID, this.__hash);
};
// @pragma Iteration
Stack.prototype.__iterate = function(fn, reverse) {
if (reverse) {
return this.reverse().__iterate(fn);
}
var iterations = 0;
var node = this._head;
while (node) {
if (fn(node.value, iterations++, this) === false) {
break;
}
node = node.next;
}
return iterations;
};
Stack.prototype.__iterator = function(type, reverse) {
if (reverse) {
return this.reverse().__iterator(type);
}
var iterations = 0;
var node = this._head;
return new Iterator(function() {
if (node) {
var value = node.value;
node = node.next;
return iteratorValue(type, iterations++, value);
}
return iteratorDone();
});
};
function isStack(maybeStack) {
return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
}
Stack.isStack = isStack;
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
var StackPrototype = Stack.prototype;
StackPrototype[IS_STACK_SENTINEL] = true;
StackPrototype.withMutations = MapPrototype.withMutations;
StackPrototype.asMutable = MapPrototype.asMutable;
StackPrototype.asImmutable = MapPrototype.asImmutable;
StackPrototype.wasAltered = MapPrototype.wasAltered;
function makeStack(size, head, ownerID, hash) {
var map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
/**
* Contributes additional methods to a constructor
*/
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
Iterable.Iterator = Iterator;
mixin(Iterable, {
// ### Conversion to other types
toArray: function() {
assertNotInfinite(this.size);
var array = new Array(this.size || 0);
this.valueSeq().__iterate(function(v, i) { array[i] = v; });
return array;
},
toIndexedSeq: function() {
return new ToIndexedSequence(this);
},
toJS: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
).__toJS();
},
toJSON: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
).__toJS();
},
toKeyedSeq: function() {
return new ToKeyedSequence(this, true);
},
toMap: function() {
// Use Late Binding here to solve the circular dependency.
return Map(this.toKeyedSeq());
},
toObject: function() {
assertNotInfinite(this.size);
var object = {};
this.__iterate(function(v, k) { object[k] = v; });
return object;
},
toOrderedMap: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedMap(this.toKeyedSeq());
},
toOrderedSet: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
},
toSet: function() {
// Use Late Binding here to solve the circular dependency.
return Set(isKeyed(this) ? this.valueSeq() : this);
},
toSetSeq: function() {
return new ToSetSequence(this);
},
toSeq: function() {
return isIndexed(this) ? this.toIndexedSeq() :
isKeyed(this) ? this.toKeyedSeq() :
this.toSetSeq();
},
toStack: function() {
// Use Late Binding here to solve the circular dependency.
return Stack(isKeyed(this) ? this.valueSeq() : this);
},
toList: function() {
// Use Late Binding here to solve the circular dependency.
return List(isKeyed(this) ? this.valueSeq() : this);
},
// ### Common JavaScript methods and properties
toString: function() {
return '[Iterable]';
},
__toString: function(head, tail) {
if (this.size === 0) {
return head + tail;
}
return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
},
// ### ES6 Collection methods (ES6 Array and Map)
concat: function() {var values = SLICE$0.call(arguments, 0);
return reify(this, concatFactory(this, values));
},
includes: function(searchValue) {
return this.some(function(value ) {return is(value, searchValue)});
},
entries: function() {
return this.__iterator(ITERATE_ENTRIES);
},
every: function(predicate, context) {
assertNotInfinite(this.size);
var returnValue = true;
this.__iterate(function(v, k, c) {
if (!predicate.call(context, v, k, c)) {
returnValue = false;
return false;
}
});
return returnValue;
},
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, true));
},
find: function(predicate, context, notSetValue) {
var entry = this.findEntry(predicate, context);
return entry ? entry[1] : notSetValue;
},
forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
},
join: function(separator) {
assertNotInfinite(this.size);
separator = separator !== undefined ? '' + separator : ',';
var joined = '';
var isFirst = true;
this.__iterate(function(v ) {
isFirst ? (isFirst = false) : (joined += separator);
joined += v !== null && v !== undefined ? v.toString() : '';
});
return joined;
},
keys: function() {
return this.__iterator(ITERATE_KEYS);
},
map: function(mapper, context) {
return reify(this, mapFactory(this, mapper, context));
},
reduce: function(reducer, initialReduction, context) {
assertNotInfinite(this.size);
var reduction;
var useFirst;
if (arguments.length < 2) {
useFirst = true;
} else {
reduction = initialReduction;
}
this.__iterate(function(v, k, c) {
if (useFirst) {
useFirst = false;
reduction = v;
} else {
reduction = reducer.call(context, reduction, v, k, c);
}
});
return reduction;
},
reduceRight: function(reducer, initialReduction, context) {
var reversed = this.toKeyedSeq().reverse();
return reversed.reduce.apply(reversed, arguments);
},
reverse: function() {
return reify(this, reverseFactory(this, true));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, true));
},
some: function(predicate, context) {
return !this.every(not(predicate), context);
},
sort: function(comparator) {
return reify(this, sortFactory(this, comparator));
},
values: function() {
return this.__iterator(ITERATE_VALUES);
},
// ### More sequential methods
butLast: function() {
return this.slice(0, -1);
},
isEmpty: function() {
return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
},
count: function(predicate, context) {
return ensureSize(
predicate ? this.toSeq().filter(predicate, context) : this
);
},
countBy: function(grouper, context) {
return countByFactory(this, grouper, context);
},
equals: function(other) {
return deepEqual(this, other);
},
entrySeq: function() {
var iterable = this;
if (iterable._cache) {
// We cache as an entries array, so we can just return the cache!
return new ArraySeq(iterable._cache);
}
var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
return entriesSequence;
},
filterNot: function(predicate, context) {
return this.filter(not(predicate), context);
},
findEntry: function(predicate, context, notSetValue) {
var found = notSetValue;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},
findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},
findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},
findLastEntry: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().findEntry(predicate, context, notSetValue);
},
findLastKey: function(predicate, context) {
return this.toKeyedSeq().reverse().findKey(predicate, context);
},
first: function() {
return this.find(returnTrue);
},
flatMap: function(mapper, context) {
return reify(this, flatMapFactory(this, mapper, context));
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, true));
},
fromEntrySeq: function() {
return new FromEntriesSequence(this);
},
get: function(searchKey, notSetValue) {
return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
},
getIn: function(searchKeyPath, notSetValue) {
var nested = this;
// Note: in an ES6 environment, we would prefer:
// for (var key of searchKeyPath) {
var iter = forceIterator(searchKeyPath);
var step;
while (!(step = iter.next()).done) {
var key = step.value;
nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
if (nested === NOT_SET) {
return notSetValue;
}
}
return nested;
},
groupBy: function(grouper, context) {
return groupByFactory(this, grouper, context);
},
has: function(searchKey) {
return this.get(searchKey, NOT_SET) !== NOT_SET;
},
hasIn: function(searchKeyPath) {
return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
},
isSubset: function(iter) {
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
return this.every(function(value ) {return iter.includes(value)});
},
isSuperset: function(iter) {
iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
return iter.isSubset(this);
},
keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},
keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
last: function() {
return this.toSeq().reverse().first();
},
lastKeyOf: function(searchValue) {
return this.toKeyedSeq().reverse().keyOf(searchValue);
},
max: function(comparator) {
return maxFactory(this, comparator);
},
maxBy: function(mapper, comparator) {
return maxFactory(this, comparator, mapper);
},
min: function(comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
},
minBy: function(mapper, comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
},
rest: function() {
return this.slice(1);
},
skip: function(amount) {
return this.slice(Math.max(0, amount));
},
skipLast: function(amount) {
return reify(this, this.toSeq().reverse().skip(amount).reverse());
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, true));
},
skipUntil: function(predicate, context) {
return this.skipWhile(not(predicate), context);
},
sortBy: function(mapper, comparator) {
return reify(this, sortFactory(this, comparator, mapper));
},
take: function(amount) {
return this.slice(0, Math.max(0, amount));
},
takeLast: function(amount) {
return reify(this, this.toSeq().reverse().take(amount).reverse());
},
takeWhile: function(predicate, context) {
return reify(this, takeWhileFactory(this, predicate, context));
},
takeUntil: function(predicate, context) {
return this.takeWhile(not(predicate), context);
},
valueSeq: function() {
return this.toIndexedSeq();
},
// ### Hashable Object
hashCode: function() {
return this.__hash || (this.__hash = hashIterable(this));
}
// ### Internal
// abstract __iterate(fn, reverse)
// abstract __iterator(type, reverse)
});
// var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
// var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
// var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
// var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
var IterablePrototype = Iterable.prototype;
IterablePrototype[IS_ITERABLE_SENTINEL] = true;
IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
IterablePrototype.__toJS = IterablePrototype.toArray;
IterablePrototype.__toStringMapper = quoteString;
IterablePrototype.inspect =
IterablePrototype.toSource = function() { return this.toString(); };
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;
mixin(KeyedIterable, {
// ### More sequential methods
flip: function() {
return reify(this, flipFactory(this));
},
mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
this.toSeq().map(
function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
).fromEntrySeq()
);
},
mapKeys: function(mapper, context) {var this$0 = this;
return reify(this,
this.toSeq().flip().map(
function(k, v) {return mapper.call(context, k, v, this$0)}
).flip()
);
}
});
var KeyedIterablePrototype = KeyedIterable.prototype;
KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
mixin(IndexedIterable, {
// ### Conversion to other types
toKeyedSeq: function() {
return new ToKeyedSequence(this, false);
},
// ### ES6 Collection methods (ES6 Array and Map)
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, false));
},
findIndex: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry ? entry[0] : -1;
},
indexOf: function(searchValue) {
var key = this.keyOf(searchValue);
return key === undefined ? -1 : key;
},
lastIndexOf: function(searchValue) {
var key = this.lastKeyOf(searchValue);
return key === undefined ? -1 : key;
},
reverse: function() {
return reify(this, reverseFactory(this, false));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, false));
},
splice: function(index, removeNum /*, ...values*/) {
var numArgs = arguments.length;
removeNum = Math.max(removeNum | 0, 0);
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
return this;
}
// If index is negative, it should resolve relative to the size of the
// collection. However size may be expensive to compute if not cached, so
// only call count() if the number is in fact negative.
index = resolveBegin(index, index < 0 ? this.count() : this.size);
var spliced = this.slice(0, index);
return reify(
this,
numArgs === 1 ?
spliced :
spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
);
},
// ### More collection methods
findLastIndex: function(predicate, context) {
var entry = this.findLastEntry(predicate, context);
return entry ? entry[0] : -1;
},
first: function() {
return this.get(0);
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, false));
},
get: function(index, notSetValue) {
index = wrapIndex(this, index);
return (index < 0 || (this.size === Infinity ||
(this.size !== undefined && index > this.size))) ?
notSetValue :
this.find(function(_, key) {return key === index}, undefined, notSetValue);
},
has: function(index) {
index = wrapIndex(this, index);
return index >= 0 && (this.size !== undefined ?
this.size === Infinity || index < this.size :
this.indexOf(index) !== -1
);
},
interpose: function(separator) {
return reify(this, interposeFactory(this, separator));
},
interleave: function(/*...iterables*/) {
var iterables = [this].concat(arrCopy(arguments));
var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
var interleaved = zipped.flatten(true);
if (zipped.size) {
interleaved.size = zipped.size * iterables.length;
}
return reify(this, interleaved);
},
keySeq: function() {
return Range(0, this.size);
},
last: function() {
return this.get(-1);
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, false));
},
zip: function(/*, ...iterables */) {
var iterables = [this].concat(arrCopy(arguments));
return reify(this, zipWithFactory(this, defaultZipper, iterables));
},
zipWith: function(zipper/*, ...iterables */) {
var iterables = arrCopy(arguments);
iterables[0] = this;
return reify(this, zipWithFactory(this, zipper, iterables));
}
});
IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
mixin(SetIterable, {
// ### ES6 Collection methods (ES6 Array and Map)
get: function(value, notSetValue) {
return this.has(value) ? value : notSetValue;
},
includes: function(value) {
return this.has(value);
},
// ### More sequential methods
keySeq: function() {
return this.valueSeq();
}
});
SetIterable.prototype.has = IterablePrototype.includes;
SetIterable.prototype.contains = SetIterable.prototype.includes;
// Mixin subclasses
mixin(KeyedSeq, KeyedIterable.prototype);
mixin(IndexedSeq, IndexedIterable.prototype);
mixin(SetSeq, SetIterable.prototype);
mixin(KeyedCollection, KeyedIterable.prototype);
mixin(IndexedCollection, IndexedIterable.prototype);
mixin(SetCollection, SetIterable.prototype);
// #pragma Helper functions
function keyMapper(v, k) {
return k;
}
function entryMapper(v, k) {
return [k, v];
}
function not(predicate) {
return function() {
return !predicate.apply(this, arguments);
}
}
function neg(predicate) {
return function() {
return -predicate.apply(this, arguments);
}
}
function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : String(value);
}
function defaultZipper() {
return arrCopy(arguments);
}
function defaultNegComparator(a, b) {
return a < b ? 1 : a > b ? -1 : 0;
}
function hashIterable(iterable) {
if (iterable.size === Infinity) {
return 0;
}
var ordered = isOrdered(iterable);
var keyed = isKeyed(iterable);
var h = ordered ? 1 : 0;
var size = iterable.__iterate(
keyed ?
ordered ?
function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
ordered ?
function(v ) { h = 31 * h + hash(v) | 0; } :
function(v ) { h = h + hash(v) | 0; }
);
return murmurHashOfSize(size, h);
}
function murmurHashOfSize(size, h) {
h = imul(h, 0xCC9E2D51);
h = imul(h << 15 | h >>> -15, 0x1B873593);
h = imul(h << 13 | h >>> -13, 5);
h = (h + 0xE6546B64 | 0) ^ size;
h = imul(h ^ h >>> 16, 0x85EBCA6B);
h = imul(h ^ h >>> 13, 0xC2B2AE35);
h = smi(h ^ h >>> 16);
return h;
}
function hashMerge(a, b) {
return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
}
var Immutable = {
Iterable: Iterable,
Seq: Seq,
Collection: Collection,
Map: Map,
OrderedMap: OrderedMap,
List: List,
Stack: Stack,
Set: Set,
OrderedSet: OrderedSet,
Record: Record,
Range: Range,
Repeat: Repeat,
is: is,
fromJS: fromJS
};
return Immutable;
}));
/***/ }),
/***/ 4350:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __webpack_unused_export__;
__webpack_unused_export__ = ({ value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = __webpack_require__(6540);
var React__default = _interopDefault(React);
var UAParser = __webpack_require__(6204);
var UA = new UAParser();
var browser = UA.getBrowser();
var cpu = UA.getCPU();
var device = UA.getDevice();
var engine = UA.getEngine();
var os = UA.getOS();
var ua = UA.getUA();
var setDefaults = function setDefaults(p) {
var d = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'none';
return p ? p : d;
};
var getNavigatorInstance = function getNavigatorInstance() {
if (typeof window !== 'undefined') {
if (window.navigator || navigator) {
return window.navigator || navigator;
}
}
return false;
};
var isIOS13Check = function isIOS13Check(type) {
var nav = getNavigatorInstance();
return nav && nav.platform && (nav.platform.indexOf(type) !== -1 || nav.platform === 'MacIntel' && nav.maxTouchPoints > 1 && !window.MSStream);
};
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
var DEVICE_TYPES = {
MOBILE: 'mobile',
TABLET: 'tablet',
SMART_TV: 'smarttv',
CONSOLE: 'console',
WEARABLE: 'wearable',
BROWSER: undefined
};
var BROWSER_TYPES = {
CHROME: 'Chrome',
FIREFOX: "Firefox",
OPERA: "Opera",
YANDEX: "Yandex",
SAFARI: "Safari",
INTERNET_EXPLORER: "Internet Explorer",
EDGE: "Edge",
CHROMIUM: "Chromium",
IE: 'IE',
MOBILE_SAFARI: "Mobile Safari",
EDGE_CHROMIUM: "Edge Chromium",
MIUI: "MIUI Browser"
};
var OS_TYPES = {
IOS: 'iOS',
ANDROID: "Android",
WINDOWS_PHONE: "Windows Phone",
WINDOWS: 'Windows',
MAC_OS: 'Mac OS'
};
var initialData = {
isMobile: false,
isTablet: false,
isBrowser: false,
isSmartTV: false,
isConsole: false,
isWearable: false
};
var checkType = function checkType(type) {
switch (type) {
case DEVICE_TYPES.MOBILE:
return {
isMobile: true
};
case DEVICE_TYPES.TABLET:
return {
isTablet: true
};
case DEVICE_TYPES.SMART_TV:
return {
isSmartTV: true
};
case DEVICE_TYPES.CONSOLE:
return {
isConsole: true
};
case DEVICE_TYPES.WEARABLE:
return {
isWearable: true
};
case DEVICE_TYPES.BROWSER:
return {
isBrowser: true
};
default:
return initialData;
}
};
var broPayload = function broPayload(isBrowser, browser, engine, os, ua) {
return {
isBrowser: isBrowser,
browserMajorVersion: setDefaults(browser.major),
browserFullVersion: setDefaults(browser.version),
browserName: setDefaults(browser.name),
engineName: setDefaults(engine.name),
engineVersion: setDefaults(engine.version),
osName: setDefaults(os.name),
osVersion: setDefaults(os.version),
userAgent: setDefaults(ua)
};
};
var mobilePayload = function mobilePayload(type, device, os, ua) {
return _objectSpread2({}, type, {
vendor: setDefaults(device.vendor),
model: setDefaults(device.model),
os: setDefaults(os.name),
osVersion: setDefaults(os.version),
ua: setDefaults(ua)
});
};
var stvPayload = function stvPayload(isSmartTV, engine, os, ua) {
return {
isSmartTV: isSmartTV,
engineName: setDefaults(engine.name),
engineVersion: setDefaults(engine.version),
osName: setDefaults(os.name),
osVersion: setDefaults(os.version),
userAgent: setDefaults(ua)
};
};
var consolePayload = function consolePayload(isConsole, engine, os, ua) {
return {
isConsole: isConsole,
engineName: setDefaults(engine.name),
engineVersion: setDefaults(engine.version),
osName: setDefaults(os.name),
osVersion: setDefaults(os.version),
userAgent: setDefaults(ua)
};
};
var wearPayload = function wearPayload(isWearable, engine, os, ua) {
return {
isWearable: isWearable,
engineName: setDefaults(engine.name),
engineVersion: setDefaults(engine.version),
osName: setDefaults(os.name),
osVersion: setDefaults(os.version),
userAgent: setDefaults(ua)
};
};
var type = checkType(device.type);
function deviceDetect() {
var isBrowser = type.isBrowser,
isMobile = type.isMobile,
isTablet = type.isTablet,
isSmartTV = type.isSmartTV,
isConsole = type.isConsole,
isWearable = type.isWearable;
if (isBrowser) {
return broPayload(isBrowser, browser, engine, os, ua);
}
if (isSmartTV) {
return stvPayload(isSmartTV, engine, os, ua);
}
if (isConsole) {
return consolePayload(isConsole, engine, os, ua);
}
if (isMobile) {
return mobilePayload(type, device, os, ua);
}
if (isTablet) {
return mobilePayload(type, device, os, ua);
}
if (isWearable) {
return wearPayload(isWearable, engine, os, ua);
}
}
var isMobileType = function isMobileType() {
return device.type === DEVICE_TYPES.MOBILE;
};
var isTabletType = function isTabletType() {
return device.type === DEVICE_TYPES.TABLET;
};
var isMobileAndTabletType = function isMobileAndTabletType() {
switch (device.type) {
case DEVICE_TYPES.MOBILE:
case DEVICE_TYPES.TABLET:
return true;
default:
return false;
}
};
var isEdgeChromiumType = function isEdgeChromiumType() {
return typeof ua === 'string' && ua.indexOf('Edg/') !== -1;
};
var isSmartTVType = function isSmartTVType() {
return device.type === DEVICE_TYPES.SMART_TV;
};
var isBrowserType = function isBrowserType() {
return device.type === DEVICE_TYPES.BROWSER;
};
var isWearableType = function isWearableType() {
return device.type === DEVICE_TYPES.WEARABLE;
};
var isConsoleType = function isConsoleType() {
return device.type === DEVICE_TYPES.CONSOLE;
};
var isAndroidType = function isAndroidType() {
return os.name === OS_TYPES.ANDROID;
};
var isWindowsType = function isWindowsType() {
return os.name === OS_TYPES.WINDOWS;
};
var isMacOsType = function isMacOsType() {
return os.name === OS_TYPES.MAC_OS;
};
var isWinPhoneType = function isWinPhoneType() {
return os.name === OS_TYPES.WINDOWS_PHONE;
};
var isIOSType = function isIOSType() {
return os.name === OS_TYPES.IOS;
};
var isChromeType = function isChromeType() {
return browser.name === BROWSER_TYPES.CHROME;
};
var isFirefoxType = function isFirefoxType() {
return browser.name === BROWSER_TYPES.FIREFOX;
};
var isChromiumType = function isChromiumType() {
return browser.name === BROWSER_TYPES.CHROMIUM;
};
var isEdgeType = function isEdgeType() {
return browser.name === BROWSER_TYPES.EDGE;
};
var isYandexType = function isYandexType() {
return browser.name === BROWSER_TYPES.YANDEX;
};
var isSafariType = function isSafariType() {
return browser.name === BROWSER_TYPES.SAFARI || browser.name === BROWSER_TYPES.MOBILE_SAFARI;
};
var isMobileSafariType = function isMobileSafariType() {
return browser.name === BROWSER_TYPES.MOBILE_SAFARI;
};
var isOperaType = function isOperaType() {
return browser.name === BROWSER_TYPES.OPERA;
};
var isIEType = function isIEType() {
return browser.name === BROWSER_TYPES.INTERNET_EXPLORER || browser.name === BROWSER_TYPES.IE;
};
var isMIUIType = function isMIUIType() {
return browser.name === BROWSER_TYPES.MIUI;
};
var isElectronType = function isElectronType() {
var nav = getNavigatorInstance();
var ua = nav && nav.userAgent.toLowerCase();
return typeof ua === 'string' ? /electron/.test(ua) : false;
};
var getIOS13 = function getIOS13() {
var nav = getNavigatorInstance();
return nav && (/iPad|iPhone|iPod/.test(nav.platform) || nav.platform === 'MacIntel' && nav.maxTouchPoints > 1) && !window.MSStream;
};
var getIPad13 = function getIPad13() {
return isIOS13Check('iPad');
};
var getIphone13 = function getIphone13() {
return isIOS13Check('iPhone');
};
var getIPod13 = function getIPod13() {
return isIOS13Check('iPod');
};
var getBrowserFullVersion = function getBrowserFullVersion() {
return setDefaults(browser.version);
};
var getBrowserVersion = function getBrowserVersion() {
return setDefaults(browser.major);
};
var getOsVersion = function getOsVersion() {
return setDefaults(os.version);
};
var getOsName = function getOsName() {
return setDefaults(os.name);
};
var getBrowserName = function getBrowserName() {
return setDefaults(browser.name);
};
var getMobileVendor = function getMobileVendor() {
return setDefaults(device.vendor);
};
var getMobileModel = function getMobileModel() {
return setDefaults(device.model);
};
var getEngineName = function getEngineName() {
return setDefaults(engine.name);
};
var getEngineVersion = function getEngineVersion() {
return setDefaults(engine.version);
};
var getUseragent = function getUseragent() {
return setDefaults(ua);
};
var getDeviceType = function getDeviceType() {
return setDefaults(device.type, 'browser');
};
var isSmartTV = isSmartTVType();
var isConsole = isConsoleType();
var isWearable = isWearableType();
var isMobileSafari = isMobileSafariType() || getIPad13();
var isChromium = isChromiumType();
var isMobile = isMobileAndTabletType() || getIPad13();
var isMobileOnly = isMobileType();
var isTablet = isTabletType() || getIPad13();
var isBrowser = isBrowserType();
var isAndroid = isAndroidType();
var isWinPhone = isWinPhoneType();
var isIOS = isIOSType() || getIPad13();
var isChrome = isChromeType();
var isFirefox = isFirefoxType();
var isSafari = isSafariType();
var isOpera = isOperaType();
var isIE = isIEType();
var osVersion = getOsVersion();
var osName = getOsName();
var fullBrowserVersion = getBrowserFullVersion();
var browserVersion = getBrowserVersion();
var browserName = getBrowserName();
var mobileVendor = getMobileVendor();
var mobileModel = getMobileModel();
var engineName = getEngineName();
var engineVersion = getEngineVersion();
var getUA = getUseragent();
var isEdge = isEdgeType() || isEdgeChromiumType();
var isYandex = isYandexType();
var deviceType = getDeviceType();
var isIOS13 = getIOS13();
var isIPad13 = getIPad13();
var isIPhone13 = getIphone13();
var isIPod13 = getIPod13();
var isElectron = isElectronType();
var isEdgeChromium = isEdgeChromiumType();
var isLegacyEdge = isEdgeType() && !isEdgeChromiumType();
var isWindows = isWindowsType();
var isMacOs = isMacOsType();
var isMIUI = isMIUIType();
var AndroidView = function AndroidView(_ref) {
var renderWithFragment = _ref.renderWithFragment,
children = _ref.children,
viewClassName = _ref.viewClassName,
style = _ref.style;
return isAndroid ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var BrowserView = function BrowserView(_ref2) {
var renderWithFragment = _ref2.renderWithFragment,
children = _ref2.children,
viewClassName = _ref2.viewClassName,
style = _ref2.style;
return isBrowser ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var IEView = function IEView(_ref3) {
var renderWithFragment = _ref3.renderWithFragment,
children = _ref3.children,
viewClassName = _ref3.viewClassName,
style = _ref3.style;
return isIE ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var IOSView = function IOSView(_ref4) {
var renderWithFragment = _ref4.renderWithFragment,
children = _ref4.children,
viewClassName = _ref4.viewClassName,
style = _ref4.style;
return isIOS ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var MobileView = function MobileView(_ref5) {
var renderWithFragment = _ref5.renderWithFragment,
children = _ref5.children,
viewClassName = _ref5.viewClassName,
style = _ref5.style;
return isMobile ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var TabletView = function TabletView(_ref6) {
var renderWithFragment = _ref6.renderWithFragment,
children = _ref6.children,
viewClassName = _ref6.viewClassName,
style = _ref6.style;
return isTablet ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var WinPhoneView = function WinPhoneView(_ref7) {
var renderWithFragment = _ref7.renderWithFragment,
children = _ref7.children,
viewClassName = _ref7.viewClassName,
style = _ref7.style;
return isWinPhone ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var MobileOnlyView = function MobileOnlyView(_ref8) {
var renderWithFragment = _ref8.renderWithFragment,
children = _ref8.children,
viewClassName = _ref8.viewClassName,
style = _ref8.style;
return isMobileOnly ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var SmartTVView = function SmartTVView(_ref9) {
var renderWithFragment = _ref9.renderWithFragment,
children = _ref9.children,
viewClassName = _ref9.viewClassName,
style = _ref9.style;
return isSmartTV ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var ConsoleView = function ConsoleView(_ref10) {
var renderWithFragment = _ref10.renderWithFragment,
children = _ref10.children,
viewClassName = _ref10.viewClassName,
style = _ref10.style;
return isConsole ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var WearableView = function WearableView(_ref11) {
var renderWithFragment = _ref11.renderWithFragment,
children = _ref11.children,
viewClassName = _ref11.viewClassName,
style = _ref11.style;
return isWearable ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
var CustomView = function CustomView(_ref12) {
var renderWithFragment = _ref12.renderWithFragment,
children = _ref12.children,
viewClassName = _ref12.viewClassName,
style = _ref12.style,
condition = _ref12.condition;
return condition ? renderWithFragment ? React__default.createElement(React.Fragment, null, children) : React__default.createElement("div", {
className: viewClassName,
style: style
}, children) : null;
};
function withOrientationChange(WrappedComponent) {
return (
/*#__PURE__*/
function (_React$Component) {
_inherits(_class, _React$Component);
function _class(props) {
var _this;
_classCallCheck(this, _class);
_this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, props));
_this.isEventListenerAdded = false;
_this.handleOrientationChange = _this.handleOrientationChange.bind(_assertThisInitialized(_this));
_this.onOrientationChange = _this.onOrientationChange.bind(_assertThisInitialized(_this));
_this.onPageLoad = _this.onPageLoad.bind(_assertThisInitialized(_this));
_this.state = {
isLandscape: false,
isPortrait: false
};
return _this;
}
_createClass(_class, [{
key: "handleOrientationChange",
value: function handleOrientationChange() {
if (!this.isEventListenerAdded) {
this.isEventListenerAdded = true;
}
var orientation = window.innerWidth > window.innerHeight ? 90 : 0;
this.setState({
isPortrait: orientation === 0,
isLandscape: orientation === 90
});
}
}, {
key: "onOrientationChange",
value: function onOrientationChange() {
this.handleOrientationChange();
}
}, {
key: "onPageLoad",
value: function onPageLoad() {
this.handleOrientationChange();
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined && isMobile) {
if (!this.isEventListenerAdded) {
this.handleOrientationChange();
window.addEventListener("load", this.onPageLoad, false);
} else {
window.removeEventListener("load", this.onPageLoad, false);
}
window.addEventListener("resize", this.onOrientationChange, false);
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
window.removeEventListener("resize", this.onOrientationChange, false);
}
}, {
key: "render",
value: function render() {
return React__default.createElement(WrappedComponent, _extends({}, this.props, {
isLandscape: this.state.isLandscape,
isPortrait: this.state.isPortrait
}));
}
}]);
return _class;
}(React__default.Component)
);
}
__webpack_unused_export__ = AndroidView;
__webpack_unused_export__ = BrowserView;
__webpack_unused_export__ = ConsoleView;
__webpack_unused_export__ = CustomView;
__webpack_unused_export__ = IEView;
__webpack_unused_export__ = IOSView;
__webpack_unused_export__ = MobileOnlyView;
__webpack_unused_export__ = MobileView;
__webpack_unused_export__ = SmartTVView;
__webpack_unused_export__ = TabletView;
__webpack_unused_export__ = WearableView;
__webpack_unused_export__ = WinPhoneView;
__webpack_unused_export__ = browserName;
__webpack_unused_export__ = browserVersion;
__webpack_unused_export__ = deviceDetect;
__webpack_unused_export__ = deviceType;
__webpack_unused_export__ = engineName;
__webpack_unused_export__ = engineVersion;
__webpack_unused_export__ = fullBrowserVersion;
__webpack_unused_export__ = getUA;
exports.m0 = isAndroid;
__webpack_unused_export__ = isBrowser;
__webpack_unused_export__ = isChrome;
__webpack_unused_export__ = isChromium;
__webpack_unused_export__ = isConsole;
__webpack_unused_export__ = isEdge;
__webpack_unused_export__ = isEdgeChromium;
__webpack_unused_export__ = isElectron;
exports.gm = isFirefox;
__webpack_unused_export__ = isIE;
exports.un = isIOS;
__webpack_unused_export__ = isIOS13;
__webpack_unused_export__ = isIPad13;
__webpack_unused_export__ = isIPhone13;
__webpack_unused_export__ = isIPod13;
__webpack_unused_export__ = isLegacyEdge;
__webpack_unused_export__ = isMIUI;
__webpack_unused_export__ = isMacOs;
exports.Fr = isMobile;
exports.XF = isMobileOnly;
__webpack_unused_export__ = isMobileSafari;
__webpack_unused_export__ = isOpera;
exports.nr = isSafari;
__webpack_unused_export__ = isSmartTV;
exports.v1 = isTablet;
__webpack_unused_export__ = isWearable;
__webpack_unused_export__ = isWinPhone;
__webpack_unused_export__ = isWindows;
__webpack_unused_export__ = isYandex;
__webpack_unused_export__ = mobileModel;
__webpack_unused_export__ = mobileVendor;
__webpack_unused_export__ = osName;
__webpack_unused_export__ = osVersion;
exports.LZ = withOrientationChange;
/***/ }),
/***/ 6302:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
!function(e,t){ true?module.exports=t(__webpack_require__(6540)):0}(this,(e=>(()=>{var t={703:(e,t,n)=>{"use strict";var i=n(414);function r(){}function a(){}a.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,a,o){if(o!==i){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:r};return n.PropTypes=n,n}},697:(e,t,n)=>{e.exports=n(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},590:e=>{var t="undefined"!=typeof Element,n="function"==typeof Map,i="function"==typeof Set,r="function"==typeof ArrayBuffer&&!!ArrayBuffer.isView;function a(e,o){if(e===o)return!0;if(e&&o&&"object"==typeof e&&"object"==typeof o){if(e.constructor!==o.constructor)return!1;var s,l,u,c;if(Array.isArray(e)){if((s=e.length)!=o.length)return!1;for(l=s;0!=l--;)if(!a(e[l],o[l]))return!1;return!0}if(n&&e instanceof Map&&o instanceof Map){if(e.size!==o.size)return!1;for(c=e.entries();!(l=c.next()).done;)if(!o.has(l.value[0]))return!1;for(c=e.entries();!(l=c.next()).done;)if(!a(l.value[1],o.get(l.value[0])))return!1;return!0}if(i&&e instanceof Set&&o instanceof Set){if(e.size!==o.size)return!1;for(c=e.entries();!(l=c.next()).done;)if(!o.has(l.value[0]))return!1;return!0}if(r&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(o)){if((s=e.length)!=o.length)return!1;for(l=s;0!=l--;)if(e[l]!==o[l])return!1;return!0}if(e.constructor===RegExp)return e.source===o.source&&e.flags===o.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===o.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===o.toString();if((s=(u=Object.keys(e)).length)!==Object.keys(o).length)return!1;for(l=s;0!=l--;)if(!Object.prototype.hasOwnProperty.call(o,u[l]))return!1;if(t&&e instanceof Element)return!1;for(l=s;0!=l--;)if(("_owner"!==u[l]&&"__v"!==u[l]&&"__o"!==u[l]||!e.$$typeof)&&!a(e[u[l]],o[u[l]]))return!1;return!0}return e!=e&&o!=o}e.exports=function(e,t){try{return a(e,t)}catch(e){if((e.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw e}}},359:t=>{"use strict";t.exports=e}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";function e(t){var n,i,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t))for(n=0;nnt});var n=i(359),a=i.n(n);const o=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},s="object"==typeof __webpack_require__.g&&__webpack_require__.g&&__webpack_require__.g.Object===Object&&__webpack_require__.g;var l="object"==typeof self&&self&&self.Object===Object&&self;const u=s||l||Function("return this")(),c=function(){return u.Date.now()};var h=/\s/;var d=/^\s+/;const p=function(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&h.test(e.charAt(t)););return t}(e)+1).replace(d,""):e},f=u.Symbol;var m=Object.prototype,b=m.hasOwnProperty,g=m.toString,v=f?f.toStringTag:void 0;var y=Object.prototype.toString;var w=f?f.toStringTag:void 0;const S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":w&&w in Object(e)?function(e){var t=b.call(e,v),n=e[v];try{e[v]=void 0;var i=!0}catch(e){}var r=g.call(e);return i&&(t?e[v]=n:delete e[v]),r}(e):function(e){return y.call(e)}(e)};var T=/^[-+]0x[0-9a-f]+$/i,O=/^0b[01]+$/i,E=/^0o[0-7]+$/i,k=parseInt;const I=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==S(e)}(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=p(e);var n=O.test(e);return n||E.test(e)?k(e.slice(2),n?2:8):T.test(e)?NaN:+e};var j=Math.max,x=Math.min;const P=function(e,t,n){var i,r,a,s,l,u,h=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var n=i,a=r;return i=r=void 0,h=t,s=e.apply(a,n)}function b(e){return h=e,l=setTimeout(v,t),d?m(e):s}function g(e){var n=e-u;return void 0===u||n>=t||n<0||p&&e-h>=a}function v(){var e=c();if(g(e))return y(e);l=setTimeout(v,function(e){var n=t-(e-u);return p?x(n,a-(e-h)):n}(e))}function y(e){return l=void 0,f&&i?m(e):(i=r=void 0,s)}function w(){var e=c(),n=g(e);if(i=arguments,r=this,u=e,n){if(void 0===l)return b(u);if(p)return clearTimeout(l),l=setTimeout(v,t),m(u)}return void 0===l&&(l=setTimeout(v,t)),s}return t=I(t)||0,o(n)&&(d=!!n.leading,a=(p="maxWait"in n)?j(I(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),w.cancel=function(){void 0!==l&&clearTimeout(l),h=0,i=u=r=l=void 0},w.flush=function(){return void 0===l?s:y(c())},w},_=function(e,t,n){var i=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return o(n)&&(i="leading"in n?!!n.leading:i,r="trailing"in n?!!n.trailing:r),P(e,t,{leading:i,maxWait:t,trailing:r})};var R=i(590),M=i.n(R),L=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some((function(e,i){return e[0]===t&&(n=i,!0)})),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),i=this.__entries__[n];return i&&i[1]},t.prototype.set=function(t,n){var i=e(this.__entries__,t);~i?this.__entries__[i][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,i=e(n,t);~i&&n.splice(i,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,i=this.__entries__;n0},e.prototype.connect_=function(){D&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),z?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){D&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t;F.some((function(e){return!!~n.indexOf(e)}))&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),B=function(e,t){for(var n=0,i=Object.keys(t);n0},e}(),J="undefined"!=typeof WeakMap?new WeakMap:new L,Q=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=N.getInstance(),i=new Y(t,n,this);J.set(this,i)};["observe","unobserve","disconnect"].forEach((function(e){Q.prototype[e]=function(){var t;return(t=J.get(this))[e].apply(t,arguments)}}));const Z=void 0!==W.ResizeObserver?W.ResizeObserver:Q,ee="Left",te="Right",ne="Up",ie="Down",re={delta:10,preventScrollOnSwipe:!1,rotationAngle:0,trackMouse:!1,trackTouch:!0,swipeDuration:1/0,touchEventOptions:{passive:!0}},ae={first:!0,initial:[0,0],start:0,swiping:!1,xy:[0,0]},oe="mousemove",se="mouseup";function le(e,t){if(0===t)return e;const n=Math.PI/180*t;return[e[0]*Math.cos(n)+e[1]*Math.sin(n),e[1]*Math.cos(n)-e[0]*Math.sin(n)]}function ue(e){const{trackMouse:t}=e,i=n.useRef(Object.assign({},ae)),r=n.useRef(Object.assign({},re)),a=n.useRef(Object.assign({},r.current));let o;for(o in a.current=Object.assign({},r.current),r.current=Object.assign(Object.assign({},re),e),re)void 0===r.current[o]&&(r.current[o]=re[o]);const[s,l]=n.useMemo((()=>function(e,t){const n=t=>{const n="touches"in t;n&&t.touches.length>1||e(((e,r)=>{r.trackMouse&&!n&&(document.addEventListener(oe,i),document.addEventListener(se,a));const{clientX:o,clientY:s}=n?t.touches[0]:t,l=le([o,s],r.rotationAngle);return r.onTouchStartOrOnMouseDown&&r.onTouchStartOrOnMouseDown({event:t}),Object.assign(Object.assign(Object.assign({},e),ae),{initial:l.slice(),xy:l,start:t.timeStamp||0})}))},i=t=>{e(((e,n)=>{const i="touches"in t;if(i&&t.touches.length>1)return e;if(t.timeStamp-e.start>n.swipeDuration)return e.swiping?Object.assign(Object.assign({},e),{swiping:!1}):e;const{clientX:r,clientY:a}=i?t.touches[0]:t,[o,s]=le([r,a],n.rotationAngle),l=o-e.xy[0],u=s-e.xy[1],c=Math.abs(l),h=Math.abs(u),d=(t.timeStamp||0)-e.start,p=Math.sqrt(c*c+h*h)/(d||1),f=[l/(d||1),u/(d||1)],m=function(e,t,n,i){return e>t?n>0?te:ee:i>0?ie:ne}(c,h,l,u),b="number"==typeof n.delta?n.delta:n.delta[m.toLowerCase()]||re.delta;if(c{e(((e,n)=>{let i;if(e.swiping&&e.eventData){if(t.timeStamp-e.start{document.removeEventListener(oe,i),document.removeEventListener(se,a),r(e)},o=(e,t)=>{let a=()=>{};if(e&&e.addEventListener){const o=Object.assign(Object.assign({},re.touchEventOptions),t.touchEventOptions),s=[["touchstart",n,o],["touchmove",i,Object.assign(Object.assign({},o),t.preventScrollOnSwipe?{passive:!1}:{})],["touchend",r,o]];s.forEach((([t,n,i])=>e.addEventListener(t,n,i))),a=()=>s.forEach((([t,n])=>e.removeEventListener(t,n)))}return a},s={ref:t=>{null!==t&&e(((e,n)=>{if(e.el===t)return e;const i={};return e.el&&e.el!==t&&e.cleanUpTouch&&(e.cleanUpTouch(),i.cleanUpTouch=void 0),n.trackTouch&&t&&(i.cleanUpTouch=o(t,n)),Object.assign(Object.assign(Object.assign({},e),{el:t}),i)}))}};return t.trackMouse&&(s.onMouseDown=n),[s,o]}((e=>i.current=e(i.current,r.current)),{trackMouse:t})),[t]);return i.current=function(e,t,n,i){return t.trackTouch&&e.el?e.cleanUpTouch?t.preventScrollOnSwipe!==n.preventScrollOnSwipe||t.touchEventOptions.passive!==n.touchEventOptions.passive?(e.cleanUpTouch(),Object.assign(Object.assign({},e),{cleanUpTouch:i(e.el,t)})):e:Object.assign(Object.assign({},e),{cleanUpTouch:i(e.el,t)}):(e.cleanUpTouch&&e.cleanUpTouch(),Object.assign(Object.assign({},e),{cleanUpTouch:void 0}))}(i.current,r.current,a.current,l),s}var ce=i(697);function he(e){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},he(e)}function de(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function pe(e){for(var t=1;t=3&&i&&(0===e&&t===r.length-1?a=" ".concat(s):e===r.length-1&&0===t&&(a=" ".concat(o))),a}},{key:"getTranslateXForTwoSlide",value:function(e){var t=this.state,n=t.currentIndex,i=t.currentSlideOffset,r=t.previousIndex,a=n!==r,o=0===e&&0===r,s=1===e&&1===r,l=0===e&&1===n,u=1===e&&0===n,c=0===i,h=-100*n+100*e+i;return i>0?this.direction="left":i<0&&(this.direction="right"),u&&i>0&&(h=-100+i),l&&i<0&&(h=100+i),a?o&&c&&"left"===this.direction?h=100:s&&c&&"right"===this.direction&&(h=-100):(u&&c&&"left"===this.direction&&(h=-100),l&&c&&"right"===this.direction&&(h=100)),h}},{key:"getThumbnailBarHeight",value:function(){return this.isThumbnailVertical()?{height:this.state.gallerySlideWrapperHeight}:{}}},{key:"getSlideStyle",value:function(e){var t=this.state,n=t.currentIndex,i=t.currentSlideOffset,r=t.slideStyle,a=this.props,o=a.infinite,s=a.items,l=a.useTranslate3D,u=a.isRTL,c=-100*n,h=s.length-1,d=(c+100*e)*(u?-1:1)+i;o&&s.length>2&&(0===n&&e===h?d=-100*(u?-1:1)+i:n===h&&0===e&&(d=100*(u?-1:1)+i)),o&&2===s.length&&(d=this.getTranslateXForTwoSlide(e));var p="translate(".concat(d,"%, 0)");return l&&(p="translate3d(".concat(d,"%, 0, 0)")),qe({display:this.isSlideVisible(e)?"inherit":"none",WebkitTransform:p,MozTransform:p,msTransform:p,OTransform:p,transform:p},r)}},{key:"getCurrentIndex",value:function(){return this.state.currentIndex}},{key:"getThumbnailStyle",value:function(){var e,t=this.props,n=t.useTranslate3D,i=t.isRTL,r=this.state,a=r.thumbsTranslate,o=r.thumbsStyle,s=i?-1*a:a;return this.isThumbnailVertical()?(e="translate(0, ".concat(a,"px)"),n&&(e="translate3d(0, ".concat(a,"px, 0)"))):(e="translate(".concat(s,"px, 0)"),n&&(e="translate3d(".concat(s,"px, 0, 0)"))),qe({WebkitTransform:e,MozTransform:e,msTransform:e,OTransform:e,transform:e},o)}},{key:"getSlideItems",value:function(){var e=this,n=this.state.currentIndex,i=this.props,r=i.items,o=i.slideOnThumbnailOver,s=i.onClick,l=i.lazyLoad,u=i.onTouchMove,c=i.onTouchEnd,h=i.onTouchStart,d=i.onMouseOver,p=i.onMouseLeave,f=i.renderItem,m=i.renderThumbInner,b=i.showThumbnails,g=i.showBullets,v=[],y=[],w=[];return r.forEach((function(i,r){var S=e.getAlignmentClassName(r),T=i.originalClass?" ".concat(i.originalClass):"",O=i.thumbnailClass?" ".concat(i.thumbnailClass):"",E=i.renderItem||f||e.renderItem,k=i.renderThumbInner||m||e.renderThumbInner,I=!l||S||e.lazyLoaded[r];I&&l&&!e.lazyLoaded[r]&&(e.lazyLoaded[r]=!0);var j=e.getSlideStyle(r),x=a().createElement("div",{"aria-label":"Go to Slide ".concat(r+1),key:"slide-".concat(r),tabIndex:"-1",className:"image-gallery-slide ".concat(S," ").concat(T),style:j,onClick:s,onKeyUp:e.handleSlideKeyUp,onTouchMove:u,onTouchEnd:c,onTouchStart:h,onMouseOver:d,onFocus:d,onMouseLeave:p,role:"button"},I?E(i):a().createElement("div",{style:{height:"100%"}}));if(v.push(x),b&&i.thumbnail){var P=t("image-gallery-thumbnail",O,{active:n===r});y.push(a().createElement("button",{key:"thumbnail-".concat(r),type:"button",tabIndex:"0","aria-pressed":n===r?"true":"false","aria-label":"Go to Slide ".concat(r+1),className:P,onMouseLeave:o?e.onThumbnailMouseLeave:null,onMouseOver:function(t){return e.handleThumbnailMouseOver(t,r)},onFocus:function(t){return e.handleThumbnailMouseOver(t,r)},onKeyUp:function(t){return e.handleThumbnailKeyUp(t,r)},onClick:function(t){return e.onThumbnailClick(t,r)}},k(i)))}if(g){var _=t("image-gallery-bullet",i.bulletClass,{active:n===r});w.push(a().createElement("button",{type:"button",key:"bullet-".concat(r),className:_,onClick:function(t){return e.onBulletClick(t,r)},"aria-pressed":n===r?"true":"false","aria-label":"Go to Slide ".concat(r+1)}))}})),{slides:v,thumbnails:y,bullets:w}}},{key:"ignoreIsTransitioning",value:function(){var e=this.props.items,t=this.state,n=t.previousIndex,i=t.currentIndex,r=e.length-1;return Math.abs(n-i)>1&&!(0===n&&i===r)&&!(n===r&&0===i)}},{key:"isFirstOrLastSlide",value:function(e){return e===this.props.items.length-1||0===e}},{key:"slideIsTransitioning",value:function(e){var t=this.state,n=t.isTransitioning,i=t.previousIndex,r=t.currentIndex;return n&&!(e===i||e===r)}},{key:"isSlideVisible",value:function(e){return!this.slideIsTransitioning(e)||this.ignoreIsTransitioning()&&!this.isFirstOrLastSlide(e)}},{key:"slideThumbnailBar",value:function(){var e=this.state,t=e.currentIndex,n=e.isSwipingThumbnail,i=-this.getThumbsTranslate(t);n||(0===t?this.setState({thumbsTranslate:0,thumbsSwipedTranslate:0}):this.setState({thumbsTranslate:i,thumbsSwipedTranslate:i}))}},{key:"canSlide",value:function(){return this.props.items.length>=2}},{key:"canSlideLeft",value:function(){return this.props.infinite||this.canSlidePrevious()}},{key:"canSlideRight",value:function(){return this.props.infinite||this.canSlideNext()}},{key:"canSlidePrevious",value:function(){return this.state.currentIndex>0}},{key:"canSlideNext",value:function(){return this.state.currentIndex=100&&(f=100);var m={transition:"transform ".concat(d,"ms ease-out")};this.setState({currentSlideOffset:p*f,slideStyle:m})}}}else c||this.setState({swipingUpDown:!0})}},{key:"handleThumbnailSwiping",value:function(e){var t=e.event,n=e.absX,i=e.absY,r=e.dir,a=this.props,o=a.stopPropagation,s=a.swipingThumbnailTransitionDuration,l=this.state,u=l.thumbsSwipedTranslate,c=l.thumbnailsWrapperHeight,h=l.thumbnailsWrapperWidth,d=l.swipingUpDown,p=l.swipingLeftRight;if(this.isThumbnailVertical()){if((r===ee||r===te||p)&&!d)return void(p||this.setState({swipingLeftRight:!0}));r!==ne&&r!==ie||d||this.setState({swipingUpDown:!0})}else{if((r===ne||r===ie||d)&&!p)return void(d||this.setState({swipingUpDown:!0}));r!==ee&&r!==te||p||this.setState({swipingLeftRight:!0})}var f,m,b,g,v,y=this.thumbnails&&this.thumbnails.current;if(this.isThumbnailVertical()?(f=u+(r===ie?i:-i),m=y.scrollHeight-c+20,b=Math.abs(f)>m,g=f>20,v=y.scrollHeight<=c):(f=u+(r===te?n:-n),m=y.scrollWidth-h+20,b=Math.abs(f)>m,g=f>20,v=y.scrollWidth<=h),!v&&(r!==ee&&r!==ne||!b)&&(r!==te&&r!==ie||!g)){o&&t.stopPropagation();var w={transition:"transform ".concat(s,"ms ease-out")};this.setState({thumbsTranslate:f,thumbsStyle:w})}}},{key:"handleOnThumbnailSwiped",value:function(){var e=this.state.thumbsTranslate,t=this.props.slideDuration;this.resetSwipingDirection(),this.setState({isSwipingThumbnail:!0,thumbsSwipedTranslate:e,thumbsStyle:{transition:"all ".concat(t,"ms ease-out")}})}},{key:"sufficientSwipe",value:function(){var e=this.state.currentSlideOffset,t=this.props.swipeThreshold;return Math.abs(e)>t}},{key:"resetSwipingDirection",value:function(){var e=this.state,t=e.swipingUpDown,n=e.swipingLeftRight;t&&this.setState({swipingUpDown:!1}),n&&this.setState({swipingLeftRight:!1})}},{key:"handleOnSwiped",value:function(e){var t=e.event,n=e.dir,i=e.velocity,r=this.props,a=r.disableSwipe,o=r.stopPropagation,s=r.flickThreshold;if(!a){var l=this.props.isRTL;o&&t.stopPropagation(),this.resetSwipingDirection();var u=(n===ee?1:-1)*(l?-1:1),c=i>s&&!(n===ne||n===ie);this.handleOnSwipedTo(u,c)}}},{key:"handleOnSwipedTo",value:function(e,t){var n=this.state,i=n.currentIndex,r=n.isTransitioning,a=i;!this.sufficientSwipe()&&!t||r||(a+=e),(-1===e&&!this.canSlideLeft()||1===e&&!this.canSlideRight())&&(a=i),this.unthrottledSlideToIndex(a)}},{key:"handleTouchMove",value:function(e){this.state.swipingLeftRight&&e.preventDefault()}},{key:"handleMouseDown",value:function(){this.imageGallery.current.classList.add("image-gallery-using-mouse")}},{key:"handleKeyDown",value:function(e){var t=this.props,n=t.disableKeyDown,i=t.useBrowserFullscreen,r=this.state.isFullscreen;if(this.imageGallery.current.classList.remove("image-gallery-using-mouse"),!n)switch(parseInt(e.keyCode||e.which||0,10)){case 37:this.canSlideLeft()&&!this.playPauseIntervalId&&this.slideLeft(e);break;case 39:this.canSlideRight()&&!this.playPauseIntervalId&&this.slideRight(e);break;case 27:r&&!i&&this.exitFullScreen()}}},{key:"handleImageError",value:function(e){var t=this.props.onErrorImageURL;t&&-1===e.target.src.indexOf(t)&&(e.target.src=t)}},{key:"removeThumbnailsResizeObserver",value:function(){this.resizeThumbnailWrapperObserver&&this.thumbnailsWrapper&&this.thumbnailsWrapper.current&&(this.resizeThumbnailWrapperObserver.unobserve(this.thumbnailsWrapper.current),this.resizeThumbnailWrapperObserver=null)}},{key:"removeResizeObserver",value:function(){this.resizeSlideWrapperObserver&&this.imageGallerySlideWrapper&&this.imageGallerySlideWrapper.current&&(this.resizeSlideWrapperObserver.unobserve(this.imageGallerySlideWrapper.current),this.resizeSlideWrapperObserver=null),this.removeThumbnailsResizeObserver()}},{key:"handleResize",value:function(){var e=this.state.currentIndex;this.imageGallery&&(this.imageGallery&&this.imageGallery.current&&this.setState({galleryWidth:this.imageGallery.current.offsetWidth}),this.imageGallerySlideWrapper&&this.imageGallerySlideWrapper.current&&this.setState({gallerySlideWrapperHeight:this.imageGallerySlideWrapper.current.offsetHeight}),this.setThumbsTranslate(-this.getThumbsTranslate(e)))}},{key:"initSlideWrapperResizeObserver",value:function(e){var t=this;e&&!e.current||(this.resizeSlideWrapperObserver=new Z(P((function(e){e&&e.forEach((function(e){t.setState({thumbnailsWrapperWidth:e.contentRect.width},t.handleResize)}))}),50)),this.resizeSlideWrapperObserver.observe(e.current))}},{key:"initThumbnailWrapperResizeObserver",value:function(e){var t=this;e&&!e.current||(this.resizeThumbnailWrapperObserver=new Z(P((function(e){e&&e.forEach((function(e){t.setState({thumbnailsWrapperHeight:e.contentRect.height},t.handleResize)}))}),50)),this.resizeThumbnailWrapperObserver.observe(e.current))}},{key:"toggleFullScreen",value:function(){this.state.isFullscreen?this.exitFullScreen():this.fullScreen()}},{key:"togglePlay",value:function(){this.playPauseIntervalId?this.pause():this.play()}},{key:"handleScreenChange",value:function(){var e=this.props,t=e.onScreenChange,n=e.useBrowserFullscreen,i=document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement,r=this.imageGallery.current===i;t&&t(r),n&&this.setState({isFullscreen:r})}},{key:"slideToIndex",value:function(e,t){var n=this.state,i=n.currentIndex,r=n.isTransitioning,a=this.props,o=a.items,s=a.slideDuration,l=a.onBeforeSlide;if(!r){t&&this.playPauseIntervalId&&(this.pause(!1),this.play(!1));var u=o.length-1,c=e;e<0?c=u:e>u&&(c=0),l&&c!==i&&l(c),this.setState({previousIndex:i,currentIndex:c,isTransitioning:c!==i,currentSlideOffset:0,slideStyle:{transition:"all ".concat(s,"ms ease-out")}},this.onSliding)}}},{key:"slideLeft",value:function(e){var t=this.props.isRTL;this.slideTo(e,t?"right":"left")}},{key:"slideRight",value:function(e){var t=this.props.isRTL;this.slideTo(e,t?"left":"right")}},{key:"slideTo",value:function(e,t){var n=this.state,i=n.currentIndex,r=n.isTransitioning,a=this.props.items,o=i+("left"===t?-1:1);r||(2===a.length?this.slideToIndexWithStyleReset(o,e):this.slideToIndex(o,e))}},{key:"slideToIndexWithStyleReset",value:function(e,t){var n=this,i=this.state,r=i.currentIndex,a=i.currentSlideOffset;this.setState({currentSlideOffset:a+(r>e?.001:-.001),slideStyle:{transition:"none"}},(function(){window.setTimeout((function(){return n.slideToIndex(e,t)}),25)}))}},{key:"handleThumbnailMouseOver",value:function(e,t){this.props.slideOnThumbnailOver&&this.onThumbnailMouseOver(e,t)}},{key:"handleThumbnailKeyUp",value:function(e,t){et(e)&&this.onThumbnailClick(e,t)}},{key:"handleSlideKeyUp",value:function(e){et(e)&&(0,this.props.onClick)(e)}},{key:"isThumbnailVertical",value:function(){var e=this.props.thumbnailPosition;return"left"===e||"right"===e}},{key:"addScreenChangeEvent",value:function(){var e=this;Qe.forEach((function(t){document.addEventListener(t,e.handleScreenChange)}))}},{key:"removeScreenChangeEvent",value:function(){var e=this;Qe.forEach((function(t){document.removeEventListener(t,e.handleScreenChange)}))}},{key:"fullScreen",value:function(){var e=this.props.useBrowserFullscreen,t=this.imageGallery.current;e?t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():this.setModalFullscreen(!0):this.setModalFullscreen(!0),this.setState({isFullscreen:!0})}},{key:"exitFullScreen",value:function(){var e=this.state.isFullscreen,t=this.props.useBrowserFullscreen;e&&(t?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():this.setModalFullscreen(!1):this.setModalFullscreen(!1),this.setState({isFullscreen:!1}))}},{key:"pauseOrPlay",value:function(){var e=this.props.infinite,t=this.state.currentIndex;e||this.canSlideRight()?this.slideToIndex(t+1):this.pause()}},{key:"play",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.props,n=t.onPlay,i=t.slideInterval,r=t.slideDuration,a=this.state.currentIndex;this.playPauseIntervalId||(this.setState({isPlaying:!0}),this.playPauseIntervalId=window.setInterval(this.pauseOrPlay,Math.max(i,r)),n&&e&&n(a))}},{key:"pause",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.props.onPause,n=this.state.currentIndex;this.playPauseIntervalId&&(window.clearInterval(this.playPauseIntervalId),this.playPauseIntervalId=null,this.setState({isPlaying:!1}),t&&e&&t(n))}},{key:"isImageLoaded",value:function(e){return!!this.loadedImages[e.original]||(this.loadedImages[e.original]=!0,!1)}},{key:"handleImageLoaded",value:function(e,t){var n=this.props.onImageLoad;!this.loadedImages[t]&&n&&(this.loadedImages[t]=!0,n(e))}},{key:"renderItem",value:function(e){var t=this.state.isFullscreen,n=this.props.onImageError||this.handleImageError;return a().createElement(ge,{description:e.description,fullscreen:e.fullscreen,handleImageLoaded:this.handleImageLoaded,isFullscreen:t,onImageError:n,original:e.original,originalAlt:e.originalAlt,originalHeight:e.originalHeight,originalWidth:e.originalWidth,originalTitle:e.originalTitle,sizes:e.sizes,loading:e.loading,srcSet:e.srcSet})}},{key:"renderThumbInner",value:function(e){var t=this.props.onThumbnailError||this.handleImageError;return a().createElement("span",{className:"image-gallery-thumbnail-inner"},a().createElement("img",{className:"image-gallery-thumbnail-image",src:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth,alt:e.thumbnailAlt,title:e.thumbnailTitle,loading:e.thumbnailLoading,onError:t}),e.thumbnailLabel&&a().createElement("div",{className:"image-gallery-thumbnail-label"},e.thumbnailLabel))}},{key:"render",value:function(){var e=this.state,n=e.currentIndex,i=e.isFullscreen,r=e.modalFullscreen,o=e.isPlaying,s=this.props,l=s.additionalClass,u=s.disableThumbnailSwipe,c=s.indexSeparator,h=s.isRTL,d=s.items,p=s.thumbnailPosition,f=s.renderFullscreenButton,m=s.renderCustomControls,b=s.renderLeftNav,g=s.renderRightNav,v=s.showBullets,y=s.showFullscreenButton,w=s.showIndex,S=s.showThumbnails,T=s.showNav,O=s.showPlayButton,E=s.renderPlayPauseButton,k=this.getThumbnailStyle(),I=this.getSlideItems(),j=I.slides,x=I.thumbnails,P=I.bullets,_=t("image-gallery-slide-wrapper",this.getThumbnailPositionClassName(p),{"image-gallery-rtl":h}),R=a().createElement("div",{ref:this.imageGallerySlideWrapper,className:_},m&&m(),this.canSlide()?a().createElement(a().Fragment,null,T&&a().createElement(a().Fragment,null,b(this.slideLeft,!this.canSlideLeft()),g(this.slideRight,!this.canSlideRight())),a().createElement(Ae,{className:"image-gallery-swipe",delta:0,onSwiping:this.handleSwiping,onSwiped:this.handleOnSwiped},a().createElement("div",{className:"image-gallery-slides"},j))):a().createElement("div",{className:"image-gallery-slides"},j),O&&E(this.togglePlay,o),v&&a().createElement("div",{className:"image-gallery-bullets"},a().createElement("div",{className:"image-gallery-bullets-container",role:"navigation","aria-label":"Bullet Navigation"},P)),y&&f(this.toggleFullScreen,i),w&&a().createElement("div",{className:"image-gallery-index"},a().createElement("span",{className:"image-gallery-index-current"},n+1),a().createElement("span",{className:"image-gallery-index-separator"},c),a().createElement("span",{className:"image-gallery-index-total"},d.length))),M=t("image-gallery",l,{"fullscreen-modal":r}),L=t("image-gallery-content",this.getThumbnailPositionClassName(p),{fullscreen:i}),D=t("image-gallery-thumbnails-wrapper",this.getThumbnailPositionClassName(p),{"thumbnails-wrapper-rtl":!this.isThumbnailVertical()&&h},{"thumbnails-swipe-horizontal":!this.isThumbnailVertical()&&!u},{"thumbnails-swipe-vertical":this.isThumbnailVertical()&&!u});return a().createElement("div",{ref:this.imageGallery,className:M,"aria-live":"polite"},a().createElement("div",{className:L},("bottom"===p||"right"===p)&&R,S&&x.length>0?a().createElement(Ae,{className:D,delta:0,onSwiping:!u&&this.handleThumbnailSwiping,onSwiped:!u&&this.handleOnThumbnailSwiped},a().createElement("div",{className:"image-gallery-thumbnails",ref:this.thumbnailsWrapper,style:this.getThumbnailBarHeight()},a().createElement("nav",{ref:this.thumbnails,className:"image-gallery-thumbnails-container",style:k,"aria-label":"Thumbnail Navigation"},x))):null,("top"===p||"left"===p)&&R))}}],i&&He(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),l}(a().Component);tt.propTypes={flickThreshold:ce.number,items:(0,ce.arrayOf)((0,ce.shape)({bulletClass:ce.string,bulletOnClick:ce.func,description:ce.string,original:ce.string,originalHeight:ce.number,originalWidth:ce.number,loading:ce.string,thumbnailHeight:ce.number,thumbnailWidth:ce.number,thumbnailLoading:ce.string,fullscreen:ce.string,originalAlt:ce.string,originalTitle:ce.string,thumbnail:ce.string,thumbnailAlt:ce.string,thumbnailLabel:ce.string,thumbnailTitle:ce.string,originalClass:ce.string,thumbnailClass:ce.string,renderItem:ce.func,renderThumbInner:ce.func,imageSet:Ze,srcSet:ce.string,sizes:ce.string})).isRequired,showNav:ce.bool,autoPlay:ce.bool,lazyLoad:ce.bool,infinite:ce.bool,showIndex:ce.bool,showBullets:ce.bool,showThumbnails:ce.bool,showPlayButton:ce.bool,showFullscreenButton:ce.bool,disableThumbnailScroll:ce.bool,disableKeyDown:ce.bool,disableSwipe:ce.bool,disableThumbnailSwipe:ce.bool,useBrowserFullscreen:ce.bool,onErrorImageURL:ce.string,indexSeparator:ce.string,thumbnailPosition:(0,ce.oneOf)(["top","bottom","left","right"]),startIndex:ce.number,slideDuration:ce.number,slideInterval:ce.number,slideOnThumbnailOver:ce.bool,swipeThreshold:ce.number,swipingTransitionDuration:ce.number,swipingThumbnailTransitionDuration:ce.number,onSlide:ce.func,onBeforeSlide:ce.func,onScreenChange:ce.func,onPause:ce.func,onPlay:ce.func,onClick:ce.func,onImageLoad:ce.func,onImageError:ce.func,onTouchMove:ce.func,onTouchEnd:ce.func,onTouchStart:ce.func,onMouseOver:ce.func,onMouseLeave:ce.func,onBulletClick:ce.func,onThumbnailError:ce.func,onThumbnailClick:ce.func,renderCustomControls:ce.func,renderLeftNav:ce.func,renderRightNav:ce.func,renderPlayPauseButton:ce.func,renderFullscreenButton:ce.func,renderItem:ce.func,renderThumbInner:ce.func,stopPropagation:ce.bool,additionalClass:ce.string,useTranslate3D:ce.bool,isRTL:ce.bool,useWindowKeyDown:ce.bool},tt.defaultProps={onErrorImageURL:"",additionalClass:"",showNav:!0,autoPlay:!1,lazyLoad:!1,infinite:!0,showIndex:!1,showBullets:!1,showThumbnails:!0,showPlayButton:!0,showFullscreenButton:!0,disableThumbnailScroll:!1,disableKeyDown:!1,disableSwipe:!1,disableThumbnailSwipe:!1,useTranslate3D:!0,isRTL:!1,useBrowserFullscreen:!0,flickThreshold:.4,stopPropagation:!1,indexSeparator:" / ",thumbnailPosition:"bottom",startIndex:0,slideDuration:450,swipingTransitionDuration:0,swipingThumbnailTransitionDuration:0,onSlide:null,onBeforeSlide:null,onScreenChange:null,onPause:null,onPlay:null,onClick:null,onImageLoad:null,onImageError:null,onTouchMove:null,onTouchEnd:null,onTouchStart:null,onMouseOver:null,onMouseLeave:null,onBulletClick:null,onThumbnailError:null,onThumbnailClick:null,renderCustomControls:null,renderThumbInner:null,renderItem:null,slideInterval:3e3,slideOnThumbnailOver:!1,swipeThreshold:30,renderLeftNav:function(e,t){return a().createElement(Pe,{onClick:e,disabled:t})},renderRightNav:function(e,t){return a().createElement(Re,{onClick:e,disabled:t})},renderPlayPauseButton:function(e,t){return a().createElement(Le,{onClick:e,isPlaying:t})},renderFullscreenButton:function(e,t){return a().createElement(je,{onClick:e,isFullscreen:t})},useWindowKeyDown:!0};const nt=tt})(),r})()));
/***/ }),
/***/ 5301:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
/**
* This is a straight rip-off of the React.js ReactPropTypes.js proptype validators,
* modified to make it possible to validate Immutable.js data.
* ImmutableTypes.listOf is patterned after React.PropTypes.arrayOf, but for Immutable.List
* ImmutableTypes.shape is based on React.PropTypes.shape, but for any Immutable.Iterable
*/
var Immutable = __webpack_require__(3096);
var ANONYMOUS = "<>";
var ImmutablePropTypes;
if (false) {} else {
var productionTypeChecker = function productionTypeChecker() {
invariant(false, "ImmutablePropTypes type checking code is stripped in production.");
};
productionTypeChecker.isRequired = productionTypeChecker;
var getProductionTypeChecker = function getProductionTypeChecker() {
return productionTypeChecker;
};
ImmutablePropTypes = {
listOf: getProductionTypeChecker,
mapOf: getProductionTypeChecker,
orderedMapOf: getProductionTypeChecker,
setOf: getProductionTypeChecker,
orderedSetOf: getProductionTypeChecker,
stackOf: getProductionTypeChecker,
iterableOf: getProductionTypeChecker,
recordOf: getProductionTypeChecker,
shape: getProductionTypeChecker,
contains: getProductionTypeChecker,
mapContains: getProductionTypeChecker,
orderedMapContains: getProductionTypeChecker,
// Primitive Types
list: productionTypeChecker,
map: productionTypeChecker,
orderedMap: productionTypeChecker,
set: productionTypeChecker,
orderedSet: productionTypeChecker,
stack: productionTypeChecker,
seq: productionTypeChecker,
record: productionTypeChecker,
iterable: productionTypeChecker
};
}
ImmutablePropTypes.iterable.indexed = createIterableSubclassTypeChecker("Indexed", Immutable.Iterable.isIndexed);
ImmutablePropTypes.iterable.keyed = createIterableSubclassTypeChecker("Keyed", Immutable.Iterable.isKeyed);
function getPropType(propValue) {
var propType = typeof propValue;
if (Array.isArray(propValue)) {
return "array";
}
if (propValue instanceof RegExp) {
// Old webkits (at least until Android 4.0) return 'function' rather than
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
// passes PropTypes.object.
return "object";
}
if (propValue instanceof Immutable.Iterable) {
return "Immutable." + propValue.toSource().split(" ")[0];
}
return propType;
}
function createChainableTypeChecker(validate) {
function checkType(isRequired, props, propName, componentName, location, propFullName) {
for (var _len = arguments.length, rest = Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
rest[_key - 6] = arguments[_key];
}
propFullName = propFullName || propName;
componentName = componentName || ANONYMOUS;
if (props[propName] == null) {
var locationName = location;
if (isRequired) {
return new Error("Required " + locationName + " `" + propFullName + "` was not specified in " + ("`" + componentName + "`."));
}
} else {
return validate.apply(undefined, [props, propName, componentName, location, propFullName].concat(rest));
}
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
function createImmutableTypeChecker(immutableClassName, immutableClassTypeValidator) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
if (!immutableClassTypeValidator(propValue)) {
var propType = getPropType(propValue);
return new Error("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `" + immutableClassName + "`."));
}
return null;
}
return createChainableTypeChecker(validate);
}
function createIterableSubclassTypeChecker(subclassName, validator) {
return createImmutableTypeChecker("Iterable." + subclassName, function (propValue) {
return Immutable.Iterable.isIterable(propValue) && validator(propValue);
});
}
function createIterableTypeChecker(typeChecker, immutableClassName, immutableClassTypeValidator) {
function validate(props, propName, componentName, location, propFullName) {
for (var _len = arguments.length, rest = Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
rest[_key - 5] = arguments[_key];
}
var propValue = props[propName];
if (!immutableClassTypeValidator(propValue)) {
var locationName = location;
var propType = getPropType(propValue);
return new Error("Invalid " + locationName + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an Immutable.js " + immutableClassName + "."));
}
if (typeof typeChecker !== "function") {
return new Error("Invalid typeChecker supplied to `" + componentName + "` " + ("for propType `" + propFullName + "`, expected a function."));
}
var propValues = propValue.valueSeq().toArray();
for (var i = 0, len = propValues.length; i < len; i++) {
var error = typeChecker.apply(undefined, [propValues, i, componentName, location, "" + propFullName + "[" + i + "]"].concat(rest));
if (error instanceof Error) {
return error;
}
}
}
return createChainableTypeChecker(validate);
}
function createKeysTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
for (var _len = arguments.length, rest = Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
rest[_key - 5] = arguments[_key];
}
var propValue = props[propName];
if (typeof typeChecker !== "function") {
return new Error("Invalid keysTypeChecker (optional second argument) supplied to `" + componentName + "` " + ("for propType `" + propFullName + "`, expected a function."));
}
var keys = propValue.keySeq().toArray();
for (var i = 0, len = keys.length; i < len; i++) {
var error = typeChecker.apply(undefined, [keys, i, componentName, location, "" + propFullName + " -> key(" + keys[i] + ")"].concat(rest));
if (error instanceof Error) {
return error;
}
}
}
return createChainableTypeChecker(validate);
}
function createListOfTypeChecker(typeChecker) {
return createIterableTypeChecker(typeChecker, "List", Immutable.List.isList);
}
function createMapOfTypeCheckerFactory(valuesTypeChecker, keysTypeChecker, immutableClassName, immutableClassTypeValidator) {
function validate() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return createIterableTypeChecker(valuesTypeChecker, immutableClassName, immutableClassTypeValidator).apply(undefined, args) || keysTypeChecker && createKeysTypeChecker(keysTypeChecker).apply(undefined, args);
}
return createChainableTypeChecker(validate);
}
function createMapOfTypeChecker(valuesTypeChecker, keysTypeChecker) {
return createMapOfTypeCheckerFactory(valuesTypeChecker, keysTypeChecker, "Map", Immutable.Map.isMap);
}
function createOrderedMapOfTypeChecker(valuesTypeChecker, keysTypeChecker) {
return createMapOfTypeCheckerFactory(valuesTypeChecker, keysTypeChecker, "OrderedMap", Immutable.OrderedMap.isOrderedMap);
}
function createSetOfTypeChecker(typeChecker) {
return createIterableTypeChecker(typeChecker, "Set", Immutable.Set.isSet);
}
function createOrderedSetOfTypeChecker(typeChecker) {
return createIterableTypeChecker(typeChecker, "OrderedSet", Immutable.OrderedSet.isOrderedSet);
}
function createStackOfTypeChecker(typeChecker) {
return createIterableTypeChecker(typeChecker, "Stack", Immutable.Stack.isStack);
}
function createIterableOfTypeChecker(typeChecker) {
return createIterableTypeChecker(typeChecker, "Iterable", Immutable.Iterable.isIterable);
}
function createRecordOfTypeChecker(recordKeys) {
function validate(props, propName, componentName, location, propFullName) {
for (var _len = arguments.length, rest = Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
rest[_key - 5] = arguments[_key];
}
var propValue = props[propName];
if (!(propValue instanceof Immutable.Record)) {
var propType = getPropType(propValue);
var locationName = location;
return new Error("Invalid " + locationName + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected an Immutable.js Record."));
}
for (var key in recordKeys) {
var checker = recordKeys[key];
if (!checker) {
continue;
}
var mutablePropValue = propValue.toObject();
var error = checker.apply(undefined, [mutablePropValue, key, componentName, location, "" + propFullName + "." + key].concat(rest));
if (error) {
return error;
}
}
}
return createChainableTypeChecker(validate);
}
// there is some irony in the fact that shapeTypes is a standard hash and not an immutable collection
function createShapeTypeChecker(shapeTypes) {
var immutableClassName = arguments[1] === undefined ? "Iterable" : arguments[1];
var immutableClassTypeValidator = arguments[2] === undefined ? Immutable.Iterable.isIterable : arguments[2];
function validate(props, propName, componentName, location, propFullName) {
for (var _len = arguments.length, rest = Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
rest[_key - 5] = arguments[_key];
}
var propValue = props[propName];
if (!immutableClassTypeValidator(propValue)) {
var propType = getPropType(propValue);
var locationName = location;
return new Error("Invalid " + locationName + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected an Immutable.js " + immutableClassName + "."));
}
var mutablePropValue = propValue.toObject();
for (var key in shapeTypes) {
var checker = shapeTypes[key];
if (!checker) {
continue;
}
var error = checker.apply(undefined, [mutablePropValue, key, componentName, location, "" + propFullName + "." + key].concat(rest));
if (error) {
return error;
}
}
}
return createChainableTypeChecker(validate);
}
function createShapeChecker(shapeTypes) {
return createShapeTypeChecker(shapeTypes);
}
function createMapContainsChecker(shapeTypes) {
return createShapeTypeChecker(shapeTypes, "Map", Immutable.Map.isMap);
}
function createOrderedMapContainsChecker(shapeTypes) {
return createShapeTypeChecker(shapeTypes, "OrderedMap", Immutable.OrderedMap.isOrderedMap);
}
module.exports = ImmutablePropTypes;
/***/ }),
/***/ 8618:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var _postcssValueParser = __webpack_require__(5482);
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
var _parser = __webpack_require__(4579);
var _reducer = __webpack_require__(6018);
var _reducer2 = _interopRequireDefault(_reducer);
var _stringifier = __webpack_require__(2459);
var _stringifier2 = _interopRequireDefault(_stringifier);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-line
var MATCH_CALC = /((?:\-[a-z]+\-)?calc)/;
exports["default"] = function (value) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
return (0, _postcssValueParser2.default)(value).walk(function (node) {
// skip anything which isn't a calc() function
if (node.type !== 'function' || !MATCH_CALC.test(node.value)) return;
// stringify calc expression and produce an AST
var contents = _postcssValueParser2.default.stringify(node.nodes);
// skip constant() and env()
if (contents.indexOf('constant') >= 0 || contents.indexOf('env') >= 0) return;
var ast = _parser.parser.parse(contents);
// reduce AST to its simplest form, that is, either to a single value
// or a simplified calc expression
var reducedAst = (0, _reducer2.default)(ast, precision);
// stringify AST and write it back
node.type = 'word';
node.value = (0, _stringifier2.default)(node.value, reducedAst, precision);
}, true).toString();
};
module.exports = exports['default'];
/***/ }),
/***/ 6293:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
var _cssUnitConverter = __webpack_require__(2480);
var _cssUnitConverter2 = _interopRequireDefault(_cssUnitConverter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function convertNodes(left, right, precision) {
switch (left.type) {
case 'LengthValue':
case 'AngleValue':
case 'TimeValue':
case 'FrequencyValue':
case 'ResolutionValue':
return convertAbsoluteLength(left, right, precision);
default:
return { left: left, right: right };
}
}
function convertAbsoluteLength(left, right, precision) {
if (right.type === left.type) {
right = {
type: left.type,
value: (0, _cssUnitConverter2.default)(right.value, right.unit, left.unit, precision),
unit: left.unit
};
}
return { left: left, right: right };
}
exports["default"] = convertNodes;
module.exports = exports['default'];
/***/ }),
/***/ 6018:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.flip = flip;
var _convert = __webpack_require__(6293);
var _convert2 = _interopRequireDefault(_convert);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function reduce(node, precision) {
if (node.type === "MathExpression") return reduceMathExpression(node, precision);
if (node.type === "Calc") return reduce(node.value, precision);
return node;
}
function isEqual(left, right) {
return left.type === right.type && left.value === right.value;
}
function isValueType(type) {
switch (type) {
case 'LengthValue':
case 'AngleValue':
case 'TimeValue':
case 'FrequencyValue':
case 'ResolutionValue':
case 'EmValue':
case 'ExValue':
case 'ChValue':
case 'RemValue':
case 'VhValue':
case 'VwValue':
case 'VminValue':
case 'VmaxValue':
case 'PercentageValue':
case 'Value':
return true;
}
return false;
}
function convertMathExpression(node, precision) {
var nodes = (0, _convert2.default)(node.left, node.right, precision);
var left = reduce(nodes.left, precision);
var right = reduce(nodes.right, precision);
if (left.type === "MathExpression" && right.type === "MathExpression") {
if (left.operator === '/' && right.operator === '*' || left.operator === '-' && right.operator === '+' || left.operator === '*' && right.operator === '/' || left.operator === '+' && right.operator === '-') {
if (isEqual(left.right, right.right)) nodes = (0, _convert2.default)(left.left, right.left, precision);else if (isEqual(left.right, right.left)) nodes = (0, _convert2.default)(left.left, right.right, precision);
left = reduce(nodes.left, precision);
right = reduce(nodes.right, precision);
}
}
node.left = left;
node.right = right;
return node;
}
function flip(operator) {
return operator === '+' ? '-' : '+';
}
function flipValue(node) {
if (isValueType(node.type)) node.value = -node.value;else if (node.type == 'MathExpression') {
node.left = flipValue(node.left);
node.right = flipValue(node.right);
}
return node;
}
function reduceAddSubExpression(node, precision) {
var _node = node,
left = _node.left,
right = _node.right,
op = _node.operator;
if (left.type === 'CssVariable' || right.type === 'CssVariable') return node;
// something + 0 => something
// something - 0 => something
if (right.value === 0) return left;
// 0 + something => something
if (left.value === 0 && op === "+") return right;
// 0 - something => -something
if (left.value === 0 && op === "-") return flipValue(right);
// value + value
// value - value
if (left.type === right.type && isValueType(left.type)) {
node = Object.assign({}, left);
if (op === "+") node.value = left.value + right.value;else node.value = left.value - right.value;
}
// value (expr)
if (isValueType(left.type) && (right.operator === '+' || right.operator === '-') && right.type === 'MathExpression') {
// value + (value + something) => (value + value) + something
// value + (value - something) => (value + value) - something
// value - (value + something) => (value - value) - something
// value - (value - something) => (value - value) + something
if (left.type === right.left.type) {
node = Object.assign({}, node);
node.left = reduce({
type: 'MathExpression',
operator: op,
left: left,
right: right.left
}, precision);
node.right = right.right;
node.operator = op === '-' ? flip(right.operator) : right.operator;
return reduce(node, precision);
}
// value + (something + value) => (value + value) + something
// value + (something - value) => (value - value) + something
// value - (something + value) => (value - value) - something
// value - (something - value) => (value + value) - something
else if (left.type === right.right.type) {
node = Object.assign({}, node);
node.left = reduce({
type: 'MathExpression',
operator: op === '-' ? flip(right.operator) : right.operator,
left: left,
right: right.right
}, precision);
node.right = right.left;
return reduce(node, precision);
}
}
// (expr) value
if (left.type === 'MathExpression' && (left.operator === '+' || left.operator === '-') && isValueType(right.type)) {
// (value + something) + value => (value + value) + something
// (value - something) + value => (value + value) - something
// (value + something) - value => (value - value) + something
// (value - something) - value => (value - value) - something
if (right.type === left.left.type) {
node = Object.assign({}, left);
node.left = reduce({
type: 'MathExpression',
operator: op,
left: left.left,
right: right
}, precision);
return reduce(node, precision);
}
// (something + value) + value => something + (value + value)
// (something - value1) + value2 => something - (value2 - value1)
// (something + value) - value => something + (value - value)
// (something - value) - value => something - (value + value)
else if (right.type === left.right.type) {
node = Object.assign({}, left);
if (left.operator === '-') {
node.right = reduce({
type: 'MathExpression',
operator: op === '-' ? '+' : '-',
left: right,
right: left.right
}, precision);
node.operator = op === '-' ? '-' : '+';
} else {
node.right = reduce({
type: 'MathExpression',
operator: op,
left: left.right,
right: right
}, precision);
}
if (node.right.value < 0) {
node.right.value *= -1;
node.operator = node.operator === '-' ? '+' : '-';
}
return reduce(node, precision);
}
}
return node;
}
function reduceDivisionExpression(node, precision) {
if (!isValueType(node.right.type)) return node;
if (node.right.type !== 'Value') throw new Error("Cannot divide by \"" + node.right.unit + "\", number expected");
if (node.right.value === 0) throw new Error('Cannot divide by zero');
// (expr) / value
if (node.left.type === 'MathExpression') {
if (isValueType(node.left.left.type) && isValueType(node.left.right.type)) {
node.left.left.value /= node.right.value;
node.left.right.value /= node.right.value;
return reduce(node.left, precision);
}
return node;
}
// something / value
else if (isValueType(node.left.type)) {
node.left.value /= node.right.value;
return node.left;
}
return node;
}
function reduceMultiplicationExpression(node) {
// (expr) * value
if (node.left.type === 'MathExpression' && node.right.type === 'Value') {
if (isValueType(node.left.left.type) && isValueType(node.left.right.type)) {
node.left.left.value *= node.right.value;
node.left.right.value *= node.right.value;
return node.left;
}
}
// something * value
else if (isValueType(node.left.type) && node.right.type === 'Value') {
node.left.value *= node.right.value;
return node.left;
}
// value * (expr)
else if (node.left.type === 'Value' && node.right.type === 'MathExpression') {
if (isValueType(node.right.left.type) && isValueType(node.right.right.type)) {
node.right.left.value *= node.left.value;
node.right.right.value *= node.left.value;
return node.right;
}
}
// value * something
else if (node.left.type === 'Value' && isValueType(node.right.type)) {
node.right.value *= node.left.value;
return node.right;
}
return node;
}
function reduceMathExpression(node, precision) {
node = convertMathExpression(node, precision);
switch (node.operator) {
case "+":
case "-":
return reduceAddSubExpression(node, precision);
case "/":
return reduceDivisionExpression(node, precision);
case "*":
return reduceMultiplicationExpression(node);
}
return node;
}
exports["default"] = reduce;
/***/ }),
/***/ 2459:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = function (calc, node, precision) {
var str = stringify(node, precision);
if (node.type === "MathExpression") {
// if calc expression couldn't be resolved to a single value, re-wrap it as
// a calc()
str = calc + "(" + str + ")";
}
return str;
};
var _reducer = __webpack_require__(6018);
var order = {
"*": 0,
"/": 0,
"+": 1,
"-": 1
};
function round(value, prec) {
if (prec !== false) {
var precision = Math.pow(10, prec);
return Math.round(value * precision) / precision;
}
return value;
}
function stringify(node, prec) {
switch (node.type) {
case "MathExpression":
{
var left = node.left,
right = node.right,
op = node.operator;
var str = "";
if (left.type === 'MathExpression' && order[op] < order[left.operator]) str += "(" + stringify(left, prec) + ")";else str += stringify(left, prec);
str += " " + node.operator + " ";
if (right.type === 'MathExpression' && order[op] < order[right.operator]) {
str += "(" + stringify(right, prec) + ")";
} else if (right.type === 'MathExpression' && op === "-" && ["+", "-"].includes(right.operator)) {
// fix #52 : a-(b+c) = a-b-c
right.operator = (0, _reducer.flip)(right.operator);
str += stringify(right, prec);
} else {
str += stringify(right, prec);
}
return str;
}
case "Value":
return round(node.value, prec);
case 'CssVariable':
if (node.fallback) {
return "var(" + node.value + ", " + stringify(node.fallback, prec, true) + ")";
}
return "var(" + node.value + ")";
case 'Calc':
if (node.prefix) {
return "-" + node.prefix + "-calc(" + stringify(node.value, prec) + ")";
}
return "calc(" + stringify(node.value, prec) + ")";
default:
return round(node.value, prec) + node.unit;
}
}
module.exports = exports["default"];
/***/ }),
/***/ 4579:
/***/ (function(__unused_webpack_module, exports) {
/* parser generated by jison 0.6.1-215 */
/*
* Returns a Parser object of the following structure:
*
* Parser: {
* yy: {} The so-called "shared state" or rather the *source* of it;
* the real "shared state" `yy` passed around to
* the rule actions, etc. is a derivative/copy of this one,
* not a direct reference!
* }
*
* Parser.prototype: {
* yy: {},
* EOF: 1,
* TERROR: 2,
*
* trace: function(errorMessage, ...),
*
* JisonParserError: function(msg, hash),
*
* quoteName: function(name),
* Helper function which can be overridden by user code later on: put suitable
* quotes around literal IDs in a description string.
*
* originalQuoteName: function(name),
* The basic quoteName handler provided by JISON.
* `cleanupAfterParse()` will clean up and reset `quoteName()` to reference this function
* at the end of the `parse()`.
*
* describeSymbol: function(symbol),
* Return a more-or-less human-readable description of the given symbol, when
* available, or the symbol itself, serving as its own 'description' for lack
* of something better to serve up.
*
* Return NULL when the symbol is unknown to the parser.
*
* symbols_: {associative list: name ==> number},
* terminals_: {associative list: number ==> name},
* nonterminals: {associative list: rule-name ==> {associative list: number ==> rule-alt}},
* terminal_descriptions_: (if there are any) {associative list: number ==> description},
* productions_: [...],
*
* performAction: function parser__performAction(yytext, yyleng, yylineno, yyloc, yystate, yysp, yyvstack, yylstack, yystack, yysstack),
*
* The function parameters and `this` have the following value/meaning:
* - `this` : reference to the `yyval` internal object, which has members (`$` and `_$`)
* to store/reference the rule value `$$` and location info `@$`.
*
* One important thing to note about `this` a.k.a. `yyval`: every *reduce* action gets
* to see the same object via the `this` reference, i.e. if you wish to carry custom
* data from one reduce action through to the next within a single parse run, then you
* may get nasty and use `yyval` a.k.a. `this` for storing you own semi-permanent data.
*
* `this.yy` is a direct reference to the `yy` shared state object.
*
* `%parse-param`-specified additional `parse()` arguments have been added to this `yy`
* object at `parse()` start and are therefore available to the action code via the
* same named `yy.xxxx` attributes (where `xxxx` represents a identifier name from
* the %parse-param` list.
*
* - `yytext` : reference to the lexer value which belongs to the last lexer token used
* to match this rule. This is *not* the look-ahead token, but the last token
* that's actually part of this rule.
*
* Formulated another way, `yytext` is the value of the token immediately preceeding
* the current look-ahead token.
* Caveats apply for rules which don't require look-ahead, such as epsilon rules.
*
* - `yyleng` : ditto as `yytext`, only now for the lexer.yyleng value.
*
* - `yylineno`: ditto as `yytext`, only now for the lexer.yylineno value.
*
* - `yyloc` : ditto as `yytext`, only now for the lexer.yylloc lexer token location info.
*
* WARNING: since jison 0.4.18-186 this entry may be NULL/UNDEFINED instead
* of an empty object when no suitable location info can be provided.
*
* - `yystate` : the current parser state number, used internally for dispatching and
* executing the action code chunk matching the rule currently being reduced.
*
* - `yysp` : the current state stack position (a.k.a. 'stack pointer')
*
* This one comes in handy when you are going to do advanced things to the parser
* stacks, all of which are accessible from your action code (see the next entries below).
*
* Also note that you can access this and other stack index values using the new double-hash
* syntax, i.e. `##$ === ##0 === yysp`, while `##1` is the stack index for all things
* related to the first rule term, just like you have `$1`, `@1` and `#1`.
* This is made available to write very advanced grammar action rules, e.g. when you want
* to investigate the parse state stack in your action code, which would, for example,
* be relevant when you wish to implement error diagnostics and reporting schemes similar
* to the work described here:
*
* + Pottier, F., 2016. Reachability and error diagnosis in LR(1) automata.
* In Journées Francophones des Languages Applicatifs.
*
* + Jeffery, C.L., 2003. Generating LR syntax error messages from examples.
* ACM Transactions on Programming Languages and Systems (TOPLAS), 25(5), pp.631–640.
*
* - `yyrulelength`: the current rule's term count, i.e. the number of entries occupied on the stack.
*
* This one comes in handy when you are going to do advanced things to the parser
* stacks, all of which are accessible from your action code (see the next entries below).
*
* - `yyvstack`: reference to the parser value stack. Also accessed via the `$1` etc.
* constructs.
*
* - `yylstack`: reference to the parser token location stack. Also accessed via
* the `@1` etc. constructs.
*
* WARNING: since jison 0.4.18-186 this array MAY contain slots which are
* UNDEFINED rather than an empty (location) object, when the lexer/parser
* action code did not provide a suitable location info object when such a
* slot was filled!
*
* - `yystack` : reference to the parser token id stack. Also accessed via the
* `#1` etc. constructs.
*
* Note: this is a bit of a **white lie** as we can statically decode any `#n` reference to
* its numeric token id value, hence that code wouldn't need the `yystack` but *you* might
* want access this array for your own purposes, such as error analysis as mentioned above!
*
* Note that this stack stores the current stack of *tokens*, that is the sequence of
* already parsed=reduced *nonterminals* (tokens representing rules) and *terminals*
* (lexer tokens *shifted* onto the stack until the rule they belong to is found and
* *reduced*.
*
* - `yysstack`: reference to the parser state stack. This one carries the internal parser
* *states* such as the one in `yystate`, which are used to represent
* the parser state machine in the *parse table*. *Very* *internal* stuff,
* what can I say? If you access this one, you're clearly doing wicked things
*
* - `...` : the extra arguments you specified in the `%parse-param` statement in your
* grammar definition file.
*
* table: [...],
* State transition table
* ----------------------
*
* index levels are:
* - `state` --> hash table
* - `symbol` --> action (number or array)
*
* If the `action` is an array, these are the elements' meaning:
* - index [0]: 1 = shift, 2 = reduce, 3 = accept
* - index [1]: GOTO `state`
*
* If the `action` is a number, it is the GOTO `state`
*
* defaultActions: {...},
*
* parseError: function(str, hash, ExceptionClass),
* yyError: function(str, ...),
* yyRecovering: function(),
* yyErrOk: function(),
* yyClearIn: function(),
*
* constructParseErrorInfo: function(error_message, exception_object, expected_token_set, is_recoverable),
* Helper function **which will be set up during the first invocation of the `parse()` method**.
* Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
* See it's use in this parser kernel in many places; example usage:
*
* var infoObj = parser.constructParseErrorInfo('fail!', null,
* parser.collect_expected_token_set(state), true);
* var retVal = parser.parseError(infoObj.errStr, infoObj, parser.JisonParserError);
*
* originalParseError: function(str, hash, ExceptionClass),
* The basic `parseError` handler provided by JISON.
* `cleanupAfterParse()` will clean up and reset `parseError()` to reference this function
* at the end of the `parse()`.
*
* options: { ... parser %options ... },
*
* parse: function(input[, args...]),
* Parse the given `input` and return the parsed value (or `true` when none was provided by
* the root action, in which case the parser is acting as a *matcher*).
* You MAY use the additional `args...` parameters as per `%parse-param` spec of this grammar:
* these extra `args...` are added verbatim to the `yy` object reference as member variables.
*
* WARNING:
* Parser's additional `args...` parameters (via `%parse-param`) MAY conflict with
* any attributes already added to `yy` by the jison run-time;
* when such a collision is detected an exception is thrown to prevent the generated run-time
* from silently accepting this confusing and potentially hazardous situation!
*
* The lexer MAY add its own set of additional parameters (via the `%parse-param` line in
* the lexer section of the grammar spec): these will be inserted in the `yy` shared state
* object and any collision with those will be reported by the lexer via a thrown exception.
*
* cleanupAfterParse: function(resultValue, invoke_post_methods, do_not_nuke_errorinfos),
* Helper function **which will be set up during the first invocation of the `parse()` method**.
* This helper API is invoked at the end of the `parse()` call, unless an exception was thrown
* and `%options no-try-catch` has been defined for this grammar: in that case this helper MAY
* be invoked by calling user code to ensure the `post_parse` callbacks are invoked and
* the internal parser gets properly garbage collected under these particular circumstances.
*
* yyMergeLocationInfo: function(first_index, last_index, first_yylloc, last_yylloc, dont_look_back),
* Helper function **which will be set up during the first invocation of the `parse()` method**.
* This helper API can be invoked to calculate a spanning `yylloc` location info object.
*
* Note: %epsilon rules MAY specify no `first_index` and `first_yylloc`, in which case
* this function will attempt to obtain a suitable location marker by inspecting the location stack
* backwards.
*
* For more info see the documentation comment further below, immediately above this function's
* implementation.
*
* lexer: {
* yy: {...}, A reference to the so-called "shared state" `yy` once
* received via a call to the `.setInput(input, yy)` lexer API.
* EOF: 1,
* ERROR: 2,
* JisonLexerError: function(msg, hash),
* parseError: function(str, hash, ExceptionClass),
* setInput: function(input, [yy]),
* input: function(),
* unput: function(str),
* more: function(),
* reject: function(),
* less: function(n),
* pastInput: function(n),
* upcomingInput: function(n),
* showPosition: function(),
* test_match: function(regex_match_array, rule_index, ...),
* next: function(...),
* lex: function(...),
* begin: function(condition),
* pushState: function(condition),
* popState: function(),
* topState: function(),
* _currentRules: function(),
* stateStackSize: function(),
* cleanupAfterLex: function()
*
* options: { ... lexer %options ... },
*
* performAction: function(yy, yy_, $avoiding_name_collisions, YY_START, ...),
* rules: [...],
* conditions: {associative list: name ==> set},
* }
* }
*
*
* token location info (@$, _$, etc.): {
* first_line: n,
* last_line: n,
* first_column: n,
* last_column: n,
* range: [start_number, end_number]
* (where the numbers are indexes into the input string, zero-based)
* }
*
* ---
*
* The `parseError` function receives a 'hash' object with these members for lexer and
* parser errors:
*
* {
* text: (matched text)
* token: (the produced terminal token, if any)
* token_id: (the produced terminal token numeric ID, if any)
* line: (yylineno)
* loc: (yylloc)
* }
*
* parser (grammar) errors will also provide these additional members:
*
* {
* expected: (array describing the set of expected tokens;
* may be UNDEFINED when we cannot easily produce such a set)
* state: (integer (or array when the table includes grammar collisions);
* represents the current internal state of the parser kernel.
* can, for example, be used to pass to the `collect_expected_token_set()`
* API to obtain the expected token set)
* action: (integer; represents the current internal action which will be executed)
* new_state: (integer; represents the next/planned internal state, once the current
* action has executed)
* recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
* available for this particular error)
* state_stack: (array: the current parser LALR/LR internal state stack; this can be used,
* for instance, for advanced error analysis and reporting)
* value_stack: (array: the current parser LALR/LR internal `$$` value stack; this can be used,
* for instance, for advanced error analysis and reporting)
* location_stack: (array: the current parser LALR/LR internal location stack; this can be used,
* for instance, for advanced error analysis and reporting)
* yy: (object: the current parser internal "shared state" `yy`
* as is also available in the rule actions; this can be used,
* for instance, for advanced error analysis and reporting)
* lexer: (reference to the current lexer instance used by the parser)
* parser: (reference to the current parser instance)
* }
*
* while `this` will reference the current parser instance.
*
* When `parseError` is invoked by the lexer, `this` will still reference the related *parser*
* instance, while these additional `hash` fields will also be provided:
*
* {
* lexer: (reference to the current lexer instance which reported the error)
* }
*
* When `parseError` is invoked by the parser due to a **JavaScript exception** being fired
* from either the parser or lexer, `this` will still reference the related *parser*
* instance, while these additional `hash` fields will also be provided:
*
* {
* exception: (reference to the exception thrown)
* }
*
* Please do note that in the latter situation, the `expected` field will be omitted as
* this type of failure is assumed not to be due to *parse errors* but rather due to user
* action code in either parser or lexer failing unexpectedly.
*
* ---
*
* You can specify parser options by setting / modifying the `.yy` object of your Parser instance.
* These options are available:
*
* ### options which are global for all parser instances
*
* Parser.pre_parse: function(yy)
* optional: you can specify a pre_parse() function in the chunk following
* the grammar, i.e. after the last `%%`.
* Parser.post_parse: function(yy, retval, parseInfo) { return retval; }
* optional: you can specify a post_parse() function in the chunk following
* the grammar, i.e. after the last `%%`. When it does not return any value,
* the parser will return the original `retval`.
*
* ### options which can be set up per parser instance
*
* yy: {
* pre_parse: function(yy)
* optional: is invoked before the parse cycle starts (and before the first
* invocation of `lex()`) but immediately after the invocation of
* `parser.pre_parse()`).
* post_parse: function(yy, retval, parseInfo) { return retval; }
* optional: is invoked when the parse terminates due to success ('accept')
* or failure (even when exceptions are thrown).
* `retval` contains the return value to be produced by `Parser.parse()`;
* this function can override the return value by returning another.
* When it does not return any value, the parser will return the original
* `retval`.
* This function is invoked immediately before `parser.post_parse()`.
*
* parseError: function(str, hash, ExceptionClass)
* optional: overrides the default `parseError` function.
* quoteName: function(name),
* optional: overrides the default `quoteName` function.
* }
*
* parser.lexer.options: {
* pre_lex: function()
* optional: is invoked before the lexer is invoked to produce another token.
* `this` refers to the Lexer object.
* post_lex: function(token) { return token; }
* optional: is invoked when the lexer has produced a token `token`;
* this function can override the returned token value by returning another.
* When it does not return any (truthy) value, the lexer will return
* the original `token`.
* `this` refers to the Lexer object.
*
* ranges: boolean
* optional: `true` ==> token location info will include a .range[] member.
* flex: boolean
* optional: `true` ==> flex-like lexing behaviour where the rules are tested
* exhaustively to find the longest match.
* backtrack_lexer: boolean
* optional: `true` ==> lexer regexes are tested in order and for invoked;
* the lexer terminates the scan when a token is returned by the action code.
* xregexp: boolean
* optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
* `XRegExp` library. When this `%option` has not been specified at compile time, all lexer
* rule regexes have been written as standard JavaScript RegExp expressions.
* }
*/
var parser = (function () {
// See also:
// http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
// but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
// with userland code which might access the derived class in a 'classic' way.
function JisonParserError(msg, hash) {
Object.defineProperty(this, 'name', {
enumerable: false,
writable: false,
value: 'JisonParserError'
});
if (msg == null) msg = '???';
Object.defineProperty(this, 'message', {
enumerable: false,
writable: true,
value: msg
});
this.hash = hash;
var stacktrace;
if (hash && hash.exception instanceof Error) {
var ex2 = hash.exception;
this.message = ex2.message || msg;
stacktrace = ex2.stack;
}
if (!stacktrace) {
if (Error.hasOwnProperty('captureStackTrace')) { // V8/Chrome engine
Error.captureStackTrace(this, this.constructor);
} else {
stacktrace = (new Error(msg)).stack;
}
}
if (stacktrace) {
Object.defineProperty(this, 'stack', {
enumerable: false,
writable: false,
value: stacktrace
});
}
}
if (typeof Object.setPrototypeOf === 'function') {
Object.setPrototypeOf(JisonParserError.prototype, Error.prototype);
} else {
JisonParserError.prototype = Object.create(Error.prototype);
}
JisonParserError.prototype.constructor = JisonParserError;
JisonParserError.prototype.name = 'JisonParserError';
// helper: reconstruct the productions[] table
function bp(s) {
var rv = [];
var p = s.pop;
var r = s.rule;
for (var i = 0, l = p.length; i < l; i++) {
rv.push([
p[i],
r[i]
]);
}
return rv;
}
// helper: reconstruct the defaultActions[] table
function bda(s) {
var rv = {};
var d = s.idx;
var g = s.goto;
for (var i = 0, l = d.length; i < l; i++) {
var j = d[i];
rv[j] = g[i];
}
return rv;
}
// helper: reconstruct the 'goto' table
function bt(s) {
var rv = [];
var d = s.len;
var y = s.symbol;
var t = s.type;
var a = s.state;
var m = s.mode;
var g = s.goto;
for (var i = 0, l = d.length; i < l; i++) {
var n = d[i];
var q = {};
for (var j = 0; j < n; j++) {
var z = y.shift();
switch (t.shift()) {
case 2:
q[z] = [
m.shift(),
g.shift()
];
break;
case 0:
q[z] = a.shift();
break;
default:
// type === 1: accept
q[z] = [
3
];
}
}
rv.push(q);
}
return rv;
}
// helper: runlength encoding with increment step: code, length: step (default step = 0)
// `this` references an array
function s(c, l, a) {
a = a || 0;
for (var i = 0; i < l; i++) {
this.push(c);
c += a;
}
}
// helper: duplicate sequence from *relative* offset and length.
// `this` references an array
function c(i, l) {
i = this.length - i;
for (l += i; i < l; i++) {
this.push(this[i]);
}
}
// helper: unpack an array using helpers and data, all passed in an array argument 'a'.
function u(a) {
var rv = [];
for (var i = 0, l = a.length; i < l; i++) {
var e = a[i];
// Is this entry a helper function?
if (typeof e === 'function') {
i++;
e.apply(rv, a[i]);
} else {
rv.push(e);
}
}
return rv;
}
var parser = {
// Code Generator Information Report
// ---------------------------------
//
// Options:
//
// default action mode: ............. ["classic","merge"]
// test-compile action mode: ........ "parser:*,lexer:*"
// try..catch: ...................... true
// default resolve on conflict: ..... true
// on-demand look-ahead: ............ false
// error recovery token skip maximum: 3
// yyerror in parse actions is: ..... NOT recoverable,
// yyerror in lexer actions and other non-fatal lexer are:
// .................................. NOT recoverable,
// debug grammar/output: ............ false
// has partial LR conflict upgrade: true
// rudimentary token-stack support: false
// parser table compression mode: ... 2
// export debug tables: ............. false
// export *all* tables: ............. false
// module type: ..................... commonjs
// parser engine type: .............. lalr
// output main() in the module: ..... true
// has user-specified main(): ....... false
// has user-specified require()/import modules for main():
// .................................. false
// number of expected conflicts: .... 0
//
//
// Parser Analysis flags:
//
// no significant actions (parser is a language matcher only):
// .................................. false
// uses yyleng: ..................... false
// uses yylineno: ................... false
// uses yytext: ..................... false
// uses yylloc: ..................... false
// uses ParseError API: ............. false
// uses YYERROR: .................... false
// uses YYRECOVERING: ............... false
// uses YYERROK: .................... false
// uses YYCLEARIN: .................. false
// tracks rule values: .............. true
// assigns rule values: ............. true
// uses location tracking: .......... false
// assigns location: ................ false
// uses yystack: .................... false
// uses yysstack: ................... false
// uses yysp: ....................... true
// uses yyrulelength: ............... false
// uses yyMergeLocationInfo API: .... false
// has error recovery: .............. false
// has error reporting: ............. false
//
// --------- END OF REPORT -----------
trace: function no_op_trace() { },
JisonParserError: JisonParserError,
yy: {},
options: {
type: "lalr",
hasPartialLrUpgradeOnConflict: true,
errorRecoveryTokenDiscardCount: 3
},
symbols_: {
"$accept": 0,
"$end": 1,
"ADD": 3,
"ANGLE": 16,
"CHS": 22,
"COMMA": 14,
"CSS_CPROP": 13,
"CSS_VAR": 12,
"DIV": 6,
"EMS": 20,
"EOF": 1,
"EXS": 21,
"FREQ": 18,
"LENGTH": 15,
"LPAREN": 7,
"MUL": 5,
"NESTED_CALC": 9,
"NUMBER": 11,
"PERCENTAGE": 28,
"PREFIX": 10,
"REMS": 23,
"RES": 19,
"RPAREN": 8,
"SUB": 4,
"TIME": 17,
"VHS": 24,
"VMAXS": 27,
"VMINS": 26,
"VWS": 25,
"css_value": 33,
"css_variable": 32,
"error": 2,
"expression": 29,
"math_expression": 30,
"value": 31
},
terminals_: {
1: "EOF",
2: "error",
3: "ADD",
4: "SUB",
5: "MUL",
6: "DIV",
7: "LPAREN",
8: "RPAREN",
9: "NESTED_CALC",
10: "PREFIX",
11: "NUMBER",
12: "CSS_VAR",
13: "CSS_CPROP",
14: "COMMA",
15: "LENGTH",
16: "ANGLE",
17: "TIME",
18: "FREQ",
19: "RES",
20: "EMS",
21: "EXS",
22: "CHS",
23: "REMS",
24: "VHS",
25: "VWS",
26: "VMINS",
27: "VMAXS",
28: "PERCENTAGE"
},
TERROR: 2,
EOF: 1,
// internals: defined here so the object *structure* doesn't get modified by parse() et al,
// thus helping JIT compilers like Chrome V8.
originalQuoteName: null,
originalParseError: null,
cleanupAfterParse: null,
constructParseErrorInfo: null,
yyMergeLocationInfo: null,
__reentrant_call_depth: 0, // INTERNAL USE ONLY
__error_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
__error_recovery_infos: [], // INTERNAL USE ONLY: the set of parseErrorInfo objects created since the last cleanup
// APIs which will be set up depending on user action code analysis:
//yyRecovering: 0,
//yyErrOk: 0,
//yyClearIn: 0,
// Helper APIs
// -----------
// Helper function which can be overridden by user code later on: put suitable quotes around
// literal IDs in a description string.
quoteName: function parser_quoteName(id_str) {
return '"' + id_str + '"';
},
// Return the name of the given symbol (terminal or non-terminal) as a string, when available.
//
// Return NULL when the symbol is unknown to the parser.
getSymbolName: function parser_getSymbolName(symbol) {
if (this.terminals_[symbol]) {
return this.terminals_[symbol];
}
// Otherwise... this might refer to a RULE token i.e. a non-terminal: see if we can dig that one up.
//
// An example of this may be where a rule's action code contains a call like this:
//
// parser.getSymbolName(#$)
//
// to obtain a human-readable name of the current grammar rule.
var s = this.symbols_;
for (var key in s) {
if (s[key] === symbol) {
return key;
}
}
return null;
},
// Return a more-or-less human-readable description of the given symbol, when available,
// or the symbol itself, serving as its own 'description' for lack of something better to serve up.
//
// Return NULL when the symbol is unknown to the parser.
describeSymbol: function parser_describeSymbol(symbol) {
if (symbol !== this.EOF && this.terminal_descriptions_ && this.terminal_descriptions_[symbol]) {
return this.terminal_descriptions_[symbol];
}
else if (symbol === this.EOF) {
return 'end of input';
}
var id = this.getSymbolName(symbol);
if (id) {
return this.quoteName(id);
}
return null;
},
// Produce a (more or less) human-readable list of expected tokens at the point of failure.
//
// The produced list may contain token or token set descriptions instead of the tokens
// themselves to help turning this output into something that easier to read by humans
// unless `do_not_describe` parameter is set, in which case a list of the raw, *numeric*,
// expected terminals and nonterminals is produced.
//
// The returned list (array) will not contain any duplicate entries.
collect_expected_token_set: function parser_collect_expected_token_set(state, do_not_describe) {
var TERROR = this.TERROR;
var tokenset = [];
var check = {};
// Has this (error?) state been outfitted with a custom expectations description text for human consumption?
// If so, use that one instead of the less palatable token set.
if (!do_not_describe && this.state_descriptions_ && this.state_descriptions_[state]) {
return [
this.state_descriptions_[state]
];
}
for (var p in this.table[state]) {
p = +p;
if (p !== TERROR) {
var d = do_not_describe ? p : this.describeSymbol(p);
if (d && !check[d]) {
tokenset.push(d);
check[d] = true; // Mark this token description as already mentioned to prevent outputting duplicate entries.
}
}
}
return tokenset;
},
productions_: bp({
pop: u([
29,
s,
[30, 10],
31,
31,
32,
32,
s,
[33, 15]
]),
rule: u([
2,
s,
[3, 5],
4,
7,
s,
[1, 4],
2,
4,
6,
s,
[1, 14],
2
])
}),
performAction: function parser__PerformAction(yystate /* action[1] */, yysp, yyvstack) {
/* this == yyval */
// the JS engine itself can go and remove these statements when `yy` turns out to be unused in any action code!
var yy = this.yy;
var yyparser = yy.parser;
var yylexer = yy.lexer;
switch (yystate) {
case 0:
/*! Production:: $accept : expression $end */
// default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-):
this.$ = yyvstack[yysp - 1];
// END of default action (generated by JISON mode classic/merge :: 1,VT,VA,-,-,-,-,-,-)
break;
case 1:
/*! Production:: expression : math_expression EOF */
// default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-):
this.$ = yyvstack[yysp - 1];
// END of default action (generated by JISON mode classic/merge :: 2,VT,VA,-,-,-,-,-,-)
return yyvstack[yysp - 1];
break;
case 2:
/*! Production:: math_expression : math_expression ADD math_expression */
case 3:
/*! Production:: math_expression : math_expression SUB math_expression */
case 4:
/*! Production:: math_expression : math_expression MUL math_expression */
case 5:
/*! Production:: math_expression : math_expression DIV math_expression */
this.$ = { type: 'MathExpression', operator: yyvstack[yysp - 1], left: yyvstack[yysp - 2], right: yyvstack[yysp] };
break;
case 6:
/*! Production:: math_expression : LPAREN math_expression RPAREN */
this.$ = yyvstack[yysp - 1];
break;
case 7:
/*! Production:: math_expression : NESTED_CALC LPAREN math_expression RPAREN */
this.$ = { type: 'Calc', value: yyvstack[yysp - 1] };
break;
case 8:
/*! Production:: math_expression : SUB PREFIX SUB NESTED_CALC LPAREN math_expression RPAREN */
this.$ = { type: 'Calc', value: yyvstack[yysp - 1], prefix: yyvstack[yysp - 5] };
break;
case 9:
/*! Production:: math_expression : css_variable */
case 10:
/*! Production:: math_expression : css_value */
case 11:
/*! Production:: math_expression : value */
this.$ = yyvstack[yysp];
break;
case 12:
/*! Production:: value : NUMBER */
this.$ = { type: 'Value', value: parseFloat(yyvstack[yysp]) };
break;
case 13:
/*! Production:: value : SUB NUMBER */
this.$ = { type: 'Value', value: parseFloat(yyvstack[yysp]) * -1 };
break;
case 14:
/*! Production:: css_variable : CSS_VAR LPAREN CSS_CPROP RPAREN */
this.$ = { type: 'CssVariable', value: yyvstack[yysp - 1] };
break;
case 15:
/*! Production:: css_variable : CSS_VAR LPAREN CSS_CPROP COMMA math_expression RPAREN */
this.$ = { type: 'CssVariable', value: yyvstack[yysp - 3], fallback: yyvstack[yysp - 1] };
break;
case 16:
/*! Production:: css_value : LENGTH */
this.$ = { type: 'LengthValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
break;
case 17:
/*! Production:: css_value : ANGLE */
this.$ = { type: 'AngleValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
break;
case 18:
/*! Production:: css_value : TIME */
this.$ = { type: 'TimeValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
break;
case 19:
/*! Production:: css_value : FREQ */
this.$ = { type: 'FrequencyValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
break;
case 20:
/*! Production:: css_value : RES */
this.$ = { type: 'ResolutionValue', value: parseFloat(yyvstack[yysp]), unit: /[a-z]+/.exec(yyvstack[yysp])[0] };
break;
case 21:
/*! Production:: css_value : EMS */
this.$ = { type: 'EmValue', value: parseFloat(yyvstack[yysp]), unit: 'em' };
break;
case 22:
/*! Production:: css_value : EXS */
this.$ = { type: 'ExValue', value: parseFloat(yyvstack[yysp]), unit: 'ex' };
break;
case 23:
/*! Production:: css_value : CHS */
this.$ = { type: 'ChValue', value: parseFloat(yyvstack[yysp]), unit: 'ch' };
break;
case 24:
/*! Production:: css_value : REMS */
this.$ = { type: 'RemValue', value: parseFloat(yyvstack[yysp]), unit: 'rem' };
break;
case 25:
/*! Production:: css_value : VHS */
this.$ = { type: 'VhValue', value: parseFloat(yyvstack[yysp]), unit: 'vh' };
break;
case 26:
/*! Production:: css_value : VWS */
this.$ = { type: 'VwValue', value: parseFloat(yyvstack[yysp]), unit: 'vw' };
break;
case 27:
/*! Production:: css_value : VMINS */
this.$ = { type: 'VminValue', value: parseFloat(yyvstack[yysp]), unit: 'vmin' };
break;
case 28:
/*! Production:: css_value : VMAXS */
this.$ = { type: 'VmaxValue', value: parseFloat(yyvstack[yysp]), unit: 'vmax' };
break;
case 29:
/*! Production:: css_value : PERCENTAGE */
this.$ = { type: 'PercentageValue', value: parseFloat(yyvstack[yysp]), unit: '%' };
break;
case 30:
/*! Production:: css_value : SUB css_value */
var prev = yyvstack[yysp]; prev.value *= -1; this.$ = prev;
break;
}
},
table: bt({
len: u([
24,
1,
5,
23,
1,
18,
s,
[0, 3],
1,
s,
[0, 16],
s,
[23, 4],
c,
[28, 3],
0,
0,
16,
1,
6,
6,
s,
[0, 3],
5,
1,
2,
c,
[37, 3],
c,
[20, 3],
5,
0,
0
]),
symbol: u([
4,
7,
9,
11,
12,
s,
[15, 19, 1],
1,
1,
s,
[3, 4, 1],
c,
[30, 19],
c,
[29, 4],
7,
4,
10,
11,
c,
[22, 14],
c,
[19, 3],
c,
[43, 22],
c,
[23, 69],
c,
[139, 4],
8,
c,
[51, 24],
4,
c,
[138, 15],
13,
c,
[186, 5],
8,
c,
[6, 6],
c,
[5, 5],
9,
8,
14,
c,
[159, 47],
c,
[60, 10]
]),
type: u([
s,
[2, 19],
s,
[0, 5],
1,
s,
[2, 24],
s,
[0, 4],
c,
[22, 19],
c,
[43, 42],
c,
[23, 70],
c,
[28, 25],
c,
[45, 25],
c,
[113, 54]
]),
state: u([
1,
2,
8,
6,
7,
30,
c,
[4, 3],
33,
37,
c,
[5, 3],
38,
c,
[4, 3],
39,
c,
[4, 3],
40,
c,
[4, 3],
42,
c,
[21, 4],
50,
c,
[5, 3],
51,
c,
[4, 3]
]),
mode: u([
s,
[1, 179],
s,
[2, 3],
c,
[5, 5],
c,
[6, 4],
s,
[1, 57]
]),
goto: u([
5,
3,
4,
24,
s,
[9, 15, 1],
s,
[25, 5, 1],
c,
[24, 19],
31,
35,
32,
34,
c,
[18, 14],
36,
c,
[38, 19],
c,
[19, 57],
c,
[118, 4],
41,
c,
[24, 19],
43,
35,
c,
[16, 14],
44,
s,
[2, 3],
28,
29,
2,
s,
[3, 3],
28,
29,
3,
c,
[53, 4],
s,
[45, 5, 1],
c,
[100, 42],
52,
c,
[5, 4],
53
])
}),
defaultActions: bda({
idx: u([
6,
7,
8,
s,
[10, 16, 1],
33,
34,
39,
40,
41,
45,
47,
52,
53
]),
goto: u([
9,
10,
11,
s,
[16, 14, 1],
12,
1,
30,
13,
s,
[4, 4, 1],
14,
15,
8
])
}),
parseError: function parseError(str, hash, ExceptionClass) {
if (hash.recoverable) {
if (typeof this.trace === 'function') {
this.trace(str);
}
hash.destroy(); // destroy... well, *almost*!
} else {
if (typeof this.trace === 'function') {
this.trace(str);
}
if (!ExceptionClass) {
ExceptionClass = this.JisonParserError;
}
throw new ExceptionClass(str, hash);
}
},
parse: function parse(input) {
var self = this;
var stack = new Array(128); // token stack: stores token which leads to state at the same index (column storage)
var sstack = new Array(128); // state stack: stores states (column storage)
var vstack = new Array(128); // semantic value stack
var table = this.table;
var sp = 0; // 'stack pointer': index into the stacks
var symbol = 0;
var TERROR = this.TERROR;
var EOF = this.EOF;
var ERROR_RECOVERY_TOKEN_DISCARD_COUNT = (this.options.errorRecoveryTokenDiscardCount | 0) || 3;
var NO_ACTION = [0, 54 /* === table.length :: ensures that anyone using this new state will fail dramatically! */];
var lexer;
if (this.__lexer__) {
lexer = this.__lexer__;
} else {
lexer = this.__lexer__ = Object.create(this.lexer);
}
var sharedState_yy = {
parseError: undefined,
quoteName: undefined,
lexer: undefined,
parser: undefined,
pre_parse: undefined,
post_parse: undefined,
pre_lex: undefined,
post_lex: undefined // WARNING: must be written this way for the code expanders to work correctly in both ES5 and ES6 modes!
};
var ASSERT;
if (typeof assert !== 'function') {
ASSERT = function JisonAssert(cond, msg) {
if (!cond) {
throw new Error('assertion failed: ' + (msg || '***'));
}
};
} else {
ASSERT = assert;
}
this.yyGetSharedState = function yyGetSharedState() {
return sharedState_yy;
};
function shallow_copy_noclobber(dst, src) {
for (var k in src) {
if (typeof dst[k] === 'undefined' && Object.prototype.hasOwnProperty.call(src, k)) {
dst[k] = src[k];
}
}
}
// copy state
shallow_copy_noclobber(sharedState_yy, this.yy);
sharedState_yy.lexer = lexer;
sharedState_yy.parser = this;
// Does the shared state override the default `parseError` that already comes with this instance?
if (typeof sharedState_yy.parseError === 'function') {
this.parseError = function parseErrorAlt(str, hash, ExceptionClass) {
if (!ExceptionClass) {
ExceptionClass = this.JisonParserError;
}
return sharedState_yy.parseError.call(this, str, hash, ExceptionClass);
};
} else {
this.parseError = this.originalParseError;
}
// Does the shared state override the default `quoteName` that already comes with this instance?
if (typeof sharedState_yy.quoteName === 'function') {
this.quoteName = function quoteNameAlt(id_str) {
return sharedState_yy.quoteName.call(this, id_str);
};
} else {
this.quoteName = this.originalQuoteName;
}
// set up the cleanup function; make it an API so that external code can re-use this one in case of
// calamities or when the `%options no-try-catch` option has been specified for the grammar, in which
// case this parse() API method doesn't come with a `finally { ... }` block any more!
//
// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
// or else your `sharedState`, etc. references will be *wrong*!
this.cleanupAfterParse = function parser_cleanupAfterParse(resultValue, invoke_post_methods, do_not_nuke_errorinfos) {
var rv;
if (invoke_post_methods) {
var hash;
if (sharedState_yy.post_parse || this.post_parse) {
// create an error hash info instance: we re-use this API in a **non-error situation**
// as this one delivers all parser internals ready for access by userland code.
hash = this.constructParseErrorInfo(null /* no error! */, null /* no exception! */, null, false);
}
if (sharedState_yy.post_parse) {
rv = sharedState_yy.post_parse.call(this, sharedState_yy, resultValue, hash);
if (typeof rv !== 'undefined') resultValue = rv;
}
if (this.post_parse) {
rv = this.post_parse.call(this, sharedState_yy, resultValue, hash);
if (typeof rv !== 'undefined') resultValue = rv;
}
// cleanup:
if (hash && hash.destroy) {
hash.destroy();
}
}
if (this.__reentrant_call_depth > 1) return resultValue; // do not (yet) kill the sharedState when this is a reentrant run.
// clean up the lingering lexer structures as well:
if (lexer.cleanupAfterLex) {
lexer.cleanupAfterLex(do_not_nuke_errorinfos);
}
// prevent lingering circular references from causing memory leaks:
if (sharedState_yy) {
sharedState_yy.lexer = undefined;
sharedState_yy.parser = undefined;
if (lexer.yy === sharedState_yy) {
lexer.yy = undefined;
}
}
sharedState_yy = undefined;
this.parseError = this.originalParseError;
this.quoteName = this.originalQuoteName;
// nuke the vstack[] array at least as that one will still reference obsoleted user values.
// To be safe, we nuke the other internal stack columns as well...
stack.length = 0; // fastest way to nuke an array without overly bothering the GC
sstack.length = 0;
vstack.length = 0;
sp = 0;
// nuke the error hash info instances created during this run.
// Userland code must COPY any data/references
// in the error hash instance(s) it is more permanently interested in.
if (!do_not_nuke_errorinfos) {
for (var i = this.__error_infos.length - 1; i >= 0; i--) {
var el = this.__error_infos[i];
if (el && typeof el.destroy === 'function') {
el.destroy();
}
}
this.__error_infos.length = 0;
}
return resultValue;
};
// NOTE: as this API uses parse() as a closure, it MUST be set again on every parse() invocation,
// or else your `lexer`, `sharedState`, etc. references will be *wrong*!
this.constructParseErrorInfo = function parser_constructParseErrorInfo(msg, ex, expected, recoverable) {
var pei = {
errStr: msg,
exception: ex,
text: lexer.match,
value: lexer.yytext,
token: this.describeSymbol(symbol) || symbol,
token_id: symbol,
line: lexer.yylineno,
expected: expected,
recoverable: recoverable,
state: state,
action: action,
new_state: newState,
symbol_stack: stack,
state_stack: sstack,
value_stack: vstack,
stack_pointer: sp,
yy: sharedState_yy,
lexer: lexer,
parser: this,
// and make sure the error info doesn't stay due to potential
// ref cycle via userland code manipulations.
// These would otherwise all be memory leak opportunities!
//
// Note that only array and object references are nuked as those
// constitute the set of elements which can produce a cyclic ref.
// The rest of the members is kept intact as they are harmless.
destroy: function destructParseErrorInfo() {
// remove cyclic references added to error info:
// info.yy = null;
// info.lexer = null;
// info.value = null;
// info.value_stack = null;
// ...
var rec = !!this.recoverable;
for (var key in this) {
if (this.hasOwnProperty(key) && typeof key === 'object') {
this[key] = undefined;
}
}
this.recoverable = rec;
}
};
// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
this.__error_infos.push(pei);
return pei;
};
function getNonTerminalFromCode(symbol) {
var tokenName = self.getSymbolName(symbol);
if (!tokenName) {
tokenName = symbol;
}
return tokenName;
}
function stdLex() {
var token = lexer.lex();
// if token isn't its numeric value, convert
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token || EOF;
}
function fastLex() {
var token = lexer.fastLex();
// if token isn't its numeric value, convert
if (typeof token !== 'number') {
token = self.symbols_[token] || token;
}
return token || EOF;
}
var lex = stdLex;
var state, action, r, t;
var yyval = {
$: true,
_$: undefined,
yy: sharedState_yy
};
var p;
var yyrulelen;
var this_production;
var newState;
var retval = false;
try {
this.__reentrant_call_depth++;
lexer.setInput(input, sharedState_yy);
// NOTE: we *assume* no lexer pre/post handlers are set up *after*
// this initial `setInput()` call: hence we can now check and decide
// whether we'll go with the standard, slower, lex() API or the
// `fast_lex()` one:
if (typeof lexer.canIUse === 'function') {
var lexerInfo = lexer.canIUse();
if (lexerInfo.fastLex && typeof fastLex === 'function') {
lex = fastLex;
}
}
vstack[sp] = null;
sstack[sp] = 0;
stack[sp] = 0;
++sp;
if (this.pre_parse) {
this.pre_parse.call(this, sharedState_yy);
}
if (sharedState_yy.pre_parse) {
sharedState_yy.pre_parse.call(this, sharedState_yy);
}
newState = sstack[sp - 1];
for (;;) {
// retrieve state number from top of stack
state = newState; // sstack[sp - 1];
// use default actions if available
if (this.defaultActions[state]) {
action = 2;
newState = this.defaultActions[state];
} else {
// The single `==` condition below covers both these `===` comparisons in a single
// operation:
//
// if (symbol === null || typeof symbol === 'undefined') ...
if (!symbol) {
symbol = lex();
}
// read action for current state and first input
t = (table[state] && table[state][symbol]) || NO_ACTION;
newState = t[1];
action = t[0];
// handle parse error
if (!action) {
var errStr;
var errSymbolDescr = (this.describeSymbol(symbol) || symbol);
var expected = this.collect_expected_token_set(state);
// Report error
if (typeof lexer.yylineno === 'number') {
errStr = 'Parse error on line ' + (lexer.yylineno + 1) + ': ';
} else {
errStr = 'Parse error: ';
}
if (typeof lexer.showPosition === 'function') {
errStr += '\n' + lexer.showPosition(79 - 10, 10) + '\n';
}
if (expected.length) {
errStr += 'Expecting ' + expected.join(', ') + ', got unexpected ' + errSymbolDescr;
} else {
errStr += 'Unexpected ' + errSymbolDescr;
}
// we cannot recover from the error!
p = this.constructParseErrorInfo(errStr, null, expected, false);
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
break;
}
}
switch (action) {
// catch misc. parse failures:
default:
// this shouldn't happen, unless resolve defaults are off
if (action instanceof Array) {
p = this.constructParseErrorInfo('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol, null, null, false);
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
break;
}
// Another case of better safe than sorry: in case state transitions come out of another error recovery process
// or a buggy LUT (LookUp Table):
p = this.constructParseErrorInfo('Parsing halted. No viable error recovery approach available due to internal system failure.', null, null, false);
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
break;
// shift:
case 1:
stack[sp] = symbol;
vstack[sp] = lexer.yytext;
sstack[sp] = newState; // push state
++sp;
symbol = 0;
// Pick up the lexer details for the current symbol as that one is not 'look-ahead' any more:
continue;
// reduce:
case 2:
this_production = this.productions_[newState - 1]; // `this.productions_[]` is zero-based indexed while states start from 1 upwards...
yyrulelen = this_production[1];
r = this.performAction.call(yyval, newState, sp - 1, vstack);
if (typeof r !== 'undefined') {
retval = r;
break;
}
// pop off stack
sp -= yyrulelen;
// don't overwrite the `symbol` variable: use a local var to speed things up:
var ntsymbol = this_production[0]; // push nonterminal (reduce)
stack[sp] = ntsymbol;
vstack[sp] = yyval.$;
// goto new state = table[STATE][NONTERMINAL]
newState = table[sstack[sp - 1]][ntsymbol];
sstack[sp] = newState;
++sp;
continue;
// accept:
case 3:
if (sp !== -2) {
retval = true;
// Return the `$accept` rule's `$$` result, if available.
//
// Also note that JISON always adds this top-most `$accept` rule (with implicit,
// default, action):
//
// $accept: $end
// %{ $$ = $1; @$ = @1; %}
//
// which, combined with the parse kernel's `$accept` state behaviour coded below,
// will produce the `$$` value output of the rule as the parse result,
// IFF that result is *not* `undefined`. (See also the parser kernel code.)
//
// In code:
//
// %{
// @$ = @1; // if location tracking support is included
// if (typeof $1 !== 'undefined')
// return $1;
// else
// return true; // the default parse result if the rule actions don't produce anything
// %}
sp--;
if (typeof vstack[sp] !== 'undefined') {
retval = vstack[sp];
}
}
break;
}
// break out of loop: we accept or fail with error
break;
}
} catch (ex) {
// report exceptions through the parseError callback too, but keep the exception intact
// if it is a known parser or lexer error which has been thrown by parseError() already:
if (ex instanceof this.JisonParserError) {
throw ex;
}
else if (lexer && typeof lexer.JisonLexerError === 'function' && ex instanceof lexer.JisonLexerError) {
throw ex;
}
p = this.constructParseErrorInfo('Parsing aborted due to exception.', ex, null, false);
retval = false;
r = this.parseError(p.errStr, p, this.JisonParserError);
if (typeof r !== 'undefined') {
retval = r;
}
} finally {
retval = this.cleanupAfterParse(retval, true, true);
this.__reentrant_call_depth--;
} // /finally
return retval;
}
};
parser.originalParseError = parser.parseError;
parser.originalQuoteName = parser.quoteName;
/* lexer generated by jison-lex 0.6.1-215 */
/*
* Returns a Lexer object of the following structure:
*
* Lexer: {
* yy: {} The so-called "shared state" or rather the *source* of it;
* the real "shared state" `yy` passed around to
* the rule actions, etc. is a direct reference!
*
* This "shared context" object was passed to the lexer by way of
* the `lexer.setInput(str, yy)` API before you may use it.
*
* This "shared context" object is passed to the lexer action code in `performAction()`
* so userland code in the lexer actions may communicate with the outside world
* and/or other lexer rules' actions in more or less complex ways.
*
* }
*
* Lexer.prototype: {
* EOF: 1,
* ERROR: 2,
*
* yy: The overall "shared context" object reference.
*
* JisonLexerError: function(msg, hash),
*
* performAction: function lexer__performAction(yy, yyrulenumber, YY_START),
*
* The function parameters and `this` have the following value/meaning:
* - `this` : reference to the `lexer` instance.
* `yy_` is an alias for `this` lexer instance reference used internally.
*
* - `yy` : a reference to the `yy` "shared state" object which was passed to the lexer
* by way of the `lexer.setInput(str, yy)` API before.
*
* Note:
* The extra arguments you specified in the `%parse-param` statement in your
* **parser** grammar definition file are passed to the lexer via this object
* reference as member variables.
*
* - `yyrulenumber` : index of the matched lexer rule (regex), used internally.
*
* - `YY_START`: the current lexer "start condition" state.
*
* parseError: function(str, hash, ExceptionClass),
*
* constructLexErrorInfo: function(error_message, is_recoverable),
* Helper function.
* Produces a new errorInfo 'hash object' which can be passed into `parseError()`.
* See it's use in this lexer kernel in many places; example usage:
*
* var infoObj = lexer.constructParseErrorInfo('fail!', true);
* var retVal = lexer.parseError(infoObj.errStr, infoObj, lexer.JisonLexerError);
*
* options: { ... lexer %options ... },
*
* lex: function(),
* Produce one token of lexed input, which was passed in earlier via the `lexer.setInput()` API.
* You MAY use the additional `args...` parameters as per `%parse-param` spec of the **lexer** grammar:
* these extra `args...` are added verbatim to the `yy` object reference as member variables.
*
* WARNING:
* Lexer's additional `args...` parameters (via lexer's `%parse-param`) MAY conflict with
* any attributes already added to `yy` by the **parser** or the jison run-time;
* when such a collision is detected an exception is thrown to prevent the generated run-time
* from silently accepting this confusing and potentially hazardous situation!
*
* cleanupAfterLex: function(do_not_nuke_errorinfos),
* Helper function.
*
* This helper API is invoked when the **parse process** has completed: it is the responsibility
* of the **parser** (or the calling userland code) to invoke this method once cleanup is desired.
*
* This helper may be invoked by user code to ensure the internal lexer gets properly garbage collected.
*
* setInput: function(input, [yy]),
*
*
* input: function(),
*
*
* unput: function(str),
*
*
* more: function(),
*
*
* reject: function(),
*
*
* less: function(n),
*
*
* pastInput: function(n),
*
*
* upcomingInput: function(n),
*
*
* showPosition: function(),
*
*
* test_match: function(regex_match_array, rule_index),
*
*
* next: function(),
*
*
* begin: function(condition),
*
*
* pushState: function(condition),
*
*
* popState: function(),
*
*
* topState: function(),
*
*
* _currentRules: function(),
*
*
* stateStackSize: function(),
*
*
* performAction: function(yy, yy_, yyrulenumber, YY_START),
*
*
* rules: [...],
*
*
* conditions: {associative list: name ==> set},
* }
*
*
* token location info (`yylloc`): {
* first_line: n,
* last_line: n,
* first_column: n,
* last_column: n,
* range: [start_number, end_number]
* (where the numbers are indexes into the input string, zero-based)
* }
*
* ---
*
* The `parseError` function receives a 'hash' object with these members for lexer errors:
*
* {
* text: (matched text)
* token: (the produced terminal token, if any)
* token_id: (the produced terminal token numeric ID, if any)
* line: (yylineno)
* loc: (yylloc)
* recoverable: (boolean: TRUE when the parser MAY have an error recovery rule
* available for this particular error)
* yy: (object: the current parser internal "shared state" `yy`
* as is also available in the rule actions; this can be used,
* for instance, for advanced error analysis and reporting)
* lexer: (reference to the current lexer instance used by the parser)
* }
*
* while `this` will reference the current lexer instance.
*
* When `parseError` is invoked by the lexer, the default implementation will
* attempt to invoke `yy.parser.parseError()`; when this callback is not provided
* it will try to invoke `yy.parseError()` instead. When that callback is also not
* provided, a `JisonLexerError` exception will be thrown containing the error
* message and `hash`, as constructed by the `constructLexErrorInfo()` API.
*
* Note that the lexer's `JisonLexerError` error class is passed via the
* `ExceptionClass` argument, which is invoked to construct the exception
* instance to be thrown, so technically `parseError` will throw the object
* produced by the `new ExceptionClass(str, hash)` JavaScript expression.
*
* ---
*
* You can specify lexer options by setting / modifying the `.options` object of your Lexer instance.
* These options are available:
*
* (Options are permanent.)
*
* yy: {
* parseError: function(str, hash, ExceptionClass)
* optional: overrides the default `parseError` function.
* }
*
* lexer.options: {
* pre_lex: function()
* optional: is invoked before the lexer is invoked to produce another token.
* `this` refers to the Lexer object.
* post_lex: function(token) { return token; }
* optional: is invoked when the lexer has produced a token `token`;
* this function can override the returned token value by returning another.
* When it does not return any (truthy) value, the lexer will return
* the original `token`.
* `this` refers to the Lexer object.
*
* WARNING: the next set of options are not meant to be changed. They echo the abilities of
* the lexer as per when it was compiled!
*
* ranges: boolean
* optional: `true` ==> token location info will include a .range[] member.
* flex: boolean
* optional: `true` ==> flex-like lexing behaviour where the rules are tested
* exhaustively to find the longest match.
* backtrack_lexer: boolean
* optional: `true` ==> lexer regexes are tested in order and for invoked;
* the lexer terminates the scan when a token is returned by the action code.
* xregexp: boolean
* optional: `true` ==> lexer rule regexes are "extended regex format" requiring the
* `XRegExp` library. When this %option has not been specified at compile time, all lexer
* rule regexes have been written as standard JavaScript RegExp expressions.
* }
*/
var lexer = function() {
/**
* See also:
* http://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript/#35881508
* but we keep the prototype.constructor and prototype.name assignment lines too for compatibility
* with userland code which might access the derived class in a 'classic' way.
*
* @public
* @constructor
* @nocollapse
*/
function JisonLexerError(msg, hash) {
Object.defineProperty(this, 'name', {
enumerable: false,
writable: false,
value: 'JisonLexerError'
});
if (msg == null)
msg = '???';
Object.defineProperty(this, 'message', {
enumerable: false,
writable: true,
value: msg
});
this.hash = hash;
var stacktrace;
if (hash && hash.exception instanceof Error) {
var ex2 = hash.exception;
this.message = ex2.message || msg;
stacktrace = ex2.stack;
}
if (!stacktrace) {
if (Error.hasOwnProperty('captureStackTrace')) {
// V8
Error.captureStackTrace(this, this.constructor);
} else {
stacktrace = new Error(msg).stack;
}
}
if (stacktrace) {
Object.defineProperty(this, 'stack', {
enumerable: false,
writable: false,
value: stacktrace
});
}
}
if (typeof Object.setPrototypeOf === 'function') {
Object.setPrototypeOf(JisonLexerError.prototype, Error.prototype);
} else {
JisonLexerError.prototype = Object.create(Error.prototype);
}
JisonLexerError.prototype.constructor = JisonLexerError;
JisonLexerError.prototype.name = 'JisonLexerError';
var lexer = {
// Code Generator Information Report
// ---------------------------------
//
// Options:
//
// backtracking: .................... false
// location.ranges: ................. false
// location line+column tracking: ... true
//
//
// Forwarded Parser Analysis flags:
//
// uses yyleng: ..................... false
// uses yylineno: ................... false
// uses yytext: ..................... false
// uses yylloc: ..................... false
// uses lexer values: ............... true / true
// location tracking: ............... false
// location assignment: ............. false
//
//
// Lexer Analysis flags:
//
// uses yyleng: ..................... ???
// uses yylineno: ................... ???
// uses yytext: ..................... ???
// uses yylloc: ..................... ???
// uses ParseError API: ............. ???
// uses yyerror: .................... ???
// uses location tracking & editing: ???
// uses more() API: ................. ???
// uses unput() API: ................ ???
// uses reject() API: ............... ???
// uses less() API: ................. ???
// uses display APIs pastInput(), upcomingInput(), showPosition():
// ............................. ???
// uses describeYYLLOC() API: ....... ???
//
// --------- END OF REPORT -----------
EOF: 1,
ERROR: 2,
// JisonLexerError: JisonLexerError, /// <-- injected by the code generator
// options: {}, /// <-- injected by the code generator
// yy: ..., /// <-- injected by setInput()
__currentRuleSet__: null, /// INTERNAL USE ONLY: internal rule set cache for the current lexer state
__error_infos: [], /// INTERNAL USE ONLY: the set of lexErrorInfo objects created since the last cleanup
__decompressed: false, /// INTERNAL USE ONLY: mark whether the lexer instance has been 'unfolded' completely and is now ready for use
done: false, /// INTERNAL USE ONLY
_backtrack: false, /// INTERNAL USE ONLY
_input: '', /// INTERNAL USE ONLY
_more: false, /// INTERNAL USE ONLY
_signaled_error_token: false, /// INTERNAL USE ONLY
conditionStack: [], /// INTERNAL USE ONLY; managed via `pushState()`, `popState()`, `topState()` and `stateStackSize()`
match: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction. `match` is identical to `yytext` except that this one still contains the matched input string after `lexer.performAction()` has been invoked, where userland code MAY have changed/replaced the `yytext` value entirely!
matched: '', /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks entire input which has been matched so far
matches: false, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks RE match result for last (successful) match attempt
yytext: '', /// ADVANCED USE ONLY: tracks input which has been matched so far for the lexer token under construction; this value is transferred to the parser as the 'token value' when the parser consumes the lexer token produced through a call to the `lex()` API.
offset: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks the 'cursor position' in the input string, i.e. the number of characters matched so far
yyleng: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: length of matched input for the token under construction (`yytext`)
yylineno: 0, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: 'line number' at which the token under construction is located
yylloc: null, /// READ-ONLY EXTERNAL ACCESS - ADVANCED USE ONLY: tracks location info (lines + columns) for the token under construction
/**
* INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
*
* @public
* @this {RegExpLexer}
*/
constructLexErrorInfo: function lexer_constructLexErrorInfo(msg, recoverable, show_input_position) {
msg = '' + msg;
// heuristic to determine if the error message already contains a (partial) source code dump
// as produced by either `showPosition()` or `prettyPrintRange()`:
if (show_input_position == undefined) {
show_input_position = !(msg.indexOf('\n') > 0 && msg.indexOf('^') > 0);
}
if (this.yylloc && show_input_position) {
if (typeof this.prettyPrintRange === 'function') {
var pretty_src = this.prettyPrintRange(this.yylloc);
if (!/\n\s*$/.test(msg)) {
msg += '\n';
}
msg += '\n Erroneous area:\n' + this.prettyPrintRange(this.yylloc);
} else if (typeof this.showPosition === 'function') {
var pos_str = this.showPosition();
if (pos_str) {
if (msg.length && msg[msg.length - 1] !== '\n' && pos_str[0] !== '\n') {
msg += '\n' + pos_str;
} else {
msg += pos_str;
}
}
}
}
/** @constructor */
var pei = {
errStr: msg,
recoverable: !!recoverable,
text: this.match, // This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'...
token: null,
line: this.yylineno,
loc: this.yylloc,
yy: this.yy,
lexer: this,
/**
* and make sure the error info doesn't stay due to potential
* ref cycle via userland code manipulations.
* These would otherwise all be memory leak opportunities!
*
* Note that only array and object references are nuked as those
* constitute the set of elements which can produce a cyclic ref.
* The rest of the members is kept intact as they are harmless.
*
* @public
* @this {LexErrorInfo}
*/
destroy: function destructLexErrorInfo() {
// remove cyclic references added to error info:
// info.yy = null;
// info.lexer = null;
// ...
var rec = !!this.recoverable;
for (var key in this) {
if (this.hasOwnProperty(key) && typeof key === 'object') {
this[key] = undefined;
}
}
this.recoverable = rec;
}
};
// track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
this.__error_infos.push(pei);
return pei;
},
/**
* handler which is invoked when a lexer error occurs.
*
* @public
* @this {RegExpLexer}
*/
parseError: function lexer_parseError(str, hash, ExceptionClass) {
if (!ExceptionClass) {
ExceptionClass = this.JisonLexerError;
}
if (this.yy) {
if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
return this.yy.parser.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
} else if (typeof this.yy.parseError === 'function') {
return this.yy.parseError.call(this, str, hash, ExceptionClass) || this.ERROR;
}
}
throw new ExceptionClass(str, hash);
},
/**
* method which implements `yyerror(str, ...args)` functionality for use inside lexer actions.
*
* @public
* @this {RegExpLexer}
*/
yyerror: function yyError(str /*, ...args */) {
var lineno_msg = '';
if (this.yylloc) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo(
'Lexical error' + lineno_msg + ': ' + str,
this.options.lexerErrorsAreRecoverable
);
// Add any extra args to the hash under the name `extra_error_attributes`:
var args = Array.prototype.slice.call(arguments, 1);
if (args.length) {
p.extra_error_attributes = args;
}
return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
},
/**
* final cleanup function for when we have completed lexing the input;
* make it an API so that external code can use this one once userland
* code has decided it's time to destroy any lingering lexer error
* hash object instances and the like: this function helps to clean
* up these constructs, which *may* carry cyclic references which would
* otherwise prevent the instances from being properly and timely
* garbage-collected, i.e. this function helps prevent memory leaks!
*
* @public
* @this {RegExpLexer}
*/
cleanupAfterLex: function lexer_cleanupAfterLex(do_not_nuke_errorinfos) {
// prevent lingering circular references from causing memory leaks:
this.setInput('', {});
// nuke the error hash info instances created during this run.
// Userland code must COPY any data/references
// in the error hash instance(s) it is more permanently interested in.
if (!do_not_nuke_errorinfos) {
for (var i = this.__error_infos.length - 1; i >= 0; i--) {
var el = this.__error_infos[i];
if (el && typeof el.destroy === 'function') {
el.destroy();
}
}
this.__error_infos.length = 0;
}
return this;
},
/**
* clear the lexer token context; intended for internal use only
*
* @public
* @this {RegExpLexer}
*/
clear: function lexer_clear() {
this.yytext = '';
this.yyleng = 0;
this.match = '';
// - DO NOT reset `this.matched`
this.matches = false;
this._more = false;
this._backtrack = false;
var col = (this.yylloc ? this.yylloc.last_column : 0);
this.yylloc = {
first_line: this.yylineno + 1,
first_column: col,
last_line: this.yylineno + 1,
last_column: col,
range: [this.offset, this.offset]
};
},
/**
* resets the lexer, sets new input
*
* @public
* @this {RegExpLexer}
*/
setInput: function lexer_setInput(input, yy) {
this.yy = yy || this.yy || {};
// also check if we've fully initialized the lexer instance,
// including expansion work to be done to go from a loaded
// lexer to a usable lexer:
if (!this.__decompressed) {
// step 1: decompress the regex list:
var rules = this.rules;
for (var i = 0, len = rules.length; i < len; i++) {
var rule_re = rules[i];
// compression: is the RE an xref to another RE slot in the rules[] table?
if (typeof rule_re === 'number') {
rules[i] = rules[rule_re];
}
}
// step 2: unfold the conditions[] set to make these ready for use:
var conditions = this.conditions;
for (var k in conditions) {
var spec = conditions[k];
var rule_ids = spec.rules;
var len = rule_ids.length;
var rule_regexes = new Array(len + 1); // slot 0 is unused; we use a 1-based index approach here to keep the hottest code in `lexer_next()` fast and simple!
var rule_new_ids = new Array(len + 1);
for (var i = 0; i < len; i++) {
var idx = rule_ids[i];
var rule_re = rules[idx];
rule_regexes[i + 1] = rule_re;
rule_new_ids[i + 1] = idx;
}
spec.rules = rule_new_ids;
spec.__rule_regexes = rule_regexes;
spec.__rule_count = len;
}
this.__decompressed = true;
}
this._input = input || '';
this.clear();
this._signaled_error_token = false;
this.done = false;
this.yylineno = 0;
this.matched = '';
this.conditionStack = ['INITIAL'];
this.__currentRuleSet__ = null;
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0,
range: [0, 0]
};
this.offset = 0;
return this;
},
/**
* edit the remaining input via user-specified callback.
* This can be used to forward-adjust the input-to-parse,
* e.g. inserting macro expansions and alike in the
* input which has yet to be lexed.
* The behaviour of this API contrasts the `unput()` et al
* APIs as those act on the *consumed* input, while this
* one allows one to manipulate the future, without impacting
* the current `yyloc` cursor location or any history.
*
* Use this API to help implement C-preprocessor-like
* `#include` statements, etc.
*
* The provided callback must be synchronous and is
* expected to return the edited input (string).
*
* The `cpsArg` argument value is passed to the callback
* as-is.
*
* `callback` interface:
* `function callback(input, cpsArg)`
*
* - `input` will carry the remaining-input-to-lex string
* from the lexer.
* - `cpsArg` is `cpsArg` passed into this API.
*
* The `this` reference for the callback will be set to
* reference this lexer instance so that userland code
* in the callback can easily and quickly access any lexer
* API.
*
* When the callback returns a non-string-type falsey value,
* we assume the callback did not edit the input and we
* will using the input as-is.
*
* When the callback returns a non-string-type value, it
* is converted to a string for lexing via the `"" + retval`
* operation. (See also why: http://2ality.com/2012/03/converting-to-string.html
* -- that way any returned object's `toValue()` and `toString()`
* methods will be invoked in a proper/desirable order.)
*
* @public
* @this {RegExpLexer}
*/
editRemainingInput: function lexer_editRemainingInput(callback, cpsArg) {
var rv = callback.call(this, this._input, cpsArg);
if (typeof rv !== 'string') {
if (rv) {
this._input = '' + rv;
}
// else: keep `this._input` as is.
} else {
this._input = rv;
}
return this;
},
/**
* consumes and returns one char from the input
*
* @public
* @this {RegExpLexer}
*/
input: function lexer_input() {
if (!this._input) {
//this.done = true; -- don't set `done` as we want the lex()/next() API to be able to produce one custom EOF token match after this anyhow. (lexer can match special <> tokens and perform user action code for a <> match, but only does so *once*)
return null;
}
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
// Count the linenumber up when we hit the LF (or a stand-alone CR).
// On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo
// and we advance immediately past the LF as well, returning both together as if
// it was all a single 'character' only.
var slice_len = 1;
var lines = false;
if (ch === '\n') {
lines = true;
} else if (ch === '\r') {
lines = true;
var ch2 = this._input[1];
if (ch2 === '\n') {
slice_len++;
ch += ch2;
this.yytext += ch2;
this.yyleng++;
this.offset++;
this.match += ch2;
this.matched += ch2;
this.yylloc.range[1]++;
}
}
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
this.yylloc.last_column = 0;
} else {
this.yylloc.last_column++;
}
this.yylloc.range[1]++;
this._input = this._input.slice(slice_len);
return ch;
},
/**
* unshifts one char (or an entire string) into the input
*
* @public
* @this {RegExpLexer}
*/
unput: function lexer_unput(ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len);
this.yyleng = this.yytext.length;
this.offset -= len;
this.match = this.match.substr(0, this.match.length - len);
this.matched = this.matched.substr(0, this.matched.length - len);
if (lines.length > 1) {
this.yylineno -= lines.length - 1;
this.yylloc.last_line = this.yylineno + 1;
// Get last entirely matched line into the `pre_lines[]` array's
// last index slot; we don't mind when other previously
// matched lines end up in the array too.
var pre = this.match;
var pre_lines = pre.split(/(?:\r\n?|\n)/g);
if (pre_lines.length === 1) {
pre = this.matched;
pre_lines = pre.split(/(?:\r\n?|\n)/g);
}
this.yylloc.last_column = pre_lines[pre_lines.length - 1].length;
} else {
this.yylloc.last_column -= len;
}
this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng;
this.done = false;
return this;
},
/**
* cache matched text and append it on next action
*
* @public
* @this {RegExpLexer}
*/
more: function lexer_more() {
this._more = true;
return this;
},
/**
* signal the lexer that this rule fails to match the input, so the
* next matching rule (regex) should be tested instead.
*
* @public
* @this {RegExpLexer}
*/
reject: function lexer_reject() {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
// when the `parseError()` call returns, we MUST ensure that the error is registered.
// We accomplish this by signaling an 'error' token to be produced for the current
// `.lex()` run.
var lineno_msg = '';
if (this.yylloc) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo(
'Lexical error' + lineno_msg + ': You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).',
false
);
this._signaled_error_token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
}
return this;
},
/**
* retain first n characters of the match
*
* @public
* @this {RegExpLexer}
*/
less: function lexer_less(n) {
return this.unput(this.match.slice(n));
},
/**
* return (part of the) already matched input, i.e. for error
* messages.
*
* Limit the returned string length to `maxSize` (default: 20).
*
* Limit the returned string to the `maxLines` number of lines of
* input (default: 1).
*
* Negative limit values equal *unlimited*.
*
* @public
* @this {RegExpLexer}
*/
pastInput: function lexer_pastInput(maxSize, maxLines) {
var past = this.matched.substring(0, this.matched.length - this.match.length);
if (maxSize < 0)
maxSize = past.length;
else if (!maxSize)
maxSize = 20;
if (maxLines < 0)
maxLines = past.length; // can't ever have more input lines than this!
else if (!maxLines)
maxLines = 1;
// `substr` anticipation: treat \r\n as a single character and take a little
// more than necessary so that we can still properly check against maxSize
// after we've transformed and limited the newLines in here:
past = past.substr(-maxSize * 2 - 2);
// now that we have a significantly reduced string to process, transform the newlines
// and chop them, then limit them:
var a = past.replace(/\r\n|\r/g, '\n').split('\n');
a = a.slice(-maxLines);
past = a.join('\n');
// When, after limiting to maxLines, we still have too much to return,
// do add an ellipsis prefix...
if (past.length > maxSize) {
past = '...' + past.substr(-maxSize);
}
return past;
},
/**
* return (part of the) upcoming input, i.e. for error messages.
*
* Limit the returned string length to `maxSize` (default: 20).
*
* Limit the returned string to the `maxLines` number of lines of input (default: 1).
*
* Negative limit values equal *unlimited*.
*
* > ### NOTE ###
* >
* > *"upcoming input"* is defined as the whole of the both
* > the *currently lexed* input, together with any remaining input
* > following that. *"currently lexed"* input is the input
* > already recognized by the lexer but not yet returned with
* > the lexer token. This happens when you are invoking this API
* > from inside any lexer rule action code block.
* >
*
* @public
* @this {RegExpLexer}
*/
upcomingInput: function lexer_upcomingInput(maxSize, maxLines) {
var next = this.match;
if (maxSize < 0)
maxSize = next.length + this._input.length;
else if (!maxSize)
maxSize = 20;
if (maxLines < 0)
maxLines = maxSize; // can't ever have more input lines than this!
else if (!maxLines)
maxLines = 1;
// `substring` anticipation: treat \r\n as a single character and take a little
// more than necessary so that we can still properly check against maxSize
// after we've transformed and limited the newLines in here:
if (next.length < maxSize * 2 + 2) {
next += this._input.substring(0, maxSize * 2 + 2); // substring is faster on Chrome/V8
}
// now that we have a significantly reduced string to process, transform the newlines
// and chop them, then limit them:
var a = next.replace(/\r\n|\r/g, '\n').split('\n');
a = a.slice(0, maxLines);
next = a.join('\n');
// When, after limiting to maxLines, we still have too much to return,
// do add an ellipsis postfix...
if (next.length > maxSize) {
next = next.substring(0, maxSize) + '...';
}
return next;
},
/**
* return a string which displays the character position where the
* lexing error occurred, i.e. for error messages
*
* @public
* @this {RegExpLexer}
*/
showPosition: function lexer_showPosition(maxPrefix, maxPostfix) {
var pre = this.pastInput(maxPrefix).replace(/\s/g, ' ');
var c = new Array(pre.length + 1).join('-');
return pre + this.upcomingInput(maxPostfix).replace(/\s/g, ' ') + '\n' + c + '^';
},
/**
* return an YYLLOC info object derived off the given context (actual, preceding, following, current).
* Use this method when the given `actual` location is not guaranteed to exist (i.e. when
* it MAY be NULL) and you MUST have a valid location info object anyway:
* then we take the given context of the `preceding` and `following` locations, IFF those are available,
* and reconstruct the `actual` location info from those.
* If this fails, the heuristic is to take the `current` location, IFF available.
* If this fails as well, we assume the sought location is at/around the current lexer position
* and then produce that one as a response. DO NOTE that these heuristic/derived location info
* values MAY be inaccurate!
*
* NOTE: `deriveLocationInfo()` ALWAYS produces a location info object *copy* of `actual`, not just
* a *reference* hence all input location objects can be assumed to be 'constant' (function has no side-effects).
*
* @public
* @this {RegExpLexer}
*/
deriveLocationInfo: function lexer_deriveYYLLOC(actual, preceding, following, current) {
var loc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0,
range: [0, 0]
};
if (actual) {
loc.first_line = actual.first_line | 0;
loc.last_line = actual.last_line | 0;
loc.first_column = actual.first_column | 0;
loc.last_column = actual.last_column | 0;
if (actual.range) {
loc.range[0] = actual.range[0] | 0;
loc.range[1] = actual.range[1] | 0;
}
}
if (loc.first_line <= 0 || loc.last_line < loc.first_line) {
// plan B: heuristic using preceding and following:
if (loc.first_line <= 0 && preceding) {
loc.first_line = preceding.last_line | 0;
loc.first_column = preceding.last_column | 0;
if (preceding.range) {
loc.range[0] = actual.range[1] | 0;
}
}
if ((loc.last_line <= 0 || loc.last_line < loc.first_line) && following) {
loc.last_line = following.first_line | 0;
loc.last_column = following.first_column | 0;
if (following.range) {
loc.range[1] = actual.range[0] | 0;
}
}
// plan C?: see if the 'current' location is useful/sane too:
if (loc.first_line <= 0 && current && (loc.last_line <= 0 || current.last_line <= loc.last_line)) {
loc.first_line = current.first_line | 0;
loc.first_column = current.first_column | 0;
if (current.range) {
loc.range[0] = current.range[0] | 0;
}
}
if (loc.last_line <= 0 && current && (loc.first_line <= 0 || current.first_line >= loc.first_line)) {
loc.last_line = current.last_line | 0;
loc.last_column = current.last_column | 0;
if (current.range) {
loc.range[1] = current.range[1] | 0;
}
}
}
// sanitize: fix last_line BEFORE we fix first_line as we use the 'raw' value of the latter
// or plan D heuristics to produce a 'sensible' last_line value:
if (loc.last_line <= 0) {
if (loc.first_line <= 0) {
loc.first_line = this.yylloc.first_line;
loc.last_line = this.yylloc.last_line;
loc.first_column = this.yylloc.first_column;
loc.last_column = this.yylloc.last_column;
loc.range[0] = this.yylloc.range[0];
loc.range[1] = this.yylloc.range[1];
} else {
loc.last_line = this.yylloc.last_line;
loc.last_column = this.yylloc.last_column;
loc.range[1] = this.yylloc.range[1];
}
}
if (loc.first_line <= 0) {
loc.first_line = loc.last_line;
loc.first_column = 0; // loc.last_column;
loc.range[1] = loc.range[0];
}
if (loc.first_column < 0) {
loc.first_column = 0;
}
if (loc.last_column < 0) {
loc.last_column = (loc.first_column > 0 ? loc.first_column : 80);
}
return loc;
},
/**
* return a string which displays the lines & columns of input which are referenced
* by the given location info range, plus a few lines of context.
*
* This function pretty-prints the indicated section of the input, with line numbers
* and everything!
*
* This function is very useful to provide highly readable error reports, while
* the location range may be specified in various flexible ways:
*
* - `loc` is the location info object which references the area which should be
* displayed and 'marked up': these lines & columns of text are marked up by `^`
* characters below each character in the entire input range.
*
* - `context_loc` is the *optional* location info object which instructs this
* pretty-printer how much *leading* context should be displayed alongside
* the area referenced by `loc`. This can help provide context for the displayed
* error, etc.
*
* When this location info is not provided, a default context of 3 lines is
* used.
*
* - `context_loc2` is another *optional* location info object, which serves
* a similar purpose to `context_loc`: it specifies the amount of *trailing*
* context lines to display in the pretty-print output.
*
* When this location info is not provided, a default context of 1 line only is
* used.
*
* Special Notes:
*
* - when the `loc`-indicated range is very large (about 5 lines or more), then
* only the first and last few lines of this block are printed while a
* `...continued...` message will be printed between them.
*
* This serves the purpose of not printing a huge amount of text when the `loc`
* range happens to be huge: this way a manageable & readable output results
* for arbitrary large ranges.
*
* - this function can display lines of input which whave not yet been lexed.
* `prettyPrintRange()` can access the entire input!
*
* @public
* @this {RegExpLexer}
*/
prettyPrintRange: function lexer_prettyPrintRange(loc, context_loc, context_loc2) {
loc = this.deriveLocationInfo(loc, context_loc, context_loc2);
const CONTEXT = 3;
const CONTEXT_TAIL = 1;
const MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT = 2;
var input = this.matched + this._input;
var lines = input.split('\n');
var l0 = Math.max(1, (context_loc ? context_loc.first_line : loc.first_line - CONTEXT));
var l1 = Math.max(1, (context_loc2 ? context_loc2.last_line : loc.last_line + CONTEXT_TAIL));
var lineno_display_width = 1 + Math.log10(l1 | 1) | 0;
var ws_prefix = new Array(lineno_display_width).join(' ');
var nonempty_line_indexes = [];
var rv = lines.slice(l0 - 1, l1 + 1).map(function injectLineNumber(line, index) {
var lno = index + l0;
var lno_pfx = (ws_prefix + lno).substr(-lineno_display_width);
var rv = lno_pfx + ': ' + line;
var errpfx = new Array(lineno_display_width + 1).join('^');
var offset = 2 + 1;
var len = 0;
if (lno === loc.first_line) {
offset += loc.first_column;
len = Math.max(
2,
((lno === loc.last_line ? loc.last_column : line.length)) - loc.first_column + 1
);
} else if (lno === loc.last_line) {
len = Math.max(2, loc.last_column + 1);
} else if (lno > loc.first_line && lno < loc.last_line) {
len = Math.max(2, line.length + 1);
}
if (len) {
var lead = new Array(offset).join('.');
var mark = new Array(len).join('^');
rv += '\n' + errpfx + lead + mark;
if (line.trim().length > 0) {
nonempty_line_indexes.push(index);
}
}
rv = rv.replace(/\t/g, ' ');
return rv;
});
// now make sure we don't print an overly large amount of error area: limit it
// to the top and bottom line count:
if (nonempty_line_indexes.length > 2 * MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT) {
var clip_start = nonempty_line_indexes[MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT - 1] + 1;
var clip_end = nonempty_line_indexes[nonempty_line_indexes.length - MINIMUM_VISIBLE_NONEMPTY_LINE_COUNT] - 1;
var intermediate_line = new Array(lineno_display_width + 1).join(' ') + ' (...continued...)';
intermediate_line += '\n' + new Array(lineno_display_width + 1).join('-') + ' (---------------)';
rv.splice(clip_start, clip_end - clip_start + 1, intermediate_line);
}
return rv.join('\n');
},
/**
* helper function, used to produce a human readable description as a string, given
* the input `yylloc` location object.
*
* Set `display_range_too` to TRUE to include the string character index position(s)
* in the description if the `yylloc.range` is available.
*
* @public
* @this {RegExpLexer}
*/
describeYYLLOC: function lexer_describe_yylloc(yylloc, display_range_too) {
var l1 = yylloc.first_line;
var l2 = yylloc.last_line;
var c1 = yylloc.first_column;
var c2 = yylloc.last_column;
var dl = l2 - l1;
var dc = c2 - c1;
var rv;
if (dl === 0) {
rv = 'line ' + l1 + ', ';
if (dc <= 1) {
rv += 'column ' + c1;
} else {
rv += 'columns ' + c1 + ' .. ' + c2;
}
} else {
rv = 'lines ' + l1 + '(column ' + c1 + ') .. ' + l2 + '(column ' + c2 + ')';
}
if (yylloc.range && display_range_too) {
var r1 = yylloc.range[0];
var r2 = yylloc.range[1] - 1;
if (r2 <= r1) {
rv += ' {String Offset: ' + r1 + '}';
} else {
rv += ' {String Offset range: ' + r1 + ' .. ' + r2 + '}';
}
}
return rv;
},
/**
* test the lexed token: return FALSE when not a match, otherwise return token.
*
* `match` is supposed to be an array coming out of a regex match, i.e. `match[0]`
* contains the actually matched text string.
*
* Also move the input cursor forward and update the match collectors:
*
* - `yytext`
* - `yyleng`
* - `match`
* - `matches`
* - `yylloc`
* - `offset`
*
* @public
* @this {RegExpLexer}
*/
test_match: function lexer_test_match(match, indexed_rule) {
var token, lines, backup, match_str, match_str_len;
if (this.options.backtrack_lexer) {
// save context
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.yylloc.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column,
range: this.yylloc.range.slice(0)
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
//_signaled_error_token: this._signaled_error_token,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
}
match_str = match[0];
match_str_len = match_str.length;
// if (match_str.indexOf('\n') !== -1 || match_str.indexOf('\r') !== -1) {
lines = match_str.split(/(?:\r\n?|\n)/g);
if (lines.length > 1) {
this.yylineno += lines.length - 1;
this.yylloc.last_line = this.yylineno + 1;
this.yylloc.last_column = lines[lines.length - 1].length;
} else {
this.yylloc.last_column += match_str_len;
}
// }
this.yytext += match_str;
this.match += match_str;
this.matched += match_str;
this.matches = match;
this.yyleng = this.yytext.length;
this.yylloc.range[1] += match_str_len;
// previous lex rules MAY have invoked the `more()` API rather than producing a token:
// those rules will already have moved this `offset` forward matching their match lengths,
// hence we must only add our own match length now:
this.offset += match_str_len;
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match_str_len);
// calling this method:
//
// function lexer__performAction(yy, yyrulenumber, YY_START) {...}
token = this.performAction.call(
this,
this.yy,
indexed_rule,
this.conditionStack[this.conditionStack.length - 1] /* = YY_START */
);
// otherwise, when the action codes are all simple return token statements:
//token = this.simpleCaseActionClusters[indexed_rule];
if (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else if (this._backtrack) {
// recover context
for (var k in backup) {
this[k] = backup[k];
}
this.__currentRuleSet__ = null;
return false; // rule action called reject() implying the next rule should be tested instead.
} else if (this._signaled_error_token) {
// produce one 'error' token as `.parseError()` in `reject()`
// did not guarantee a failure signal by throwing an exception!
token = this._signaled_error_token;
this._signaled_error_token = false;
return token;
}
return false;
},
/**
* return next match in input
*
* @public
* @this {RegExpLexer}
*/
next: function lexer_next() {
if (this.done) {
this.clear();
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token, match, tempMatch, index;
if (!this._more) {
this.clear();
}
var spec = this.__currentRuleSet__;
if (!spec) {
// Update the ruleset cache as we apparently encountered a state change or just started lexing.
// The cache is set up for fast lookup -- we assume a lexer will switch states much less often than it will
// invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps
// speed up those activities a tiny bit.
spec = this.__currentRuleSet__ = this._currentRules();
// Check whether a *sane* condition has been pushed before: this makes the lexer robust against
// user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19
if (!spec || !spec.rules) {
var lineno_msg = '';
if (this.options.trackPosition) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo(
'Internal lexer engine error' + lineno_msg + ': The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!',
false
);
// produce one 'error' token until this situation has been resolved, most probably by parse termination!
return this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
}
}
var rule_ids = spec.rules;
var regexes = spec.__rule_regexes;
var len = spec.__rule_count;
// Note: the arrays are 1-based, while `len` itself is a valid index,
// hence the non-standard less-or-equal check in the next loop condition!
for (var i = 1; i <= len; i++) {
tempMatch = this._input.match(regexes[i]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
if (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rule_ids[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = undefined;
continue; // rule action called reject() implying a rule MISmatch.
} else {
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
} else if (!this.options.flex) {
break;
}
}
}
if (match) {
token = this.test_match(match, rule_ids[index]);
if (token !== false) {
return token;
}
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
if (!this._input) {
this.done = true;
this.clear();
return this.EOF;
} else {
var lineno_msg = '';
if (this.options.trackPosition) {
lineno_msg = ' on line ' + (this.yylineno + 1);
}
var p = this.constructLexErrorInfo(
'Lexical error' + lineno_msg + ': Unrecognized text.',
this.options.lexerErrorsAreRecoverable
);
var pendingInput = this._input;
var activeCondition = this.topState();
var conditionStackDepth = this.conditionStack.length;
token = this.parseError(p.errStr, p, this.JisonLexerError) || this.ERROR;
if (token === this.ERROR) {
// we can try to recover from a lexer error that `parseError()` did not 'recover' for us
// by moving forward at least one character at a time IFF the (user-specified?) `parseError()`
// has not consumed/modified any pending input or changed state in the error handler:
if (!this.matches && // and make sure the input has been modified/consumed ...
pendingInput === this._input && // ...or the lexer state has been modified significantly enough
// to merit a non-consuming error handling action right now.
activeCondition === this.topState() && conditionStackDepth === this.conditionStack.length) {
this.input();
}
}
return token;
}
},
/**
* return next match that has a token
*
* @public
* @this {RegExpLexer}
*/
lex: function lexer_lex() {
var r;
// allow the PRE/POST handlers set/modify the return token for maximum flexibility of the generated lexer:
if (typeof this.pre_lex === 'function') {
r = this.pre_lex.call(this, 0);
}
if (typeof this.options.pre_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.options.pre_lex.call(this, r) || r;
}
if (this.yy && typeof this.yy.pre_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.yy.pre_lex.call(this, r) || r;
}
while (!r) {
r = this.next();
}
if (this.yy && typeof this.yy.post_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.yy.post_lex.call(this, r) || r;
}
if (typeof this.options.post_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.options.post_lex.call(this, r) || r;
}
if (typeof this.post_lex === 'function') {
// (also account for a userdef function which does not return any value: keep the token as is)
r = this.post_lex.call(this, r) || r;
}
return r;
},
/**
* return next match that has a token. Identical to the `lex()` API but does not invoke any of the
* `pre_lex()` nor any of the `post_lex()` callbacks.
*
* @public
* @this {RegExpLexer}
*/
fastLex: function lexer_fastLex() {
var r;
while (!r) {
r = this.next();
}
return r;
},
/**
* return info about the lexer state that can help a parser or other lexer API user to use the
* most efficient means available. This API is provided to aid run-time performance for larger
* systems which employ this lexer.
*
* @public
* @this {RegExpLexer}
*/
canIUse: function lexer_canIUse() {
var rv = {
fastLex: !(typeof this.pre_lex === 'function' || typeof this.options.pre_lex === 'function' || this.yy && typeof this.yy.pre_lex === 'function' || this.yy && typeof this.yy.post_lex === 'function' || typeof this.options.post_lex === 'function' || typeof this.post_lex === 'function') && typeof this.fastLex === 'function'
};
return rv;
},
/**
* backwards compatible alias for `pushState()`;
* the latter is symmetrical with `popState()` and we advise to use
* those APIs in any modern lexer code, rather than `begin()`.
*
* @public
* @this {RegExpLexer}
*/
begin: function lexer_begin(condition) {
return this.pushState(condition);
},
/**
* activates a new lexer condition state (pushes the new lexer
* condition state onto the condition stack)
*
* @public
* @this {RegExpLexer}
*/
pushState: function lexer_pushState(condition) {
this.conditionStack.push(condition);
this.__currentRuleSet__ = null;
return this;
},
/**
* pop the previously active lexer condition state off the condition
* stack
*
* @public
* @this {RegExpLexer}
*/
popState: function lexer_popState() {
var n = this.conditionStack.length - 1;
if (n > 0) {
this.__currentRuleSet__ = null;
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
},
/**
* return the currently active lexer condition state; when an index
* argument is provided it produces the N-th previous condition state,
* if available
*
* @public
* @this {RegExpLexer}
*/
topState: function lexer_topState(n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return 'INITIAL';
}
},
/**
* (internal) determine the lexer rule set which is active for the
* currently active lexer condition state
*
* @public
* @this {RegExpLexer}
*/
_currentRules: function lexer__currentRules() {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]];
} else {
return this.conditions['INITIAL'];
}
},
/**
* return the number of states currently on the stack
*
* @public
* @this {RegExpLexer}
*/
stateStackSize: function lexer_stateStackSize() {
return this.conditionStack.length;
},
options: {
trackPosition: true
},
JisonLexerError: JisonLexerError,
performAction: function lexer__performAction(yy, yyrulenumber, YY_START) {
var yy_ = this;
var YYSTATE = YY_START;
switch (yyrulenumber) {
case 1:
/*! Conditions:: INITIAL */
/*! Rule:: \s+ */
/* skip whitespace */
break;
default:
return this.simpleCaseActionClusters[yyrulenumber];
}
},
simpleCaseActionClusters: {
/*! Conditions:: INITIAL */
/*! Rule:: (--[0-9a-z-A-Z-]*) */
0: 13,
/*! Conditions:: INITIAL */
/*! Rule:: \* */
2: 5,
/*! Conditions:: INITIAL */
/*! Rule:: \/ */
3: 6,
/*! Conditions:: INITIAL */
/*! Rule:: \+ */
4: 3,
/*! Conditions:: INITIAL */
/*! Rule:: - */
5: 4,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)px\b */
6: 15,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)cm\b */
7: 15,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)mm\b */
8: 15,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)in\b */
9: 15,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)pt\b */
10: 15,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)pc\b */
11: 15,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)deg\b */
12: 16,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)grad\b */
13: 16,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)rad\b */
14: 16,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)turn\b */
15: 16,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)s\b */
16: 17,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)ms\b */
17: 17,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)Hz\b */
18: 18,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)kHz\b */
19: 18,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)dpi\b */
20: 19,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)dpcm\b */
21: 19,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)dppx\b */
22: 19,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)em\b */
23: 20,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)ex\b */
24: 21,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)ch\b */
25: 22,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)rem\b */
26: 23,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vw\b */
27: 25,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vh\b */
28: 24,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vmin\b */
29: 26,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)vmax\b */
30: 27,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)% */
31: 28,
/*! Conditions:: INITIAL */
/*! Rule:: ([0-9]+(\.[0-9]*)?|\.[0-9]+)\b */
32: 11,
/*! Conditions:: INITIAL */
/*! Rule:: (calc) */
33: 9,
/*! Conditions:: INITIAL */
/*! Rule:: (var) */
34: 12,
/*! Conditions:: INITIAL */
/*! Rule:: ([a-z]+) */
35: 10,
/*! Conditions:: INITIAL */
/*! Rule:: \( */
36: 7,
/*! Conditions:: INITIAL */
/*! Rule:: \) */
37: 8,
/*! Conditions:: INITIAL */
/*! Rule:: , */
38: 14,
/*! Conditions:: INITIAL */
/*! Rule:: $ */
39: 1
},
rules: [
/* 0: */ /^(?:(--[\d\-A-Za-z]*))/,
/* 1: */ /^(?:\s+)/,
/* 2: */ /^(?:\*)/,
/* 3: */ /^(?:\/)/,
/* 4: */ /^(?:\+)/,
/* 5: */ /^(?:-)/,
/* 6: */ /^(?:(\d+(\.\d*)?|\.\d+)px\b)/,
/* 7: */ /^(?:(\d+(\.\d*)?|\.\d+)cm\b)/,
/* 8: */ /^(?:(\d+(\.\d*)?|\.\d+)mm\b)/,
/* 9: */ /^(?:(\d+(\.\d*)?|\.\d+)in\b)/,
/* 10: */ /^(?:(\d+(\.\d*)?|\.\d+)pt\b)/,
/* 11: */ /^(?:(\d+(\.\d*)?|\.\d+)pc\b)/,
/* 12: */ /^(?:(\d+(\.\d*)?|\.\d+)deg\b)/,
/* 13: */ /^(?:(\d+(\.\d*)?|\.\d+)grad\b)/,
/* 14: */ /^(?:(\d+(\.\d*)?|\.\d+)rad\b)/,
/* 15: */ /^(?:(\d+(\.\d*)?|\.\d+)turn\b)/,
/* 16: */ /^(?:(\d+(\.\d*)?|\.\d+)s\b)/,
/* 17: */ /^(?:(\d+(\.\d*)?|\.\d+)ms\b)/,
/* 18: */ /^(?:(\d+(\.\d*)?|\.\d+)Hz\b)/,
/* 19: */ /^(?:(\d+(\.\d*)?|\.\d+)kHz\b)/,
/* 20: */ /^(?:(\d+(\.\d*)?|\.\d+)dpi\b)/,
/* 21: */ /^(?:(\d+(\.\d*)?|\.\d+)dpcm\b)/,
/* 22: */ /^(?:(\d+(\.\d*)?|\.\d+)dppx\b)/,
/* 23: */ /^(?:(\d+(\.\d*)?|\.\d+)em\b)/,
/* 24: */ /^(?:(\d+(\.\d*)?|\.\d+)ex\b)/,
/* 25: */ /^(?:(\d+(\.\d*)?|\.\d+)ch\b)/,
/* 26: */ /^(?:(\d+(\.\d*)?|\.\d+)rem\b)/,
/* 27: */ /^(?:(\d+(\.\d*)?|\.\d+)vw\b)/,
/* 28: */ /^(?:(\d+(\.\d*)?|\.\d+)vh\b)/,
/* 29: */ /^(?:(\d+(\.\d*)?|\.\d+)vmin\b)/,
/* 30: */ /^(?:(\d+(\.\d*)?|\.\d+)vmax\b)/,
/* 31: */ /^(?:(\d+(\.\d*)?|\.\d+)%)/,
/* 32: */ /^(?:(\d+(\.\d*)?|\.\d+)\b)/,
/* 33: */ /^(?:(calc))/,
/* 34: */ /^(?:(var))/,
/* 35: */ /^(?:([a-z]+))/,
/* 36: */ /^(?:\()/,
/* 37: */ /^(?:\))/,
/* 38: */ /^(?:,)/,
/* 39: */ /^(?:$)/
],
conditions: {
'INITIAL': {
rules: [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39
],
inclusive: true
}
}
};
return lexer;
}();
parser.lexer = lexer;
function Parser() {
this.yy = {};
}
Parser.prototype = parser;
parser.Parser = Parser;
return new Parser();
})();
if (true) {
exports.parser = parser;
exports.Parser = parser.Parser;
exports.parse = function () {
return parser.parse.apply(parser, arguments);
};
}
/***/ }),
/***/ 6204:
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/* UAParser.js v0.7.36
Copyright © 2012-2021 Faisal Salman
MIT License */
(function(window,undefined){"use strict";var LIBVERSION="0.7.36",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",STR_TYPE="string",MAJOR="major",MODEL="model",NAME="name",TYPE="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",EMBEDDED="embedded",UA_MAX_LENGTH=350;var AMAZON="Amazon",APPLE="Apple",ASUS="ASUS",BLACKBERRY="BlackBerry",BROWSER="Browser",CHROME="Chrome",EDGE="Edge",FIREFOX="Firefox",GOOGLE="Google",HUAWEI="Huawei",LG="LG",MICROSOFT="Microsoft",MOTOROLA="Motorola",OPERA="Opera",SAMSUNG="Samsung",SHARP="Sharp",SONY="Sony",VIERA="Viera",XIAOMI="Xiaomi",ZEBRA="Zebra",FACEBOOK="Facebook",CHROMIUM_OS="Chromium OS",MAC_OS="Mac OS";var extend=function(regexes,extensions){var mergedRegexes={};for(var i in regexes){if(extensions[i]&&extensions[i].length%2===0){mergedRegexes[i]=extensions[i].concat(regexes[i])}else{mergedRegexes[i]=regexes[i]}}return mergedRegexes},enumerize=function(arr){var enums={};for(var i=0;i0){if(q.length===2){if(typeof q[1]==FUNC_TYPE){this[q[0]]=q[1].call(this,match)}else{this[q[0]]=q[1]}}else if(q.length===3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){this[q[0]]=match?q[1].call(this,match,q[2]):undefined}else{this[q[0]]=match?match.replace(q[1],q[2]):undefined}}else if(q.length===4){this[q[0]]=match?q[3].call(this,match.replace(q[1],q[2])):undefined}}else{this[q]=match?match:undefined}}}}i+=2}},strMapper=function(str,map){for(var i in map){if(typeof map[i]===OBJ_TYPE&&map[i].length>0){for(var j=0;j