text: "use strict";function NVJSMenu(e,t,n){const l=this,s=arguments;let o,i,r,a,c,u=".header",d=".hamburger",f=".header__menu",h={autoInitialize:!0,lockBody:!0,menuOpenClass:"open"},v={scroll:{},toggle:{}},y=!1,g=!1,b=!1;function m(e){return[o,i]=C([this,u],"",1,!0),o?(o.dispatchEvent(new Event("ready")),l.header=o,""===o.getAttribute("ready")||o.getAttribute("ready")?(S("NVJS_Menu initialization error. NVJS_Menu was initialized early. Initialization Aborted","error"),!1):(o.setAttribute("ready",""),a=C([e.menu,f],i,1),l.menu=a,r=C([e.menuShowButtons,d],i),l.menuShowButtons=r,Object.keys(h).forEach(t=>{null!=e[t]&&N(h[t])==N(e[t])&&(h[t]=e[t]),l[t]=h[t]}),function(e){if(v.toggle={enable:!0,elements:["header","menuShowButtons","menu"],addClass:!0,activeClass:l.menuOpenClass,callingFunction:!1},v.toggle.elements=t.call(v.toggle),v.scroll={enable:!1,sensivityLevel:{low:40,medium:20,hight:0,default:20},addClass:!0,activeClass:"scrolled",callingFunction:!1},v.scroll.sensivity=v.scroll.sensivityLevel.default,e){let n=["enable","addClass","activeClass","callingFunction"];Object.keys(e).forEach(l=>{switch(v[l]||(v[l]={}),N(e[l])){case"function":v[l].callingFunction=e[l];break;case"boolean":v[l].enable=e[l];break;case"object":v[l].enable=!0;for(let t of n)null!=e[l][t]&&(v[l][t]=e[l][t]),"activeClass"==t&&null!=e[l].activeClass&&null==v[l].addClass&&null==e[l].addClass&&(v[l].addClass=!0);(function(){switch(this){case"toggle":e.toggle.elements&&(v.toggle.elements=t.call(e.toggle,v.toggle.elements));break;case"scroll":e.scroll.sensivity&&function(){let e=this.sensivity;switch(N(e)){case"number":e<0?S("NVJS_Menu setEvents warn. Scroll sensivity can't be less than 0. Use default 20."):e>100?(v.scroll.sensivity=e,S("NVJS_Menu setEvents warn. Scroll sensivity wery low. Try to use default 20.")):v.scroll.sensivity=e;break;case"string":v.scroll.sensivityLevel[e]?v.scroll.sensivity=v.scroll.sensivityLevel[e]:S(`NVJS_Menu setEvents warn. Scroll sensivity ${e} can't be find. Use default 20.`)}}.call(e.scroll)}}).call(l)}});for(let e in v)v[e].callingFunction&&(l.userFunc||(l.userFunc={}),Object.defineProperty(l.userFunc,e,{configurable:!0,enumerable:!0,value:v[e].callingFunction,writable:!1}))}function t(e){let t=this.elements;if(t==[void 0])return[];let n=N(this.elements),s=[];var o;return"string"==n?r(t):"array"==n&&t.forEach(e=>{let t=N(e);"string"==t?r(e):"array"==t&&e.forEach(e=>{s.push(C([e],i))})}),s.length<1&&e&&t!==[]?(s=e,console.log(t)):s.length>0&&(o=function e(t){let n=[];t.forEach(t=>{switch(N(t)){case"Node":n.push(t);break;case"array":n=n.concat(e(t))}});return n}(s),s=o.reduce((e,t)=>(e.includes(t)||e.push(t),e),[])),s;function r(e){l[e]?s.push(l[e]):S("NVJS_Menu setEvents warn. Some toggled elements not found.")}}}(e.on),void(l.autoInitialize&&p()))):(S("NVJS_Menu initialization error. Header element unavaliable. Initialization Aborted","error"),!1)}function p(){y=!0,o.dispatchEvent(new Event("initialized")),function(){v.toggle.enable&&(r.forEach(e=>{e.addEventListener("click",e=>{e.preventDefault(),w()})}),a.addEventListener("click",e=>e.stopPropagation()));if(v.scroll.enable){let t=v.scroll;function e(...t){let n=t.length>1?"add":"remove",l=t.shift(),s=v[l];s.enable&&s.addClass&&s.activeClass?E.call(o,n,s.activeClass):s.activeClass||S(`NVJS_Menu onScroll error. Name of ${l} active class is undefined`),t.length>0&&e(t[0])}o.addEventListener("scroll",n=>{t.addClass&&t.activeClass?b?E.call(o,"add",t.activeClass):(E.call(o,"remove",t.activeClass),e("scrollToTop")):t.activeClass||S(`NVJS_Menu on ${n.type} error. Name of ${n.type} active class is undefined`),b&&!h.lockBody&&w.call("hide")}),o.addEventListener("scrollToTop",t=>{e(t.type,"scrollToBottom")}),o.addEventListener("scrollToBottom",t=>{e(t.type,"scrollToTop")}),function(){let e,t=0,n=new Event("scroll"),l=v.scroll.sensivity,s={scrollToTop:!1,scrollToBottom:!1};function i(e){(!b&&e||b&&!e)&&(b=e,o.dispatchEvent(n))}function r(){let[e,n]="scrollToTop"==this?[1,"scrollToBottom"]:[-1,"scrollToTop"];s[this]=!0;let i=t;setTimeout(()=>{e*t<e*(i-l)?(s[n]=!1,o.dispatchEvent(new Event(this))):s[this]=!1},300)}!b&&window.scrollY>0&&i(!0),window.addEventListener("scroll",()=>{if(e=t,(t=window.scrollY)<=0)i(!1);else if(t>0)if(i(!0),t>e){let e="scrollToBottom";s[e]||r.call(e)}else if(t<e){let e="scrollToTop";s[e]||r.call(e)}})}()}l.userFunc&&Object.keys(l.userFunc).forEach(e=>{o.addEventListener(e,l.userFunc[e].call())})}()}function w(){let e={show:{setClass:"add",bodyLock:!0},hide:{setClass:"remove",bodyLock:!1}},t=null!=this?this:g?"hide":"show";if("hide"==t&&g||"show"==t&&!g){let n=v.toggle;n.addClass&&n.activeClass?E.call(n.elements,e[t].setClass,n.activeClass):n.activeClass||S("NVJS_Menu onScroll error. Name of Show active class is undefined"),function(e){h.lockBody&&(e?(c=document.body.style.overflow,document.body.style.overflow="hidden"):e||(document.body.style.overflow=c,c=void 0))}.call(l.body,e[t].bodyLock),o.dispatchEvent(new Event(t)),g=!g}}function E(e,t){switch(N(this)){case"Node":("add"==e&&!this.classList.contains(t)||"remove"==e&&this.classList.contains(t))&&this.classList[e](t);break;case"array":this.forEach(n=>E.call(n,e,t))}}function S(e,t){n&&e&&(t&&"warn"!=t?"error"==t&&console.error(e):console.warn(e))}function C(e,t,n,l,s){let o,i;if(s?s++:s=1,e.length>0){let r=e.shift(),a=function e(t,n){let l=n||"body";let s=document.querySelector(l);let o=[];switch(N(t)){case"string":return(o=e(s.querySelectorAll(t),l))[0]?[!0,o[1]]:[!1];case"NodeList":return Array.prototype.slice.call(t,0).forEach(e=>{e.closest(l)&&o.push(e)}),o.length>0?[!0,o]:[!1];case"array":return t.forEach(t=>{let n=e(t,l);n[0]&&(o=o.concat(n[1]))}),o.length>0?[!0,o]:[!1];default:return[!1]}}(r,t);a[0]?(i=r,o=n&&N("number"==n)?1==n?a[1][0]:a[1].slice(0,n):a[1]):(1==s&&S(`NVJS_Menu initialization warn. '${r}' selector unavaliable. Trying used default`),l?[o,i]=o=C(e,t,n,l,s):o=C(e,t,n,l,s))}else S("NVJS_Menu initialization error. some selector unavaliable. Some function may work not correct"),o=!1;return l?[o,i]:o}function N(e){if("string"==typeof e||e instanceof String)return"string";if("boolean"==typeof e)return"boolean";if("number"==typeof e&&isFinite(e))return"number";if(void 0===e)return"undefined";if("function"==typeof e)return"function";if("object"==typeof e){if(Array.isArray(e))return"array";if(NodeList.prototype.isPrototypeOf(e))return"NodeList";if(e instanceof Node)return"Node";if(e.constructor===Object)return"object";if(e.constructor===RegExp)return"regexp"}else{if(null===e)return"null";if(e instanceof Error&&void 0!==e.message)return"error";if(e instanceof Date)return"date";if("symbol"==typeof e)return"symbol"}}this.toggle=(()=>{w()}),this.hide=function(){w.call("hide")},this.show=function(){w.call("show")},this.on=function(e,t){o.addEventListener(e,()=>{t()})},this.initialize=function(){y?S("NVJS_Menu initialization error. NVJS_Menu already initialized","error"):p()},function(){let e=[["string","NVJS_Menu initialization warn. Header selector doesn't exist. Try used default."],["object","NVJS_Menu initialization warn. Configuration doesn't exist. Try used default."],["boolean"]],t=[],l=[],o=Array.prototype.slice.call(s,0,e.length);for(let n=0;n<e.length;n++)e[n][0]==N(o[0])?l.push(o.shift()):(l.push(void 0),t.push(e[n][1]));1==l.pop()&&(n=!0,t.forEach(e=>S(e))),m.call(l[0],l[1])}()}