Skip to content

Instantly share code, notes, and snippets.

@vwochnik
Last active December 20, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vwochnik/8cca64d23741705049f0abb9d688242b to your computer and use it in GitHub Desktop.
Save vwochnik/8cca64d23741705049f0abb9d688242b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Example iframe</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 20px;
}
.footer {
padding-top: 40px;
padding-bottom: 40px;
margin-top: 40px;
border-top: 1px solid #eee;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
background-color: transparent;
}
.jumbotron .btn {
padding: 14px 24px;
font-size: 21px;
}
/* Customize the nav-justified links to be fill the entire space of the .navbar */
.nav-justified {
background-color: #eee;
border: 1px solid #ccc;
border-radius: 5px;
}
.nav-justified > li > a {
padding-top: 15px;
padding-bottom: 15px;
margin-bottom: 0;
font-weight: bold;
color: #777;
text-align: center;
background-color: #e5e5e5; /* Old browsers */
background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e5e5e5));
background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
background-image: -o-linear-gradient(top, #f5f5f5 0%, #e5e5e5 100%);
background-image: linear-gradient(to bottom, #f5f5f5 0%,#e5e5e5 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background-repeat: repeat-x; /* Repeat the gradient */
border-bottom: 1px solid #d5d5d5;
}
.nav-justified > .active > a,
.nav-justified > .active > a:hover,
.nav-justified > .active > a:focus {
background-color: #ddd;
background-image: none;
-webkit-box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified > li:first-child > a {
border-radius: 5px 5px 0 0;
}
.nav-justified > li:last-child > a {
border-bottom: 0;
border-radius: 0 0 5px 5px;
}
@media (min-width: 768px) {
.nav-justified {
max-height: 52px;
}
.nav-justified > li > a {
border-right: 1px solid #d5d5d5;
border-left: 1px solid #fff;
}
.nav-justified > li:first-child > a {
border-left: 0;
border-radius: 5px 0 0 5px;
}
.nav-justified > li:last-child > a {
border-right: 0;
border-radius: 0 5px 5px 0;
}
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
.masthead,
.marketing,
.footer {
padding-right: 0;
padding-left: 0;
}
}
</style>
</head>
<body>
<div class="container">
<!-- The justified navigation menu is meant for single line per list item.
Multiple lines will require custom code not provided by Bootstrap. -->
<div class="masthead">
<h3 class="text-muted">Project name</h3>
<nav>
<ul class="nav nav-justified">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
<!-- Jumbotron -->
<div class="jumbotron">
<h1>Marketing stuff!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet.</p>
<p><a class="btn btn-lg btn-success" href="#" role="button">Get started today</a></p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="col-lg-4">
<h2>Safari bug warning!</h2>
<p class="text-danger">As of v9.1.2, Safari exhibits a bug in which resizing your browser horizontally causes rendering errors in the justified nav that are cleared upon refreshing.</p>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
<p><a class="btn btn-primary" href="#" role="button">View details &raquo;</a></p>
</div>
</div>
<!-- Site footer -->
<footer class="footer">
<p>&copy; 2016 Company, Inc.</p>
</footer>
</div> <!-- /container -->
<script src="osc-ies.js"></script>
<script type="text/javascript">
var bridge = new ies.ChildBridge();
window.odoscopeInject = function(parent, before) {
var elem = document.createElement("div");
elem.innerHTML = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veritatis perspiciatis delectus ut saepe nam quidem numquam quasi itaque voluptatibus reprehenderit error, similique porro nobis iusto enim quam laborum repellendus, pariatur?";
parent.insertBefore(elem, before);
return elem;
};
setTimeout(function() {
bridge.initialize();
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>odoscope Injection Test</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 14px;
}
body {
margin: 0;
background: #efefff;
color: #334;
}
h1 {
text-align: center;
margin-bottom: 1rem;
}
.clear:after {
content: '';
display: table;
clear: both;
}
#wrapper {
max-width: 96rem;
margin: 2rem auto;
padding: 0 2rem;
}
.browser-mockup {
border-top: 2em solid rgba(230, 230, 230, 0.7);
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
position: relative;
border-radius: 3px 3px 0 0
}
.browser-mockup:before {
display: block;
position: absolute;
content: '';
top: -1.25em;
left: 1em;
width: 0.5em;
height: 0.5em;
border-radius: 50%;
background-color: #f44;
box-shadow: 0 0 0 2px #f44, 1.5em 0 0 2px #9b3, 3em 0 0 2px #fb5;
}
.browser-mockup:after {
display: block;
position: absolute;
content: '';
top: -1.6em;
left: 5.5em;
width: calc(100% - 6em);
height: 1.2em;
border-radius: 2px;
background-color: white;
}
.gap {
margin-bottom: 1rem;
}
.browser-mockup iframe {
display: block;
border: none;
width: 100%;
height: 40rem;
}
.wizard-btn {
font-size: 2rem;
line-height: 2rem;
width: 3.5rem;
height: 3.5rem;
padding: 0.75rem;
text-align: center;
margin-right: 0.5rem;
border: none;
border-radius: 50%;
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
background-color: rgba(230, 230, 230, 0.7);
color: #334;
}
.wizard-btn:hover {
background-color: rgba(220, 220, 240, 0.7);
}
.sel-text {
display: inline-block;
line-height: 3.5rem;
font-size: 1.5rem;
color: #393;
}
.log, .wizard {
box-shadow: 0 0.1em 1em 0 rgba(0, 0, 0, 0.4);
border-radius: 3px 3px 0 0;
padding: 0.5rem;
overflow: auto;
}
.wizard {
background-color: rgba(230, 230, 230, 0.7);
height: 16rem;
}
.log {
background-color: rgba(230, 230, 230, 0.7);
height: 16rem;
}
.log .msg:not(:last-child) {
margin-bottom: 0.5rem;
}
.log .msg .date {
color: #f44;
}
</style>
<link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
</head>
<body>
<div id="wrapper">
<h1>odoscope Injection Test</h1>
<div class="browser-mockup gap" id="browser"></div>
<div class="clear gap">
<button id="prev" class="wizard-btn" style="float:left"><i class="ion ion-chevron-left"></i></button>
<button id="next" class="wizard-btn" style="float:right"><i class="ion ion-chevron-right"></i></button>
</div>
<div class="clear gap">
<div class="wizard" id="wizard" style="float:left;width:59%"></div>
<div class="log" id="log" style="float:right;width:39%"></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/taylorhakes/promise-polyfill/master/promise.min.js"></script>
<script src="osc-ies.js"></script>
<script src="wizard.js"></script>
</body>
</html>
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.ies = global.ies || {})));
}(this, (function (exports) { 'use strict';
var MAX_Z_INDEX = 2147483647;
var OSC_C_LIGHT = 'rgba(0,158,224,0.7)';
var OSC_C_WHITE = 'rgba(255,255,255,0.8)';
var OSC_C_DARK = 'rgba(0,158,224,0.9)';
var OSC_C_GRAY = 'rgba(60,89,101,0.8)';
var OSC_STRIPES = 'repeating-linear-gradient(45deg,rgba(0,158,224,0.7),rgba(0,158,224,0.7) 10px,rgba(0,158,224,0.8) 10px,rgba(0,158,224,0.8) 20px)';
var OSC_MODE_NONE = 0;
var OSC_MODE_SELECT = 1;
var OSC_MODE_INJECT = 2;
var OSC_POSITION_THIS = 0;
var OSC_POSITION_BEFORE = 1;
var OSC_POSITION_AFTER = 2;
/**
* Returns the Tag of the element
* @param { Object } element
* @return { String }
*/
function getID(el) {
return '#' + el.getAttribute('id');
}
/**
* Get class names for an element
*
* @pararm { Element } el
* @return { Array }
*/
function getClasses(el) {
var classNames = void 0;
try {
classNames = el.classList.toString().split(' ');
} catch (e) {
if (!el.hasAttribute('class')) {
return [];
}
var className = el.getAttribute('class');
// remove duplicate and leading/trailing whitespaces
className = className.trim().replace(/\s+/g, ' ');
// split into separate classnames
classNames = className.split(' ');
}
return classNames;
}
/**
* Returns the Class selectors of the element
* @param { Object } element
* @return { Array }
*/
function getClassSelectors(el) {
var classList = getClasses(el).filter(Boolean);
return classList.map(function (cl) {
return '.' + cl;
});
}
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
/**
* Returns the Attribute selectors of the element
* @param { DOM Element } element
* @param { Array } array of attributes to ignore
* @return { Array }
*/
function getAttributes(el) {
var attributesToIgnore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['id', 'class', 'length'];
var attributes = el.attributes;
var attrs = [].concat(toConsumableArray(attributes));
return attrs.reduce(function (sum, next) {
if (!(attributesToIgnore.indexOf(next.nodeName) > -1)) {
sum.push('[' + next.nodeName + '="' + next.value + '"]');
}
return sum;
}, []);
}
/**
* Determines if the passed el is a DOM element
*/
function isElement(el) {
var isElem = void 0;
if ((typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object') {
isElem = el instanceof HTMLElement;
} else {
isElem = !!el && (typeof el === 'undefined' ? 'undefined' : _typeof(el)) === 'object' && el.nodeType === 1 && typeof el.nodeName === 'string';
}
return isElem;
}
/**
* Returns the selectors based on the position of the element relative to its siblings
* @param { Object } element
* @return { Array }
*/
function getNthChild(element) {
var counter = 0;
var k = void 0;
var sibling = void 0;
var parentNode = element.parentNode;
if (Boolean(parentNode)) {
var childNodes = parentNode.childNodes;
var len = childNodes.length;
for (k = 0; k < len; k++) {
sibling = childNodes[k];
if (isElement(sibling)) {
counter++;
if (sibling === element) {
return ':nth-child(' + counter + ')';
}
}
}
}
return null;
}
/**
* Returns the Tag of the element
* @param { Object } element
* @return { String }
*/
function getTag(el) {
return el.tagName.toLowerCase();
}
/**
* Checks if the selector is unique
* @param { Object } element
* @param { String } selector
* @return { Array }
*/
function isUnique(el, selector) {
if (!Boolean(selector)) return false;
var elems = el.ownerDocument.querySelectorAll(selector);
return elems.length === 1 && elems[0] === el;
}
/**
* Returns all the element and all of its parents
* @param { DOM Element }
* @return { Array of DOM elements }
*/
function getParents(el) {
var parents = [];
var currentElement = el;
while (isElement(currentElement)) {
parents.push(currentElement);
currentElement = currentElement.parentNode;
}
return parents;
}
/**
* Expose `unique`
*/
/**
* Returns all the selectors of the elmenet
* @param { Object } element
* @return { Object }
*/
function getAllSelectors(el, selectors, attributesToIgnore) {
var funcs = {
'Tag': getTag,
'NthChild': getNthChild,
'Attributes': function Attributes(elem) {
return getAttributes(elem, attributesToIgnore);
},
'Class': getClassSelectors,
'ID': getID
};
return selectors.reduce(function (res, next) {
res[next] = funcs[next](el);
return res;
}, {});
}
/**
* Tests uniqueNess of the element inside its parent
* @param { Object } element
* @param { String } Selectors
* @return { Boolean }
*/
function testUniqueness(element, selector) {
var parentNode = element.parentNode;
var elements = parentNode.querySelectorAll(selector);
return elements.length === 1 && elements[0] === element;
}
/**
* Checks all the possible selectors of an element to find one unique and return it
* @param { Object } element
* @param { Array } items
* @param { String } tag
* @return { String }
*/
function getUniqueCombination(element, items, tag) {
var combinations = getCombinations(items);
var uniqCombinations = combinations.filter(testUniqueness.bind(this, element));
if (uniqCombinations.length) return uniqCombinations[0];
if (Boolean(tag)) {
var _combinations = items.map(function (item) {
return tag + item;
});
var _uniqCombinations = _combinations.filter(testUniqueness.bind(this, element));
if (_uniqCombinations.length) return _uniqCombinations[0];
}
return null;
}
/**
* Returns a uniqueSelector based on the passed options
* @param { DOM } element
* @param { Array } options
* @return { String }
*/
function getUniqueSelector(element, selectorTypes, attributesToIgnore) {
var foundSelector = void 0;
var elementSelectors = getAllSelectors(element, selectorTypes, attributesToIgnore);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = selectorTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var selectorType = _step.value;
var ID = elementSelectors.ID,
Tag = elementSelectors.Tag,
Classes = elementSelectors.Class,
Attributes = elementSelectors.Attributes,
NthChild = elementSelectors.NthChild;
switch (selectorType) {
case 'ID':
if (Boolean(ID) && testUniqueness(element, ID)) {
return ID;
}
break;
case 'Tag':
if (Boolean(Tag) && testUniqueness(element, Tag)) {
return Tag;
}
break;
case 'Class':
if (Boolean(Classes) && Classes.length) {
foundSelector = getUniqueCombination(element, Classes, Tag);
if (foundSelector) {
return foundSelector;
}
}
break;
case 'Attributes':
if (Boolean(Attributes) && Attributes.length) {
foundSelector = getUniqueCombination(element, Attributes, Tag);
if (foundSelector) {
return foundSelector;
}
}
break;
case 'NthChild':
if (Boolean(NthChild)) {
return NthChild;
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return '*';
}
/**
* Returns all the possible selector combinations
*/
function getCombinations(items) {
items = items ? items : [];
var result = [[]];
var i = void 0,
j = void 0,
k = void 0,
l = void 0,
ref = void 0,
ref1 = void 0;
for (i = k = 0, ref = items.length - 1; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
for (j = l = 0, ref1 = result.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
result.push(result[j].concat(items[i]));
}
}
result.shift();
result = result.sort(function (a, b) {
return a.length - b.length;
});
result = result.map(function (item) {
return item.join('');
});
return result;
}
/**
* Generate unique CSS selector for given DOM element
*
* @param {Element} el
* @return {String}
* @api private
*/
function unique(el) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$selectorType = options.selectorTypes,
selectorTypes = _options$selectorType === undefined ? ['ID', 'Class', 'Tag', 'NthChild'] : _options$selectorType,
_options$attributesTo = options.attributesToIgnore,
attributesToIgnore = _options$attributesTo === undefined ? ['id', 'class', 'length'] : _options$attributesTo;
var allSelectors = [];
var parents = getParents(el);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = parents[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var elem = _step2.value;
var selector = getUniqueSelector(elem, selectorTypes, attributesToIgnore);
if (Boolean(selector)) {
allSelectors.push(selector);
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
var selectors = [];
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = allSelectors[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var it = _step3.value;
selectors.unshift(it);
var _selector = selectors.join(' > ');
if (isUnique(el, _selector)) {
return _selector;
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return null;
}
function currentStyles(element) {
return element.currentStyle || window.getComputedStyle(element, null) || {};
}
function currentStyle(element, property) {
var style = currentStyles(element);
return style[property];
}
function outerHTML(element) {
if (element.outerHTML) {
return element.outerHTML;
}
var wrapper = document.createElement('div');
wrapper.appendChild(element.cloneNode(true));
return wrapper.innerHTML;
}
function withAncestors(element) {
var cursor = element,
result = [];
while (cursor) {
result.push(cursor);
cursor = cursor.parentElement;
}
return result;
}
function isAncestor(element1, element2) {
return element1 !== element2 && withAncestors(element2).includes(element1);
}
function elementLabel(element, withClasses) {
var result = element.tagName.toLowerCase();
if (element.id) {
result += "#" + element.id;
}
if (withClasses) {
element.className.split(' ').forEach(function (cls) {
if (cls.trim()) {
result += "." + cls.trim();
}
});
}
return result;
}
var HASH = '#'.charCodeAt(0);
var DOT = '.'.charCodeAt(0);
function createElement(query, ns) {
var tag;
var id;
var className;
var mode = 0;
var start = 0;
for (var i = 0; i <= query.length; i++) {
var char = query.charCodeAt(i);
if (char === HASH || char === DOT || !char) {
if (mode === 0) {
if (i === 0) {
tag = 'div';
} else if (!char) {
tag = query;
} else {
tag = query.substring(start, i);
}
} else {
var slice = query.substring(start, i);
if (mode === 1) {
id = slice;
} else if (className) {
className += ' ' + slice;
} else {
className = slice;
}
}
start = i + 1;
if (char === HASH) {
mode = 1;
} else {
mode = 2;
}
}
}
var element = ns ? document.createElementNS(ns, tag) : document.createElement(tag);
if (id) {
element.id = id;
}
if (className) {
element.className = className;
}
return element;
}
function text(content) {
return document.createTextNode(content);
}
function mount(parent, child, before) {
var parentEl = parent.el || parent;
var childEl = child.el || child;
if (childEl.__redom_list) {
childEl = childEl.el;
}
if (child === childEl && childEl.__redom_view) {
// try to look up the view if not provided
child = childEl.__redom_view;
}
if (child !== childEl) {
childEl.__redom_view = child;
}
if (child.isMounted) {
child.remount && child.remount();
} else {
child.mount && child.mount();
}
if (before) {
parentEl.insertBefore(childEl, before.el || before);
} else {
parentEl.appendChild(childEl);
}
if (child.isMounted) {
child.remounted && child.remounted();
} else {
child.isMounted = true;
child.mounted && child.mounted();
}
}
function unmount(parent, child) {
var parentEl = parent.el || parent;
var childEl = child.el || child;
if (child === childEl && childEl.__redom_view) {
// try to look up the view if not provided
child = childEl.__redom_view;
}
child.unmount && child.unmount();
parentEl.removeChild(childEl);
child.isMounted = false;
child.unmounted && child.unmounted();
}
var elcache = {};
function el(query) {
var arguments$1 = arguments;
var element;
if (typeof query === 'string') {
element = (elcache[query] || (elcache[query] = createElement(query))).cloneNode(false);
} else if (query && query.nodeType) {
element = query.cloneNode(false);
} else {
throw new Error('At least one argument required');
}
var empty = true;
for (var i = 1; i < arguments.length; i++) {
var arg = arguments$1[i];
if (!arg) {
continue;
}
// support middleware
if (typeof arg === 'function') {
arg(element);
} else if (typeof arg === 'string' || typeof arg === 'number') {
if (empty) {
empty = false;
element.textContent = arg;
} else {
element.appendChild(text(arg));
}
} else if (arg.nodeType || arg.el && arg.el.nodeType) {
empty = false;
mount(element, arg);
} else if (arg.length) {
empty = false;
for (var j = 0; j < arg.length; j++) {
mount(element, arg[j]);
}
} else if ((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'object') {
for (var key in arg) {
var value = arg[key];
if (key === 'style') {
if (typeof value === 'string') {
element.setAttribute(key, value);
} else {
for (var cssKey in value) {
element.style[cssKey] = value[cssKey];
}
}
} else if (key in element || typeof value === 'function') {
element[key] = value;
} else {
element.setAttribute(key, value);
}
}
}
}
return element;
}
el.extend = function (query) {
var clone = elcache[query] || (elcache[query] = createElement(query));
return el.bind(this, clone);
};
function setChildren(parent, children) {
var parentEl = parent.el || parent;
var traverse = parentEl.firstChild;
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (!child) {
continue;
}
var childEl = child.el || child;
if (childEl === traverse) {
traverse = traverse.nextSibling;
continue;
}
mount(parent, child, traverse);
}
while (traverse) {
var next = traverse.nextSibling;
unmount(parent, traverse);
traverse = next;
}
}
function list(parent, View, key, initData) {
return new List(parent, View, key, initData);
}
function List(parent, View, key, initData) {
this.__redom_list = true;
this.View = View;
this.key = key;
this.initData = initData;
this.views = [];
this.el = typeof parent === 'string' ? el(parent) : parent;
if (key) {
this.lookup = {};
}
}
List.extend = function (parent, View, key, initData) {
return List.bind(List, parent, View, key, initData);
};
list.extend = List.extend;
List.prototype.update = function (data) {
if (data === void 0) data = [];
var View = this.View;
var key = this.key;
var functionKey = typeof key === 'function';
var initData = this.initData;
var newViews = new Array(data.length);
var oldViews = this.views;
var newLookup = key && {};
var oldLookup = key && this.lookup;
for (var i = 0; i < data.length; i++) {
var item = data[i];
var view = void 0;
if (key) {
var id = functionKey ? key(item) : item[key];
view = newViews[i] = oldLookup[id] || new View(initData, item, i, data);
newLookup[id] = view;
view.__id = id;
} else {
view = newViews[i] = oldViews[i] || new View(initData, item, i, data);
}
var el$$1 = view.el;
if (el$$1.__redom_list) {
el$$1 = el$$1.el;
}
el$$1.__redom_view = view;
view.update && view.update(item, i, data);
}
setChildren(this, newViews);
if (key) {
this.lookup = newLookup;
}
this.views = newViews;
};
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function unwrapExports (x) {
return x && x.__esModule ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var __moduleExports$1 = createCommonjsModule(function (module, exports) {
/**
* @ignore
* base event object for custom and dom event.
* @author yiminghe@gmail.com
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function returnFalse() {
return false;
}
function returnTrue() {
return true;
}
function EventBaseObject() {
this.timeStamp = Date.now();
this.target = undefined;
this.currentTarget = undefined;
}
EventBaseObject.prototype = {
isEventObject: 1,
constructor: EventBaseObject,
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
preventDefault: function preventDefault() {
this.isDefaultPrevented = returnTrue;
},
stopPropagation: function stopPropagation() {
this.isPropagationStopped = returnTrue;
},
stopImmediatePropagation: function stopImmediatePropagation() {
this.isImmediatePropagationStopped = returnTrue;
// fixed 1.2
// call stopPropagation implicitly
this.stopPropagation();
},
halt: function halt(immediate) {
if (immediate) {
this.stopImmediatePropagation();
} else {
this.stopPropagation();
}
this.preventDefault();
}
};
exports["default"] = EventBaseObject;
module.exports = exports["default"];
});
unwrapExports(__moduleExports$1);
/* eslint-disable no-unused-vars */
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (e) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
var __moduleExports$2 = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (Object.getOwnPropertySymbols) {
symbols = Object.getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
var __moduleExports = createCommonjsModule(function (module, exports) {
/**
* @ignore
* event object for dom
* @author yiminghe@gmail.com
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}
var _EventBaseObject = __moduleExports$1;
var _EventBaseObject2 = _interopRequireDefault(_EventBaseObject);
var _objectAssign = __moduleExports$2;
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var TRUE = true;
var FALSE = false;
var commonProps = ['altKey', 'bubbles', 'cancelable', 'ctrlKey', 'currentTarget', 'eventPhase', 'metaKey', 'shiftKey', 'target', 'timeStamp', 'view', 'type'];
function isNullOrUndefined(w) {
return w === null || w === undefined;
}
var eventNormalizers = [{
reg: /^key/,
props: ['char', 'charCode', 'key', 'keyCode', 'which'],
fix: function fix(event, nativeEvent) {
if (isNullOrUndefined(event.which)) {
event.which = !isNullOrUndefined(nativeEvent.charCode) ? nativeEvent.charCode : nativeEvent.keyCode;
}
// add metaKey to non-Mac browsers (use ctrl for PC 's and Meta for Macs)
if (event.metaKey === undefined) {
event.metaKey = event.ctrlKey;
}
}
}, {
reg: /^touch/,
props: ['touches', 'changedTouches', 'targetTouches']
}, {
reg: /^hashchange$/,
props: ['newURL', 'oldURL']
}, {
reg: /^gesturechange$/i,
props: ['rotation', 'scale']
}, {
reg: /^(mousewheel|DOMMouseScroll)$/,
props: [],
fix: function fix(event, nativeEvent) {
var deltaX = undefined;
var deltaY = undefined;
var delta = undefined;
var wheelDelta = nativeEvent.wheelDelta;
var axis = nativeEvent.axis;
var wheelDeltaY = nativeEvent.wheelDeltaY;
var wheelDeltaX = nativeEvent.wheelDeltaX;
var detail = nativeEvent.detail;
// ie/webkit
if (wheelDelta) {
delta = wheelDelta / 120;
}
// gecko
if (detail) {
// press control e.detail == 1 else e.detail == 3
delta = 0 - (detail % 3 === 0 ? detail / 3 : detail);
}
// Gecko
if (axis !== undefined) {
if (axis === event.HORIZONTAL_AXIS) {
deltaY = 0;
deltaX = 0 - delta;
} else if (axis === event.VERTICAL_AXIS) {
deltaX = 0;
deltaY = delta;
}
}
// Webkit
if (wheelDeltaY !== undefined) {
deltaY = wheelDeltaY / 120;
}
if (wheelDeltaX !== undefined) {
deltaX = -1 * wheelDeltaX / 120;
}
// 默认 deltaY (ie)
if (!deltaX && !deltaY) {
deltaY = delta;
}
if (deltaX !== undefined) {
/**
* deltaX of mousewheel event
* @property deltaX
* @member Event.DomEvent.Object
*/
event.deltaX = deltaX;
}
if (deltaY !== undefined) {
/**
* deltaY of mousewheel event
* @property deltaY
* @member Event.DomEvent.Object
*/
event.deltaY = deltaY;
}
if (delta !== undefined) {
/**
* delta of mousewheel event
* @property delta
* @member Event.DomEvent.Object
*/
event.delta = delta;
}
}
}, {
reg: /^mouse|contextmenu|click|mspointer|(^DOMMouseScroll$)/i,
props: ['buttons', 'clientX', 'clientY', 'button', 'offsetX', 'relatedTarget', 'which', 'fromElement', 'toElement', 'offsetY', 'pageX', 'pageY', 'screenX', 'screenY'],
fix: function fix(event, nativeEvent) {
var eventDoc = undefined;
var doc = undefined;
var body = undefined;
var target = event.target;
var button = nativeEvent.button;
// Calculate pageX/Y if missing and clientX/Y available
if (target && isNullOrUndefined(event.pageX) && !isNullOrUndefined(nativeEvent.clientX)) {
eventDoc = target.ownerDocument || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
event.pageX = nativeEvent.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = nativeEvent.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
}
// which for click: 1 === left; 2 === middle; 3 === right
// do not use button
if (!event.which && button !== undefined) {
if (button & 1) {
event.which = 1;
} else if (button & 2) {
event.which = 3;
} else if (button & 4) {
event.which = 2;
} else {
event.which = 0;
}
}
// add relatedTarget, if necessary
if (!event.relatedTarget && event.fromElement) {
event.relatedTarget = event.fromElement === target ? event.toElement : event.fromElement;
}
return event;
}
}];
function retTrue() {
return TRUE;
}
function retFalse() {
return FALSE;
}
function DomEventObject(nativeEvent) {
var type = nativeEvent.type;
var isNative = typeof nativeEvent.stopPropagation === 'function' || typeof nativeEvent.cancelBubble === 'boolean';
_EventBaseObject2['default'].call(this);
this.nativeEvent = nativeEvent;
// in case dom event has been mark as default prevented by lower dom node
var isDefaultPrevented = retFalse;
if ('defaultPrevented' in nativeEvent) {
isDefaultPrevented = nativeEvent.defaultPrevented ? retTrue : retFalse;
} else if ('getPreventDefault' in nativeEvent) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=691151
isDefaultPrevented = nativeEvent.getPreventDefault() ? retTrue : retFalse;
} else if ('returnValue' in nativeEvent) {
isDefaultPrevented = nativeEvent.returnValue === FALSE ? retTrue : retFalse;
}
this.isDefaultPrevented = isDefaultPrevented;
var fixFns = [];
var fixFn = undefined;
var l = undefined;
var prop = undefined;
var props = commonProps.concat();
eventNormalizers.forEach(function (normalizer) {
if (type.match(normalizer.reg)) {
props = props.concat(normalizer.props);
if (normalizer.fix) {
fixFns.push(normalizer.fix);
}
}
});
l = props.length;
// clone properties of the original event object
while (l) {
prop = props[--l];
this[prop] = nativeEvent[prop];
}
// fix target property, if necessary
if (!this.target && isNative) {
this.target = nativeEvent.srcElement || document; // srcElement might not be defined either
}
// check if target is a text node (safari)
if (this.target && this.target.nodeType === 3) {
this.target = this.target.parentNode;
}
l = fixFns.length;
while (l) {
fixFn = fixFns[--l];
fixFn(this, nativeEvent);
}
this.timeStamp = nativeEvent.timeStamp || Date.now();
}
var EventBaseObjectProto = _EventBaseObject2['default'].prototype;
(0, _objectAssign2['default'])(DomEventObject.prototype, EventBaseObjectProto, {
constructor: DomEventObject,
preventDefault: function preventDefault() {
var e = this.nativeEvent;
// if preventDefault exists run it on the original event
if (e.preventDefault) {
e.preventDefault();
} else {
// otherwise set the returnValue property of the original event to FALSE (IE)
e.returnValue = FALSE;
}
EventBaseObjectProto.preventDefault.call(this);
},
stopPropagation: function stopPropagation() {
var e = this.nativeEvent;
// if stopPropagation exists run it on the original event
if (e.stopPropagation) {
e.stopPropagation();
} else {
// otherwise set the cancelBubble property of the original event to TRUE (IE)
e.cancelBubble = TRUE;
}
EventBaseObjectProto.stopPropagation.call(this);
}
});
exports['default'] = DomEventObject;
module.exports = exports['default'];
});
unwrapExports(__moduleExports);
var index = createCommonjsModule(function (module, exports) {
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports['default'] = addEventListener;
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { 'default': obj };
}
var _EventObject = __moduleExports;
var _EventObject2 = _interopRequireDefault(_EventObject);
function addEventListener(target, eventType, callback) {
function wrapCallback(e) {
var ne = new _EventObject2['default'](e);
callback.call(target, ne);
}
if (target.addEventListener) {
target.addEventListener(eventType, wrapCallback, false);
return {
remove: function remove() {
target.removeEventListener(eventType, wrapCallback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, wrapCallback);
return {
remove: function remove() {
target.detachEvent('on' + eventType, wrapCallback);
}
};
}
}
module.exports = exports['default'];
});
var addEventListener = unwrapExports(index);
var __moduleExports$4 = createCommonjsModule(function (module) {
// Generated by CoffeeScript 1.7.1
(function () {
var getNanoSeconds, hrtime, loadTime;
if (typeof performance !== "undefined" && performance !== null && performance.now) {
module.exports = function () {
return performance.now();
};
} else if (typeof process !== "undefined" && process !== null && process.hrtime) {
module.exports = function () {
return (getNanoSeconds() - loadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function getNanoSeconds() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
loadTime = getNanoSeconds();
} else if (Date.now) {
module.exports = function () {
return Date.now() - loadTime;
};
loadTime = Date.now();
} else {
module.exports = function () {
return new Date().getTime() - loadTime;
};
loadTime = new Date().getTime();
}
}).call(commonjsGlobal);
});
var now = __moduleExports$4;
var root = typeof window === 'undefined' ? commonjsGlobal : window;
var vendors = ['moz', 'webkit'];
var suffix = 'AnimationFrame';
var raf = root['request' + suffix];
var caf = root['cancel' + suffix] || root['cancelRequest' + suffix];
for (var i = 0; !raf && i < vendors.length; i++) {
raf = root[vendors[i] + 'Request' + suffix];
caf = root[vendors[i] + 'Cancel' + suffix] || root[vendors[i] + 'CancelRequest' + suffix];
}
// Some versions of FF have rAF but not cAF
if (!raf || !caf) {
var last = 0,
id = 0,
queue = [],
frameDuration = 1000 / 60;
raf = function raf(callback) {
if (queue.length === 0) {
var _now = now(),
next = Math.max(0, frameDuration - (_now - last));
last = next + _now;
setTimeout(function () {
var cp = queue.slice(0);
// Clear queue here to prevent
// callbacks from appending listeners
// to the current frame's queue
queue.length = 0;
for (var i = 0; i < cp.length; i++) {
if (!cp[i].cancelled) {
try {
cp[i].callback(last);
} catch (e) {
setTimeout(function () {
throw e;
}, 0);
}
}
}
}, Math.round(next));
}
queue.push({
handle: ++id,
callback: callback,
cancelled: false
});
return id;
};
caf = function caf(handle) {
for (var i = 0; i < queue.length; i++) {
if (queue[i].handle === handle) {
queue[i].cancelled = true;
}
}
};
}
var __moduleExports$3 = function index(fn) {
// Wrap in a new function to prevent
// `cancel` potentially being assigned
// to the native rAF function
return raf.call(root, fn);
};
var cancel = function cancel() {
caf.apply(root, arguments);
};
var polyfill = function polyfill() {
root.requestAnimationFrame = raf;
root.cancelAnimationFrame = caf;
};
__moduleExports$3.cancel = cancel;
__moduleExports$3.polyfill = polyfill;
var index$1 = createCommonjsModule(function (module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _raf = __moduleExports$3;
var _raf2 = _interopRequireDefault(_raf);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _toConsumableArray(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}return arr2;
} else {
return Array.from(arr);
}
}
var rafThrottle = function rafThrottle(callback) {
var requestId = void 0;
var later = function later(args) {
return function () {
requestId = null;
callback.apply(undefined, _toConsumableArray(args));
};
};
var throttled = function throttled() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (requestId == null) {
requestId = (0, _raf2.default)(later(args));
}
};
throttled.cancel = function () {
return _raf2.default.cancel(requestId);
};
return throttled;
};
exports.default = rafThrottle;
});
var throttle = unwrapExports(index$1);
var cssx = createCommonjsModule(function (module, exports) {
(function webpackUniversalModuleDefinition(root, factory) {
if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object') module.exports = factory();else if (typeof define === 'function' && define.amd) define("cssx", [], factory);else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') exports["cssx"] = factory();else root["cssx"] = factory();
})(commonjsGlobal, function () {
return (/******/function (modules) {
// webpackBootstrap
/******/ // The module cache
/******/var installedModules = {};
/******/
/******/ // The require function
/******/function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/if (installedModules[moduleId])
/******/return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/var module = installedModules[moduleId] = {
/******/exports: {},
/******/id: moduleId,
/******/loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/__webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/__webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/__webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/return __webpack_require__(0);
/******/
}(
/************************************************************************/
/******/[
/* 0 */
/***/function (module, exports, __webpack_require__) {
var factory,
goGlobal,
stylesheets,
api,
randomId,
plugins = [];
__webpack_require__(1);
factory = __webpack_require__(5);
goGlobal = __webpack_require__(15);
randomId = __webpack_require__(16);
stylesheets = [];
function createStyleSheet(id) {
var s, i;
if (typeof id === 'undefined') {
id = randomId();
}
for (i = 0; i < stylesheets.length; i++) {
if (stylesheets[i].id() === id) {
return stylesheets[i];
}
}
s = factory.apply(factory, arguments);
stylesheets.push(s);
return s;
};
api = function api(id) {
return createStyleSheet(id, plugins);
};
api.domChanges = function (flag) {
factory.disableDOMChanges = !flag;
};
api.minify = function (flag) {
factory.minify = flag;
};
api.nextTick = function (flag) {
factory.useNextTick = flag;
};
api.getStylesheets = function () {
return stylesheets;
};
api.clear = function () {
var i;
for (i = 0; i < stylesheets.length; i++) {
stylesheets[i].clear();
}
stylesheets = [];
return api;
};
api.getCSS = function () {
var i,
css = '';
for (i = 0; i < stylesheets.length; i++) {
css += stylesheets[i].getCSS();
}
return css;
};
api.plugins = function (arr) {
plugins = plugins.concat(arr);
};
module.exports = api;
goGlobal(module.exports);
/***/
},
/* 1 */
/***/function (module, exports, __webpack_require__) {
__webpack_require__(2);
__webpack_require__(3);
__webpack_require__(4);
/***/
},
/* 2 */
/***/function (module, exports) {
if (!Array.prototype.filter) {
Array.prototype.filter = function (fun /*, thisArg*/) {
'use strict';
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== 'function') {
throw new TypeError();
}
var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++) {
if (i in t) {
var val = t[i];
// NOTE: Technically this should Object.defineProperty at
// the next index, as push can be affected by
// properties on Object.prototype and Array.prototype.
// But that method's new, and collisions should be
// rare, so use the more-compatible alternative.
if (fun.call(thisArg, val, i, t)) {
res.push(val);
}
}
}
return res;
};
}
/***/
},
/* 3 */
/***/function (module, exports) {
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}
/***/
},
/* 4 */
/***/function (module, exports) {
// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.io/#x15.4.4.19
if (!Array.prototype.map) {
Array.prototype.map = function (callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling ToObject passing the |this|
// value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal
// method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== 'function') {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let A be a new array created as if by the expression new Array(len)
// where Array is the standard built-in constructor with that name and
// len is the value of len.
A = new Array(len);
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while (k < len) {
var kValue, mappedValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal
// method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal
// method of O with argument Pk.
kValue = O[k];
// ii. Let mappedValue be the result of calling the Call internal
// method of callback with T as the this value and argument
// list containing kValue, k, and O.
mappedValue = callback.call(T, kValue, k, O);
// iii. Call the DefineOwnProperty internal method of A with arguments
// Pk, Property Descriptor
// { Value: mappedValue,
// Writable: true,
// Enumerable: true,
// Configurable: true },
// and false.
// In browsers that support Object.defineProperty, use the following:
// Object.defineProperty(A, k, {
// value: mappedValue,
// writable: true,
// enumerable: true,
// configurable: true
// });
// For best browser support, use the following:
A[k] = mappedValue;
}
// d. Increase k by 1.
k++;
}
// 9. return A
return A;
};
}
/***/
},
/* 5 */
/***/function (module, exports, __webpack_require__) {
var CSSRule = __webpack_require__(6);
var applyToDOM = __webpack_require__(8);
var nextTick = __webpack_require__(9);
var generate = __webpack_require__(13);
var isArray = __webpack_require__(7);
var ids = 0;
var getId = function getId() {
return 'x' + ++ids;
};
module.exports = function (id, plugins) {
var _id = id || getId();
var _api = {};
var _rules = [];
var _customProperties = {};
var _remove = null;
var _css = '';
var _scope = '';
var ruleExists = function ruleExists(rules, selector, parent) {
return rules.reduce(function (result, rule) {
if (result !== false) return result;
if (rule.selector === selector) {
if (parent) {
return rule.parent && parent.selector === rule.parent.selector ? rule : false;
}
return rule;
}
return false;
}, false);
};
var registerRule = function registerRule(rule, addAt) {
if (typeof addAt !== 'undefined') {
_rules.splice(addAt, 0, rule);
} else {
_rules.push(rule);
}
rule.index = _rules.length - 1;
};
var isNested = function isNested(obj) {
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
return true;
} else if (isArray(obj)) {
return typeof obj[0] === 'string';
}
return false;
};
_api.id = function () {
return _id;
};
_api.add = _api.update = function (rawRules, parent, addAt, considerAsNew) {
var rule, prop, tmpRawRules, cssProps, props, nestedRules, selector, tmp;
var created = [];
if (typeof rawRules === 'string') {
tmp = {};
tmp[rawRules] = {};
rawRules = tmp;
}
if (typeof rawRules === 'function') {
rawRules = rawRules();
}
for (selector in rawRules) {
if (isArray(rawRules[selector])) {
rawRules[selector].forEach(function (r) {
tmp = {};
tmp[selector] = r;
_api.add(tmp, parent, undefined, true);
});
} else {
rule = ruleExists(_rules, selector, parent);
cssProps = {};
props = {};
nestedRules = [];
// new rule
if (considerAsNew || !rule) {
props = rawRules[selector];
for (prop in props) {
if (isNested(props[prop])) {
cssProps[prop] = props[prop];
} else {
tmpRawRules = {};
tmpRawRules[prop] = props[prop];
nestedRules.push(tmpRawRules);
}
}
rule = CSSRule(selector, this.resolveCustomProps(cssProps), _api);
if (!parent) {
registerRule(rule, addAt);
} else {
rule.parent = parent;
parent.registerNested(rule);
}
nestedRules.forEach(function (rawRulesNested) {
_api.add(rawRulesNested, rule);
});
// existing rule
} else {
rule.update(rawRules[selector]);
}
this.compile();
created.push(rule);
}
}
return created.length === 1 ? created[0] : created;
};
_api.rules = function () {
return _rules;
};
_api.compile = function () {
if (module.exports.useNextTick) {
nextTick(function () {
_api.compileImmediate();
}, _id);
return _api;
}
return _api.compileImmediate();
};
_api.compileImmediate = function () {
_css = generate(_rules, module.exports.minify, plugins, _scope);
if (!module.exports.disableDOMChanges) {
_remove = applyToDOM(_css, _id);
}
return _api;
};
_api.clear = function () {
_rules = [];
_css = '';
if (_remove !== null) {
_remove();
_remove = null;
}
return _api;
};
_api.destroy = function () {
return _api.clear();
};
_api.getCSS = function () {
this.compileImmediate();
return _css;
};
_api.define = function (prop, func) {
_customProperties[prop] = func;
};
_api.scope = function (scope) {
_scope = scope;
};
_api._getCustomProps = function () {
return _customProperties;
};
_api.resolveCustomProps = function (actual) {
var result = actual,
prop,
newProp,
value;
var custom = _customProperties;
for (prop in custom) {
if (typeof actual[prop] !== 'undefined') {
value = custom[prop](actual[prop]);
delete actual[prop];
for (newProp in value) {
actual[newProp] = value[newProp];
}
}
}
return result;
};
return _api;
};
module.exports.disableDOMChanges = false;
module.exports.minify = true;
module.exports.useNextTick = true;
/***/
},
/* 6 */
/***/function (module, exports, __webpack_require__) {
var isArray = __webpack_require__(7);
module.exports = function CSSRule(selector, props, stylesheet) {
var _api = {
selector: selector,
props: props,
stylesheet: stylesheet,
index: null,
nestedRules: null,
parent: null
};
_api.clone = function () {
var rule = CSSRule(this.selector, this.props, this.stylesheet);
rule.index = this.index;
rule.nestedRules = this.nestedRules;
rule.parent = this.parent;
return rule;
};
_api.descendant = _api.d = function (rawRules) {
var selector;
if (typeof rawRules === 'function') rawRules = rawRules();
for (selector in rawRules) {
rawRules[_api.selector + ' ' + selector] = rawRules[selector];
delete rawRules[selector];
}
return _api.stylesheet.add(rawRules, this.parent, this.index);
};
_api.nested = _api.n = function (rawRules) {
return _api.stylesheet.add(rawRules, this);
};
_api.update = function (props) {
var prop,
areThereNestedRules = this.nestedRules !== null;
if (typeof props === 'function') {
props = props();
}
props = this.stylesheet.resolveCustomProps(props);
for (prop in props) {
if (_typeof(props[prop]) !== 'object') {
this.props[prop] = props[prop];
} else if (areThereNestedRules) {
if (this.nestedRules[prop]) {
this.nestedRules[prop].update(props[prop]);
}
}
}
return this;
};
_api.registerNested = function (rule) {
var nestedRule;
if (this.nestedRules === null) this.nestedRules = {};
nestedRule = this.nestedRules[rule.selector];
if (nestedRule) {
if (isArray(nestedRule)) {
nestedRule.push(rule);
} else {
this.nestedRules[rule.selector] = [nestedRule, rule];
}
} else {
this.nestedRules[rule.selector] = rule;
}
return this;
};
return _api;
};
/***/
},
/* 7 */
/***/function (module, exports) {
module.exports = function (v) {
return Object.prototype.toString.call(v) === '[object Array]';
};
/***/
},
/* 8 */
/***/function (module, exports) {
var cache = {};
var qs = function qs(selector) {
return document.querySelector(selector);
};
var createNode = function createNode(type, attrs, content) {
var node = document.createElement(type),
i,
a;
for (i = 0; i < attrs.length; i++) {
a = attrs[i];
node.setAttribute(a.name, a.value);
}
node.innerHTML = content;
(qs('head') || qs('body')).appendChild(node);
return node;
};
var remove = function remove(id) {
return function () {
if (cache[id]) {
cache[id].el.parentNode.removeChild(cache[id].el);
delete cache[id];
}
};
};
module.exports = function (css, id) {
var el;
if (!cache[id]) {
el = createNode('style', [{ name: 'id', value: id }, { name: 'type', value: 'text/css' }], css);
cache[id] = { el: el, css: css, remove: remove(id) };
} else {
if (cache[id].css !== css) {
cache[id].css = css;
cache[id].el.innerHTML = css;
}
}
return cache[id].remove;
};
/***/
},
/* 9 */
/***/function (module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function (setImmediate) {
var cache = {};
__webpack_require__(12);
module.exports = function (work, id) {
if (!cache[id]) {
cache[id] = work;
setImmediate(function () {
delete cache[id];
work();
});
}
};
/* WEBPACK VAR INJECTION */
}).call(exports, __webpack_require__(10).setImmediate);
/***/
},
/* 10 */
/***/function (module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function (setImmediate, clearImmediate) {
var nextTick = __webpack_require__(11).nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;
var immediateIds = {};
var nextImmediateId = 0;
// DOM APIs, for completeness
exports.setTimeout = function () {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
};
exports.setInterval = function () {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
};
exports.clearTimeout = exports.clearInterval = function (timeout) {
timeout.close();
};
function Timeout(id, clearFn) {
this._id = id;
this._clearFn = clearFn;
}
Timeout.prototype.unref = Timeout.prototype.ref = function () {};
Timeout.prototype.close = function () {
this._clearFn.call(window, this._id);
};
// Does not start the time, just sets up the members needed.
exports.enroll = function (item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
};
exports.unenroll = function (item) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = -1;
};
exports._unrefActive = exports.active = function (item) {
clearTimeout(item._idleTimeoutId);
var msecs = item._idleTimeout;
if (msecs >= 0) {
item._idleTimeoutId = setTimeout(function onTimeout() {
if (item._onTimeout) item._onTimeout();
}, msecs);
}
};
// That's not how node.js implements it but the exposed api is the same.
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
var id = nextImmediateId++;
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
immediateIds[id] = true;
nextTick(function onNextTick() {
if (immediateIds[id]) {
// fn.call() is faster so we optimize for the common use-case
// @see http://jsperf.com/call-apply-segu
if (args) {
fn.apply(null, args);
} else {
fn.call(null);
}
// Prevent ids from leaking
exports.clearImmediate(id);
}
});
return id;
};
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
delete immediateIds[id];
};
/* WEBPACK VAR INJECTION */
}).call(exports, __webpack_require__(10).setImmediate, __webpack_require__(10).clearImmediate);
/***/
},
/* 11 */
/***/function (module, exports) {
// shim for using process in browser
var process = module.exports = {};
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = setTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
clearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
setTimeout(drainQueue, 0);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () {
return '/';
};
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function () {
return 0;
};
/***/
},
/* 12 */
/***/function (module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function (global, clearImmediate, process) {
(function (global, undefined) {
"use strict";
if (global.setImmediate) {
return;
}
var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};
var currentlyRunningATask = false;
var doc = global.document;
var setImmediate;
function addFromSetImmediateArguments(args) {
tasksByHandle[nextHandle] = partiallyApplied.apply(undefined, args);
return nextHandle++;
}
// This function accepts the same arguments as setImmediate, but
// returns a function that requires no arguments.
function partiallyApplied(handler) {
var args = [].slice.call(arguments, 1);
return function () {
if (typeof handler === "function") {
handler.apply(undefined, args);
} else {
new Function("" + handler)();
}
};
}
function runIfPresent(handle) {
// From the spec: "Wait until any invocations of this algorithm started before this one have completed."
// So if we're currently running a task, we'll need to delay this invocation.
if (currentlyRunningATask) {
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// "too much recursion" error.
setTimeout(partiallyApplied(runIfPresent, handle), 0);
} else {
var task = tasksByHandle[handle];
if (task) {
currentlyRunningATask = true;
try {
task();
} finally {
clearImmediate(handle);
currentlyRunningATask = false;
}
}
}
}
function clearImmediate(handle) {
delete tasksByHandle[handle];
}
function installNextTickImplementation() {
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
process.nextTick(partiallyApplied(runIfPresent, handle));
return handle;
};
}
function canUsePostMessage() {
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
// where `global.postMessage` means something completely different and can't be used for this purpose.
if (global.postMessage && !global.importScripts) {
var postMessageIsAsynchronous = true;
var oldOnMessage = global.onmessage;
global.onmessage = function () {
postMessageIsAsynchronous = false;
};
global.postMessage("", "*");
global.onmessage = oldOnMessage;
return postMessageIsAsynchronous;
}
}
function installPostMessageImplementation() {
// Installs an event handler on `global` for the `message` event: see
// * https://developer.mozilla.org/en/DOM/window.postMessage
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
var messagePrefix = "setImmediate$" + Math.random() + "$";
var onGlobalMessage = function onGlobalMessage(event) {
if (event.source === global && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) {
runIfPresent(+event.data.slice(messagePrefix.length));
}
};
if (global.addEventListener) {
global.addEventListener("message", onGlobalMessage, false);
} else {
global.attachEvent("onmessage", onGlobalMessage);
}
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
global.postMessage(messagePrefix + handle, "*");
return handle;
};
}
function installMessageChannelImplementation() {
var channel = new MessageChannel();
channel.port1.onmessage = function (event) {
var handle = event.data;
runIfPresent(handle);
};
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
channel.port2.postMessage(handle);
return handle;
};
}
function installReadyStateChangeImplementation() {
var html = doc.documentElement;
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
var script = doc.createElement("script");
script.onreadystatechange = function () {
runIfPresent(handle);
script.onreadystatechange = null;
html.removeChild(script);
script = null;
};
html.appendChild(script);
return handle;
};
}
function installSetTimeoutImplementation() {
setImmediate = function setImmediate() {
var handle = addFromSetImmediateArguments(arguments);
setTimeout(partiallyApplied(runIfPresent, handle), 0);
return handle;
};
}
// If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
// Don't get fooled by e.g. browserify environments.
if ({}.toString.call(global.process) === "[object process]") {
// For Node.js before 0.9
installNextTickImplementation();
} else if (canUsePostMessage()) {
// For non-IE10 modern browsers
installPostMessageImplementation();
} else if (global.MessageChannel) {
// For web workers, where supported
installMessageChannelImplementation();
} else if (doc && "onreadystatechange" in doc.createElement("script")) {
// For IE 6–8
installReadyStateChangeImplementation();
} else {
// For older browsers
installSetTimeoutImplementation();
}
attachTo.setImmediate = setImmediate;
attachTo.clearImmediate = clearImmediate;
})(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self);
/* WEBPACK VAR INJECTION */
}).call(exports, function () {
return this;
}(), __webpack_require__(10).clearImmediate, __webpack_require__(11));
/***/
},
/* 13 */
/***/function (module, exports, __webpack_require__) {
var isEmpty = __webpack_require__(14);
var isArray = __webpack_require__(7);
module.exports = function (topRules, minify, plugins, scope) {
var scopeTheSelector = function scopeTheSelector(selector) {
if (scope === '') return selector;
if (selector.indexOf(scope) === 0 || selector.indexOf('@') === 0) return selector;
return scope + ' ' + selector;
};
var applyPlugins = function applyPlugins(props) {
var n;
for (n = 0; n < plugins.length; n++) {
props = plugins[n](props);
}
return props;
};
var newLine = minify ? '' : '\n';
var interval = minify ? '' : ' ';
var tab = minify ? '' : ' ';
var process = function process(rules, indent) {
var css = '',
r,
prop,
props,
value;
var addLine = function addLine(line, noNewLine) {
css += line + (noNewLine ? '' : newLine);
};
var processRule = function processRule(rule) {
// console.log(rule);
if (!isEmpty(rule.props) || rule.nestedRules !== null) {
addLine(indent + scopeTheSelector(rule.selector) + interval + '{');
props = applyPlugins(rule.props);
for (prop in props) {
value = typeof props[prop] === 'function' ? props[prop]() : props[prop];
if (isArray(value)) {
value.forEach(function (v) {
addLine(indent + tab + prop + ':' + interval + v + ';');
});
} else {
addLine(indent + tab + prop + ':' + interval + value + ';');
}
}
if (rule.nestedRules) {
addLine(process(rule.nestedRules, indent + tab), true);
}
addLine(indent + '}');
}
};
indent = minify ? '' : indent;
if (isArray(rules)) {
rules.forEach(processRule);
} else {
for (r in rules) {
if (isArray(rules[r])) {
rules[r].forEach(processRule);
} else {
processRule(rules[r]);
}
}
};
return css;
};
return process(topRules, '');
};
/***/
},
/* 14 */
/***/function (module, exports) {
module.exports = function (obj) {
var prop;
for (prop in obj) {
if (obj.hasOwnProperty(prop)) {
return false;
}
}
return true;
};
/***/
},
/* 15 */
/***/function (module, exports) {
/* WEBPACK VAR INJECTION */(function (global) {
module.exports = function (api) {
if (typeof global !== 'undefined') {
global.cssx = api;
}
if (typeof window !== 'undefined') {
window.cssx = api;
}
};
/* WEBPACK VAR INJECTION */
}).call(exports, function () {
return this;
}());
/***/
},
/* 16 */
/***/function (module, exports) {
var ids = 0;
module.exports = function () {
return '_cssx' + ++ids;
};
module.exports.resetIDs = function () {
ids = 0;
};
/***/
}
/******/])
);
});
;
});
function makeInvisible(element) {
var oldVisibility = element.style.visibility,
oldTransition = element.style.transition;
element.style.transition = "none";
element.style.visibility = "hidden";
return function () {
element.style.visibility = oldVisibility;
/* force layout reflow to apply old visibility */
currentStyle(element, 'visibility');
element.style.transition = oldTransition;
};
}
function elementQualified(element) {
var styles = currentStyles(element);
return (/(block|flex|grid)$/.test(styles.display) && (!styles.transform || styles.transform === "none")
);
}
function fromPoint (x, y) {
var undo = [],
element,
last;
while ((element = document.elementFromPoint(x, y)) !== null && last !== element) {
if (withAncestors(element).every(elementQualified)) {
break;
}
undo.unshift(makeInvisible(element));
last = element;
}
undo.forEach(function (fn) {
return fn();
});
if (last === element || element === document.documentElement) {
return null;
}
return element;
}
function edgeDistance (element, x, y) {
var bounds = element.getBoundingClientRect();
return {
left: x - bounds.left,
top: y - bounds.top,
right: bounds.right - x,
bottom: bounds.bottom - y
};
}
function pointerEvents (point, select) {
var handlers = [];
var lastMousePos = void 0,
lastTouchPos = void 0,
lastTouchId = void 0;
function mouse(fn) {
return function (e) {
lastMousePos = [e.clientX, e.clientY];
fn.apply(undefined, toConsumableArray(lastMousePos));
};
}
function touch(fn, isStart) {
return function (e) {
var touch = void 0;
lastMousePos = null;
if (isStart) {
if (e.touches.length > 1) {
return;
}
touch = e.touches[0];
lastTouchId = touch.identifier;
} else {
for (var i = 0; i < e.changedTouches.length; ++i) {
if (e.changedTouches[i].identifier === lastTouchId) {
touch = e.changedTouches[i];
}
}
if (!touch) {
return;
}
}
lastTouchPos = [touch.clientX, touch.clientY];
fn.apply(undefined, toConsumableArray(lastTouchPos));
};
}
function click(e) {
if (lastMousePos) {
lastMousePos = [e.clientX, e.clientY];
select.apply(undefined, toConsumableArray(lastMousePos));
} else if (lastTouchPos) {
select.apply(undefined, toConsumableArray(lastTouchPos));
}
}
function pageScroll() {
if (lastMousePos) {
point.apply(undefined, toConsumableArray(lastMousePos));
}
}
var elem = document.documentElement;
handlers.push(addEventListener(elem, 'mousemove', mouse(point)));
handlers.push(addEventListener(elem, 'click', click));
handlers.push(addEventListener(elem, 'touchstart', touch(point, true)));
handlers.push(addEventListener(elem, 'touchmove', touch(point)));
handlers.push(addEventListener(elem, 'touchend', touch(point)));
handlers.push(addEventListener(elem, 'scroll', pageScroll));
return function () {
handlers.forEach(function (handler) {
handler.remove();
});
};
}
var __moduleExports$5 = createCommonjsModule(function (module) {
'use strict';
/* !
* type-detect
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
* MIT Licensed
*/
var getPrototypeOfExists = typeof Object.getPrototypeOf === 'function';
var promiseExists = typeof Promise === 'function';
var globalObject = typeof window !== 'undefined' ? window : typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : self; // eslint-disable-line
var isDom = 'location' in globalObject && 'document' in globalObject;
var htmlElementExists = typeof HTMLElement !== 'undefined';
var isArrayExists = typeof Array.isArray === 'function';
var symbolExists = typeof Symbol !== 'undefined';
var mapExists = typeof Map !== 'undefined';
var setExists = typeof Set !== 'undefined';
var weakMapExists = typeof WeakMap !== 'undefined';
var weakSetExists = typeof WeakSet !== 'undefined';
var dataViewExists = typeof DataView !== 'undefined';
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
var setIteratorPrototype = getPrototypeOfExists && setEntriesExists && Object.getPrototypeOf(new Set().entries());
var mapIteratorPrototype = getPrototypeOfExists && mapEntriesExists && Object.getPrototypeOf(new Map().entries());
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
var stringIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
var toStringLeftSliceLength = 8;
var toStringRightSliceLength = -1;
/**
* ### typeOf (obj)
*
* Uses `Object.prototype.toString` to determine the type of an object,
* normalising behaviour across engine versions & well optimised.
*
* @param {Mixed} object
* @return {String} object type
* @api public
*/
module.exports = function typeDetect(obj) {
/* ! Speed optimisation
* Pre:
* string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
* boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
* number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
* undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
* function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
* Post:
* string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
* boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
* number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
* undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
* function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
*/
var typeofObj = typeof obj === 'undefined' ? 'undefined' : _typeof(obj);
if (typeofObj !== 'object') {
return typeofObj;
}
/* ! Speed optimisation
* Pre:
* null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
* Post:
* null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
*/
if (obj === null) {
return 'null';
}
/* ! Spec Conformance
* Test: `Object.prototype.toString.call(window)``
* - Node === "[object global]"
* - Chrome === "[object global]"
* - Firefox === "[object Window]"
* - PhantomJS === "[object Window]"
* - Safari === "[object Window]"
* - IE 11 === "[object Window]"
* - IE Edge === "[object Window]"
* Test: `Object.prototype.toString.call(this)``
* - Chrome Worker === "[object global]"
* - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
* - Safari Worker === "[object DedicatedWorkerGlobalScope]"
* - IE 11 Worker === "[object WorkerGlobalScope]"
* - IE Edge Worker === "[object WorkerGlobalScope]"
*/
if (obj === globalObject) {
return 'global';
}
/* ! Speed optimisation
* Pre:
* array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
* Post:
* array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
*/
if (isArrayExists && Array.isArray(obj)) {
return 'Array';
}
if (isDom) {
/* ! Spec Conformance
* (https://html.spec.whatwg.org/multipage/browsers.html#location)
* WhatWG HTML$7.7.3 - The `Location` interface
* Test: `Object.prototype.toString.call(window.location)``
* - IE <=11 === "[object Object]"
* - IE Edge <=13 === "[object Object]"
*/
if (obj === globalObject.location) {
return 'Location';
}
/* ! Spec Conformance
* (https://html.spec.whatwg.org/#document)
* WhatWG HTML$3.1.1 - The `Document` object
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
* which suggests that browsers should use HTMLTableCellElement for
* both TD and TH elements. WhatWG separates these.
* WhatWG HTML states:
* > For historical reasons, Window objects must also have a
* > writable, configurable, non-enumerable property named
* > HTMLDocument whose value is the Document interface object.
* Test: `Object.prototype.toString.call(document)``
* - Chrome === "[object HTMLDocument]"
* - Firefox === "[object HTMLDocument]"
* - Safari === "[object HTMLDocument]"
* - IE <=10 === "[object Document]"
* - IE 11 === "[object HTMLDocument]"
* - IE Edge <=13 === "[object HTMLDocument]"
*/
if (obj === globalObject.document) {
return 'Document';
}
/* ! Spec Conformance
* (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
* WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
* Test: `Object.prototype.toString.call(navigator.mimeTypes)``
* - IE <=10 === "[object MSMimeTypesCollection]"
*/
if (obj === (globalObject.navigator || {}).mimeTypes) {
return 'MimeTypeArray';
}
/* ! Spec Conformance
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
* WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
* Test: `Object.prototype.toString.call(navigator.plugins)``
* - IE <=10 === "[object MSPluginsCollection]"
*/
if (obj === (globalObject.navigator || {}).plugins) {
return 'PluginArray';
}
/* ! Spec Conformance
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
* WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
* - IE <=10 === "[object HTMLBlockElement]"
*/
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'BLOCKQUOTE') {
return 'HTMLQuoteElement';
}
/* ! Spec Conformance
* (https://html.spec.whatwg.org/#htmltabledatacellelement)
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
* which suggests that browsers should use HTMLTableCellElement for
* both TD and TH elements. WhatWG separates these.
* Test: Object.prototype.toString.call(document.createElement('td'))
* - Chrome === "[object HTMLTableCellElement]"
* - Firefox === "[object HTMLTableCellElement]"
* - Safari === "[object HTMLTableCellElement]"
*/
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'TD') {
return 'HTMLTableDataCellElement';
}
/* ! Spec Conformance
* (https://html.spec.whatwg.org/#htmltableheadercellelement)
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
* which suggests that browsers should use HTMLTableCellElement for
* both TD and TH elements. WhatWG separates these.
* Test: Object.prototype.toString.call(document.createElement('th'))
* - Chrome === "[object HTMLTableCellElement]"
* - Firefox === "[object HTMLTableCellElement]"
* - Safari === "[object HTMLTableCellElement]"
*/
if (htmlElementExists && obj instanceof HTMLElement && obj.tagName === 'TH') {
return 'HTMLTableHeaderCellElement';
}
}
/* ! Speed optimisation
* Pre:
* Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
* Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
* Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
* Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
* Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
* Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
* Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
* Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
* Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
* Post:
* Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
* Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
* Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
* Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
* Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
* Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
* Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
* Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
* Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
*/
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
if (typeof stringTag === 'string') {
return stringTag;
}
if (getPrototypeOfExists) {
var objPrototype = Object.getPrototypeOf(obj);
/* ! Speed optimisation
* Pre:
* regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
* regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
* Post:
* regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
* regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
*/
if (objPrototype === RegExp.prototype) {
return 'RegExp';
}
/* ! Speed optimisation
* Pre:
* date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
* Post:
* date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
*/
if (objPrototype === Date.prototype) {
return 'Date';
}
/* ! Spec Conformance
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
* ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
* Test: `Object.prototype.toString.call(Promise.resolve())``
* - Chrome <=47 === "[object Object]"
* - Edge <=20 === "[object Object]"
* - Firefox 29-Latest === "[object Promise]"
* - Safari 7.1-Latest === "[object Promise]"
*/
if (promiseExists && objPrototype === Promise.prototype) {
return 'Promise';
}
/* ! Speed optimisation
* Pre:
* set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
* Post:
* set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
*/
if (setExists && objPrototype === Set.prototype) {
return 'Set';
}
/* ! Speed optimisation
* Pre:
* map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
* Post:
* map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
*/
if (mapExists && objPrototype === Map.prototype) {
return 'Map';
}
/* ! Speed optimisation
* Pre:
* weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
* Post:
* weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
*/
if (weakSetExists && objPrototype === WeakSet.prototype) {
return 'WeakSet';
}
/* ! Speed optimisation
* Pre:
* weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
* Post:
* weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
*/
if (weakMapExists && objPrototype === WeakMap.prototype) {
return 'WeakMap';
}
/* ! Spec Conformance
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
* ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
* Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
* - Edge <=13 === "[object Object]"
*/
if (dataViewExists && objPrototype === DataView.prototype) {
return 'DataView';
}
/* ! Spec Conformance
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
* ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
* Test: `Object.prototype.toString.call(new Map().entries())``
* - Edge <=13 === "[object Object]"
*/
if (mapExists && objPrototype === mapIteratorPrototype) {
return 'Map Iterator';
}
/* ! Spec Conformance
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
* ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
* Test: `Object.prototype.toString.call(new Set().entries())``
* - Edge <=13 === "[object Object]"
*/
if (setExists && objPrototype === setIteratorPrototype) {
return 'Set Iterator';
}
/* ! Spec Conformance
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
* ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
* Test: `Object.prototype.toString.call([][Symbol.iterator]())``
* - Edge <=13 === "[object Object]"
*/
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
return 'Array Iterator';
}
/* ! Spec Conformance
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
* ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
* Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
* - Edge <=13 === "[object Object]"
*/
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
return 'String Iterator';
}
/* ! Speed optimisation
* Pre:
* object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
* Post:
* object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
*/
if (objPrototype === null) {
return 'Object';
}
}
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
};
module.exports.typeDetect = module.exports;
});
/* globals Symbol: true, Uint8Array: true, WeakMap: true */
/*!
* deep-eql
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/*!
* Module dependencies
*/
var type = __moduleExports$5;
function FakeMap() {
this.clear();
}
FakeMap.prototype = {
clear: function clearMap() {
this.keys = [];
this.values = [];
return this;
},
set: function setMap(key, value) {
var index = this.keys.indexOf(key);
if (index >= 0) {
this.values[index] = value;
} else {
this.keys.push(key);
this.values.push(value);
}
return this;
},
get: function getMap(key) {
return this.values[this.keys.indexOf(key)];
},
delete: function deleteMap(key) {
var index = this.keys.indexOf(key);
if (index >= 0) {
this.values = this.values.slice(0, index).concat(this.values.slice(index + 1));
this.keys = this.keys.slice(0, index).concat(this.keys.slice(index + 1));
}
return this;
}
};
var MemoizeMap = null;
if (typeof WeakMap === 'function') {
MemoizeMap = WeakMap;
} else {
MemoizeMap = FakeMap;
}
/*!
* Check to see if the MemoizeMap has recorded a result of the two operands
*
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @param {MemoizeMap} memoizeMap
* @returns {Boolean|null} result
*/
function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
// Technically, WeakMap keys can *only* be objects, not primitives.
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
return null;
}
var leftHandMap = memoizeMap.get(leftHandOperand);
if (leftHandMap) {
var result = leftHandMap.get(rightHandOperand);
if (typeof result === 'boolean') {
return result;
}
}
return null;
}
/*!
* Set the result of the equality into the MemoizeMap
*
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @param {MemoizeMap} memoizeMap
* @param {Boolean} result
*/
function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
// Technically, WeakMap keys can *only* be objects, not primitives.
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
return;
}
var leftHandMap = memoizeMap.get(leftHandOperand);
if (leftHandMap) {
leftHandMap.set(rightHandOperand, result);
} else {
leftHandMap = new MemoizeMap();
leftHandMap.set(rightHandOperand, result);
memoizeMap.set(leftHandOperand, leftHandMap);
}
}
/*!
* Primary Export
*/
var index$2 = deepEqual;
var MemoizeMap_1 = MemoizeMap;
/**
* Assert deeply nested sameValue equality between two objects of any type.
*
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @param {Object} [options] (optional) Additional options
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
references to blow the stack.
* @return {Boolean} equal match
*/
function deepEqual(leftHandOperand, rightHandOperand, options) {
// If we have a comparator, we can't assume anything; so bail to its check first.
if (options && options.comparator) {
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
}
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
if (simpleResult !== null) {
return simpleResult;
}
// Deeper comparisons are pushed through to a larger function
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
}
/**
* Many comparisons can be canceled out early via simple equality or primitive checks.
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @return {Boolean|null} equal match
*/
function simpleEqual(leftHandOperand, rightHandOperand) {
// Equal references (except for Numbers) can be returned early
if (leftHandOperand === rightHandOperand) {
// Handle +-0 cases
return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
}
// handle NaN cases
if (leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare
rightHandOperand !== rightHandOperand // eslint-disable-line no-self-compare
) {
return true;
}
// Anything that is not an 'object', i.e. symbols, functions, booleans, numbers,
// strings, and undefined, can be compared by reference.
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
// Easy out b/c it would have passed the first equality check
return false;
}
return null;
}
/*!
* The main logic of the `deepEqual` function.
*
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @param {Object} [options] (optional) Additional options
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
references to blow the stack.
* @return {Boolean} equal match
*/
function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
options = options || {};
options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
var comparator = options && options.comparator;
// Check if a memoized result exists.
var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
if (memoizeResultLeft !== null) {
return memoizeResultLeft;
}
var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
if (memoizeResultRight !== null) {
return memoizeResultRight;
}
// If a comparator is present, use it.
if (comparator) {
var comparatorResult = comparator(leftHandOperand, rightHandOperand);
// Comparators may return null, in which case we want to go back to default behavior.
if (comparatorResult === false || comparatorResult === true) {
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
return comparatorResult;
}
// To allow comparators to override *any* behavior, we ran them first. Since it didn't decide
// what to do, we need to make sure to return the basic tests first before we move on.
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
if (simpleResult !== null) {
// Don't memoize this, it takes longer to set/retrieve than to just compare.
return simpleResult;
}
}
var leftHandType = type(leftHandOperand);
if (leftHandType !== type(rightHandOperand)) {
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
return false;
}
// Temporarily set the operands in the memoize object to prevent blowing the stack
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
return result;
}
function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
switch (leftHandType) {
case 'String':
case 'Number':
case 'Boolean':
case 'Date':
// If these types are their instance types (e.g. `new Number`) then re-deepEqual against their values
return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
case 'Promise':
case 'Symbol':
case 'function':
case 'WeakMap':
case 'WeakSet':
case 'Error':
return leftHandOperand === rightHandOperand;
case 'Arguments':
case 'Int8Array':
case 'Uint8Array':
case 'Uint8ClampedArray':
case 'Int16Array':
case 'Uint16Array':
case 'Int32Array':
case 'Uint32Array':
case 'Float32Array':
case 'Float64Array':
case 'Array':
return iterableEqual(leftHandOperand, rightHandOperand, options);
case 'RegExp':
return regexpEqual(leftHandOperand, rightHandOperand);
case 'Generator':
return generatorEqual(leftHandOperand, rightHandOperand, options);
case 'DataView':
return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
case 'ArrayBuffer':
return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
case 'Set':
return entriesEqual(leftHandOperand, rightHandOperand, options);
case 'Map':
return entriesEqual(leftHandOperand, rightHandOperand, options);
default:
return objectEqual(leftHandOperand, rightHandOperand, options);
}
}
/*!
* Compare two Regular Expressions for equality.
*
* @param {RegExp} leftHandOperand
* @param {RegExp} rightHandOperand
* @return {Boolean} result
*/
function regexpEqual(leftHandOperand, rightHandOperand) {
return leftHandOperand.toString() === rightHandOperand.toString();
}
/*!
* Compare two Sets/Maps for equality. Faster than other equality functions.
*
* @param {Set} leftHandOperand
* @param {Set} rightHandOperand
* @param {Object} [options] (Optional)
* @return {Boolean} result
*/
function entriesEqual(leftHandOperand, rightHandOperand, options) {
// IE11 doesn't support Set#entries or Set#@@iterator, so we need manually populate using Set#forEach
if (leftHandOperand.size !== rightHandOperand.size) {
return false;
}
if (leftHandOperand.size === 0) {
return true;
}
var leftHandItems = [];
var rightHandItems = [];
leftHandOperand.forEach(function gatherEntries(key, value) {
leftHandItems.push([key, value]);
});
rightHandOperand.forEach(function gatherEntries(key, value) {
rightHandItems.push([key, value]);
});
return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
}
/*!
* Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
*
* @param {Iterable} leftHandOperand
* @param {Iterable} rightHandOperand
* @param {Object} [options] (Optional)
* @return {Boolean} result
*/
function iterableEqual(leftHandOperand, rightHandOperand, options) {
var length = leftHandOperand.length;
if (length !== rightHandOperand.length) {
return false;
}
if (length === 0) {
return true;
}
var index = -1;
while (++index < length) {
if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
return false;
}
}
return true;
}
/*!
* Simple equality for generator objects such as those returned by generator functions.
*
* @param {Iterable} leftHandOperand
* @param {Iterable} rightHandOperand
* @param {Object} [options] (Optional)
* @return {Boolean} result
*/
function generatorEqual(leftHandOperand, rightHandOperand, options) {
return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
}
/*!
* Determine if the given object has an @@iterator function.
*
* @param {Object} target
* @return {Boolean} `true` if the object has an @@iterator function.
*/
function hasIteratorFunction(target) {
return typeof Symbol !== 'undefined' && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && typeof Symbol.iterator !== 'undefined' && typeof target[Symbol.iterator] === 'function';
}
/*!
* Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
* This will consume the iterator - which could have side effects depending on the @@iterator implementation.
*
* @param {Object} target
* @returns {Array} an array of entries from the @@iterator function
*/
function getIteratorEntries(target) {
if (hasIteratorFunction(target)) {
try {
return getGeneratorEntries(target[Symbol.iterator]());
} catch (iteratorError) {
return [];
}
}
return [];
}
/*!
* Gets all entries from a Generator. This will consume the generator - which could have side effects.
*
* @param {Generator} target
* @returns {Array} an array of entries from the Generator.
*/
function getGeneratorEntries(generator) {
var generatorResult = generator.next();
var accumulator = [generatorResult.value];
while (generatorResult.done === false) {
generatorResult = generator.next();
accumulator.push(generatorResult.value);
}
return accumulator;
}
/*!
* Gets all own and inherited enumerable keys from a target.
*
* @param {Object} target
* @returns {Array} an array of own and inherited enumerable keys from the target.
*/
function getEnumerableKeys(target) {
var keys = [];
for (var key in target) {
keys.push(key);
}
return keys;
}
/*!
* Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
* each key. If any value of the given key is not equal, the function will return false (early).
*
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
* @param {Object} [options] (Optional)
* @return {Boolean} result
*/
function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
var length = keys.length;
if (length === 0) {
return true;
}
for (var i = 0; i < length; i += 1) {
if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
return false;
}
}
return true;
}
/*!
* Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
* for each enumerable key in the object.
*
* @param {Mixed} leftHandOperand
* @param {Mixed} rightHandOperand
* @param {Object} [options] (Optional)
* @return {Boolean} result
*/
function objectEqual(leftHandOperand, rightHandOperand, options) {
var leftHandKeys = getEnumerableKeys(leftHandOperand);
var rightHandKeys = getEnumerableKeys(rightHandOperand);
if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
leftHandKeys.sort();
rightHandKeys.sort();
if (iterableEqual(leftHandKeys, rightHandKeys) === false) {
return false;
}
return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
}
var leftHandEntries = getIteratorEntries(leftHandOperand);
var rightHandEntries = getIteratorEntries(rightHandOperand);
if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
leftHandEntries.sort();
rightHandEntries.sort();
return iterableEqual(leftHandEntries, rightHandEntries, options);
}
if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) {
return true;
}
return false;
}
/*!
* Returns true if the argument is a primitive.
*
* This intentionally returns true for all objects that can be compared by reference,
* including functions and symbols.
*
* @param {Mixed} value
* @return {Boolean} result
*/
function isPrimitive(value) {
return value === null || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object';
}
index$2.MemoizeMap = MemoizeMap_1;
var index$3 = createCommonjsModule(function (module, exports) {
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
arrayTag = '[object Array]',
boolTag = '[object Boolean]',
dateTag = '[object Date]',
errorTag = '[object Error]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
mapTag = '[object Map]',
numberTag = '[object Number]',
objectTag = '[object Object]',
promiseTag = '[object Promise]',
regexpTag = '[object RegExp]',
setTag = '[object Set]',
stringTag = '[object String]',
symbolTag = '[object Symbol]',
weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]',
float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]',
int16Tag = '[object Int16Array]',
int32Tag = '[object Int32Array]',
uint8Tag = '[object Uint8Array]',
uint8ClampedTag = '[object Uint8ClampedArray]',
uint16Tag = '[object Uint16Array]',
uint32Tag = '[object Uint32Array]';
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/** Used to identify `toStringTag` values supported by `_.clone`. */
var cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
/** Detect free variable `global` from Node.js. */
var freeGlobal = _typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
/** Detect free variable `self`. */
var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Detect free variable `exports`. */
var freeExports = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/**
* Adds the key-value `pair` to `map`.
*
* @private
* @param {Object} map The map to modify.
* @param {Array} pair The key-value pair to add.
* @returns {Object} Returns `map`.
*/
function addMapEntry(map, pair) {
// Don't return `map.set` because it's not chainable in IE 11.
map.set(pair[0], pair[1]);
return map;
}
/**
* Adds `value` to `set`.
*
* @private
* @param {Object} set The set to modify.
* @param {*} value The value to add.
* @returns {Object} Returns `set`.
*/
function addSetEntry(set, value) {
// Don't return `set.add` because it's not chainable in IE 11.
set.add(value);
return set;
}
/**
* A specialized version of `_.forEach` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEach(array, iteratee) {
var index = -1,
length = array ? array.length : 0;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
}
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
/**
* A specialized version of `_.reduce` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array ? array.length : 0;
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
/**
* The base implementation of `_.times` without support for iteratee shorthands
* or max array length checks.
*
* @private
* @param {number} n The number of times to invoke `iteratee`.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the array of results.
*/
function baseTimes(n, iteratee) {
var index = -1,
result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
function isHostObject(value) {
// Many host objects are `Object` objects that can coerce to strings
// despite having improperly defined `toString` methods.
var result = false;
if (value != null && typeof value.toString != 'function') {
try {
result = !!(value + '');
} catch (e) {}
}
return result;
}
/**
* Converts `map` to its key-value pairs.
*
* @private
* @param {Object} map The map to convert.
* @returns {Array} Returns the key-value pairs.
*/
function mapToArray(map) {
var index = -1,
result = Array(map.size);
map.forEach(function (value, key) {
result[++index] = [key, value];
});
return result;
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function (arg) {
return func(transform(arg));
};
}
/**
* Converts `set` to an array of its values.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the values.
*/
function setToArray(set) {
var index = -1,
result = Array(set.size);
set.forEach(function (value) {
result[++index] = value;
});
return result;
}
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined,
_Symbol = root.Symbol,
Uint8Array = root.Uint8Array,
getPrototype = overArg(Object.getPrototypeOf, Object),
objectCreate = Object.create,
propertyIsEnumerable = objectProto.propertyIsEnumerable,
splice = arrayProto.splice;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeGetSymbols = Object.getOwnPropertySymbols,
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
nativeKeys = overArg(Object.keys, Object);
/* Built-in method references that are verified to be native. */
var DataView = getNative(root, 'DataView'),
Map = getNative(root, 'Map'),
Promise = getNative(root, 'Promise'),
Set = getNative(root, 'Set'),
WeakMap = getNative(root, 'WeakMap'),
nativeCreate = getNative(Object, 'create');
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map),
promiseCtorString = toSource(Promise),
setCtorString = toSource(Set),
weakMapCtorString = toSource(WeakMap);
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
return this;
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.__data__ = {
'hash': new Hash(),
'map': new (Map || ListCache)(),
'string': new Hash()
};
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
/**
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Stack(entries) {
this.__data__ = new ListCache(entries);
}
/**
* Removes all key-value entries from the stack.
*
* @private
* @name clear
* @memberOf Stack
*/
function stackClear() {
this.__data__ = new ListCache();
}
/**
* Removes `key` and its value from the stack.
*
* @private
* @name delete
* @memberOf Stack
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function stackDelete(key) {
return this.__data__['delete'](key);
}
/**
* Gets the stack value for `key`.
*
* @private
* @name get
* @memberOf Stack
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function stackGet(key) {
return this.__data__.get(key);
}
/**
* Checks if a stack value for `key` exists.
*
* @private
* @name has
* @memberOf Stack
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function stackHas(key) {
return this.__data__.has(key);
}
/**
* Sets the stack `key` to `value`.
*
* @private
* @name set
* @memberOf Stack
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the stack cache instance.
*/
function stackSet(key, value) {
var cache = this.__data__;
if (cache instanceof ListCache) {
var pairs = cache.__data__;
if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
pairs.push([key, value]);
return this;
}
cache = this.__data__ = new MapCache(pairs);
}
cache.set(key, value);
return this;
}
// Add methods to `Stack`.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
/**
* Creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value The value to query.
* @param {boolean} inherited Specify returning inherited property names.
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
// Safari 9 makes `arguments.length` enumerable in strict mode.
var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : [];
var length = result.length,
skipIndexes = !!length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
result.push(key);
}
}
return result;
}
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
object[key] = value;
}
}
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
/**
* The base implementation of `_.assign` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssign(object, source) {
return object && copyObject(source, keys(source), object);
}
/**
* The base implementation of `_.clone` and `_.cloneDeep` which tracks
* traversed objects.
*
* @private
* @param {*} value The value to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @param {boolean} [isFull] Specify a clone including symbols.
* @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value.
*/
function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
var result;
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
}
if (result !== undefined) {
return result;
}
if (!isObject(value)) {
return value;
}
var isArr = isArray(value);
if (isArr) {
result = initCloneArray(value);
if (!isDeep) {
return copyArray(value, result);
}
} else {
var tag = getTag(value),
isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) {
return cloneBuffer(value, isDeep);
}
if (tag == objectTag || tag == argsTag || isFunc && !object) {
if (isHostObject(value)) {
return object ? value : {};
}
result = initCloneObject(isFunc ? {} : value);
if (!isDeep) {
return copySymbols(value, baseAssign(result, value));
}
} else {
if (!cloneableTags[tag]) {
return object ? value : {};
}
result = initCloneByTag(value, tag, baseClone, isDeep);
}
}
// Check for circular references and return its corresponding clone.
stack || (stack = new Stack());
var stacked = stack.get(value);
if (stacked) {
return stacked;
}
stack.set(value, result);
if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value);
}
arrayEach(props || value, function (subValue, key) {
if (props) {
key = subValue;
subValue = value[key];
}
// Recursively populate clone (susceptible to call stack limits).
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
});
return result;
}
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
function baseCreate(proto) {
return isObject(proto) ? objectCreate(proto) : {};
}
/**
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Function} keysFunc The function to get the keys of `object`.
* @param {Function} symbolsFunc The function to get the symbols of `object`.
* @returns {Array} Returns the array of property names and symbols.
*/
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object);
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
}
/**
* The base implementation of `getTag`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
return objectToString.call(value);
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
/**
* Creates a clone of `buffer`.
*
* @private
* @param {Buffer} buffer The buffer to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Buffer} Returns the cloned buffer.
*/
function cloneBuffer(buffer, isDeep) {
if (isDeep) {
return buffer.slice();
}
var result = new buffer.constructor(buffer.length);
buffer.copy(result);
return result;
}
/**
* Creates a clone of `arrayBuffer`.
*
* @private
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function cloneArrayBuffer(arrayBuffer) {
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
new Uint8Array(result).set(new Uint8Array(arrayBuffer));
return result;
}
/**
* Creates a clone of `dataView`.
*
* @private
* @param {Object} dataView The data view to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned data view.
*/
function cloneDataView(dataView, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
}
/**
* Creates a clone of `map`.
*
* @private
* @param {Object} map The map to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned map.
*/
function cloneMap(map, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
return arrayReduce(array, addMapEntry, new map.constructor());
}
/**
* Creates a clone of `regexp`.
*
* @private
* @param {Object} regexp The regexp to clone.
* @returns {Object} Returns the cloned regexp.
*/
function cloneRegExp(regexp) {
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex;
return result;
}
/**
* Creates a clone of `set`.
*
* @private
* @param {Object} set The set to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned set.
*/
function cloneSet(set, isDeep, cloneFunc) {
var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
return arrayReduce(array, addSetEntry, new set.constructor());
}
/**
* Creates a clone of the `symbol` object.
*
* @private
* @param {Object} symbol The symbol object to clone.
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
}
/**
* Creates a clone of `typedArray`.
*
* @private
* @param {Object} typedArray The typed array to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
}
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function copyArray(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
/**
* Copies properties of `source` to `object`.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined;
assignValue(object, key, newValue === undefined ? source[key] : newValue);
}
return object;
}
/**
* Copies own symbol properties of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbols(source, object) {
return copyObject(source, getSymbols(source), object);
}
/**
* Creates an array of own enumerable property names and symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeys(object) {
return baseGetAllKeys(object, keys, getSymbols);
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
/**
* Creates an array of the own enumerable symbol properties of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
/**
* Gets the `toStringTag` of `value`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
var getTag = baseGetTag;
// Fallback for data views, maps, sets, and weak maps in IE 11,
// for data views in Edge < 14, and promises in Node.js.
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
getTag = function getTag(value) {
var result = objectToString.call(value),
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : undefined;
if (ctorString) {
switch (ctorString) {
case dataViewCtorString:
return dataViewTag;
case mapCtorString:
return mapTag;
case promiseCtorString:
return promiseTag;
case setCtorString:
return setTag;
case weakMapCtorString:
return weakMapTag;
}
}
return result;
};
}
/**
* Initializes an array clone.
*
* @private
* @param {Array} array The array to clone.
* @returns {Array} Returns the initialized clone.
*/
function initCloneArray(array) {
var length = array.length,
result = array.constructor(length);
// Add properties assigned by `RegExp#exec`.
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
result.index = array.index;
result.input = array.input;
}
return result;
}
/**
* Initializes an object clone.
*
* @private
* @param {Object} object The object to clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneObject(object) {
return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
}
/**
* Initializes an object clone based on its `toStringTag`.
*
* **Note:** This function only supports cloning values with tags of
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
*
* @private
* @param {Object} object The object to clone.
* @param {string} tag The `toStringTag` of the object to clone.
* @param {Function} cloneFunc The function to clone values.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneByTag(object, tag, cloneFunc, isDeep) {
var Ctor = object.constructor;
switch (tag) {
case arrayBufferTag:
return cloneArrayBuffer(object);
case boolTag:
case dateTag:
return new Ctor(+object);
case dataViewTag:
return cloneDataView(object, isDeep);
case float32Tag:case float64Tag:
case int8Tag:case int16Tag:case int32Tag:
case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:
return cloneTypedArray(object, isDeep);
case mapTag:
return cloneMap(object, isDeep, cloneFunc);
case numberTag:
case stringTag:
return new Ctor(object);
case regexpTag:
return cloneRegExp(object);
case setTag:
return cloneSet(object, isDeep, cloneFunc);
case symbolTag:
return cloneSymbol(object);
}
}
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && maskSrcKey in func;
}
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
return value === proto;
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return func + '';
} catch (e) {}
}
return '';
}
/**
* This method is like `_.clone` except that it recursively clones `value`.
*
* @static
* @memberOf _
* @since 1.0.0
* @category Lang
* @param {*} value The value to recursively clone.
* @returns {*} Returns the deep cloned value.
* @see _.clone
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];
*
* var deep = _.cloneDeep(objects);
* console.log(deep[0] === objects[0]);
* // => false
*/
function cloneDeep(value) {
return baseClone(value, true, true);
}
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || value !== value && other !== other;
}
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
function isArguments(value) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
/**
* This method is like `_.isArrayLike` except that it also checks if `value`
* is an object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object,
* else `false`.
* @example
*
* _.isArrayLikeObject([1, 2, 3]);
* // => true
*
* _.isArrayLikeObject(document.body.children);
* // => true
*
* _.isArrayLikeObject('abc');
* // => false
*
* _.isArrayLikeObject(_.noop);
* // => false
*/
function isArrayLikeObject(value) {
return isObjectLike(value) && isArrayLike(value);
}
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = nativeIsBuffer || stubFalse;
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8-9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
}
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object';
}
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* for more details.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
/**
* This method returns a new empty array.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {Array} Returns the new empty array.
* @example
*
* var arrays = _.times(2, _.stubArray);
*
* console.log(arrays);
* // => [[], []]
*
* console.log(arrays[0] === arrays[1]);
* // => false
*/
function stubArray() {
return [];
}
/**
* This method returns `false`.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {boolean} Returns `false`.
* @example
*
* _.times(2, _.stubFalse);
* // => [false, false]
*/
function stubFalse() {
return false;
}
module.exports = cloneDeep;
});
function withDeepChange(callback) {
var oldArgs = void 0;
return function () {
var args = index$3(Array.prototype.slice.call(arguments));
if (!index$2(oldArgs, args)) {
callback.apply(this, args);
}
oldArgs = args;
};
}
function withChange(callback) {
var oldArgs = [];
return function () {
var args = Array.prototype.slice.call(arguments);
for (var i = 0; i < Math.max(oldArgs.length, args.length); ++i) {
if (oldArgs[i] !== args[i]) {
callback.apply(this, args);
break;
}
}
oldArgs = args;
};
}
function elementStyles$1() {
return function () {
var _5 = {},
_6 = {},
_7 = {},
_8 = {},
_9 = {},
_10 = {},
_11 = {},
_12 = {},
_13 = {};
_6['position'] = 'absolute';
_6['display'] = 'block';
_6['left'] = 0;
_6['top'] = 0;
_6['right'] = 0;
_6['bottom'] = 0;
_6['z-index'] = 0;
_7['position'] = 'absolute';
_7['display'] = 'block';
_7['left'] = 0;
_7['top'] = 0;
_7['right'] = 0;
_7['bottom'] = 0;
_7['background'] = OSC_C_GRAY;
_8['left'] = 0;
_9['right'] = 0;
_10['left'] = 0;
_10['right'] = 0;
_11['top'] = 0;
_12['bottom'] = 0;
_13['display'] = 'none';
_5['osc-overlay'] = _6;
_5['osc-bound'] = _7;
_5['osc-bound.osc-left-bound'] = _8;
_5['osc-bound.osc-right-bound'] = _9;
_5['osc-bound.osc-top-bound,\n osc-bound.osc-bottom-bound'] = _10;
_5['osc-bound.osc-top-bound'] = _11;
_5['osc-bound.osc-bottom-bound'] = _12;
_5['osc-overlay.osc-hide-bounds osc-bound'] = _13;
return _5;
}.apply(this);
}
function className(cls) {
return function (elem) {
elem.className = cls;
};
}
function setPx(elem, cssProp, value) {
elem.style[cssProp] = value + "px";
}
cssx('osc-css').add(elementStyles$1());
var MarkerList = function () {
function MarkerList() {
var _this = this;
classCallCheck(this, MarkerList);
this.el = el('osc-overlay', this.leftBound = el('osc-bound', className('osc-left-bound')), this.topBound = el('osc-bound', className('osc-top-bound')), this.rightBound = el('osc-bound', className('osc-right-bound')), this.bottomBound = el('osc-bound', className('osc-bottom-bound')));
this.updateBounds = withDeepChange(function (bounds) {
if (bounds) {
var left = bounds.left,
top = bounds.top,
right = bounds.right,
bottom = bounds.bottom,
width = bounds.width,
height = bounds.height;
setPx(_this.topBound, 'height', Math.max(0, top));
setPx(_this.leftBound, 'top', Math.max(0, top));
setPx(_this.leftBound, 'width', Math.max(0, left));
setPx(_this.leftBound, 'height', Math.max(0, bottom) - Math.max(0, top));
setPx(_this.rightBound, 'top', Math.max(0, top));
setPx(_this.rightBound, 'left', Math.max(0, right));
setPx(_this.rightBound, 'height', Math.max(0, bottom) - Math.max(0, top));
setPx(_this.bottomBound, 'top', Math.max(0, bottom));
}
_this.el.classList.toggle("osc-hide-bounds", !bounds);
});
this.updateBounds(null);
}
createClass(MarkerList, [{
key: 'update',
value: function update(element) {
if (element) {
this.updateBounds(element.getBoundingClientRect());
} else {
this.updateBounds(null);
}
}
}]);
return MarkerList;
}();
function elementStyles$3() {
return function () {
var _19 = {},
_20 = {},
_21 = {},
_22 = {};
_20['left'] = 0;
_20['top'] = 0;
_20['right'] = 0;
_20['bottom'] = 0;
_20['background'] = OSC_C_LIGHT;
_20['box-sizing'] = 'border-box';
_21['font'] = 'normal 12pt/14pt sans-serif';
_21['left'] = 0;
_21['bottom'] = 0;
_21['padding'] = '2pt';
_21['max-width'] = '100%';
_21['overflow-x'] = 'hidden';
_21['text-overflow'] = 'ellipsis';
_21['color'] = OSC_C_WHITE;
_21['background'] = OSC_C_LIGHT;
_21['white-space'] = 'nowrap';
_21['pointer-events'] = 'none';
_22['position'] = 'absolute';
_22['display'] = 'block';
_19['osc-marker-rect'] = _20;
_19['osc-marker-label'] = _21;
_19['osc-marker, osc-marker-rect, osc-marker-label'] = _22;
return _19;
}.apply(this);
}
cssx('osc-css').add(elementStyles$3());
var Marker = function () {
function Marker() {
var _this = this;
classCallCheck(this, Marker);
this.el = el('osc-marker', this.rect = el('osc-marker-rect'), this.label = el('osc-marker-label'));
this.updateBounds = withDeepChange(function (bounds) {
['left', 'top', 'width', 'height'].forEach(function (prop) {
_this.el.style[prop] = bounds[prop] + 'px';
});
});
this.updateArrangement = withDeepChange(function (index, total) {
_this.el.style.opacity = 1 / (1 + index);
_this.el.style.zIndex = total - index;
_this.label.style.display = index ? 'none' : '';
});
this.updateLabel = withChange(function (element) {
_this.label.textContent = elementLabel(element, true);
});
this.markerStyle = withChange(function (borderTop, borderBottom, stripes) {
[[borderTop, 'borderTop'], [borderBottom, 'borderBottom']].forEach(function (iter) {
var _iter = slicedToArray(iter, 2),
hasBorder = _iter[0],
property = _iter[1];
_this.rect.style[property] = hasBorder ? "6pt solid " + OSC_C_DARK : "";
});
_this.rect.style.background = stripes ? OSC_STRIPES : OSC_C_LIGHT;
});
}
createClass(Marker, [{
key: 'update',
value: function update(element, idx, ary) {
var bounds = element.getBoundingClientRect();
this.updateBounds(bounds);
this.updateArrangement(idx, ary.length);
if (!idx) {
this.updateLabel(element);
}
}
}]);
return Marker;
}();
function elementStyles$2() {
return function () {
var _15 = {},
_16 = {},
_17 = {};
_16['position'] = 'relative';
_16['display'] = 'block';
_16['z-index'] = 1;
_17['display'] = 'none';
_15['osc-marker-list'] = _16;
_15['.osc-marker-list-hidden'] = _17;
return _15;
}.apply(this);
}
cssx('osc-css').add(elementStyles$2());
var MarkerList$1 = function () {
function MarkerList() {
var _this = this;
classCallCheck(this, MarkerList);
this.list = list(this.el = el('osc-marker-list'), Marker);
this.toggleVisibility = withChange(function (visible) {
_this.el.classList.toggle("osc-marker-list-hidden", !visible);
});
}
createClass(MarkerList, [{
key: 'markElements',
value: function markElements(elements) {
this.list.update(elements);
}
}, {
key: 'markerStyle',
value: function markerStyle(borderTop, borderBottom, stripes) {
if (this.list.views.length) {
this.list.views[0].markerStyle(borderTop, borderBottom, stripes);
}
}
}, {
key: 'hideMarker',
value: function hideMarker() {
this.list.update([]);
}
}]);
return MarkerList;
}();
function elementStyles$5() {
return function () {
var _28 = {},
_29 = {},
_30 = {},
_31 = {},
_32 = {},
_33 = {},
_34 = {},
_35 = {},
_36 = {};
_29['display'] = 'block';
_29['float'] = 'left';
_29['cursor'] = 'pointer';
_30['opacity'] = 0.6;
_31['cursor'] = 'default';
_32['position'] = 'relative';
_32['display'] = 'block';
_32['font'] = 'normal 12pt/14pt sans-serif';
_32['height'] = '30pt';
_32['color'] = OSC_C_WHITE;
_32['background'] = OSC_C_DARK;
_32['white-space'] = 'nowrap';
_32['padding'] = '8pt 10pt 8pt 5pt';
_32['text-align'] = 'center';
_32['margin-right'] = '26pt';
_32['box-sizing'] = 'border-box';
_33['padding-left'] = '15pt';
_34['content'] = '""';
_34['position'] = 'absolute';
_34['top'] = 0;
_34['border'] = "0 solid " + OSC_C_DARK;
_34['border-width'] = '15pt 10pt';
_34['width'] = 0;
_34['height'] = 0;
_34['box-sizing'] = 'border-box';
_35['right'] = '100%';
_35['border-left-color'] = 'transparent';
_36['left'] = '100%';
_36['border-color'] = 'transparent';
_36['border-left-color'] = OSC_C_DARK;
_28['osc-crumb'] = _29;
_28['.osc-crumb-faded'] = [_30, _31];
_28['osc-crumb-label'] = _32;
_28['osc-crumb:first-child osc-crumb-label'] = _33;
_28['osc-crumb:not(:first-child) osc-crumb-label:before,\n osc-crumb osc-crumb-label:after'] = _34;
_28['osc-crumb:not(:first-child) osc-crumb-label:before'] = _35;
_28['osc-crumb osc-crumb-label:after'] = _36;
return _28;
}.apply(this);
}
function parentCallWithElement(self, prop) {
if (self.element) {
self.parent[prop](self.element);
}
}
cssx("osc-css").add(elementStyles$5());
var Crumb = function () {
function Crumb(parent) {
var _this = this;
classCallCheck(this, Crumb);
var self = this;
this.parent = parent;
this.el = el('osc-crumb', this.label = el('osc-crumb-label'), {
onclick: function onclick(e) {
parentCallWithElement(self, 'onElementSelected');
e.stopPropagation();
},
onmouseover: function onmouseover() {
parentCallWithElement(self, 'onMouseOverElement');
self.parent.fadeViewsAfter(self);
},
onmouseout: function onmouseout() {
parentCallWithElement(self, 'onMouseOutElement');
self.parent.toggleFadeForAllViews(false);
}
});
this.updateLabel = withChange(function (element) {
_this.element = element;
_this.label.textContent = elementLabel(element);
});
this.toggleFade = withChange(function (faded) {
_this.el.classList.toggle("osc-crumb-faded", faded);
});
}
createClass(Crumb, [{
key: 'update',
value: function update(element, idx, ary) {
this.updateLabel(element);
}
}]);
return Crumb;
}();
function elementStyles$4() {
return function () {
var _24 = {},
_25 = {},
_26 = {};
_25['position'] = 'absolute';
_25['display'] = 'block';
_25['left'] = 0;
_25['bottom'] = 0;
_25['z-index'] = 2;
_25['height'] = '30pt';
_25['list-style'] = 'none';
_25['overflow'] = 'hidden';
_26['display'] = 'none';
_24['osc-crumb-list'] = _25;
_24['.osc-crumb-list-hidden'] = _26;
return _24;
}.apply(this);
}
cssx("osc-css").add(elementStyles$4());
var CrumbList = function () {
function CrumbList() {
var _this = this;
classCallCheck(this, CrumbList);
this.list = list(this.el = el('osc-crumb-list'), Crumb, null, this);
this.toggleVisibility = withChange(function (visible) {
_this.el.classList.toggle("osc-crumb-list-hidden", !visible);
});
}
createClass(CrumbList, [{
key: 'elementCrumbs',
value: function elementCrumbs(element) {
var elements = withAncestors(element).filter(function (element) {
return element !== document.documentElement;
});
this.list.update(elements.reverse());
}
}, {
key: 'toggleFadeForAllViews',
value: function toggleFadeForAllViews(fade) {
this.list.views.forEach(function (view) {
return view.toggleFade(fade);
});
}
}, {
key: 'fadeViewsAfter',
value: function fadeViewsAfter(view) {
var fade = false;
this.list.views.forEach(function (view2) {
view2.toggleFade(fade);
if (view2 === view) {
fade = true;
}
});
}
}, {
key: 'onElementSelected',
value: function onElementSelected(element) {}
}, {
key: 'onMouseOverElement',
value: function onMouseOverElement(element) {}
}, {
key: 'onMouseOutElement',
value: function onMouseOutElement(element) {}
}]);
return CrumbList;
}();
function elementStyles() {
return function () {
var _2 = {},
_3 = {};
_3['position'] = 'fixed';
_3['display'] = 'block';
_3['left'] = 0;
_3['top'] = 0;
_3['right'] = 0;
_3['bottom'] = 0;
_3['z-index'] = MAX_Z_INDEX;
_2['osc-selector'] = _3;
return _2;
}.apply(this);
}
cssx('osc-css').add(elementStyles());
var Selector = function () {
function Selector() {
var _this = this;
classCallCheck(this, Selector);
this._unmount = [];
this.el = el('osc-selector', this.overlay = new MarkerList(), this.markerList = new MarkerList$1(), this.crumbList = new CrumbList());
this._element = null;
this._root = null;
this._hovered = null;
this._position = null;
this._locked = false;
this.throttledUpdate = throttle(function () {
_this.update();
});
this.crumbList.onElementSelected = function (element) {
if (_this._root === null || isAncestor(_this._root, element)) {
_this.element = element;
} else {
_this.element = null;
}
_this.position = OSC_POSITION_THIS;
_this.throttledUpdate();
};
this.crumbList.onMouseOverElement = function (element) {
if (_this._root === null || isAncestor(_this._root, element)) {
_this._hovered = element;
} else {
_this._hovered = null;
}
_this.throttledUpdate();
};
this.crumbList.onMouseOutElement = function () {
_this._hovered = null;
_this.throttledUpdate();
};
}
createClass(Selector, [{
key: 'mount',
value: function mount$$() {
var _this2 = this;
if (this._unmount.length) {
return;
}
var unmountLater = function unmountLater(fn) {
return _this2._unmount.push(fn);
};
mount(document.documentElement, this.el);
unmountLater(function () {
return unmount(document.documentElement, _this2.el);
});
unmountLater(addEventListener(window, 'scroll', function () {
return _this2.throttledUpdate();
}).remove);
unmountLater(addEventListener(window, 'resize', function () {
return _this2.throttledUpdate();
}).remove);
var intervalId = window.setInterval(function () {
return _this2.throttledUpdate();
}, 500);
unmountLater(function () {
return window.clearInterval(intervalId);
});
unmountLater(pointerEvents(function (x, y) {
return _this2._pointAt(x, y);
}, function (x, y) {
return _this2._selectPoint(x, y);
}));
unmountLater(addEventListener(this.el, "contextmenu", function (e) {
return e.preventDefault();
}).remove);
}
}, {
key: 'unmount',
value: function unmount() {
this._unmount.reverse().forEach(function (fn) {
return fn();
});
this._unmount = [];
}
}, {
key: 'update',
value: function update() {
var hasSelection = this._element !== null;
if (hasSelection) {
var elements = [this._element];
if (this._hovered !== null) {
elements.push(this._hovered);
}
this.markerList.markElements(elements);
this.crumbList.elementCrumbs(this._element);
}
this.markerList.toggleVisibility(hasSelection);
this.crumbList.toggleVisibility(hasSelection && this._locked);
this.overlay.update(this._root);
this.markerList.markerStyle(this._position === OSC_POSITION_BEFORE, this._position === OSC_POSITION_AFTER, this._locked);
}
}, {
key: '_pointAt',
value: function _pointAt(x, y) {
if (!this._locked) {
this._elementFromPoint(x, y);
if (this._element !== null) {
this._positionFromPoint(x, y);
}
this.throttledUpdate();
}
}
}, {
key: '_selectPoint',
value: function _selectPoint(x, y) {
var oldElement = this._element,
oldLocked = this._locked,
oldPosition = this._position;
this._elementFromPoint(x, y);
this._locked = this._element !== null && oldElement === this._element ? !this._locked : false;
if (this._element !== null) {
this._positionFromPoint(x, y);
} else {
this._position = null;
}
if (this._locked !== oldLocked) {
this.onElementChanged();
this.onPositionChanged();
} else {
if (this._element !== oldElement) {
this.onElementChanged();
}
if (this._position !== oldPosition) {
this.onPositionChanged();
}
}
this.update();
}
}, {
key: '_elementFromPoint',
value: function _elementFromPoint(x, y) {
/* temporarily make overlay invisible to prevent an additional loop cycle
* in `fromPoint()`. */
this.el.style.visibility = "hidden";
this._element = fromPoint(x, y);
this.el.style.visibility = "";
if (this._root !== null && !isAncestor(this._root, this._element)) {
this._element = null;
}
}
}, {
key: '_positionFromPoint',
value: function _positionFromPoint(x, y) {
var distance = edgeDistance(this._element, x, y),
top = distance.top >= 0 && distance.top < 10,
bottom = distance.bottom >= 0 && distance.bottom < 10;
if (top && !bottom) {
this._position = OSC_POSITION_BEFORE;
} else if (bottom && !top) {
this._position = OSC_POSITION_AFTER;
} else {
this._position = OSC_POSITION_THIS;
}
}
}, {
key: 'onElementChanged',
value: function onElementChanged() {}
}, {
key: 'onPositionChanged',
value: function onPositionChanged() {}
}, {
key: 'element',
get: function get() {
return this._locked ? this._element : null;
},
set: function set(element) {
if (element !== this._element || !this._locked) {
this._element = element;
this._hovered = null;
this._locked = !!element;
this.onElementChanged();
}
}
}, {
key: 'root',
get: function get() {
return this._root;
},
set: function set(root) {
if (root !== this._root) {
this._root = root;
}
}
}, {
key: 'position',
get: function get() {
return this._locked ? this._position : null;
},
set: function set(position) {
if (position !== this._position) {
this._position = position;
if (this._locked) {
this.onPositionChanged();
}
}
}
}]);
return Selector;
}();
var hiddenElem = document.createElement("osc-hidden");
hiddenElem.style.display = "none";
document.documentElement.appendChild(hiddenElem);
var Injector = function () {
function Injector() {
classCallCheck(this, Injector);
this._element = null;
this._position = null;
this._reset();
}
createClass(Injector, [{
key: "mount",
value: function mount() {
if (this._element !== null && this._position !== null) {
this._inject();
}
}
}, {
key: "unmount",
value: function unmount() {
if (this._iMarker !== null) {
this._restore();
}
}
}, {
key: "_inject",
value: function _inject() {
var parent = this._iParent = this._element.parentElement;
this._iMarker = document.createTextNode("");
if (this._position === OSC_POSITION_AFTER) {
parent.insertBefore(this._iMarker, this._element.nextSibling);
} else {
parent.insertBefore(this._iMarker, this._element);
}
if (this._position === OSC_POSITION_THIS) {
this._iOriginal = this._element;
parent.removeChild(this._element);
hiddenElem.appendChild(this._iOriginal);
}
this._iInjected = window.odoscopeInject(parent, this._iMarker);
}
}, {
key: "_restore",
value: function _restore() {
var parent = this._iParent;
if (this._iInjected !== null) {
parent.removeChild(this._iInjected);
}
if (this._iOriginal) {
hiddenElem.removeChild(this._iOriginal);
parent.insertBefore(this._iOriginal, this._iMarker);
}
parent.removeChild(this._iMarker);
this._reset();
}
}, {
key: "_reset",
value: function _reset() {
this._iMarker = null;
this._iOriginal = null;
this._iInjected = null;
this._iParent = null;
}
}, {
key: "element",
get: function get() {
return this._element;
},
set: function set(element) {
this._element = element;
}
}, {
key: "position",
get: function get() {
return this._position;
},
set: function set(position) {
this._position = position;
}
}]);
return Injector;
}();
var Facade = function () {
function Facade() {
var _this = this;
classCallCheck(this, Facade);
this._selector = new Selector();
this._injector = new Injector();
this._mode = OSC_MODE_NONE;
this._selector.onElementChanged = function () {
_this._injector.element = _this._selector.element;
_this.onSelectorChanged();
};
this._selector.onPositionChanged = function () {
_this._injector.position = _this._selector.position;
_this.onPositionChanged();
};
}
createClass(Facade, [{
key: 'extractMarkup',
value: function extractMarkup(selector) {
if (selector !== null) {
var elems = document.querySelectorAll(selector);
if (elems.length === 1) {
return outerHTML(elems[0]);
}
}
}
}, {
key: 'onModeChanged',
value: function onModeChanged() {}
}, {
key: 'onSelectorChanged',
value: function onSelectorChanged() {}
}, {
key: 'onPositionChanged',
value: function onPositionChanged() {}
}, {
key: 'mode',
get: function get() {
return this._mode;
},
set: function set(mode) {
if (this._mode !== mode) {
if (this._mode === OSC_MODE_SELECT) {
this._selector.unmount();
}
if (this._mode === OSC_MODE_INJECT) {
this._injector.unmount();
}
if (mode === OSC_MODE_SELECT) {
this._selector.mount();
}
if (mode === OSC_MODE_INJECT) {
this._injector.mount();
}
this.onModeChanged();
}
this._mode = mode;
}
}, {
key: 'selector',
get: function get() {
return unique(this._selector.element);
},
set: function set(selector) {
if (selector !== null) {
var elems = document.querySelectorAll(selector);
if (elems.length === 1) {
this._selector.element = elems[0];
}
} else {
this._selector.element = null;
}
}
}, {
key: 'rootSelector',
get: function get() {
return unique(this._selector.root);
},
set: function set(rootSelector) {
if (rootSelector !== null) {
var elems = document.querySelectorAll(rootSelector);
if (elems.length === 1) {
this._selector.root = elems[0];
}
} else {
this._selector.root = null;
}
}
}, {
key: 'position',
get: function get() {
return this._selector.position;
},
set: function set(position) {
this._selector.position = position;
}
}]);
return Facade;
}();
var postmate_min = createCommonjsModule(function (module, exports) {
/**
* postmate - A powerful, simple, promise-based postMessage library
* @version v1.1.4
* @link https://github.com/dollarshaveclub/postmate
* @author Jacob Kelley <jakie8@gmail.com>
* @license MIT */
!function (e, t) {
"object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : e.Postmate = t();
}(commonjsGlobal, function () {
"use strict";
function e() {
return ++l;
}function t() {
var e;c.debug && (e = console).log.apply(e, arguments);
}function n(e) {
var t = document.createElement("a");return t.href = e, t.origin || t.protocol + "//" + t.hostname;
}function i(e, t) {
return e.origin === t && "object" === r(e.data) && "postmate" in e.data && e.data.type === d && !!{ "handshake-reply": 1, call: 1, emit: 1, reply: 1, request: 1 }[e.data.postmate];
}function a(e, t) {
var n = "function" == typeof e[t] ? e[t]() : e[t];return c.Promise.resolve(n);
}var r = "function" == typeof Symbol && "symbol" == _typeof(Symbol.iterator) ? function (e) {
return typeof e === "undefined" ? "undefined" : _typeof(e);
} : function (e) {
return e && "function" == typeof Symbol && e.constructor === Symbol ? "symbol" : typeof e === "undefined" ? "undefined" : _typeof(e);
},
o = function o(e, t) {
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
},
s = function () {
function e(e, t) {
for (var n = 0; n < t.length; n++) {
var i = t[n];i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i);
}
}return function (t, n, i) {
return n && e(t.prototype, n), i && e(t, i), t;
};
}(),
d = "application/x-postmate-v1+json",
l = 0,
h = function () {
function n(e) {
var i = this;o(this, n), this.parent = e.parent, this.frame = e.frame, this.child = e.child, this.childOrigin = e.childOrigin, this.events = {}, t("Parent: Registering API"), t("Parent: Awaiting messages..."), this.listener = function (e) {
var n = ((e || {}).data || {}).value || {},
a = n.data,
r = n.name;"emit" === e.data.postmate && (t("Parent: Received event emission: " + r), r in i.events && i.events[r].call(i, a));
}, this.parent.addEventListener("message", this.listener, !1), t("Parent: Awaiting event emissions from Child");
}return s(n, [{ key: "get", value: function value(t) {
var n = this;return new c.Promise(function (i) {
var a = e(),
r = function e(t) {
t.data.uid === a && "reply" === t.data.postmate && (n.parent.removeEventListener("message", e, !1), i(t.data.value));
};n.parent.addEventListener("message", r, !1), n.child.postMessage({ postmate: "request", type: d, property: t, uid: a }, n.childOrigin);
});
} }, { key: "call", value: function value(e, t) {
this.child.postMessage({ postmate: "call", type: d, property: e, data: t }, this.childOrigin);
} }, { key: "on", value: function value(e, t) {
this.events[e] = t;
} }, { key: "destroy", value: function value() {
t("Parent: Destroying Postmate instance"), window.removeEventListener("message", this.listener, !1), this.frame.parentNode.removeChild(this.frame);
} }]), n;
}(),
u = function () {
function e(n) {
var r = this;o(this, e), this.model = n.model, this.parent = n.parent, this.parentOrigin = n.parentOrigin, this.child = n.child, t("Child: Registering API"), t("Child: Awaiting messages..."), this.child.addEventListener("message", function (e) {
if (i(e, r.parentOrigin)) {
t("Child: Received request", e.data);var n = e.data,
o = n.property,
s = n.uid,
l = n.data;return "call" === e.data.postmate ? void (o in r.model && "function" == typeof r.model[o] && r.model[o].call(r, l)) : void a(r.model, o).then(function (t) {
return e.source.postMessage({ property: o, postmate: "reply", type: d, uid: s, value: t }, e.origin);
});
}
});
}return s(e, [{ key: "emit", value: function value(e, n) {
t('Child: Emitting Event "' + e + '"', n), this.parent.postMessage({ postmate: "emit", type: d, value: { name: e, data: n } }, this.parentOrigin);
} }]), e;
}(),
c = function () {
function e(t) {
o(this, e);var n = t.container,
i = t.url,
a = t.model;return this.parent = window, this.frame = document.createElement("iframe"), (n || document.body).appendChild(this.frame), this.child = this.frame.contentWindow || this.frame.contentDocument.parentWindow, this.model = a || {}, this.sendHandshake(i);
}return s(e, [{ key: "sendHandshake", value: function value(a) {
var r = this,
o = n(a);return new e.Promise(function (e, n) {
var s = function a(s) {
return !!i(s, o) && ("handshake-reply" === s.data.postmate ? (t("Parent: Received handshake reply from Child"), r.parent.removeEventListener("message", a, !1), r.childOrigin = s.origin, t("Parent: Saving Child origin", r.childOrigin), e(new h(r))) : (t("Parent: Invalid handshake reply"), n("Failed handshake")));
};r.parent.addEventListener("message", s, !1);var l = function l() {
t("Parent: Sending handshake", { childOrigin: o }), setTimeout(function () {
return r.child.postMessage({ postmate: "handshake", type: d, model: r.model }, o);
}, 0);
};r.frame.attachEvent ? r.frame.attachEvent("onload", l) : r.frame.onload = l, t("Parent: Loading frame", { url: a }), r.frame.src = a;
});
} }]), e;
}();return c.debug = !1, c.Promise = function () {
try {
return window ? window.Promise : Promise;
} catch (e) {
return null;
}
}(), c.Model = function () {
function e(t) {
return o(this, e), this.child = window, this.model = t, this.parent = this.child.parent, this.sendHandshakeReply();
}return s(e, [{ key: "sendHandshakeReply", value: function value() {
var e = this;return new c.Promise(function (n, i) {
var a = function a(r) {
if ("handshake" === r.data.postmate) {
t("Child: Received handshake from Parent"), e.child.removeEventListener("message", a, !1), t("Child: Sending handshake reply to Parent"), r.source.postMessage({ postmate: "handshake-reply", type: d }, r.origin), e.parentOrigin = r.origin;var o = r.data.model;if (o) {
for (var s = Object.keys(o), l = 0; l < s.length; l++) {
o.hasOwnProperty(s[l]) && (e.model[s[l]] = o[s[l]]);
}t("Child: Inherited and extended model from Parent");
}return t("Child: Saving Parent origin", e.parentOrigin), n(new u(e));
}return i("Handshake Reply Failed");
};e.child.addEventListener("message", a, !1);
});
} }]), e;
}(), c;
});
});
var ParentBridge = function () {
function ParentBridge() {
classCallCheck(this, ParentBridge);
this._parent = null;
this._mode = OSC_MODE_NONE;
this._selector = null;
this._rootSelector = null;
this._position = null;
}
createClass(ParentBridge, [{
key: 'initialize',
value: function initialize(url, container) {
var _this = this;
new postmate_min({ url: url, container: container }).then(function (parent) {
_this._parent = parent;
parent.on('onModeChanged', function (mode) {
_this._mode = mode;
_this.onModeChanged();
});
parent.on('onSelectorChanged', function (selector) {
_this._selector = selector;
_this.onSelectorChanged();
});
parent.on('onPositionChanged', function (position) {
_this._position = position;
_this.onPositionChanged();
});
_this.onInitialized();
});
}
}, {
key: 'terminate',
value: function terminate() {
if (this._parent) {
this._parent.destroy();
this._parent = null;
}
}
}, {
key: 'extractMarkup',
value: function extractMarkup(selector) {
if (this._parent === null) {
return Promise.reject("Parent bridge not initialized.");
}
return this._parent.call('extractMarkup', selector);
}
}, {
key: 'onInitialized',
value: function onInitialized() {}
}, {
key: 'onModeChanged',
value: function onModeChanged() {}
}, {
key: 'onSelectorChanged',
value: function onSelectorChanged() {}
}, {
key: 'onPositionChanged',
value: function onPositionChanged() {}
}, {
key: 'mode',
get: function get() {
return this._mode;
},
set: function set(mode) {
if (this._parent !== null) {
this._parent.call('setMode', mode);
}
}
}, {
key: 'selector',
get: function get() {
return this._selector;
},
set: function set(selector) {
if (this._parent !== null) {
this._parent.call('setSelector', selector);
}
}
}, {
key: 'rootSelector',
get: function get() {
return this._rootSelector;
},
set: function set(rootSelector) {
if (this._parent !== null) {
this._parent.call('setRootSelector', rootSelector);
}
}
}, {
key: 'position',
get: function get() {
return this._position;
},
set: function set(position) {
if (this._parent !== null) {
this._parent.call('setPosition', position);
}
}
}]);
return ParentBridge;
}();
var ChildBridge = function () {
function ChildBridge() {
classCallCheck(this, ChildBridge);
this._facade = new Facade();
this._child = null;
}
createClass(ChildBridge, [{
key: 'initialize',
value: function initialize() {
var _this = this;
new postmate_min.Model({
getMode: function getMode() {
return _this._facade.mode;
},
setMode: function setMode(mode) {
return _this._facade.mode = mode;
},
getSelector: function getSelector() {
return _this._facade.selector;
},
setSelector: function setSelector(selector) {
return _this._facade.selector = selector;
},
getRootSelector: function getRootSelector() {
return _this._facade.rootSelector;
},
setRootSelector: function setRootSelector(rootSelector) {
return _this._facade.rootSelector = rootSelector;
},
getPosition: function getPosition() {
return _this._facade.position;
},
setPosition: function setPosition(position) {
return _this._facade.position = position;
},
extractMarkup: function extractMarkup(selector) {
return _this._facade.extractMarkup(selector);
}
}).then(function (child) {
_this._child = child;
_this._facade.onModeChanged = function () {
return child.emit('onModeChanged', _this._facade.mode);
};
_this._facade.onSelectorChanged = function () {
return child.emit('onSelectorChanged', _this._facade.selector);
};
_this._facade.onPositionChanged = function () {
return child.emit('onPositionChanged', _this._facade.position);
};
});
}
}, {
key: 'terminate',
value: function terminate() {
if (this._child) {
this._child.destroy();
this._child = null;
}
}
}]);
return ChildBridge;
}();
exports.Facade = Facade;
exports.ParentBridge = ParentBridge;
exports.ChildBridge = ChildBridge;
exports.MAX_Z_INDEX = MAX_Z_INDEX;
exports.OSC_C_LIGHT = OSC_C_LIGHT;
exports.OSC_C_WHITE = OSC_C_WHITE;
exports.OSC_C_DARK = OSC_C_DARK;
exports.OSC_C_GRAY = OSC_C_GRAY;
exports.OSC_STRIPES = OSC_STRIPES;
exports.OSC_MODE_NONE = OSC_MODE_NONE;
exports.OSC_MODE_SELECT = OSC_MODE_SELECT;
exports.OSC_MODE_INJECT = OSC_MODE_INJECT;
exports.OSC_POSITION_THIS = OSC_POSITION_THIS;
exports.OSC_POSITION_BEFORE = OSC_POSITION_BEFORE;
exports.OSC_POSITION_AFTER = OSC_POSITION_AFTER;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=osc-ies.js.map
{
"name": "osc-injection-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Vincent Wochnik <v.wochnik@gmail.com> (https://github.com/vwochni)",
"license": "ISC",
"devDependencies": {
"osc-interactive-element-selector": "git+ssh://git@gitlab.com/osc_dev/oscInteractiveElementSelector.git#master",
"postmate": "^1.1.4"
}
}
<h2>Select a wrapper element</h2>
<p>A wrapper element is that element which wraps the content you'd like
to replace. For instance, if you'd like to replace the product list of
a content section, select the content section element as the wrapper
element.</p>
class WizardStep {
constructor(wizard) {
this.wizard = wizard;
}
activate() { }
deactivate() { }
canPrev() {
return true;
}
canNext() {
return true;
}
}
class SelectWrapperStep extends WizardStep {
activate() {
$.get("step-1.html", (html) => {
this.wizard.content(html)
this.wizard.bridge.selector = this.wizard.state.wrapper || null;
this.wizard.bridge.position = ies.OSC_POSITION_THIS;
this.wizard.bridge.mode = ies.OSC_MODE_SELECT;
this.wizard.bridge.onSelectorChanged = () => {
this.wizard.state.wrapper = this.wizard.bridge.selector;
};
this.wizard.log("Loaded step 1.");
});
}
deactivate() {
this.wizard.bridge.onSelectorChanged = function(){};
this.wizard.bridge.selector = null;
this.wizard.bridge.mode = ies.OSC_MODE_NONE;
}
canNext() {
return !!this.wizard.state.wrapper;
}
}
class SelectElementStep extends WizardStep {
activate() {
$.get("step-2.html", (html) => {
this.wizard.content(html)
this.wizard.bridge.selector = this.wizard.state.product || null;
this.wizard.bridge.position = ies.OSC_POSITION_THIS;
this.wizard.bridge.rootSelector = this.wizard.state.wrapper || null;
this.wizard.bridge.mode = ies.OSC_MODE_SELECT;
this.wizard.bridge.onSelectorChanged = () => {
this.wizard.state.product = this.wizard.bridge.selector;
};
this.wizard.log("Loaded step 2.");
});
}
deactivate() {
this.wizard.bridge.onSelectorChanged = function(){};
this.wizard.bridge.selector = null;
this.wizard.bridge.rootSelector = null;
this.wizard.bridge.mode = ies.OSC_MODE_NONE;
}
}
class Wizard {
constructor() {
this.state = {};
$("#prev").bind('click', () => this.prev());
$("#next").bind('click', () => this.next());
this.log = (msg) => $('<div class="msg"></div>')
.append($('<span class="date"></span>').text(new Date().toUTCString()))
.append(" "+msg).appendTo('#log');
this.content = (html) => $('#wizard').html(html);
this.steps = [
new SelectWrapperStep(this),
new SelectElementStep(this)
];
this.bridge = new ies.ParentBridge();
this.bridge.initialize("iframe.html", $("#browser").get(0));
this.bridge.onInitialized = () => {
this.log("Parent-child communication initialized!");
this.step = 0;
this.steps[this.step].activate();
};
}
prev() {
if ((this.step > 0) && (this.steps[this.step].canPrev())) {
this.steps[this.step].deactivate();
this.step--;
this.steps[this.step].activate();
}
}
next() {
if ((this.step < this.steps.length - 1) && (this.steps[this.step].canNext())) {
this.steps[this.step].deactivate();
this.step++;
this.steps[this.step].activate();
}
}
}
const wizard = new Wizard();
var WizardStep = function WizardStep(wizard) {
this.wizard = wizard;
};
WizardStep.prototype.activate = function activate () { };
WizardStep.prototype.deactivate = function deactivate () { };
WizardStep.prototype.canPrev = function canPrev () {
return true;
};
WizardStep.prototype.canNext = function canNext () {
return true;
};
var SelectWrapperStep = (function (WizardStep) {
function SelectWrapperStep () {
WizardStep.apply(this, arguments);
}
if ( WizardStep ) SelectWrapperStep.__proto__ = WizardStep;
SelectWrapperStep.prototype = Object.create( WizardStep && WizardStep.prototype );
SelectWrapperStep.prototype.constructor = SelectWrapperStep;
SelectWrapperStep.prototype.activate = function activate () {
var this$1 = this;
$.get("step-1.html", function (html) {
this$1.wizard.content(html)
this$1.wizard.bridge.selector = this$1.wizard.state.wrapper || null;
this$1.wizard.bridge.position = ies.OSC_POSITION_THIS;
this$1.wizard.bridge.mode = ies.OSC_MODE_SELECT;
this$1.wizard.bridge.onSelectorChanged = function () {
this$1.wizard.state.wrapper = this$1.wizard.bridge.selector;
};
this$1.wizard.log("Loaded step 1.");
});
};
SelectWrapperStep.prototype.deactivate = function deactivate () {
this.wizard.bridge.onSelectorChanged = function(){};
this.wizard.bridge.selector = null;
this.wizard.bridge.mode = ies.OSC_MODE_NONE;
};
SelectWrapperStep.prototype.canNext = function canNext () {
return !!this.wizard.state.wrapper;
};
return SelectWrapperStep;
}(WizardStep));
var SelectElementStep = (function (WizardStep) {
function SelectElementStep () {
WizardStep.apply(this, arguments);
}
if ( WizardStep ) SelectElementStep.__proto__ = WizardStep;
SelectElementStep.prototype = Object.create( WizardStep && WizardStep.prototype );
SelectElementStep.prototype.constructor = SelectElementStep;
SelectElementStep.prototype.activate = function activate () {
var this$1 = this;
$.get("step-2.html", function (html) {
this$1.wizard.content(html)
this$1.wizard.bridge.selector = this$1.wizard.state.product || null;
this$1.wizard.bridge.position = ies.OSC_POSITION_THIS;
this$1.wizard.bridge.rootSelector = this$1.wizard.state.wrapper || null;
this$1.wizard.bridge.mode = ies.OSC_MODE_SELECT;
this$1.wizard.bridge.onSelectorChanged = function () {
this$1.wizard.state.product = this$1.wizard.bridge.selector;
};
this$1.wizard.log("Loaded step 2.");
});
};
SelectElementStep.prototype.deactivate = function deactivate () {
this.wizard.bridge.onSelectorChanged = function(){};
this.wizard.bridge.selector = null;
this.wizard.bridge.rootSelector = null;
this.wizard.bridge.mode = ies.OSC_MODE_NONE;
};
return SelectElementStep;
}(WizardStep));
var Wizard = function Wizard() {
var this$1 = this;
this.state = {};
$("#prev").bind('click', function () { return this$1.prev(); });
$("#next").bind('click', function () { return this$1.next(); });
this.log = function (msg) { return $('<div class="msg"></div>')
.append($('<span class="date"></span>').text(new Date().toUTCString()))
.append(" "+msg).appendTo('#log'); };
this.content = function (html) { return $('#wizard').html(html); };
this.steps = [
new SelectWrapperStep(this),
new SelectElementStep(this)
];
this.bridge = new ies.ParentBridge();
this.bridge.initialize("iframe.html", $("#browser").get(0));
this.bridge.onInitialized = function () {
this$1.log("Parent-child communication initialized!");
this$1.step = 0;
this$1.steps[this$1.step].activate();
};
};
Wizard.prototype.prev = function prev () {
if ((this.step > 0) && (this.steps[this.step].canPrev())) {
this.steps[this.step].deactivate();
this.step--;
this.steps[this.step].activate();
}
};
Wizard.prototype.next = function next () {
if ((this.step < this.steps.length - 1) && (this.steps[this.step].canNext())) {
this.steps[this.step].deactivate();
this.step++;
this.steps[this.step].activate();
}
};
var wizard = new Wizard();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment