iwmlib/3rdparty/optimal-select.min.js
2019-03-21 09:57:27 +01:00

2 lines
10 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OptimalSelect=t():e.OptimalSelect=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,r){"use strict";function n(e){for(var t=e.length,r=new Array(t),n=0;n<t;n++)r[n]=e[n];return r}function o(e){return e&&e.replace(/['"`\\\/:\?&!#$%^()[\]{|}*+;,.<=>@~]/g,"\\$&").replace(/\n/g,"A")}Object.defineProperty(t,"__esModule",{value:!0}),t.convertNodeList=n,t.escapeValue=o},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.root,n=void 0===r?document:r,o=[];e.forEach(function(e,t){for(var r=[];e!==n;)e=e.parentNode,r.unshift(e);o[t]=r}),o.sort(function(e,t){return e.length-t.length});for(var u=o.shift(),i=null,l=function(){var e=u[a],t=o.some(function(t){return!t.some(function(t){return t===e})});return t?"break":void(i=e)},a=0,c=u.length;a<c;a++){var f=l();if("break"===f)break}return i}function o(e){var t={classes:[],attributes:{},tag:null};return e.forEach(function(e){var r=t.classes,n=t.attributes,o=t.tag;if(void 0!==r){var u=e.getAttribute("class");u?(u=u.trim().split(" "),r.length?(r=r.filter(function(e){return u.some(function(t){return t===e})}),r.length?t.classes=r:delete t.classes):t.classes=u):delete t.classes}if(void 0!==n&&!function(){var r=e.attributes,o=Object.keys(r).reduce(function(e,t){var n=r[t],o=n.name;return n&&"class"!==o&&(e[o]=n.value),e},{}),u=Object.keys(o),i=Object.keys(n);u.length?i.length?(n=i.reduce(function(e,t){var r=n[t];return r===o[t]&&(e[t]=r),e},{}),Object.keys(n).length?t.attributes=n:delete t.attributes):t.attributes=o:delete t.attributes}(),void 0!==o){var i=e.tagName.toLowerCase();o?i!==o&&delete t.tag:t.tag=i}}),t}Object.defineProperty(t,"__esModule",{value:!0}),t.getCommonAncestor=n,t.getCommonProperties=o},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(Array.isArray(t)||(t=t.length?(0,c.convertNodeList)(t):[t]),!t.length||t.some(function(e){return 1!==e.nodeType}))throw new Error('Invalid input - to compare HTMLElements its necessary to provide a reference of the selected node(s)! (missing "elements")');var n=(0,a.default)(t[0],r),o=e.replace(/> /g,">").split(/\s+(?=(?:(?:[^"]*"){2})*[^"]*$)/);if(o.length<2)return u("",e,"",t);for(var i=[o.pop()];o.length>1;){var l=o.pop(),f=o.join(" "),s=i.join(" "),d=f+" "+s,p=document.querySelectorAll(d);p.length!==t.length&&i.unshift(u(f,l,s,t))}return i.unshift(o[0]),o=i,o[0]=u("",o[0],o.slice(1).join(" "),t),o[o.length-1]=u(o.slice(0,-1).join(" "),o[o.length-1],"",t),n&&delete!0,o.join(" ").replace(/>/g,"> ").trim()}function u(e,t,r,n){if(e.length&&(e+=" "),r.length&&(r=" "+r),/\[*\]/.test(t)){var o=t.replace(/=.*$/,"]"),u=""+e+o+r,l=document.querySelectorAll(u);if(i(l,n))t=o;else for(var a=document.querySelectorAll(""+e+o),c=function(){var o=a[f];if(n.some(function(e){return o.contains(e)})){var c=o.tagName.toLowerCase();return u=""+e+c+r,l=document.querySelectorAll(u),i(l,n)&&(t=c),"break"}},f=0,s=a.length;f<s;f++){var u,l,d=c();if("break"===d)break}}if(/>/.test(t)){var p=t.replace(/>/,""),u=""+e+p+r,l=document.querySelectorAll(u);i(l,n)&&(t=p)}if(/:nth-child/.test(t)){var v=t.replace(/nth-child/g,"nth-of-type"),u=""+e+v+r,l=document.querySelectorAll(u);i(l,n)&&(t=v)}if(/\.\S+\.\S+/.test(t)){for(var y=t.trim().split(".").slice(1).map(function(e){return"."+e}).sort(function(e,t){return e.length-t.length});y.length;){var g=t.replace(y.shift(),"").trim(),u=(""+e+g+r).trim();if(!u.length||">"===u.charAt(0)||">"===u.charAt(u.length-1))break;var l=document.querySelectorAll(u);i(l,n)&&(t=g)}if(y=t&&t.match(/\./g),y&&y.length>2)for(var m=document.querySelectorAll(""+e+t),h=function(){var o=m[f];if(n.some(function(e){return o.contains(e)})){var a=o.tagName.toLowerCase();return u=""+e+a+r,l=document.querySelectorAll(u),i(l,n)&&(t=a),"break"}},f=0,s=m.length;f<s;f++){var u,l,b=h();if("break"===b)break}}return t}function i(e,t){var r=e.length;return r===t.length&&t.every(function(t){for(var n=0;n<r;n++)if(e[n]===t)return!0;return!1})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var l=r(3),a=n(l),c=r(0);e.exports=t.default},function(e,t,r){"use strict";function n(e,t){return!1}Object.defineProperty(t,"__esModule",{value:!0});"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},function(){function e(e,t){var r=[],n=!0,o=!1,u=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{!n&&l.return&&l.return()}finally{if(o)throw u}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(3===e.nodeType&&(e=e.parentNode),1!==e.nodeType)throw new Error('Invalid input - only HTMLElements or representations of them are supported! (not "'+("undefined"==typeof e?"undefined":a(e))+'")');var r=(0,f.default)(e,t),n=(0,d.default)(e,t),o=(0,v.default)(n,e,t);return r&&delete!0,o}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Array.isArray(e)||(e=(0,y.convertNodeList)(e)),e.some(function(e){return 1!==e.nodeType}))throw new Error("Invalid input - only an Array of HTMLElements or representations of them is supported!");var r=(0,f.default)(e[0],t),n=(0,g.getCommonAncestor)(e,t),u=o(n,t),l=i(e),a=l[0],c=(0,v.default)(u+" "+a,e,t),s=(0,y.convertNodeList)(document.querySelectorAll(c));return e.every(function(e){return s.some(function(t){return t===e})})?(r&&delete!0,c):console.warn("\n The selected elements can't be efficiently mapped.\n Its probably best to use multiple single selectors instead!\n ",e)}function i(e){var t=(0,g.getCommonProperties)(e),r=t.classes,n=t.attributes,o=t.tag,u=[];if(o&&u.push(o),r){var i=r.map(function(e){return"."+e}).join("");u.push(i)}if(n){var l=Object.keys(n).reduce(function(e,t){return e.push("["+t+'="'+n[t]+'"]'),e},[]).join("");u.push(l)}return u.length,[u.join("")]}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.length&&!e.name?u(e,t):o(e,t)}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.getSingleSelector=o,t.getMultiSelector=u,t.default=l;var c=r(3),f=n(c),s=r(5),d=n(s),p=r(2),v=n(p),y=r(0),g=r(1)},function(e,t,r){"use strict";function n(e,t){var r=t.root,n=void 0===r?document:r,u=t.skip,l=void 0===u?null:u,f=t.priority,d=void 0===f?["id","class","href","src"]:f,p=t.ignore,v=void 0===p?{}:p,y=[],g=e,m=y.length,h=!1,b=l&&(Array.isArray(l)?l:[l]).map(function(e){return"function"!=typeof e?function(t){return t===e}:e}),S=function(e){return l&&b.some(function(t){return t(e)})};for(Object.keys(v).forEach(function(e){"class"===e&&(h=!0);var t=v[e];"function"!=typeof t&&("number"==typeof t&&(t=t.toString()),"string"==typeof t&&(t=new RegExp((0,s.escapeValue)(t).replace(/\\/g,"\\\\"))),"boolean"==typeof t&&(t=t?/(?:)/:/.^/),v[e]=function(e,r){return t.test(r)})}),h&&!function(){var e=v.attribute;v.attribute=function(t,r,n){return v.class(r)||e&&e(t,r,n)}}();g!==n;){if(S(g)!==!0){if(o(d,g,v,y,n))break;if(i(g,v,y,n))break;o(d,g,v,y),y.length===m&&i(g,v,y),y.length===m&&a(d,g,v,y)}g=g.parentNode,m=y.length}if(g===n){var j=c(d,g,v);y.unshift(j)}return y.join(" ")}function o(e,t,r,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:t.parentNode,i=u(e,t,r);if(i){var l=o.querySelectorAll(i);if(1===l.length)return n.unshift(i),!0}return!1}function u(e,t,r){for(var n=t.attributes,o=Object.keys(n).sort(function(t,r){var o=e.indexOf(n[t].name),u=e.indexOf(n[r].name);return u===-1?o===-1?0:-1:o-u}),u=0,i=o.length;u<i;u++){var l=o[u],a=n[l],c=a.name,p=(0,s.escapeValue)(a.value),v=r[c]||r.attribute,y=d[c]||d.attribute;if(!f(v,c,p,y)){var g="["+c+'="'+p+'"]';if(/\b\d/.test(p)===!1&&("id"===c&&(g="#"+p),"class"===c)){var m=p.trim().replace(/\s+/g,".");g="."+m}return g}}return null}function i(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.parentNode,o=l(e,t);if(o){var u=n.getElementsByTagName(o);if(1===u.length)return r.unshift(o),!0}return!1}function l(e,t){var r=e.tagName.toLowerCase();return f(t.tag,null,r)?null:r}function a(e,t,r,n){for(var o=t.parentNode,u=o.childTags||o.children,i=0,l=u.length;i<l;i++){var a=u[i];if(a===t){var f=c(e,a,r);if(!f)return console.warn("\n Element couldn't be matched through strict ignore pattern!\n ",a,r,f);var s="> "+f+":nth-child("+(i+1)+")";return n.unshift(s),!0}}return!1}function c(e,t,r){var n=u(e,t,r);return n||(n=l(t,r)),n}function f(e,t,r,n){if(!r)return!0;var o=e||n;return!!o&&o(t,r,n)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var s=r(0),d={attribute:function(e){return["style","data-reactid","data-react-checksum"].indexOf(e)>-1}};e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.common=t.optimize=t.getMultiSelector=t.getSingleSelector=t.select=void 0;var u=r(4);Object.defineProperty(t,"getSingleSelector",{enumerable:!0,get:function(){return u.getSingleSelector}}),Object.defineProperty(t,"getMultiSelector",{enumerable:!0,get:function(){return u.getMultiSelector}});var i=o(u),l=r(2),a=o(l),c=r(1),f=n(c);t.select=i.default,t.optimize=a.default,t.common=f,t.default=i.default}])});
//# sourceMappingURL=optimal-select.min.js.map