/**
* @license
* BSD 3-Clause License
*
* Copyright (c) 2019, Alexis Puga Ruíz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @preserve Copyright 2019 Alexis Puga Ruíz.
* @file Just js: The core for all your javascript proyects.
* @version 1.0.0-rc.17
*/
(function(e){"function"==typeof define&&define.amd?define("just",[],e):"object"==typeof module&&module.exports?module.exports=e():this.just=e()}).call(this,function(){function h(e,t,n,r){var o,i=Object.assign({},{override:!0,mutate:!1},r),u=Array.isArray(t)?t:[t],c=i.mutate?e:Object.assign({},e),s=c,a=!1,l=u[u.length-1];return u.slice(0,-1).forEach(function(e,t){if(!(s[e]instanceof Object)){if("undefined"!=typeof s[e]&&null!==s[e]&&!i.override)throw new TypeError('The value of "'+e+'" is not an object.');a=!0,s[e]={}}s=s[e]}),o=l in s&&!a,n?n.call(c,s,l,o,u):s[l]}function m(n,e){return[].slice.call(arguments,1).some(function(e,t){return[n,e].some(function(e){return null==e})?e===n:n.constructor===e.constructor})}function t(e){if(!(this instanceof t))return new t(e);this.element=e}function y(n,e,t){var r=Object.assign({},{ignoreDefaultKeys:!1,checkLooks:!0,checkDeepLooks:!0,ignoreNull:!1},t);return r.ignoreNull&&null===e&&void 0!==n?n:r.checkLooks?m(n,e)?(m(n,{})&&r.checkDeepLooks&&w(e,function(e,t){"undefined"!=typeof n[t]?n[t]=y(n[t],e,r):r.ignoreDefaultKeys||(n[t]=e)}),n):e:typeof n==typeof e?n:e}function v(n,e){return w(e,function(e,t){r(n,t,e)}),n}function r(e,t,n){var r=Object(n),o=Object.assign(Object.getOwnPropertyDescriptor(Object.defineProperty({},"_",{}),"_"),{get:void 0,set:void 0});return(n||{}).constructor==={}.constructor&&Object.keys(o).some(function(e){return e in r})&&Object.keys(r).every(function(e){return e in o})||(r={value:n}),Object.defineProperty(e,t,r),e}function w(e,t,n,r){var o,i=Object(e),u=Object.assign({},{addNonOwned:!1},r),c=!1;if("function"!=typeof t)throw new TypeError(t+" is not a function.");for(o in i){if(c)break;(u.addNonOwned||{}.hasOwnProperty.call(i,o))&&(c=!!t.call(n,i[o],o,i))}return c}function b(e,t){return[].slice.call((t||document).querySelectorAll(e))}function e(e,t,n,r){var o=e,i=0;if("function"!=typeof t)throw new TypeError(t+" is not a function.");if(!(e instanceof Node))throw new TypeError("The child isn't an instance of a Node.");for(n instanceof Node||(n=document.documentElement);o;){if((0<i||r)&&t.call(o,i,n))return o;if(o===n)return null;o=o.parentNode,i++}return null}function n(e){return!w(e,function(){return!0})}function o(){return!!("ontouchstart"in document.body||0<window.navigator.maxTouchPoints||0<window.navigator.msMaxTouchPoints||"DocumentTouch"in window&&document instanceof DocumentTouch)}function g(e,t,n,r){var o=g.nonSrcAttributes[e]||"src",i=document.createElement(e),u=d(t),c=b([e+"["+o+'="'+t+'"]',e+"["+o+'="'+u.href+'"]'].join(","))[0]||null,s="function"==typeof r?r:function(e){return e||document.head.appendChild(this),this};if(!t||"string"!=typeof t)throw new TypeError(t+" is not a valid url.");return"link"===e&&(i.rel="stylesheet"),u.origin!==window.location.origin&&0<=["video","img","script","link"].indexOf(e)&&i.setAttribute("crossorigin","anonymous"),"function"==typeof n&&(i.onerror=i.onload=function(e){return this.onload=this.onerror=null,n.call(this,e)}),i[o]=t,s.call(i,c,t)}function u(e,t){if(!(this instanceof u))return new u(e,t);v(this,{consent:!!e,isExplicit:y(t,"undefined"!=typeof e)})}function i(e,n,r,o){return"string"==typeof e&&(e=b(e)),Array.isArray(n)||(n=[n]),!e||"length"in e||(e=[e]),[].slice.call(e=e||[]).forEach(function(t){n.forEach(function(e){t.addEventListener(e,r,o||!1)})}),e}function d(e){var t,n,r,o,i,u,c,s,a,l={},f=window.location;return e=e||f.href,/^blob:/i.test(e)?(a=d(e.replace(/^blob:/i,"")),Object.assign(a,{protocol:"blob:",href:"blob:"+a.href,host:"",hostname:"",port:"",pathname:a.origin+a.pathname})):(/^(:)?\/\//.test(e)?e="//"===(e=e.replace(/^:/,""))?f.origin:f.protocol+e:/^(\?|#|\/)/.test(e)?e=f.origin+e:/:\/\//.test(e)||(e=f.protocol+"//"+e),r=(t=((n=(e||"").split(/(\?.*#?|#.*\??).*/))[1]||"").split("#"))[1]||"",l.search=t[0]||"",l.hash=r?"#"+r:r,u=((o=(n[0]||"").split("://"))[1]||"").split(/(\/.*)/),l.username="",l.password="",/@/.test(u[0])&&(s=(c=u[0].split("@"))[0].split(":"),l.username=s[0]||"",l.password=s[1]||"",u[0]=c[1]),l.host=u[0]||"",l.pathname=u[1]||"",i=l.host.split(/:([0-9]+)/),l.hostname=i[0]||"",l.port="undefined"!=typeof i[1]?i[1]:"",l.protocol=o[0]+":",l.origin=l.protocol+"//"+l.host,l.href=(c?l.protocol+"//"+l.username+":"+l.password+"@"+l.host:l.origin)+l.pathname+l.search+l.hash,l)}function O(e){var t;if(!/\{.+\}/.test(e))return{};try{t=JSON.parse(e)}catch(e){return{}}return t}function c(e){var t={};if(m(e,{},null))return Object.assign({},e);if(!m(e,[]))throw new TypeError(e+" must be either null, an object literal or an Array.");return e.forEach(function(e){var t,n;if(m(e,[]))t=e[0],n=e[1],this[t]=n;else{if(!m(e,{}))throw new TypeError(e+" must be either an object literal or an Array.");Object.assign(this,e)}},t),t}function s(t){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e),t()}):setTimeout(t)}function a(e,t,n){var r=e[t]=e[t]||n;n===r&&(r.justPolyfill=!0)}var l;a(l=Object,"assign",function(e){var t,n,r=arguments,o=r.length;for(e=Object(e);1<=--o;)for(t in n=r[o])!{}.hasOwnProperty.call(n,t)||(e[t]=n[t]);return e}),a(l,"values",function(e){var t,n=[];for(t in e)!{}.hasOwnProperty.call(e,t)||n.push(e[t]);return n}),"undefined"!=typeof window&&a(DOMTokenList.prototype,"replace",function(e,t){return t.trim()&&this.contains(e)&&(this.remove(e),this.add(t),!0)});function f(e,t){Object.defineProperty(p,e,{value:t})}var p={};f("register",f),f("access",h),f("prop",h),v(m,{throwable:function(e,t){var n=[].slice.call(arguments),r=Object(this)instanceof String?this:e+" must be like one of the following values: "+n.slice(1).map(function(e){return e+""}).join(", ");if(!m.apply(this,n))throw new TypeError(r);return e}}),f("check",m),f("is",m),v(t,{apply:function(e,t,n){var r="number"==typeof n?[n]:[].slice.call(n),o=e.classList;if(!/(?:add|remove)/.test(t))return o[t](r[0],r[1]);r.forEach(function(e){o[t](e)})}}),v(t.prototype,{add:function(){return t.apply(this.element,"add",arguments),this},remove:function(){return t.apply(this.element,"remove",arguments),this},toggle:function(){return t.apply(this.element,"toggle",arguments),this},replace:function(){return t.apply(this.element,"replace",arguments),this},contains:function(){return t.apply(this.element,"contains",arguments)},item:function(){return t.apply(this.element,"item",arguments)}}),f("ClassList",t),f("defaults",y),f("from",y),f("defineProperties",v),f("defProps",v),f("defineProperty",r),f("defProp",r),f("eachProperty",w),f("eachProp",w),f("findElements",b),f("el",b),f("getRemoteParent",e),f("parent",e),f("isEmptyObject",n),f("emptyObj",n),f("isTouchSupported",o),f("supportsTouch",o),f("isWindow",function(e){return!!(e===window||e instanceof Object&&e.document&&e.setInterval)}),v(g,{nonSrcAttributes:{link:"href"}}),f("loadElement",g),f("load",g),v(u,{DNT:{get:function(){var e=","+[navigator.doNotTrack,navigator.msDoNotTrack,window.doNotTrack]+",";return!!/,(yes|1),/i.test(e)||!/,(no|0),/i.test(e)&&void 0}},cookieExists:function(e){return new RegExp("; "+e+"(=|;)").test("; "+document.cookie+";")},getCookie:function(e){return!/=/.test(e)&&u.cookieExists(e)?("; "+document.cookie).split("; "+e+"=").pop().split(";")[0]:null}}),v(u.prototype,{setCookie:function(e,t,n){function r(e,t){o+=e+("undefined"!=typeof t?"="+t:"")+"; "}var o="",i=y(n,{secure:"https:"===location.protocol});return!!this.consent&&(i.secure&&r("secure"),delete i.secure,i.expires&&(i.expires=new Date(i.expires).toGMTString()),r(e,t),w(i,function(e,t){r(t,e)}),document.cookie=o.trim(),!0)},removeCookie:function(e,t){var n=y(t,{expires:new Date(0)});return!u.cookieExists(e)||this.setCookie(e,"",n)},isStorageAvailable:function(e,t,n){var r,o=y(t,"_"),i=y(n,"_");if(!this.consent)return!1;if(/cookie/i.test(e))return this.setCookie(o,i)&&u.getCookie(o)===i&&this.removeCookie(o);try{(r=window[e]).setItem(o,i),r.removeItem(o)}catch(e){try{r.removeItem(o)}catch(e){return!1}return!1}return!0}}),f("LocalStorage",u),f("addEventListener",i),f("on",i),f("parseUrl",d),f("stringToJSON",O),f("toJSON",O),f("toObjectLiteral",c),f("toObj",c),f("onDocumentReady",s);var j=function(){"use strict";function u(e,t,n){var r;if(!(this instanceof u))return new u(e,t,n);if("string"!=typeof e)throw new TypeError("The id must be a string");("undefined"!=typeof n||m(t,[]))&&"function"!=typeof t||(n=arguments[1],t=[]),"function"==typeof n&&(r=n),v(this,{id:e,dependencyIDs:function(e){m(e,null,void 0)&&(e=[]);return y(e,[e]).map(function(e){var t=m.throwable(e,"string");return!o(t)&&t in u.files&&s(t),t})}(t),handler:r,state:{value:a,writable:!0},returnedValue:{value:r?void 0:n,writable:!0}}),function(e,t){p[e]=t}(e,this),i()}function c(e){return p[e]}function o(e){return e in p}function i(){clearTimeout(i.timeout),i.timeout=setTimeout(function(){var n=[],r=!1;return w(p,function(e,t){e&&e.state!==f&&(!function(e){var t;if(e.state===f)return!0;if(e.state=l,!e.dependencies){if((t=e.dependencyIDs.map(function(e){return c(e)})).some(function(e){return!e||e.state===a}))return!1;e.dependencies=t}return e.handler&&(e.returnedValue=e.handler.apply(null,e.dependencies.map(function(e){return e.returnedValue}))),e.state=f,!0}(e)?n.push(e):r=!0)}),r?i():!n.length},0)}function s(r,e){var t=(u.files[r]||"").split(/\s+/),o=y(e,function(e,t){var n=t.id,r=t.url,o=this.src;c(o)||n===o||n===r||new u(o,[n],function(e){return e})}),i=t[1],n=t[0];if(!(r in u.files))throw new TypeError(r+' must be added to "files".');i||(i=t[0],n="script"),g(n,i,function(e){var t=u.globals,n="error"===e.type?new Error("Error loading the following url: "+this.src):null;r in t&&!c(r)&&new u(r,y(t[r],function(){return h(d,t[r].split("."),null,{mutate:!0})})),o.call(this,n,{event:e,id:r,url:i})})}var a=0,l=1,f=2,d=window,p={};return v(u,{init:function(){var e=u.findInDocument("data-just-Define");return u.addFiles(e).load(Object.keys(e)),u},load:function(e){return m(e,{})?w(m.throwable(e,{}),function(e,t){s(t,m.throwable(e,Function,null,void 0))}):m(e,[],"string")?y(e,[e]).forEach(function(e){s(e)}):m.throwable(e,{},[],"string"),u},files:{value:{},writable:!0},globals:{value:{},writable:!0},addGlobals:function(e){return Object.assign(u.globals,e),u},addFiles:function(e){return Object.assign(u.files,e),u},isDefined:o,clean:function(){return p={},u},findInDocument:function(t,e){var n={};return b("*["+t+"]",e).forEach(function(n){var e=O((n.getAttribute(t)+"").replace(/\[([^\]]+)\]/gi,function(e,t){return n.getAttribute(t)}));Object.assign(this,e)},n),n}}),u}();return s(j.init),f("Define",j),f("Def",j),f("version","1.0.0-rc.17"),f("just",p),p});