iwmlib/3rdparty/optimal-select.min.js.map

1 line
100 KiB
Plaintext

{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///optimal-select.min.js","webpack:///webpack/bootstrap e2ae245b56dad6ed497e","webpack:///./src/utilities.js","webpack:///./src/common.js","webpack:///./src/optimize.js","webpack:///./src/adapt.js","webpack:///./src/select.js","webpack:///./src/match.js","webpack:///./src/index.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","convertNodeList","nodes","length","arr","Array","escapeValue","replace","getCommonAncestor","elements","options","arguments","undefined","_options$root","document","ancestors","forEach","element","index","parents","parentNode","unshift","sort","curr","next","shallowAncestor","shift","ancestor","_loop","parent","missing","some","otherParents","otherParent","_ret","getCommonProperties","commonProperties","classes","attributes","tag","commonClasses","commonAttributes","commonTag","getAttribute","trim","split","filter","entry","elementAttributes","keys","reduce","key","attribute","attributeName","attributesNames","commonAttributesNames","nextCommonAttributes","tagName","toLowerCase","_interopRequireDefault","obj","default","optimize","selector","isArray","_utilities","nodeType","Error","globalModified","_adapt2","path","optimizePart","shortened","pop","current","prePart","join","postPart","pattern","matches","querySelectorAll","slice","test","compareResults","references","reference","contains","description","descendant","type","names","map","partial","charAt","match","_loop2","_ret2","every","_adapt","adapt","Symbol","iterator","constructor","sliceIterator","_arr","_n","_d","_e","_s","_i","done","push","err","TypeError","getSingleSelector","_typeof","_match2","optimized","_optimize2","getMultiSelector","_common","ancestorSelector","commonSelectors","getCommonSelectors","descendantSelector","selectorMatches","console","warn","_getCommonProperties","selectorPath","classSelector","attributeSelector","parts","getQuerySelector","input","_match","_optimize","node","_options$skip","skip","_options$priority","priority","_options$ignore","ignore","ignoreClass","skipCompare","skipChecks","compare","predicate","toString","RegExp","ignoreAttribute","defaultPredicate","class","checkAttributes","checkTag","checkChilds","findPattern","findAttributesPattern","sortedKeys","currPos","indexOf","nextPos","attributeValue","currentIgnore","currentDefaultIgnore","defaultIgnore","checkIgnore","className","findTagPattern","getElementsByTagName","children","childTags","child","childPattern","check","_interopRequireWildcard","newObj","common","select","_select2","_select3","_optimize3","_common2"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,cAAAD,IAEAD,EAAA,cAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA+DA,OAnCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAG,EAAA,SAAAK,GAA2C,MAAAA,IAG3CR,EAAAS,EAAA,SAAAf,EAAAgB,EAAAC,GACAX,EAAAY,EAAAlB,EAAAgB,IACAG,OAAAC,eAAApB,EAAAgB,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAX,EAAAkB,EAAA,SAAAvB,GACA,GAAAgB,GAAAhB,KAAAwB,WACA,WAA2B,MAAAxB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,EAAAC,IAGtDrB,EAAAwB,EAAA,GAGAxB,IAAAyB,EAAA,KDgBM,SAAS9B,EAAQD,EAASM,GAEhC,YEtEO,SAAS0B,GAAiBC,GAG/B,IAAK,GAFGC,GAAWD,EAAXC,OACFC,EAAM,GAAIC,OAAMF,GACb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optimal-select.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"OptimalSelect\"] = factory();\n\telse\n\t\troot[\"OptimalSelect\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"OptimalSelect\"] = factory();\n\telse\n\t\troot[\"OptimalSelect\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 6);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.convertNodeList = convertNodeList;\nexports.escapeValue = escapeValue;\n/**\n * # Utilities\n *\n * Convenience helpers.\n */\n\n/**\n * Create an array with the DOM nodes of the list\n *\n * @param {NodeList} nodes - [description]\n * @return {Array.<HTMLElement>} - [description]\n */\nfunction convertNodeList(nodes) {\n var length = nodes.length;\n\n var arr = new Array(length);\n for (var i = 0; i < length; i++) {\n arr[i] = nodes[i];\n }\n return arr;\n}\n\n/**\n * Escape special characters and line breaks as a simplified version of 'CSS.escape()'\n *\n * Description of valid characters: https://mathiasbynens.be/notes/css-escapes\n *\n * @param {String?} value - [description]\n * @return {String} - [description]\n */\nfunction escapeValue(value) {\n return value && value.replace(/['\"`\\\\/:\\?&!#$%^()[\\]{|}*+;,.<=>@~]/g, '\\\\$&').replace(/\\n/g, '\\A');\n}\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.getCommonAncestor = getCommonAncestor;\nexports.getCommonProperties = getCommonProperties;\n/**\n * # Common\n *\n * Process collections for similarities.\n */\n\n/**\n * Find the last common ancestor of elements\n *\n * @param {Array.<HTMLElements>} elements - [description]\n * @return {HTMLElement} - [description]\n */\nfunction getCommonAncestor(elements) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var _options$root = options.root,\n root = _options$root === undefined ? document : _options$root;\n\n\n var ancestors = [];\n\n elements.forEach(function (element, index) {\n var parents = [];\n while (element !== root) {\n element = element.parentNode;\n parents.unshift(element);\n }\n ancestors[index] = parents;\n });\n\n ancestors.sort(function (curr, next) {\n return curr.length - next.length;\n });\n\n var shallowAncestor = ancestors.shift();\n\n var ancestor = null;\n\n var _loop = function _loop() {\n var parent = shallowAncestor[i];\n var missing = ancestors.some(function (otherParents) {\n return !otherParents.some(function (otherParent) {\n return otherParent === parent;\n });\n });\n\n if (missing) {\n // TODO: find similar sub-parents, not the top root, e.g. sharing a class selector\n return 'break';\n }\n\n ancestor = parent;\n };\n\n for (var i = 0, l = shallowAncestor.length; i < l; i++) {\n var _ret = _loop();\n\n if (_ret === 'break') break;\n }\n\n return ancestor;\n}\n\n/**\n * Get a set of common properties of elements\n *\n * @param {Array.<HTMLElement>} elements - [description]\n * @return {Object} - [description]\n */\nfunction getCommonProperties(elements) {\n\n var commonProperties = {\n classes: [],\n attributes: {},\n tag: null\n };\n\n elements.forEach(function (element) {\n var commonClasses = commonProperties.classes,\n commonAttributes = commonProperties.attributes,\n commonTag = commonProperties.tag;\n\n // ~ classes\n\n if (commonClasses !== undefined) {\n var classes = element.getAttribute('class');\n if (classes) {\n classes = classes.trim().split(' ');\n if (!commonClasses.length) {\n commonProperties.classes = classes;\n } else {\n commonClasses = commonClasses.filter(function (entry) {\n return classes.some(function (name) {\n return name === entry;\n });\n });\n if (commonClasses.length) {\n commonProperties.classes = commonClasses;\n } else {\n delete commonProperties.classes;\n }\n }\n } else {\n // TODO: restructure removal as 2x set / 2x delete, instead of modify always replacing with new collection\n delete commonProperties.classes;\n }\n }\n\n // ~ attributes\n if (commonAttributes !== undefined) {\n (function () {\n var elementAttributes = element.attributes;\n var attributes = Object.keys(elementAttributes).reduce(function (attributes, key) {\n var attribute = elementAttributes[key];\n var attributeName = attribute.name;\n // NOTE: workaround detection for non-standard phantomjs NamedNodeMap behaviour\n // (issue: https://github.com/ariya/phantomjs/issues/14634)\n if (attribute && attributeName !== 'class') {\n attributes[attributeName] = attribute.value;\n }\n return attributes;\n }, {});\n\n var attributesNames = Object.keys(attributes);\n var commonAttributesNames = Object.keys(commonAttributes);\n\n if (attributesNames.length) {\n if (!commonAttributesNames.length) {\n commonProperties.attributes = attributes;\n } else {\n commonAttributes = commonAttributesNames.reduce(function (nextCommonAttributes, name) {\n var value = commonAttributes[name];\n if (value === attributes[name]) {\n nextCommonAttributes[name] = value;\n }\n return nextCommonAttributes;\n }, {});\n if (Object.keys(commonAttributes).length) {\n commonProperties.attributes = commonAttributes;\n } else {\n delete commonProperties.attributes;\n }\n }\n } else {\n delete commonProperties.attributes;\n }\n })();\n }\n\n // ~ tag\n if (commonTag !== undefined) {\n var tag = element.tagName.toLowerCase();\n if (!commonTag) {\n commonProperties.tag = tag;\n } else if (tag !== commonTag) {\n delete commonProperties.tag;\n }\n }\n });\n\n return commonProperties;\n}\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = optimize;\n\nvar _adapt = __webpack_require__(3);\n\nvar _adapt2 = _interopRequireDefault(_adapt);\n\nvar _utilities = __webpack_require__(0);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Apply different optimization techniques\n *\n * @param {string} selector - [description]\n * @param {HTMLElement|Array.<HTMLElement>} element - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\n/**\n * # Optimize\n *\n * 1.) Improve efficiency through shorter selectors by removing redundancy\n * 2.) Improve robustness through selector transformation\n */\n\nfunction optimize(selector, elements) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n\n // convert single entry and NodeList\n if (!Array.isArray(elements)) {\n elements = !elements.length ? [elements] : (0, _utilities.convertNodeList)(elements);\n }\n\n if (!elements.length || elements.some(function (element) {\n return element.nodeType !== 1;\n })) {\n throw new Error('Invalid input - to compare HTMLElements its necessary to provide a reference of the selected node(s)! (missing \"elements\")');\n }\n\n var globalModified = (0, _adapt2.default)(elements[0], options);\n\n // chunk parts outside of quotes (http://stackoverflow.com/a/25663729)\n var path = selector.replace(/> /g, '>').split(/\\s+(?=(?:(?:[^\"]*\"){2})*[^\"]*$)/);\n\n if (path.length < 2) {\n return optimizePart('', selector, '', elements);\n }\n\n var shortened = [path.pop()];\n while (path.length > 1) {\n var current = path.pop();\n var prePart = path.join(' ');\n var postPart = shortened.join(' ');\n\n var pattern = prePart + ' ' + postPart;\n var matches = document.querySelectorAll(pattern);\n if (matches.length !== elements.length) {\n shortened.unshift(optimizePart(prePart, current, postPart, elements));\n }\n }\n shortened.unshift(path[0]);\n path = shortened;\n\n // optimize start + end\n path[0] = optimizePart('', path[0], path.slice(1).join(' '), elements);\n path[path.length - 1] = optimizePart(path.slice(0, -1).join(' '), path[path.length - 1], '', elements);\n\n if (globalModified) {\n delete true;\n }\n\n return path.join(' ').replace(/>/g, '> ').trim();\n}\n\n/**\n * Improve a chunk of the selector\n *\n * @param {string} prePart - [description]\n * @param {string} current - [description]\n * @param {string} postPart - [description]\n * @param {Array.<HTMLElement>} elements - [description]\n * @return {string} - [description]\n */\nfunction optimizePart(prePart, current, postPart, elements) {\n if (prePart.length) prePart = prePart + ' ';\n if (postPart.length) postPart = ' ' + postPart;\n\n // robustness: attribute without value (generalization)\n if (/\\[*\\]/.test(current)) {\n var key = current.replace(/=.*$/, ']');\n var pattern = '' + prePart + key + postPart;\n var matches = document.querySelectorAll(pattern);\n if (compareResults(matches, elements)) {\n current = key;\n } else {\n // robustness: replace specific key-value with base tag (heuristic)\n var references = document.querySelectorAll('' + prePart + key);\n\n var _loop = function _loop() {\n var reference = references[i];\n if (elements.some(function (element) {\n return reference.contains(element);\n })) {\n var description = reference.tagName.toLowerCase();\n pattern = '' + prePart + description + postPart;\n matches = document.querySelectorAll(pattern);\n\n if (compareResults(matches, elements)) {\n current = description;\n }\n return 'break';\n }\n };\n\n for (var i = 0, l = references.length; i < l; i++) {\n var pattern;\n var matches;\n\n var _ret = _loop();\n\n if (_ret === 'break') break;\n }\n }\n }\n\n // robustness: descendant instead child (heuristic)\n if (/>/.test(current)) {\n var descendant = current.replace(/>/, '');\n var pattern = '' + prePart + descendant + postPart;\n var matches = document.querySelectorAll(pattern);\n if (compareResults(matches, elements)) {\n current = descendant;\n }\n }\n\n // robustness: 'nth-of-type' instead 'nth-child' (heuristic)\n if (/:nth-child/.test(current)) {\n // TODO: consider complete coverage of 'nth-of-type' replacement\n var type = current.replace(/nth-child/g, 'nth-of-type');\n var pattern = '' + prePart + type + postPart;\n var matches = document.querySelectorAll(pattern);\n if (compareResults(matches, elements)) {\n current = type;\n }\n }\n\n // efficiency: combinations of classname (partial permutations)\n if (/\\.\\S+\\.\\S+/.test(current)) {\n var names = current.trim().split('.').slice(1).map(function (name) {\n return '.' + name;\n }).sort(function (curr, next) {\n return curr.length - next.length;\n });\n while (names.length) {\n var partial = current.replace(names.shift(), '').trim();\n var pattern = ('' + prePart + partial + postPart).trim();\n if (!pattern.length || pattern.charAt(0) === '>' || pattern.charAt(pattern.length - 1) === '>') {\n break;\n }\n var matches = document.querySelectorAll(pattern);\n if (compareResults(matches, elements)) {\n current = partial;\n }\n }\n\n // robustness: degrade complex classname (heuristic)\n names = current && current.match(/\\./g);\n if (names && names.length > 2) {\n var _references = document.querySelectorAll('' + prePart + current);\n\n var _loop2 = function _loop2() {\n var reference = _references[i];\n if (elements.some(function (element) {\n return reference.contains(element);\n })) {\n // TODO:\n // - check using attributes + regard excludes\n var description = reference.tagName.toLowerCase();\n pattern = '' + prePart + description + postPart;\n matches = document.querySelectorAll(pattern);\n\n if (compareResults(matches, elements)) {\n current = description;\n }\n return 'break';\n }\n };\n\n for (var i = 0, l = _references.length; i < l; i++) {\n var pattern;\n var matches;\n\n var _ret2 = _loop2();\n\n if (_ret2 === 'break') break;\n }\n }\n }\n\n return current;\n}\n\n/**\n * Evaluate matches with expected elements\n *\n * @param {Array.<HTMLElement>} matches - [description]\n * @param {Array.<HTMLElement>} elements - [description]\n * @return {Boolean} - [description]\n */\nfunction compareResults(matches, elements) {\n var length = matches.length;\n\n return length === elements.length && elements.every(function (element) {\n for (var i = 0; i < length; i++) {\n if (matches[i] === element) {\n return true;\n }\n }\n return false;\n });\n}\nmodule.exports = exports['default'];\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _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; };\n\nvar _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\"); } }; }();\n\nexports.default = adapt;\n/**\n * # Adapt\n *\n * Check and extend the environment for universal usage.\n */\n\n/**\n * Modify the context based on the environment\n *\n * @param {HTMLELement} element - [description]\n * @param {Object} options - [description]\n * @return {boolean} - [description]\n */\nfunction adapt(element, options) {\n\n // detect environment setup\n if (true) {\n return false;\n } else {\n global.document = options.context || function () {\n var root = element;\n while (root.parent) {\n root = root.parent;\n }\n return root;\n }();\n }\n\n // https://github.com/fb55/domhandler/blob/master/index.js#L75\n var ElementPrototype = Object.getPrototypeOf(true);\n\n // alternative descriptor to access elements with filtering invalid elements (e.g. textnodes)\n if (!Object.getOwnPropertyDescriptor(ElementPrototype, 'childTags')) {\n Object.defineProperty(ElementPrototype, 'childTags', {\n enumerable: true,\n get: function get() {\n return this.children.filter(function (node) {\n // https://github.com/fb55/domelementtype/blob/master/index.js#L12\n return node.type === 'tag' || node.type === 'script' || node.type === 'style';\n });\n }\n });\n }\n\n if (!Object.getOwnPropertyDescriptor(ElementPrototype, 'attributes')) {\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes\n // https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap\n Object.defineProperty(ElementPrototype, 'attributes', {\n enumerable: true,\n get: function get() {\n var attribs = this.attribs;\n\n var attributesNames = Object.keys(attribs);\n var NamedNodeMap = attributesNames.reduce(function (attributes, attributeName, index) {\n attributes[index] = {\n name: attributeName,\n value: attribs[attributeName]\n };\n return attributes;\n }, {});\n Object.defineProperty(NamedNodeMap, 'length', {\n enumerable: false,\n configurable: false,\n value: attributesNames.length\n });\n return NamedNodeMap;\n }\n });\n }\n\n if (!ElementPrototype.getAttribute) {\n // https://docs.webplatform.org/wiki/dom/Element/getAttribute\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute\n ElementPrototype.getAttribute = function (name) {\n return this.attribs[name] || null;\n };\n }\n\n if (!ElementPrototype.getElementsByTagName) {\n // https://docs.webplatform.org/wiki/dom/Document/getElementsByTagName\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName\n ElementPrototype.getElementsByTagName = function (tagName) {\n var HTMLCollection = [];\n traverseDescendants(this.childTags, function (descendant) {\n if (descendant.name === tagName || tagName === '*') {\n HTMLCollection.push(descendant);\n }\n });\n return HTMLCollection;\n };\n }\n\n if (!ElementPrototype.getElementsByClassName) {\n // https://docs.webplatform.org/wiki/dom/Document/getElementsByClassName\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName\n ElementPrototype.getElementsByClassName = function (className) {\n var names = className.trim().replace(/\\s+/g, ' ').split(' ');\n var HTMLCollection = [];\n traverseDescendants([this], function (descendant) {\n var descendantClassName = descendant.attribs.class;\n if (descendantClassName && names.every(function (name) {\n return descendantClassName.indexOf(name) > -1;\n })) {\n HTMLCollection.push(descendant);\n }\n });\n return HTMLCollection;\n };\n }\n\n if (!ElementPrototype.querySelectorAll) {\n // https://docs.webplatform.org/wiki/css/selectors_api/querySelectorAll\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll\n ElementPrototype.querySelectorAll = function (selectors) {\n var _this = this;\n\n selectors = selectors.replace(/(>)(\\S)/g, '$1 $2').trim(); // add space for '>' selector\n\n // using right to left execution => https://github.com/fb55/css-select#how-does-it-work\n var instructions = getInstructions(selectors);\n var discover = instructions.shift();\n\n var total = instructions.length;\n return discover(this).filter(function (node) {\n var step = 0;\n while (step < total) {\n node = instructions[step](node, _this);\n if (!node) {\n // hierarchy doesn't match\n return false;\n }\n step += 1;\n }\n return true;\n });\n };\n }\n\n if (!ElementPrototype.contains) {\n // https://developer.mozilla.org/en-US/docs/Web/API/Node/contains\n ElementPrototype.contains = function (element) {\n var inclusive = false;\n traverseDescendants([this], function (descendant, done) {\n if (descendant === element) {\n inclusive = true;\n done();\n }\n });\n return inclusive;\n };\n }\n\n return true;\n}\n\n/**\n * Retrieve transformation steps\n *\n * @param {Array.<string>} selectors - [description]\n * @return {Array.<Function>} - [description]\n */\nfunction getInstructions(selectors) {\n return selectors.split(' ').reverse().map(function (selector, step) {\n var discover = step === 0;\n\n var _selector$split = selector.split(':'),\n _selector$split2 = _slicedToArray(_selector$split, 2),\n type = _selector$split2[0],\n pseudo = _selector$split2[1];\n\n var validate = null;\n var instruction = null;\n\n (function () {\n switch (true) {\n\n // child: '>'\n case />/.test(type):\n instruction = function checkParent(node) {\n return function (validate) {\n return validate(node.parent) && node.parent;\n };\n };\n break;\n\n // class: '.'\n case /^\\./.test(type):\n var names = type.substr(1).split('.');\n validate = function validate(node) {\n var nodeClassName = node.attribs.class;\n return nodeClassName && names.every(function (name) {\n return nodeClassName.indexOf(name) > -1;\n });\n };\n instruction = function checkClass(node, root) {\n if (discover) {\n return node.getElementsByClassName(names.join(' '));\n }\n return typeof node === 'function' ? node(validate) : getAncestor(node, root, validate);\n };\n break;\n\n // attribute: '[key=\"value\"]'\n case /^\\[/.test(type):\n var _type$replace$split = type.replace(/\\[|\\]|\"/g, '').split('='),\n _type$replace$split2 = _slicedToArray(_type$replace$split, 2),\n attributeKey = _type$replace$split2[0],\n attributeValue = _type$replace$split2[1];\n\n validate = function validate(node) {\n var hasAttribute = Object.keys(node.attribs).indexOf(attributeKey) > -1;\n if (hasAttribute) {\n // regard optional attributeValue\n if (!attributeValue || node.attribs[attributeKey] === attributeValue) {\n return true;\n }\n }\n return false;\n };\n instruction = function checkAttribute(node, root) {\n if (discover) {\n var _ret2 = function () {\n var NodeList = [];\n traverseDescendants([node], function (descendant) {\n if (validate(descendant)) {\n NodeList.push(descendant);\n }\n });\n return {\n v: NodeList\n };\n }();\n\n if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === \"object\") return _ret2.v;\n }\n return typeof node === 'function' ? node(validate) : getAncestor(node, root, validate);\n };\n break;\n\n // id: '#'\n case /^#/.test(type):\n var id = type.substr(1);\n validate = function validate(node) {\n return node.attribs.id === id;\n };\n instruction = function checkId(node, root) {\n if (discover) {\n var _ret3 = function () {\n var NodeList = [];\n traverseDescendants([node], function (descendant, done) {\n if (validate(descendant)) {\n NodeList.push(descendant);\n done();\n }\n });\n return {\n v: NodeList\n };\n }();\n\n if ((typeof _ret3 === 'undefined' ? 'undefined' : _typeof(_ret3)) === \"object\") return _ret3.v;\n }\n return typeof node === 'function' ? node(validate) : getAncestor(node, root, validate);\n };\n break;\n\n // universal: '*'\n case /\\*/.test(type):\n validate = function validate(node) {\n return true;\n };\n instruction = function checkUniversal(node, root) {\n if (discover) {\n var _ret4 = function () {\n var NodeList = [];\n traverseDescendants([node], function (descendant) {\n return NodeList.push(descendant);\n });\n return {\n v: NodeList\n };\n }();\n\n if ((typeof _ret4 === 'undefined' ? 'undefined' : _typeof(_ret4)) === \"object\") return _ret4.v;\n }\n return typeof node === 'function' ? node(validate) : getAncestor(node, root, validate);\n };\n break;\n\n // tag: '...'\n default:\n validate = function validate(node) {\n return node.name === type;\n };\n instruction = function checkTag(node, root) {\n if (discover) {\n var _ret5 = function () {\n var NodeList = [];\n traverseDescendants([node], function (descendant) {\n if (validate(descendant)) {\n NodeList.push(descendant);\n }\n });\n return {\n v: NodeList\n };\n }();\n\n if ((typeof _ret5 === 'undefined' ? 'undefined' : _typeof(_ret5)) === \"object\") return _ret5.v;\n }\n return typeof node === 'function' ? node(validate) : getAncestor(node, root, validate);\n };\n }\n })();\n\n if (!pseudo) {\n return instruction;\n }\n\n var rule = pseudo.match(/-(child|type)\\((\\d+)\\)$/);\n var kind = rule[1];\n var index = parseInt(rule[2], 10) - 1;\n\n var validatePseudo = function validatePseudo(node) {\n if (node) {\n var compareSet = node.parent.childTags;\n if (kind === 'type') {\n compareSet = compareSet.filter(validate);\n }\n var nodeIndex = compareSet.findIndex(function (child) {\n return child === node;\n });\n if (nodeIndex === index) {\n return true;\n }\n }\n return false;\n };\n\n return function enhanceInstruction(node) {\n var match = instruction(node);\n if (discover) {\n return match.reduce(function (NodeList, matchedNode) {\n if (validatePseudo(matchedNode)) {\n NodeList.push(matchedNode);\n }\n return NodeList;\n }, []);\n }\n return validatePseudo(match) && match;\n };\n });\n}\n\n/**\n * Walking recursive to invoke callbacks\n *\n * @param {Array.<HTMLElement>} nodes - [description]\n * @param {Function} handler - [description]\n */\nfunction traverseDescendants(nodes, handler) {\n nodes.forEach(function (node) {\n var progress = true;\n handler(node, function () {\n return progress = false;\n });\n if (node.childTags && progress) {\n traverseDescendants(node.childTags, handler);\n }\n });\n}\n\n/**\n * Bubble up from bottom to top\n *\n * @param {HTMLELement} node - [description]\n * @param {HTMLELement} root - [description]\n * @param {Function} validate - [description]\n * @return {HTMLELement} - [description]\n */\nfunction getAncestor(node, root, validate) {\n while (node.parent) {\n node = node.parent;\n if (validate(node)) {\n return node;\n }\n if (node === root) {\n break;\n }\n }\n return null;\n}\nmodule.exports = exports['default'];\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _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; }; /**\n * # Select\n *\n * Construct a unique CSS query selector to access the selected DOM element(s).\n * For longevity it applies different matching and optimization strategies.\n */\n\nexports.getSingleSelector = getSingleSelector;\nexports.getMultiSelector = getMultiSelector;\nexports.default = getQuerySelector;\n\nvar _adapt = __webpack_require__(3);\n\nvar _adapt2 = _interopRequireDefault(_adapt);\n\nvar _match = __webpack_require__(5);\n\nvar _match2 = _interopRequireDefault(_match);\n\nvar _optimize = __webpack_require__(2);\n\nvar _optimize2 = _interopRequireDefault(_optimize);\n\nvar _utilities = __webpack_require__(0);\n\nvar _common = __webpack_require__(1);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Get a selector for the provided element\n *\n * @param {HTMLElement} element - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nfunction getSingleSelector(element) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\n if (element.nodeType === 3) {\n element = element.parentNode;\n }\n\n if (element.nodeType !== 1) {\n throw new Error('Invalid input - only HTMLElements or representations of them are supported! (not \"' + (typeof element === 'undefined' ? 'undefined' : _typeof(element)) + '\")');\n }\n\n var globalModified = (0, _adapt2.default)(element, options);\n\n var selector = (0, _match2.default)(element, options);\n var optimized = (0, _optimize2.default)(selector, element, options);\n\n // debug\n // console.log(`\n // selector: ${selector}\n // optimized: ${optimized}\n // `)\n\n if (globalModified) {\n delete true;\n }\n\n return optimized;\n}\n\n/**\n * Get a selector to match multiple descendants from an ancestor\n *\n * @param {Array.<HTMLElement>|NodeList} elements - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nfunction getMultiSelector(elements) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\n if (!Array.isArray(elements)) {\n elements = (0, _utilities.convertNodeList)(elements);\n }\n\n if (elements.some(function (element) {\n return element.nodeType !== 1;\n })) {\n throw new Error('Invalid input - only an Array of HTMLElements or representations of them is supported!');\n }\n\n var globalModified = (0, _adapt2.default)(elements[0], options);\n\n var ancestor = (0, _common.getCommonAncestor)(elements, options);\n var ancestorSelector = getSingleSelector(ancestor, options);\n\n // TODO: consider usage of multiple selectors + parent-child relation + check for part redundancy\n var commonSelectors = getCommonSelectors(elements);\n var descendantSelector = commonSelectors[0];\n\n var selector = (0, _optimize2.default)(ancestorSelector + ' ' + descendantSelector, elements, options);\n var selectorMatches = (0, _utilities.convertNodeList)(document.querySelectorAll(selector));\n\n if (!elements.every(function (element) {\n return selectorMatches.some(function (entry) {\n return entry === element;\n });\n })) {\n // TODO: cluster matches to split into similar groups for sub selections\n return console.warn('\\n The selected elements can\\'t be efficiently mapped.\\n Its probably best to use multiple single selectors instead!\\n ', elements);\n }\n\n if (globalModified) {\n delete true;\n }\n\n return selector;\n}\n\n/**\n * Get selectors to describe a set of elements\n *\n * @param {Array.<HTMLElements>} elements - [description]\n * @return {string} - [description]\n */\nfunction getCommonSelectors(elements) {\n var _getCommonProperties = (0, _common.getCommonProperties)(elements),\n classes = _getCommonProperties.classes,\n attributes = _getCommonProperties.attributes,\n tag = _getCommonProperties.tag;\n\n var selectorPath = [];\n\n if (tag) {\n selectorPath.push(tag);\n }\n\n if (classes) {\n var classSelector = classes.map(function (name) {\n return '.' + name;\n }).join('');\n selectorPath.push(classSelector);\n }\n\n if (attributes) {\n var attributeSelector = Object.keys(attributes).reduce(function (parts, name) {\n parts.push('[' + name + '=\"' + attributes[name] + '\"]');\n return parts;\n }, []).join('');\n selectorPath.push(attributeSelector);\n }\n\n if (selectorPath.length) {\n // TODO: check for parent-child relation\n }\n\n return [selectorPath.join('')];\n}\n\n/**\n * Choose action depending on the input (multiple/single)\n *\n * NOTE: extended detection is used for special cases like the <select> element with <options>\n *\n * @param {HTMLElement|NodeList|Array.<HTMLElement>} input - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nfunction getQuerySelector(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (input.length && !input.name) {\n return getMultiSelector(input, options);\n }\n return getSingleSelector(input, options);\n}\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = match;\n\nvar _utilities = __webpack_require__(0);\n\nvar defaultIgnore = {\n attribute: function attribute(attributeName) {\n return ['style', 'data-reactid', 'data-react-checksum'].indexOf(attributeName) > -1;\n }\n};\n\n/**\n * Get the path of the element\n *\n * @param {HTMLElement} node - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\n/**\n * # Match\n *\n * Retrieve selector for a node.\n */\n\nfunction match(node, options) {\n var _options$root = options.root,\n root = _options$root === undefined ? document : _options$root,\n _options$skip = options.skip,\n skip = _options$skip === undefined ? null : _options$skip,\n _options$priority = options.priority,\n priority = _options$priority === undefined ? ['id', 'class', 'href', 'src'] : _options$priority,\n _options$ignore = options.ignore,\n ignore = _options$ignore === undefined ? {} : _options$ignore;\n\n\n var path = [];\n var element = node;\n var length = path.length;\n var ignoreClass = false;\n\n var skipCompare = skip && (Array.isArray(skip) ? skip : [skip]).map(function (entry) {\n if (typeof entry !== 'function') {\n return function (element) {\n return element === entry;\n };\n }\n return entry;\n });\n\n var skipChecks = function skipChecks(element) {\n return skip && skipCompare.some(function (compare) {\n return compare(element);\n });\n };\n\n Object.keys(ignore).forEach(function (type) {\n if (type === 'class') {\n ignoreClass = true;\n }\n var predicate = ignore[type];\n if (typeof predicate === 'function') return;\n if (typeof predicate === 'number') {\n predicate = predicate.toString();\n }\n if (typeof predicate === 'string') {\n predicate = new RegExp((0, _utilities.escapeValue)(predicate).replace(/\\\\/g, '\\\\\\\\'));\n }\n if (typeof predicate === 'boolean') {\n predicate = predicate ? /(?:)/ : /.^/;\n }\n // check class-/attributename for regex\n ignore[type] = function (name, value) {\n return predicate.test(value);\n };\n });\n\n if (ignoreClass) {\n (function () {\n var ignoreAttribute = ignore.attribute;\n ignore.attribute = function (name, value, defaultPredicate) {\n return ignore.class(value) || ignoreAttribute && ignoreAttribute(name, value, defaultPredicate);\n };\n })();\n }\n\n while (element !== root) {\n if (skipChecks(element) !== true) {\n // ~ global\n if (checkAttributes(priority, element, ignore, path, root)) break;\n if (checkTag(element, ignore, path, root)) break;\n\n // ~ local\n checkAttributes(priority, element, ignore, path);\n if (path.length === length) {\n checkTag(element, ignore, path);\n }\n\n // define only one part each iteration\n if (path.length === length) {\n checkChilds(priority, element, ignore, path);\n }\n }\n\n element = element.parentNode;\n length = path.length;\n }\n\n if (element === root) {\n var pattern = findPattern(priority, element, ignore);\n path.unshift(pattern);\n }\n\n return path.join(' ');\n}\n\n/**\n * Extend path with attribute identifier\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @param {Array.<string>} path - [description]\n * @param {HTMLElement} parent - [description]\n * @return {boolean} - [description]\n */\nfunction checkAttributes(priority, element, ignore, path) {\n var parent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : element.parentNode;\n\n var pattern = findAttributesPattern(priority, element, ignore);\n if (pattern) {\n var matches = parent.querySelectorAll(pattern);\n if (matches.length === 1) {\n path.unshift(pattern);\n return true;\n }\n }\n return false;\n}\n\n/**\n * Lookup attribute identifier\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @return {string?} - [description]\n */\nfunction findAttributesPattern(priority, element, ignore) {\n var attributes = element.attributes;\n var sortedKeys = Object.keys(attributes).sort(function (curr, next) {\n var currPos = priority.indexOf(attributes[curr].name);\n var nextPos = priority.indexOf(attributes[next].name);\n if (nextPos === -1) {\n if (currPos === -1) {\n return 0;\n }\n return -1;\n }\n return currPos - nextPos;\n });\n\n for (var i = 0, l = sortedKeys.length; i < l; i++) {\n var key = sortedKeys[i];\n var attribute = attributes[key];\n var attributeName = attribute.name;\n var attributeValue = (0, _utilities.escapeValue)(attribute.value);\n\n var currentIgnore = ignore[attributeName] || ignore.attribute;\n var currentDefaultIgnore = defaultIgnore[attributeName] || defaultIgnore.attribute;\n if (checkIgnore(currentIgnore, attributeName, attributeValue, currentDefaultIgnore)) {\n continue;\n }\n\n var pattern = '[' + attributeName + '=\"' + attributeValue + '\"]';\n\n if (/\\b\\d/.test(attributeValue) === false) {\n if (attributeName === 'id') {\n pattern = '#' + attributeValue;\n }\n\n if (attributeName === 'class') {\n var className = attributeValue.trim().replace(/\\s+/g, '.');\n pattern = '.' + className;\n }\n }\n\n return pattern;\n }\n return null;\n}\n\n/**\n * Extend path with tag identifier\n *\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @param {Array.<string>} path - [description]\n * @param {HTMLElement} parent - [description]\n * @return {boolean} - [description]\n */\nfunction checkTag(element, ignore, path) {\n var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : element.parentNode;\n\n var pattern = findTagPattern(element, ignore);\n if (pattern) {\n var matches = parent.getElementsByTagName(pattern);\n if (matches.length === 1) {\n path.unshift(pattern);\n return true;\n }\n }\n return false;\n}\n\n/**\n * Lookup tag identifier\n *\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @return {boolean} - [description]\n */\nfunction findTagPattern(element, ignore) {\n var tagName = element.tagName.toLowerCase();\n if (checkIgnore(ignore.tag, null, tagName)) {\n return null;\n }\n return tagName;\n}\n\n/**\n * Extend path with specific child identifier\n *\n * NOTE: 'childTags' is a custom property to use as a view filter for tags using 'adapter.js'\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @param {Array.<string>} path - [description]\n * @return {boolean} - [description]\n */\nfunction checkChilds(priority, element, ignore, path) {\n var parent = element.parentNode;\n var children = parent.childTags || parent.children;\n for (var i = 0, l = children.length; i < l; i++) {\n var child = children[i];\n if (child === element) {\n var childPattern = findPattern(priority, child, ignore);\n if (!childPattern) {\n return console.warn('\\n Element couldn\\'t be matched through strict ignore pattern!\\n ', child, ignore, childPattern);\n }\n var pattern = '> ' + childPattern + ':nth-child(' + (i + 1) + ')';\n path.unshift(pattern);\n return true;\n }\n }\n return false;\n}\n\n/**\n * Lookup identifier\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @return {string} - [description]\n */\nfunction findPattern(priority, element, ignore) {\n var pattern = findAttributesPattern(priority, element, ignore);\n if (!pattern) {\n pattern = findTagPattern(element, ignore);\n }\n return pattern;\n}\n\n/**\n * Validate with custom and default functions\n *\n * @param {Function} predicate - [description]\n * @param {string?} name - [description]\n * @param {string} value - [description]\n * @param {Function} defaultPredicate - [description]\n * @return {boolean} - [description]\n */\nfunction checkIgnore(predicate, name, value, defaultPredicate) {\n if (!value) {\n return true;\n }\n var check = predicate || defaultPredicate;\n if (!check) {\n return false;\n }\n return check(name, value, defaultPredicate);\n}\nmodule.exports = exports['default'];\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = exports.common = exports.optimize = exports.getMultiSelector = exports.getSingleSelector = exports.select = undefined;\n\nvar _select2 = __webpack_require__(4);\n\nObject.defineProperty(exports, 'getSingleSelector', {\n enumerable: true,\n get: function get() {\n return _select2.getSingleSelector;\n }\n});\nObject.defineProperty(exports, 'getMultiSelector', {\n enumerable: true,\n get: function get() {\n return _select2.getMultiSelector;\n }\n});\n\nvar _select3 = _interopRequireDefault(_select2);\n\nvar _optimize2 = __webpack_require__(2);\n\nvar _optimize3 = _interopRequireDefault(_optimize2);\n\nvar _common2 = __webpack_require__(1);\n\nvar _common = _interopRequireWildcard(_common2);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.select = _select3.default;\nexports.optimize = _optimize3.default;\nexports.common = _common;\nexports.default = _select3.default;\n\n/***/ }\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// optimal-select.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap e2ae245b56dad6ed497e","/**\n * # Utilities\n *\n * Convenience helpers.\n */\n\n/**\n * Create an array with the DOM nodes of the list\n *\n * @param {NodeList} nodes - [description]\n * @return {Array.<HTMLElement>} - [description]\n */\nexport function convertNodeList (nodes) {\n const { length } = nodes\n const arr = new Array(length)\n for (var i = 0; i < length; i++) {\n arr[i] = nodes[i]\n }\n return arr\n}\n\n/**\n * Escape special characters and line breaks as a simplified version of 'CSS.escape()'\n *\n * Description of valid characters: https://mathiasbynens.be/notes/css-escapes\n *\n * @param {String?} value - [description]\n * @return {String} - [description]\n */\nexport function escapeValue (value) {\n return value && value.replace(/['\"`\\\\/:\\?&!#$%^()[\\]{|}*+;,.<=>@~]/g, '\\\\$&')\n .replace(/\\n/g, '\\A')\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utilities.js","/**\n * # Common\n *\n * Process collections for similarities.\n */\n\n/**\n * Find the last common ancestor of elements\n *\n * @param {Array.<HTMLElements>} elements - [description]\n * @return {HTMLElement} - [description]\n */\nexport function getCommonAncestor (elements, options = {}) {\n\n const {\n root = document\n } = options\n\n const ancestors = []\n\n elements.forEach((element, index) => {\n const parents = []\n while (element !== root) {\n element = element.parentNode\n parents.unshift(element)\n }\n ancestors[index] = parents\n })\n\n ancestors.sort((curr, next) => curr.length - next.length)\n\n const shallowAncestor = ancestors.shift()\n\n var ancestor = null\n\n for (var i = 0, l = shallowAncestor.length; i < l; i++) {\n const parent = shallowAncestor[i]\n const missing = ancestors.some((otherParents) => {\n return !otherParents.some((otherParent) => otherParent === parent)\n })\n\n if (missing) {\n // TODO: find similar sub-parents, not the top root, e.g. sharing a class selector\n break\n }\n\n ancestor = parent\n }\n\n return ancestor\n}\n\n/**\n * Get a set of common properties of elements\n *\n * @param {Array.<HTMLElement>} elements - [description]\n * @return {Object} - [description]\n */\nexport function getCommonProperties (elements) {\n\n const commonProperties = {\n classes: [],\n attributes: {},\n tag: null\n }\n\n elements.forEach((element) => {\n\n var {\n classes: commonClasses,\n attributes: commonAttributes,\n tag: commonTag\n } = commonProperties\n\n // ~ classes\n if (commonClasses !== undefined) {\n var classes = element.getAttribute('class')\n if (classes) {\n classes = classes.trim().split(' ')\n if (!commonClasses.length) {\n commonProperties.classes = classes\n } else {\n commonClasses = commonClasses.filter((entry) => classes.some((name) => name === entry))\n if (commonClasses.length) {\n commonProperties.classes = commonClasses\n } else {\n delete commonProperties.classes\n }\n }\n } else {\n // TODO: restructure removal as 2x set / 2x delete, instead of modify always replacing with new collection\n delete commonProperties.classes\n }\n }\n\n // ~ attributes\n if (commonAttributes !== undefined) {\n const elementAttributes = element.attributes\n const attributes = Object.keys(elementAttributes).reduce((attributes, key) => {\n const attribute = elementAttributes[key]\n const attributeName = attribute.name\n // NOTE: workaround detection for non-standard phantomjs NamedNodeMap behaviour\n // (issue: https://github.com/ariya/phantomjs/issues/14634)\n if (attribute && attributeName !== 'class') {\n attributes[attributeName] = attribute.value\n }\n return attributes\n }, {})\n\n const attributesNames = Object.keys(attributes)\n const commonAttributesNames = Object.keys(commonAttributes)\n\n if (attributesNames.length) {\n if (!commonAttributesNames.length) {\n commonProperties.attributes = attributes\n } else {\n commonAttributes = commonAttributesNames.reduce((nextCommonAttributes, name) => {\n const value = commonAttributes[name]\n if (value === attributes[name]) {\n nextCommonAttributes[name] = value\n }\n return nextCommonAttributes\n }, {})\n if (Object.keys(commonAttributes).length) {\n commonProperties.attributes = commonAttributes\n } else {\n delete commonProperties.attributes\n }\n }\n } else {\n delete commonProperties.attributes\n }\n }\n\n // ~ tag\n if (commonTag !== undefined) {\n const tag = element.tagName.toLowerCase()\n if (!commonTag) {\n commonProperties.tag = tag\n } else if (tag !== commonTag) {\n delete commonProperties.tag\n }\n }\n })\n\n return commonProperties\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/common.js","/**\n * # Optimize\n *\n * 1.) Improve efficiency through shorter selectors by removing redundancy\n * 2.) Improve robustness through selector transformation\n */\n\nimport adapt from './adapt'\nimport { convertNodeList } from './utilities'\n\n/**\n * Apply different optimization techniques\n *\n * @param {string} selector - [description]\n * @param {HTMLElement|Array.<HTMLElement>} element - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nexport default function optimize (selector, elements, options = {}) {\n\n // convert single entry and NodeList\n if (!Array.isArray(elements)) {\n elements = !elements.length ? [elements] : convertNodeList(elements)\n }\n\n if (!elements.length || elements.some((element) => element.nodeType !== 1)) {\n throw new Error(`Invalid input - to compare HTMLElements its necessary to provide a reference of the selected node(s)! (missing \"elements\")`)\n }\n\n const globalModified = adapt(elements[0], options)\n\n // chunk parts outside of quotes (http://stackoverflow.com/a/25663729)\n var path = selector.replace(/> /g, '>').split(/\\s+(?=(?:(?:[^\"]*\"){2})*[^\"]*$)/)\n\n if (path.length < 2) {\n return optimizePart('', selector, '', elements)\n }\n\n const shortened = [path.pop()]\n while (path.length > 1) {\n const current = path.pop()\n const prePart = path.join(' ')\n const postPart = shortened.join(' ')\n\n const pattern = `${prePart} ${postPart}`\n const matches = document.querySelectorAll(pattern)\n if (matches.length !== elements.length) {\n shortened.unshift(optimizePart(prePart, current, postPart, elements))\n }\n }\n shortened.unshift(path[0])\n path = shortened\n\n // optimize start + end\n path[0] = optimizePart('', path[0], path.slice(1).join(' '), elements)\n path[path.length-1] = optimizePart(path.slice(0, -1).join(' '), path[path.length-1], '', elements)\n\n if (globalModified) {\n delete global.document\n }\n\n return path.join(' ').replace(/>/g, '> ').trim()\n}\n\n/**\n * Improve a chunk of the selector\n *\n * @param {string} prePart - [description]\n * @param {string} current - [description]\n * @param {string} postPart - [description]\n * @param {Array.<HTMLElement>} elements - [description]\n * @return {string} - [description]\n */\nfunction optimizePart (prePart, current, postPart, elements) {\n if (prePart.length) prePart = `${prePart} `\n if (postPart.length) postPart = ` ${postPart}`\n\n // robustness: attribute without value (generalization)\n if (/\\[*\\]/.test(current)) {\n const key = current.replace(/=.*$/, ']')\n var pattern = `${prePart}${key}${postPart}`\n var matches = document.querySelectorAll(pattern)\n if (compareResults(matches, elements)) {\n current = key\n } else {\n // robustness: replace specific key-value with base tag (heuristic)\n const references = document.querySelectorAll(`${prePart}${key}`)\n for (var i = 0, l = references.length; i < l; i++) {\n const reference = references[i]\n if (elements.some((element) => reference.contains(element))) {\n const description = reference.tagName.toLowerCase()\n var pattern = `${prePart}${description}${postPart}`\n var matches = document.querySelectorAll(pattern)\n if (compareResults(matches, elements)) {\n current = description\n }\n break\n }\n }\n }\n }\n\n // robustness: descendant instead child (heuristic)\n if (/>/.test(current)) {\n const descendant = current.replace(/>/, '')\n var pattern = `${prePart}${descendant}${postPart}`\n var matches = document.querySelectorAll(pattern)\n if (compareResults(matches, elements)) {\n current = descendant\n }\n }\n\n // robustness: 'nth-of-type' instead 'nth-child' (heuristic)\n if (/:nth-child/.test(current)) {\n // TODO: consider complete coverage of 'nth-of-type' replacement\n const type = current.replace(/nth-child/g, 'nth-of-type')\n var pattern = `${prePart}${type}${postPart}`\n var matches = document.querySelectorAll(pattern)\n if (compareResults(matches, elements)) {\n current = type\n }\n }\n\n // efficiency: combinations of classname (partial permutations)\n if (/\\.\\S+\\.\\S+/.test(current)) {\n var names = current.trim().split('.').slice(1)\n .map((name) => `.${name}`)\n .sort((curr, next) => curr.length - next.length)\n while (names.length) {\n const partial = current.replace(names.shift(), '').trim()\n var pattern = `${prePart}${partial}${postPart}`.trim()\n if (!pattern.length || pattern.charAt(0) === '>' || pattern.charAt(pattern.length-1) === '>') {\n break\n }\n var matches = document.querySelectorAll(pattern)\n if (compareResults(matches, elements)) {\n current = partial\n }\n }\n\n // robustness: degrade complex classname (heuristic)\n names = current && current.match(/\\./g)\n if (names && names.length > 2) {\n const references = document.querySelectorAll(`${prePart}${current}`)\n for (var i = 0, l = references.length; i < l; i++) {\n const reference = references[i]\n if (elements.some((element) => reference.contains(element) )) {\n // TODO:\n // - check using attributes + regard excludes\n const description = reference.tagName.toLowerCase()\n var pattern = `${prePart}${description}${postPart}`\n var matches = document.querySelectorAll(pattern)\n if (compareResults(matches, elements)) {\n current = description\n }\n break\n }\n }\n }\n }\n\n return current\n}\n\n/**\n * Evaluate matches with expected elements\n *\n * @param {Array.<HTMLElement>} matches - [description]\n * @param {Array.<HTMLElement>} elements - [description]\n * @return {Boolean} - [description]\n */\nfunction compareResults (matches, elements) {\n const { length } = matches\n return length === elements.length && elements.every((element) => {\n for (var i = 0; i < length; i++) {\n if (matches[i] === element) {\n return true\n }\n }\n return false\n })\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/optimize.js","/**\n * # Adapt\n *\n * Check and extend the environment for universal usage.\n */\n\n/**\n * Modify the context based on the environment\n *\n * @param {HTMLELement} element - [description]\n * @param {Object} options - [description]\n * @return {boolean} - [description]\n */\nexport default function adapt (element, options) {\n\n // detect environment setup\n if (global.document) {\n return false\n } else {\n global.document = options.context || (() => {\n var root = element\n while (root.parent) {\n root = root.parent\n }\n return root\n })()\n }\n\n // https://github.com/fb55/domhandler/blob/master/index.js#L75\n const ElementPrototype = Object.getPrototypeOf(global.document)\n\n // alternative descriptor to access elements with filtering invalid elements (e.g. textnodes)\n if (!Object.getOwnPropertyDescriptor(ElementPrototype, 'childTags')) {\n Object.defineProperty(ElementPrototype, 'childTags', {\n enumerable: true,\n get () {\n return this.children.filter((node) => {\n // https://github.com/fb55/domelementtype/blob/master/index.js#L12\n return node.type === 'tag' || node.type === 'script' || node.type === 'style'\n })\n }\n })\n }\n\n if (!Object.getOwnPropertyDescriptor(ElementPrototype, 'attributes')) {\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes\n // https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap\n Object.defineProperty(ElementPrototype, 'attributes', {\n enumerable: true,\n get () {\n const { attribs } = this\n const attributesNames = Object.keys(attribs)\n const NamedNodeMap = attributesNames.reduce((attributes, attributeName, index) => {\n attributes[index] = {\n name: attributeName,\n value: attribs[attributeName]\n }\n return attributes\n }, { })\n Object.defineProperty(NamedNodeMap, 'length', {\n enumerable: false,\n configurable: false,\n value: attributesNames.length\n })\n return NamedNodeMap\n }\n })\n }\n\n if (!ElementPrototype.getAttribute) {\n // https://docs.webplatform.org/wiki/dom/Element/getAttribute\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute\n ElementPrototype.getAttribute = function (name) {\n return this.attribs[name] || null\n }\n }\n\n if (!ElementPrototype.getElementsByTagName) {\n // https://docs.webplatform.org/wiki/dom/Document/getElementsByTagName\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName\n ElementPrototype.getElementsByTagName = function (tagName) {\n const HTMLCollection = []\n traverseDescendants(this.childTags, (descendant) => {\n if (descendant.name === tagName || tagName === '*') {\n HTMLCollection.push(descendant)\n }\n })\n return HTMLCollection\n }\n }\n\n if (!ElementPrototype.getElementsByClassName) {\n // https://docs.webplatform.org/wiki/dom/Document/getElementsByClassName\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName\n ElementPrototype.getElementsByClassName = function (className) {\n const names = className.trim().replace(/\\s+/g, ' ').split(' ')\n const HTMLCollection = []\n traverseDescendants([this], (descendant) => {\n const descendantClassName = descendant.attribs.class\n if (descendantClassName && names.every((name) => descendantClassName.indexOf(name) > -1)) {\n HTMLCollection.push(descendant)\n }\n })\n return HTMLCollection\n }\n }\n\n if (!ElementPrototype.querySelectorAll) {\n // https://docs.webplatform.org/wiki/css/selectors_api/querySelectorAll\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll\n ElementPrototype.querySelectorAll = function (selectors) {\n selectors = selectors.replace(/(>)(\\S)/g, '$1 $2').trim() // add space for '>' selector\n\n // using right to left execution => https://github.com/fb55/css-select#how-does-it-work\n const instructions = getInstructions(selectors)\n const discover = instructions.shift()\n\n const total = instructions.length\n return discover(this).filter((node) => {\n var step = 0\n while (step < total) {\n node = instructions[step](node, this)\n if (!node) { // hierarchy doesn't match\n return false\n }\n step += 1\n }\n return true\n })\n }\n }\n\n if (!ElementPrototype.contains) {\n // https://developer.mozilla.org/en-US/docs/Web/API/Node/contains\n ElementPrototype.contains = function (element) {\n var inclusive = false\n traverseDescendants([this], (descendant, done) => {\n if (descendant === element) {\n inclusive = true\n done()\n }\n })\n return inclusive\n }\n }\n\n return true\n}\n\n/**\n * Retrieve transformation steps\n *\n * @param {Array.<string>} selectors - [description]\n * @return {Array.<Function>} - [description]\n */\nfunction getInstructions (selectors) {\n return selectors.split(' ').reverse().map((selector, step) => {\n const discover = step === 0\n const [type, pseudo] = selector.split(':')\n\n var validate = null\n var instruction = null\n\n switch (true) {\n\n // child: '>'\n case />/.test(type):\n instruction = function checkParent (node) {\n return (validate) => validate(node.parent) && node.parent\n }\n break\n\n // class: '.'\n case /^\\./.test(type):\n const names = type.substr(1).split('.')\n validate = (node) => {\n const nodeClassName = node.attribs.class\n return nodeClassName && names.every((name) => nodeClassName.indexOf(name) > -1)\n }\n instruction = function checkClass (node, root) {\n if (discover) {\n return node.getElementsByClassName(names.join(' '))\n }\n return (typeof node === 'function') ? node(validate) : getAncestor(node, root, validate)\n }\n break\n\n // attribute: '[key=\"value\"]'\n case /^\\[/.test(type):\n const [attributeKey, attributeValue] = type.replace(/\\[|\\]|\"/g, '').split('=')\n validate = (node) => {\n const hasAttribute = Object.keys(node.attribs).indexOf(attributeKey) > -1\n if (hasAttribute) { // regard optional attributeValue\n if (!attributeValue || (node.attribs[attributeKey] === attributeValue)) {\n return true\n }\n }\n return false\n }\n instruction = function checkAttribute (node, root) {\n if (discover) {\n const NodeList = []\n traverseDescendants([node], (descendant) => {\n if (validate(descendant)) {\n NodeList.push(descendant)\n }\n })\n return NodeList\n }\n return (typeof node === 'function') ? node(validate) : getAncestor(node, root, validate)\n }\n break\n\n // id: '#'\n case /^#/.test(type):\n const id = type.substr(1)\n validate = (node) => {\n return node.attribs.id === id\n }\n instruction = function checkId (node, root) {\n if (discover) {\n const NodeList = []\n traverseDescendants([node], (descendant, done) => {\n if (validate(descendant)) {\n NodeList.push(descendant)\n done()\n }\n })\n return NodeList\n }\n return (typeof node === 'function') ? node(validate) : getAncestor(node, root, validate)\n }\n break\n\n // universal: '*'\n case /\\*/.test(type):\n validate = (node) => true\n instruction = function checkUniversal (node, root) {\n if (discover) {\n const NodeList = []\n traverseDescendants([node], (descendant) => NodeList.push(descendant))\n return NodeList\n }\n return (typeof node === 'function') ? node(validate) : getAncestor(node, root, validate)\n }\n break\n\n // tag: '...'\n default:\n validate = (node) => {\n return node.name === type\n }\n instruction = function checkTag (node, root) {\n if (discover) {\n const NodeList = []\n traverseDescendants([node], (descendant) => {\n if (validate(descendant)) {\n NodeList.push(descendant)\n }\n })\n return NodeList\n }\n return (typeof node === 'function') ? node(validate) : getAncestor(node, root, validate)\n }\n }\n\n if (!pseudo) {\n return instruction\n }\n\n const rule = pseudo.match(/-(child|type)\\((\\d+)\\)$/)\n const kind = rule[1]\n const index = parseInt(rule[2], 10) - 1\n\n const validatePseudo = (node) => {\n if (node) {\n var compareSet = node.parent.childTags\n if (kind === 'type') {\n compareSet = compareSet.filter(validate)\n }\n const nodeIndex = compareSet.findIndex((child) => child === node)\n if (nodeIndex === index) {\n return true\n }\n }\n return false\n }\n\n return function enhanceInstruction (node) {\n const match = instruction(node)\n if (discover) {\n return match.reduce((NodeList, matchedNode) => {\n if (validatePseudo(matchedNode)) {\n NodeList.push(matchedNode)\n }\n return NodeList\n }, [])\n }\n return validatePseudo(match) && match\n }\n })\n}\n\n/**\n * Walking recursive to invoke callbacks\n *\n * @param {Array.<HTMLElement>} nodes - [description]\n * @param {Function} handler - [description]\n */\nfunction traverseDescendants (nodes, handler) {\n nodes.forEach((node) => {\n var progress = true\n handler(node, () => progress = false)\n if (node.childTags && progress) {\n traverseDescendants(node.childTags, handler)\n }\n })\n}\n\n/**\n * Bubble up from bottom to top\n *\n * @param {HTMLELement} node - [description]\n * @param {HTMLELement} root - [description]\n * @param {Function} validate - [description]\n * @return {HTMLELement} - [description]\n */\nfunction getAncestor (node, root, validate) {\n while (node.parent) {\n node = node.parent\n if (validate(node)) {\n return node\n }\n if (node === root) {\n break\n }\n }\n return null\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/adapt.js","/**\n * # Select\n *\n * Construct a unique CSS query selector to access the selected DOM element(s).\n * For longevity it applies different matching and optimization strategies.\n */\n\nimport adapt from './adapt'\nimport match from './match'\nimport optimize from './optimize'\nimport { convertNodeList } from './utilities'\nimport { getCommonAncestor, getCommonProperties } from './common'\n\n/**\n * Get a selector for the provided element\n *\n * @param {HTMLElement} element - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nexport function getSingleSelector (element, options = {}) {\n\n if (element.nodeType === 3) {\n element = element.parentNode\n }\n\n if (element.nodeType !== 1) {\n throw new Error(`Invalid input - only HTMLElements or representations of them are supported! (not \"${typeof element}\")`)\n }\n\n const globalModified = adapt(element, options)\n\n const selector = match(element, options)\n const optimized = optimize(selector, element, options)\n\n // debug\n // console.log(`\n // selector: ${selector}\n // optimized: ${optimized}\n // `)\n\n if (globalModified) {\n delete global.document\n }\n\n return optimized\n}\n\n/**\n * Get a selector to match multiple descendants from an ancestor\n *\n * @param {Array.<HTMLElement>|NodeList} elements - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nexport function getMultiSelector (elements, options = {}) {\n\n if (!Array.isArray(elements)) {\n elements = convertNodeList(elements)\n }\n\n if (elements.some((element) => element.nodeType !== 1)) {\n throw new Error(`Invalid input - only an Array of HTMLElements or representations of them is supported!`)\n }\n\n const globalModified = adapt(elements[0], options)\n\n const ancestor = getCommonAncestor(elements, options)\n const ancestorSelector = getSingleSelector(ancestor, options)\n\n // TODO: consider usage of multiple selectors + parent-child relation + check for part redundancy\n const commonSelectors = getCommonSelectors(elements)\n const descendantSelector = commonSelectors[0]\n\n const selector = optimize(`${ancestorSelector} ${descendantSelector}`, elements, options)\n const selectorMatches = convertNodeList(document.querySelectorAll(selector))\n\n if (!elements.every((element) => selectorMatches.some((entry) => entry === element) )) {\n // TODO: cluster matches to split into similar groups for sub selections\n return console.warn(`\n The selected elements can\\'t be efficiently mapped.\n Its probably best to use multiple single selectors instead!\n `, elements)\n }\n\n if (globalModified) {\n delete global.document\n }\n\n return selector\n}\n\n/**\n * Get selectors to describe a set of elements\n *\n * @param {Array.<HTMLElements>} elements - [description]\n * @return {string} - [description]\n */\nfunction getCommonSelectors (elements) {\n\n const { classes, attributes, tag } = getCommonProperties(elements)\n\n const selectorPath = []\n\n if (tag) {\n selectorPath.push(tag)\n }\n\n if (classes) {\n const classSelector = classes.map((name) => `.${name}`).join('')\n selectorPath.push(classSelector)\n }\n\n if (attributes) {\n const attributeSelector = Object.keys(attributes).reduce((parts, name) => {\n parts.push(`[${name}=\"${attributes[name]}\"]`)\n return parts\n }, []).join('')\n selectorPath.push(attributeSelector)\n }\n\n if (selectorPath.length) {\n // TODO: check for parent-child relation\n }\n\n return [\n selectorPath.join('')\n ]\n}\n\n/**\n * Choose action depending on the input (multiple/single)\n *\n * NOTE: extended detection is used for special cases like the <select> element with <options>\n *\n * @param {HTMLElement|NodeList|Array.<HTMLElement>} input - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nexport default function getQuerySelector (input, options = {}) {\n if (input.length && !input.name) {\n return getMultiSelector(input, options)\n }\n return getSingleSelector(input, options)\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/select.js","/**\n * # Match\n *\n * Retrieve selector for a node.\n */\n\nimport { escapeValue } from './utilities'\n\nconst defaultIgnore = {\n attribute (attributeName) {\n return [\n 'style',\n 'data-reactid',\n 'data-react-checksum'\n ].indexOf(attributeName) > -1\n }\n}\n\n/**\n * Get the path of the element\n *\n * @param {HTMLElement} node - [description]\n * @param {Object} options - [description]\n * @return {string} - [description]\n */\nexport default function match (node, options) {\n\n const {\n root = document,\n skip = null,\n priority = ['id', 'class', 'href', 'src'],\n ignore = {}\n } = options\n\n const path = []\n var element = node\n var length = path.length\n var ignoreClass = false\n\n const skipCompare = skip && (Array.isArray(skip) ? skip : [skip]).map((entry) => {\n if (typeof entry !== 'function') {\n return (element) => element === entry\n }\n return entry\n })\n\n const skipChecks = (element) => {\n return skip && skipCompare.some((compare) => compare(element))\n }\n\n Object.keys(ignore).forEach((type) => {\n if (type === 'class') {\n ignoreClass = true\n }\n var predicate = ignore[type]\n if (typeof predicate === 'function') return\n if (typeof predicate === 'number') {\n predicate = predicate.toString()\n }\n if (typeof predicate === 'string') {\n predicate = new RegExp(escapeValue(predicate).replace(/\\\\/g, '\\\\\\\\'))\n }\n if (typeof predicate === 'boolean') {\n predicate = predicate ? /(?:)/ : /.^/\n }\n // check class-/attributename for regex\n ignore[type] = (name, value) => predicate.test(value)\n })\n\n if (ignoreClass) {\n const ignoreAttribute = ignore.attribute\n ignore.attribute = (name, value, defaultPredicate) => {\n return ignore.class(value) || ignoreAttribute && ignoreAttribute(name, value, defaultPredicate)\n }\n }\n\n while (element !== root) {\n if (skipChecks(element) !== true) {\n // ~ global\n if (checkAttributes(priority, element, ignore, path, root)) break\n if (checkTag(element, ignore, path, root)) break\n\n // ~ local\n checkAttributes(priority, element, ignore, path)\n if (path.length === length) {\n checkTag(element, ignore, path)\n }\n\n // define only one part each iteration\n if (path.length === length) {\n checkChilds(priority, element, ignore, path)\n }\n }\n\n element = element.parentNode\n length = path.length\n }\n\n if (element === root) {\n const pattern = findPattern(priority, element, ignore)\n path.unshift(pattern)\n }\n\n return path.join(' ')\n}\n\n/**\n * Extend path with attribute identifier\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @param {Array.<string>} path - [description]\n * @param {HTMLElement} parent - [description]\n * @return {boolean} - [description]\n */\nfunction checkAttributes (priority, element, ignore, path, parent = element.parentNode) {\n const pattern = findAttributesPattern(priority, element, ignore)\n if (pattern) {\n const matches = parent.querySelectorAll(pattern)\n if (matches.length === 1) {\n path.unshift(pattern)\n return true\n }\n }\n return false\n}\n\n/**\n * Lookup attribute identifier\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @return {string?} - [description]\n */\nfunction findAttributesPattern (priority, element, ignore) {\n const attributes = element.attributes\n const sortedKeys = Object.keys(attributes).sort((curr, next) => {\n const currPos = priority.indexOf(attributes[curr].name)\n const nextPos = priority.indexOf(attributes[next].name)\n if (nextPos === -1) {\n if (currPos === -1) {\n return 0\n }\n return -1\n }\n return currPos - nextPos\n })\n\n for (var i = 0, l = sortedKeys.length; i < l; i++) {\n const key = sortedKeys[i]\n const attribute = attributes[key]\n const attributeName = attribute.name\n const attributeValue = escapeValue(attribute.value)\n\n const currentIgnore = ignore[attributeName] || ignore.attribute\n const currentDefaultIgnore = defaultIgnore[attributeName] || defaultIgnore.attribute\n if (checkIgnore(currentIgnore, attributeName, attributeValue, currentDefaultIgnore)) {\n continue\n }\n\n var pattern = `[${attributeName}=\"${attributeValue}\"]`\n\n if ((/\\b\\d/).test(attributeValue) === false) {\n if (attributeName === 'id') {\n pattern = `#${attributeValue}`\n }\n\n if (attributeName === 'class') {\n const className = attributeValue.trim().replace(/\\s+/g, '.')\n pattern = `.${className}`\n }\n }\n\n return pattern\n }\n return null\n}\n\n/**\n * Extend path with tag identifier\n *\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @param {Array.<string>} path - [description]\n * @param {HTMLElement} parent - [description]\n * @return {boolean} - [description]\n */\nfunction checkTag (element, ignore, path, parent = element.parentNode) {\n const pattern = findTagPattern(element, ignore)\n if (pattern) {\n const matches = parent.getElementsByTagName(pattern)\n if (matches.length === 1) {\n path.unshift(pattern)\n return true\n }\n }\n return false\n}\n\n/**\n * Lookup tag identifier\n *\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @return {boolean} - [description]\n */\nfunction findTagPattern (element, ignore) {\n const tagName = element.tagName.toLowerCase()\n if (checkIgnore(ignore.tag, null, tagName)) {\n return null\n }\n return tagName\n}\n\n/**\n * Extend path with specific child identifier\n *\n * NOTE: 'childTags' is a custom property to use as a view filter for tags using 'adapter.js'\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @param {Array.<string>} path - [description]\n * @return {boolean} - [description]\n */\nfunction checkChilds (priority, element, ignore, path) {\n const parent = element.parentNode\n const children = parent.childTags || parent.children\n for (var i = 0, l = children.length; i < l; i++) {\n const child = children[i]\n if (child === element) {\n const childPattern = findPattern(priority, child, ignore)\n if (!childPattern) {\n return console.warn(`\n Element couldn\\'t be matched through strict ignore pattern!\n `, child, ignore, childPattern)\n }\n const pattern = `> ${childPattern}:nth-child(${i+1})`\n path.unshift(pattern)\n return true\n }\n }\n return false\n}\n\n/**\n * Lookup identifier\n *\n * @param {Array.<string>} priority - [description]\n * @param {HTMLElement} element - [description]\n * @param {Object} ignore - [description]\n * @return {string} - [description]\n */\nfunction findPattern (priority, element, ignore) {\n var pattern = findAttributesPattern(priority, element, ignore)\n if (!pattern) {\n pattern = findTagPattern(element, ignore)\n }\n return pattern\n}\n\n/**\n * Validate with custom and default functions\n *\n * @param {Function} predicate - [description]\n * @param {string?} name - [description]\n * @param {string} value - [description]\n * @param {Function} defaultPredicate - [description]\n * @return {boolean} - [description]\n */\nfunction checkIgnore (predicate, name, value, defaultPredicate) {\n if (!value) {\n return true\n }\n const check = predicate || defaultPredicate\n if (!check) {\n return false\n }\n return check(name, value, defaultPredicate)\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/match.js","export select, { getSingleSelector, getMultiSelector } from './select'\nexport optimize from './optimize'\nexport * as common from './common'\n\nexport default from './select'\n\n\n\n// WEBPACK FOOTER //\n// ./src/index.js"],"sourceRoot":""}