(function(t,e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define(e)}else{t=t||self;t.el=t.elify=e()}})(this,function(){"use strict";var q={},n={},t={},i={},o={},a={};Object.defineProperties(String.prototype,{trimLeft:{value:function(){return this.replace(/^\s+/g,"")}},trimLR:{configurable:false,value:function(){return this.replace(/^\s+|\s+$/g,"")}},trimWith:{configurable:false,value:function(t){if(typeof t!=="string"){throw new TypeError("invalid value!, can't trimWith "+t)}return this.replace(/\s+/g,t)}}});function D(t){var r=/^(\<(.*?)>(.*?)\<\/(.*?)>|\<(.*?)\>)/.test(t),i=function(t){t=t.trimLR().trimWith(" ");var e=t.match(/[^,]+\((.*?)\)/g),r=t.split(" ")[0],i=e?e.concat(t.replace(r,"").split(",")):t.replace(r,"").split(","),n=document.createElement(r),o=typeof n.type!=="undefined"?n.type:"",a=o?r.toLowerCase()+"-"+o:r.toLowerCase();n.classList.add(a);i.forEach(function(t){var e=t.trimLR().trimWith(" ").split(" "),r=e[0].trimLR(),i=t.replace(e[0],"").trimLR();try{n[r]=i;n.style[r]=i}catch(t){}});return n},n=function(t,i){if(t instanceof Object){Object.values(t).forEach(function(t){if(t instanceof HTMLElement){i.push(t)}});return}t.split(",").forEach(function(t){var e=document.createElement("temp");e.innerHTML=t;var r=e.lastChild||e.lastElementChild;i.push(r)})},e=function(t){return t.constructor.name==="n"?true:false},o=function(t){return t.constructor.name==="Elify"?true:false};if(!t){return[]}if(typeof t==="string"){var a=[];if(r){n(t,a);return a}if(/[^,]+\((.*?)\)|\,$/.test(t)){var f=i(t);a.push(f);return a}try{var c=document.querySelectorAll(t);return Array.prototype.slice.call(c)}catch(t){return[]}}if(typeof t==="object"&&Array.isArray(t)){var a=[];Array.prototype.forEach.call(t,function(t){if(!t){return[]}if(r){n(t,a);return a}if(t instanceof HTMLElement){a.push(t);return a}if(/[^,]+\((.*?)\)|\,.*?|\.*?/.test(t)){var e=i(t);a.push(e);return a}});return a}if(typeof t==="object"&&t instanceof NodeList){return Array.prototype.slice.call(t)}if(typeof t==="object"&&t instanceof HTMLCollection){return Object.values(t)}if(typeof t==="object"&&(e(t)||o(t))){var a=[];Object.values(t).forEach(function(t){if(t instanceof HTMLElement){a.push(t)}});return a}return[t]}function f(e,P){Object.keys(HTMLElement.prototype).forEach(function(t){q[t]=t});Array("children","attributes","tagName","localName","innerHTML","outerHTML","className","classList","align","itemScope","before","after","remove","scroll","scrollLeft","scrollTop","scrollTo","scrollBy","append","prepend","matches","closest","textContent","disabled","id","isContentEditable","scrollHeight","scrollWidth","clientLeft","clientTop","clientWidth","clientHeight").forEach(function(t){q[t]=t});var r={firstChild:"firstElementChild",lastChild:"lastElementChild",before:"insertBefore",after:"insertAfter",replace:"replaceWith",parent:"parentNode",clone:"cloneNode"};Object.keys(r).forEach(function(t){q[t]=r[t]});Object.keys(q).forEach(function(x){Object.defineProperty(e,x,{configurable:true,writable:true,value:function t(e){var n=P||this,r=arguments[0],i=arguments[1],o=arguments[2];if(x==="style"){var a=getComputedStyle(n[0]);if(!r){return a}for(var f in n){if(typeof r==="object"&&!Array.isArray(r)){Object.keys(r).forEach(function(t){n[f][q[x]][t]=r[t]})}if(typeof r==="string"){r=r.trimLR();var c=r.trimWith(" ").split(" "),s=r.replace(c[1]?c[0]:"","").trim(),u=getComputedStyle(n[0])[s];if(/^(get)/.test(r)||!/\s+/.test(r)){return u}if(/^(contains|has)\:?\s+(.*?)/.test(r)){return u?true:false}if(r.match(/(.*?)\:(.*?)\;/)){n[f][q[x]]["cssText"]=r}var l=r.match(/[^,]+\((.*?)\)/g),p=l?l.concat(r.split(",")):r.split(",");p.forEach(function(t){var e=t.trimLR().trimWith(" ").split(" "),r=e[0],i=t.replace(e[0],"").trimLeft();if(i){try{n[f][q[x]][r]=i}catch(t){}}})}}return this}if(x==="classList"){if(!r){return n[0][q[x]]}if(/^(contains|has)\:?\s+(.*?)/.test(r)||!/\s+/.test(r)){var h=[];for(var f in n){var v=n[f][q[x]];Array.prototype.forEach.call(v,function(t){h.push(t)})}var c=r.trimLR().trimWith(" ").split(" "),s=r.replace(c[1]?c[0]:"","").trim();return h.includes(s)}for(var f in n){var v=n[f][q[x]],m=function(t,e){e=e.trimLR().trimWith(" ").split(" ");if(t==="add"){e.forEach(function(t){t=t.trim();v.add(t)})}if(t==="remove"){e.forEach(function(t){t=t.trim();v.remove(t)})}if(t==="toggle"){e.forEach(function(t){t=t.trim();v.toggle(t)})}if(t==="replace"){var r=e[e.length-1].trim();e.forEach(function(t){t=t.trim();v.replace(t,r)})}if(t==="forEach"){cbEvent=function(){};v.forEach(cbEvent)}};if(typeof r==="object"&&!Array.isArray(r)){Object.keys(r).forEach(function(t){m(t,r[t])})}if(typeof r==="string"){r.split(",").forEach(function(t){t=t.trimLR();if(/^(add|remove|toggle|replace)\:?\s+/.test(t)){var e=t.trimLR().trimWith(" ").split(" "),r=e[0].replace(/\s+|\:?/g,""),i=t.replace(/^(add|remove|toggle|replace)\:?/g,"");m(r,i)}})}}return this}if(x==="attributes"){if(!r){return n[0][q[x]]}if(/^get/.test(r)||!/\s+/.test(r)){var c=r.trimLR().trimWith(" ").split(" "),d=c[0].replace(/\s+|\:?/g,""),s=r.replace(/^get\:?/g,"").trim();return n[0].getAttribute(s)}if(/^(contains|has)\:?\s+(.*?)/.test(r)){var c=r.trimLR().trimWith(" ").split(" "),s=c[1].trim();return n[0].hasAttribute(s)}for(var f in n){var y=n[f][q[x]],m=function(t,e){e=e.trimLR().trimWith(" ").split(" ");if(t==="set"){e.forEach(function(t){t=t.trim();y.item(t)})}if(t==="get"){e.forEach(function(t){t=t.trim();y.get(t)})}if(t==="remove"){e.forEach(function(t){t=t.trim();y.remove(t)})}if(t==="has"){e.forEach(function(t){t=t.trim();y.has(classes)})}};if(typeof r==="object"&&!Array.isArray(r)){Object.keys(r).forEach(function(t){n[f].setAttribute(t,r[t])})}if(typeof r==="string"){var b=this;r.split(",").forEach(function(t){t=t.trimLR();var e=t.trimLR().trimWith(" ").split(" ")[0],r=t.replace(e,"").trimLR().trimWith(" ");if(/^(set)/.test(t)){var i=t.trimWith(" ").split(" ")[0],e=t.trimWith(" ").split(" ")[1],r=t.replace(i,"").replace(e,"").trimLR().trimWith(" ");n[f].setAttribute(e,r);return b}if(/^(remove)/.test(t)){n[f].removeAttribute(splitedVal[1]);return b}n[f].setAttribute(e,r)})}}return this}if(x==="children"){var g=[];for(var f in n){g=Array.prototype.slice.call(n[f].children)}if(!r&&isNaN(r)){return _(g)}if(typeof r==="number"||!isNaN(r)){if(i){_(g[r],i);return this}return _(g[r])}_(g,r);return this}if(x==="dataset"){if(!r){}else{var E=r.trimLR().trimWith(" ").split(" ");for(var f in n){if(E[1]){n[f][x][E[0]]=E[1];return this}return n[f][x][E[0]]}}}if(x==="firstChild"){var L=[];for(var f in n){L.push(n[f][q[x]])}if(!r){return _(L)}_(L,r);return this}if(x==="lastChild"){var j=[];for(var f in n){j.push(n[f][q[x]])}if(!r){return _(j)}_(j,r);return this}if(x==="matches"){if(!r){throw new TypeError("arguments required to determine matched context elements")}for(var f in n){if(n[f][x]){return n[f][x](r)}if(n[f].msMatchesSelector){return n[f].msMatchesSelector(r)}if(n[f].webkitMatchesSelector){return n[f].webkitMatchesSelector(r)}var O=document.querySelectorAll(r),T=O.length;while(--T>=0&&O[T]!==n[f]){}return T>-1}}if(x==="closest"){if(!r){throw new TypeError("requires args to determine a closest context elements")}for(var f in n){if(n[f][x]){var A=n[f][x](r);return _(A?A:undefined)}var O=document.querySelectorAll(r),T=O.length;do{while(--T>=0&&O[T]!==n[f]){}}while(T<0&&(n[f]=n[f].parentNode));{return _(n[f]?n[f]:undefined)}}}if(x==="remove"||x==="removeNode"){if(!r){for(var f in n){if(n[f][x]){n[f][x]()}if(n[f].removeNode){n[f].removeNode()}}return this}_(r).remove();return this}if(x==="before"||x==="insertBefore"){var M=[];for(var f in n){M.push(n[f].previousElementSibling)}if(!r){return _(M)}if(typeof r==="object"&&r.constructor.name==="Object"){_(M,r);return this}var N=D(r);for(var f in n){if(typeof r==="string"){if(/^(\<(.*?)>(.*?)\<\/(.*?)>|\<(.*?)\>)/.test(r)){n[f].insertAdjacentHTML("beforebegin",r)}else{n[f].insertAdjacentText("beforebegin",r)}return this}for(var T in N){n[f].insertAdjacentElement("beforebegin",N[T])}}return this}if(x==="after"||x==="insertAfter"){var w=[];for(var f in n){w.push(n[f].nextElementSibling)}if(!r){return _(w)}if(typeof r==="object"&&r.constructor.name==="Object"){_(w,r);return this}var N=D(r);for(var f in n){if(typeof r==="string"){if(/^(\<(.*?)>(.*?)\<\/(.*?)>|\<(.*?)\>)/.test(r)){n[f].insertAdjacentHTML("afterend",r)}else{n[f].insertAdjacentText("afterend",r)}return this}for(var T in N){n[f].insertAdjacentElement("afterend",N[T])}}return this}if(x==="clone"||x==="cloneNode"){var C=[],S=i&&typeof i==="boolean"?i:true;for(var f in n){if(r&&!isNaN(r)){for(var H=0;H/.test(r)?r:D(r);for(var f in n){if(N instanceof Object||/<(.*?)>/.test(N)){for(var T in N){if(arguments[1]){n[f].replaceChild(arguments[0],arguments[1]);return this}if(n[f][q[x]]){n[f][q[x]](N[T])}if(n[f].replaceNode){n[f].replaceNode(N[T])}}}else{console.log(r);n[f].replaceWith(N)}}return _(N)}if(x==="append"||x==="prepend"){var N=D(r);var W=this;for(var f in W){for(var T in N){if(W[f]instanceof HTMLElement){if(W[f][q[x]]){W[f][q[x]](N[T])}else{x==="append"?W[0].insertAdjacentElement("beforeend",N[T]):W[0].insertAdjacentElement("afterbegin",N[T])}}}}return _(W,i)}if(x==="click"||x==="focus"||x==="blur"){if(r&&typeof r==="function"){r.call(this)}for(var f in n){n[f][q[x]]()}return _(n)}if(x==="el"||x==="elify"){var k={};k[r]=this;return this[0]&&r?_(k,i):function(){throw new TypeError('Could not initialize custom object "'+r+'" with undefined context')}()}for(var f in n){if(!r){return n[f][q[x]]}try{n[f][q[x]]=r}catch(t){}}return this}})});Object.keys(n).forEach(function(t){var i=n[t];Object.defineProperty(e,t,{configurable:true,writable:true,value:function t(e){var r=P||this;return i.call(this,arguments,r)}})});Object.defineProperties(e,{select:{configurable:true,value:function t(e,r,i){var n=P||this;if(!e&&isNaN(e)){return this}if(r){if(typeof e==="number"){_(n[e],r)}if(typeof e==="string"){for(var o in n){var a=n[o].querySelector(e);if(a){_(a,r)}}}return this}if(typeof e==="number"){return _(n[e])}if(typeof e==="string"){var f=[];for(var o in n){if(n[o].localName===e){return _(n[o])}var a=n[o].querySelector(e);if(a)f.push(a)}return _(f)}return _(e)}},appendTo:{configurable:true,value:function t(e,r,i){var n=P||this,o=D(e),a=[];for(var f in n){for(var c in o){if(n[f]instanceof HTMLElement){o[c].appendChild(n[f]);a.push(n[f])}}}return _(a,r)}},on:{configurable:true,value:function t(e,r){var i=P||this;for(var n in i){e.trim().split(",").forEach(function(t){t=t.trimLR();a[t]=r;if(i[n]instanceof HTMLElement){i[n].addEventListener(t,a[t])}})}return this}},off:{configurable:true,value:function(t){var e=P||this;for(var r in e){t.trim().split(",").forEach(function(t){t=t.trimLR();if(e[r]instanceof HTMLElement){e[r].removeEventListener(t,a[t])}})}return this}},trigger:{configurable:true,value:function t(e){var r=P||this,i=document.createEvent("Event");for(var n in r){e.trim().split(",").forEach(function(t){i.initEvent(t,true,true,{});var e=a[t];if(e&&r[n]instanceof HTMLElement){r[n].dispatchEvent(i)}else{throw new TypeError('Could not find event type "'+t+'" to trigger')}})}return this}},get:{configurable:true,value:function t(e){var r=P||this,i=e.trimLR().trimWith(" ").split(" ");for(var n in r){var o=r[n][i[0]];if(o instanceof CSSStyleDeclaration){return i[1]?o[i[1]]:o}if(o instanceof DOMTokenList){return i[1]?o.contains(i[1]):o}if(o instanceof HTMLCollection){var a=/[0-9]/.test(i[1])?parseInt(i[1]):i[1];return i[1]?_(o).select(a):_(o)}if(o instanceof NamedNodeMap){return i[1]?o[i[1]]:o}if(o instanceof DOMStringMap){return i[1]?o[i[1]]:o}if(o instanceof HTMLElement){return o}return r[n][e]}}},set:{configurable:true,value:function t(e){var r=P||this,i=e.trimLR().trimWith(" ").split(" ");for(var n in r){var o=r[n][i[0]];if(o instanceof CSSStyleDeclaration&&(i[1]&&i[2])){r[n].style[i[1]]=i[2];return _(r[n])}if(o instanceof DOMTokenList&&(i[1]&&i[2])){if(i[1]==="add"){r[n].classList.add(i[2])}if(i[1]==="remove"){r[n].classList.remove(i[2])}if(i[1]==="toggle"){r[n].classList.toggle(i[2])}if(i[1]==="replace"){r[n].classList.replace(i[2])}if(i[1]==="contains"){return r[n].classList.contains(i[2])}return _(r[n])}if(o instanceof HTMLCollection&&i[1]){var a=e.replace(i[0],"").trimLR();var f=D(a);return _(r[n]).append(f)}if(o instanceof NamedNodeMap&&(i[1]&&i[2])){r[n].setAttribute(i[1],i[2]);return _(r[n])}if(o instanceof DOMStringMap&&(i[1]&&i[2])){r[n].dataset[i[1]]=i[2];return _(r[n])}if(o instanceof HTMLElement){return _(o)}r[n][i[0]]=i[1]}return this}},cssPseudo:{configurable:true,writable:true,value:function(e,r){var t=this.attributes("set el-data btn"),i=this.attributes("get el-data"),n=document.createElement("style"),o="";Object.keys(r).forEach(function(t){r[t]=t==="content"?'"'+r[t]+'"':r[t];o+='[el-data="'+i+'"]:'+e+"{"+t+":"+r[t]+";}"});if(n.styleSheet){n.styleSheet.cssText=o}else{var a=document.createTextNode(o);n.appendChild(a)}this.append(n);return this}},toElement:{configurable:true,value:function t(e){var r=P||this;return r[0]}},toString:{configurable:true,value:function t(){var e=P||this,r="";for(var i in e){r+=e[i].outerHTML}return r}}});Object.keys(i).forEach(function(t){delete _.prototype[t]})}function _(t,r,e){var i=D(arguments[0]),r=arguments[1]||{};function n(){this.length=i.length;for(var t in i){this[t]=i[t]}for(var e in r){try{el(i)[e](r[e])}catch(t){}}}if(typeof arguments[0]==="object"&&arguments[0].constructor.name==="Object"){_.create(arguments[0],r);arguments[0].__proto__=_.prototype;return arguments[0]}f(_.prototype,i);n.prototype=_.prototype;return new n}_.selector=D;_.bindProperties=f;_.$=_.jQuery=function t(e){var r=window.$&&$.fn&&jQuery.fn;if(r){_.prototype=$.extend({},_.prototype,$.fn);f($.fn);if(e){return $(e)}}return r?true:false};_.create=function(f,c,s,e){var t=typeof f==="string"?f.trimLR().split(/\s+|\,/g):typeof f==="object"&&!Array.isArray(f)?Object.keys(f):f,r=function(n){var o=f[n],a=c||{};function t(t){var r=arguments;var e=function(){var t=n.toLowerCase();if(f instanceof Object){if(o instanceof Object&&Array.isArray(o)){var e=o[0],r=o[1]||{};a=r;return _([e],r).attributes("set el-data "+t).clone()}if(o instanceof Object){return _(D(o)).attribute("set el-data "+t).clone()}return _(D(o)).attributes("set el-data "+t).clone()}else{var i=document.createElement(n);i.classList.add(t);i.setAttribute("el-data",t);return _(i)}};e=e();Object.keys(a).forEach(function(t,e){a[t]=r[e]?r[e]:a[t]});if(s||c instanceof Function){if(r[0]instanceof Object){var i=Object.assign({},a,r[0]);s.call(e,i);return e}s.call(e,a);return e}if(r[0]instanceof Object){return _(e,r[0])}return _(e,a)}t.toString=function(){return"[Object Elify"+n+"]"};return t};t.forEach(function(t){if(e){e[t]=_[t]=r(t)}else{window[t]=_[t]=r(t)}})};_.defineProperty=function(t,e){function r(t,e){Object.defineProperty(_.prototype,t,{configurable:true,value:function(t){return e.call(this,arguments,context)}})}if(arguments.length===1&&arguments[0].constructor.name==="Object"){var i=arguments[0];Object.keys(i).forEach(function(t){var e=i[t];n[t]=e;r(t,e)});return}n[t]=e;r(t,e)};_.redefineProperty=function(t,e){function r(t,r){var i=_.prototype[t];if(_.prototype[t]){q[r]=t;return _.prototype[r]=function t(e){return _(this)[r]=i(e)}}else{throw new TypeError('Could not redefine undefined property "'+t+'" to "'+r+'"')}}if(arguments.length===1&&arguments[0].constructor.name==="Object"){var i=arguments[0];return Object.keys(i).forEach(function(t){var e=i[t];return r(t,e)})}return r(t,e)};_.renameProperty=function(t,e){function r(t,e){if(_.prototype[t]){o[t]=t;_.redefineProperty(t,e);_.removeProperty(t);return true}return false}if(arguments.length===1&&arguments[0].constructor.name==="Object"){var i=arguments[0];return Object.keys(i).forEach(function(t){var e=i[t];return r(t,e)})}return r(t,e)};_.removeProperty=function(t){arguments[0].split(/\,|\s+/).forEach(function(t){if(_.prototype[t]){i[t]=_.prototype[t]||t;delete _.prototype[t];return true}return false})};_.toString=function t(){return"[Object Elify]"};_.bindProperties(_.prototype);Array(HTMLElement.prototype,NodeList.prototype,HTMLCollection.prototype).forEach(function(t){t.el=t.elify=function(t,e){e=e||{};if(typeof t==="object"&&t.constructor.name==="Object"){return _(this,t)}var r=this;Object.keys(e).forEach(function(t){r[t]=e[t]});var i={};i[t]=this;return t?_(i,e):_(this)}});return _});