"use strict";var _topbar$clientHeight;function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw a}}}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,s=[],c=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var elements=document.querySelectorAll("[data-observable]"),callback=function(e,t,r){switch(t){case"fade-up":if(!r)break;e.classList.add("visible");break;case"fade-up-scroll-only":e.classList.contains("fade-up-view")?e.classList.add("visible"):r?e.classList.add("opacity-100","visible"):e.classList.add("fade-up-view");break;case"lazy-img":if(!r)break;e.setAttribute("src",e.getAttribute("data-src"));break;case"fade-left-scroll-only":e.classList.contains("fade-left-view")?e.classList.add("visible"):r?e.classList.add("opacity-100","visible"):e.classList.add("fade-left-view");break;case"fade-in-children":var n;if(!r)break;var o=null!==(n=parseInt(e.getAttribute("delay")))&&void 0!==n?n:800;(isNaN(o)||"number"!=typeof o||o<=0)&&(o=800),Array.from(e.children).forEach((function(e,t){setTimeout((function(){e.classList.add("!opacity-100")}),o*t+300)}));break;case"count-up":if(!r)break;!function e(t){"undefined"==typeof animateCountUp?setTimeout((function(){return e(t)}),1e3):animateCountUp(t)}(e);break;case"map":if(!r)break;e.hasAttribute("src")||e.parentElement.classList.contains("allowed")&&loadMap(e);break;case"recaptcha":if(!r)break;loadReCaptcha();break;case"facebook":if(!r)break;loadFacebookScript();break;default:console.error("Unknown data-observable: ".concat(t))}},observer=new IntersectionObserver(handleIntersection);function handleIntersection(e){e.forEach((function(e){callback(e.target,e.target.getAttribute("data-observable"),e.isIntersecting)}))}elements.forEach((function(e){observer.observe(e)}));var onScrollEvents=[],lastKnownScrollPosition=0,ticking=!1;document.addEventListener("scroll",(function(){lastKnownScrollPosition=window.scrollY,ticking||(window.requestAnimationFrame((function(){settings.onScroll.forEach((function(e){return e(lastKnownScrollPosition)})),ticking=!1})),ticking=!0)}));var navbar=document.querySelector("nav"),topbar=document.querySelector(".top-bar"),positionTrigger=null!==(_topbar$clientHeight=null==topbar?void 0:topbar.clientHeight)&&void 0!==_topbar$clientHeight?_topbar$clientHeight:0;settings.onScroll.push((function(e){navbar.classList[e>positionTrigger?"add":"remove"]("scrolled")}));var openModal=function(e){var t;null===(t=document.querySelector("[modal=".concat(e,"]")))||void 0===t||t.classList.add("visible"),loadReCaptcha()};function toggleMobileMenuJs(e){document.body.classList[e?"add":"remove"]("menu-open")}function handleRightFormSubmit(){var e=document.querySelector("#page-right-form");if(e){var t=e.querySelector("button");if(!t.classList.contains("loading")){t.classList.add("loading");var r=new FormData(e),n=Object.fromEntries(r),o=!1;["name","phone","message","agree"].forEach((function(t){n[t]||(console.log("error"),e.querySelector("[name=".concat(t,"]")).setAttribute("error",""),o=!0),"email"==t&&(/\S+@\S+\.\S+/.test(n[t])||(e.querySelector("[name=".concat(t,"]")).setAttribute("error",""),o=!0))})),o?t.classList.remove("loading"):fetch("".concat(settings.templateDir,"/post/call-offer.php"),{credentials:"same-origin",mode:"same-origin",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then((function(t){return 200===t.status?t.json():(e.querySelector(".result-text").innerText="Kunne ikke udføre anmodningen. Ring venligst direkte til os i stedet.",e.classList.add("text-red-600"),Promise.reject("server"))})).then((function(){t.classList.remove("loading"),t.setAttribute("disabled",""),t.innerText="Tak for din henvendelse!"})).catch((function(e){"server"!==e&&console.log(e)}))}}else console.error("Couldn't find form #page-right-form")}function handleSendEmailSubmit(e,t){var r=document.querySelector("#".concat(t)),n=r.querySelector("button");if(!n.classList.contains("loading")){n.classList.add("loading");var o=new FormData(r),a=Object.fromEntries(o),i=!1;("send-email"==t?["email","message"]:["name","phone","email","message","agree"]).forEach((function(e){a[e]||(console.log("error"),r.querySelector("[name=".concat(e,"]")).setAttribute("error",""),i=!0),"email"==e&&(/\S+@\S+\.\S+/.test(a[e])||(r.querySelector("[name=".concat(e,"]")).setAttribute("error",""),i=!0))})),i?n.classList.remove("loading"):fetch("".concat(settings.templateDir,"/post/send-email.php"),{credentials:"same-origin",mode:"same-origin",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then((function(e){return 200===e.status?e.json():(r.querySelector(".result-text").innerText="Kunne ikke udføre anmodningen. Ring venligst direkte til os i stedet.",r.classList.add("text-red-600"),Promise.reject("server"))})).then((function(){n.classList.remove("loading"),n.setAttribute("disabled",""),n.innerText="Tak for din henvendelse!"})).catch((function(e){"server"!==e&&console.log(e)}))}}document.querySelectorAll("[modal]").forEach((function(e){e.addEventListener("click",(function(t){t.target.hasAttribute("modal")&&e.classList.remove("visible")}))})),document.querySelectorAll(".sub-menu").forEach((function(e){e.setAttribute("height",e.offsetHeight),e.classList.add("max-h-0"),e.parentElement.classList.contains("open")&&(e.style.maxHeight="".concat(e.getAttribute("height"),"px"))})),document.querySelectorAll("[menu]").forEach((function(e){e.addEventListener("click",(function(){var t=document.querySelector(".menu-".concat(e.getAttribute("menu"))).classList.contains("open"),r=document.querySelector(".sub-menu-".concat(e.getAttribute("menu")));t?(document.querySelector(".menu-".concat(e.getAttribute("menu"))).classList.remove("open"),r.style.maxHeight="0px"):(document.querySelector(".menu-".concat(e.getAttribute("menu"))).classList.add("open"),r.style.maxHeight="".concat(r.getAttribute("height"),"px"))}))}));var reCaptchaLoaded=!1;function loadReCaptcha(){if(!reCaptchaLoaded){reCaptchaLoaded=!0;var e=document.createElement("script");e.src="https://www.google.com/recaptcha/api.js?hl=en",e.defer=!0,document.body.appendChild(e)}}var facebookScriptLoaded=!1;function loadFacebookScript(){if(!facebookScriptLoaded){facebookScriptLoaded=!0;var e=document.createElement("script");e.src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v13.0",e.defer=!0,e.crossOrigin="anonymous",document.body.appendChild(e)}}var slideSelectors=document.querySelectorAll(".slide-selectors > div"),selectSelector=function(e){slideSelectors.forEach((function(e){return e.classList.remove("selected")}));var t=document.querySelector(".slide-selector-".concat(e+1));t&&t.classList.add("selected")},skipNextSlide=!1,heroDelay=3500;function switchSlides(e){e.forEach((function(t,r){setTimeout((function(){t.classList.remove("opacity-0"),selectSelector(r),setInterval((function(){selectSelector(r),e.forEach((function(e){return e.classList.add("opacity-0")})),t.classList.remove("opacity-0")}),e.length*heroDelay)}),r*heroDelay)}))}var heroContainers=_toConsumableArray(new Set(_toConsumableArray(document.querySelectorAll(".hero-slide")).map((function(e){return e.parentElement}))));function setCookie(e,t,r){var n="";if(r){var o=new Date;o.setTime(o.getTime()+24*r*60*60*1e3),n="; expires="+o.toUTCString()}document.cookie=e+"="+(t||"")+n+"; path=/"}function deleteCookie(e){document.cookie=e+"=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function onCustomRightFormInputFocus(e){e.target.removeAttribute("error")}function onCustomRightFormSubmit(e){handleCustomRightFormSubmit(e,"custom-right-form")}function handleCustomRightFormSubmit(e,t){var r=document.querySelector("#".concat(t)),n=r.querySelector("button");if(!n.classList.contains("loading")){n.classList.add("loading");var o=new FormData(r),a=Object.fromEntries(o),i=!1;"agree"in a||(r.querySelector("[name=agree]").setAttribute("error",""),i=!0);for(var s=0,c=Object.entries(a);s<c.length;s++){var l=_slicedToArray(c[s],2),u=l[0],d=l[1],m=r.querySelector("[name=".concat(u,"]"));m.required&&!d&&(m.setAttribute("error",""),i=!0)}i?n.classList.remove("loading"):fetch("".concat(settings.templateDir,"/post/right-form.php"),{credentials:"same-origin",mode:"same-origin",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({parameters:a,"g-recaptcha-response":e})}).then((function(e){return 200===e.status?e.json():(r.querySelector(".result-text").innerText="Kunne ikke udføre anmodningen. Ring venligst direkte til os i stedet.",r.classList.add("text-red-600"),Promise.reject("server"))})).then((function(e){r.innerHTML='\n    <div class="text-4xl font-extrabold">Tak for din henvendelse!</div>\n    <div>Vi kontakter dig hurtigst muligt.</div>\n    ',r.classList.add("py-12")})).catch((function(e){n.classList.remove("loading"),"server"!==e&&console.log(e)}))}}heroContainers.forEach((function(e){var t=e.querySelectorAll(".hero-slide");t.length>1&&switchSlides(t)}));var scrollIntoViewById=function(e){var t,r=_createForOfIteratorHelper(e.split("||"));try{for(r.s();!(t=r.n()).done;){var n=t.value,o=document.querySelector("#".concat(n));if(o){o.scrollIntoView({behavior:"smooth"});break}}}catch(e){r.e(e)}finally{r.f()}},loadMap=function(e){e.src=e.getAttribute("x-src").startsWith("http")?e.getAttribute("x-src"):"https://google.com/"},isElementInViewport=function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},mobileMenu=document.querySelector(".mobile-menu"),links=mobileMenu.querySelectorAll("a");links.forEach((function(e){e.addEventListener("click",(function(e){e.target.classList.contains("fa-chevron-down")&&(e.preventDefault(),e.target.parentElement.parentElement.classList.toggle("open"))}))}));var scrollElement=document.querySelector("#scroll-top"),offset=200;if(scrollElement){var updateScrollPercentage=function(){var e=window.scrollY,t=function(){var e=window.scrollY,t=document.documentElement.scrollHeight-window.innerHeight;return 0===t?100:e/t*100}();scrollElement.classList[e>=offset?"add":"remove"]("active"),scrollElement.style.background="conic-gradient(var(--color-scheme) 0% ".concat(t,"%, transparent ").concat(t,"% 100%)")};settings.onScroll.push(updateScrollPercentage),updateScrollPercentage(),scrollElement.addEventListener("click",(function(e){e.preventDefault(),window.scrollTo({top:0,behavior:"smooth"})}))}function submitCustomForm(e){try{var t=function(e,t,r){var n=e.querySelector(".custom-form-result");n.innerText=r,n.className="custom-form-result ".concat(t)},r=document.querySelector("#custom-form"),n=r.querySelectorAll("input:not([type=radio]), textarea, select, .radio-group"),o=r.querySelector("button");if(o.classList.contains("loading"))return;o.classList.add("loading"),n.forEach((function(e){e.classList.contains("radio-group")?e.hasAttribute("required")&&!e.querySelector("input:checked")&&e.setAttribute("error",""):e.required&&(("email"!=e.getAttribute("type")||/\S+@\S+\.\S+/.test(e.value))&&e.value||e.setAttribute("error",""))}));var a=!1;if(n.forEach((function(e){null!==e.getAttribute("error")&&(a=!0)})),a)return void o.classList.remove("loading");var i=[];n.forEach((function(e){if(e.classList.contains("radio-group")){var t,r,n=e.querySelector("input:checked");i.push({name:null!==(t=n.getAttribute("name"))&&void 0!==t?t:"",value:null!==(r=n.value)&&void 0!==r?r:"Ikke angivet"})}else{var o,a,s;if("g-recaptcha-response"==e.getAttribute("name"))return;i.push({name:null!==(o=null!==(a=e.getAttribute("text"))&&void 0!==a?a:e.getAttribute("name"))&&void 0!==o?o:"Ukendt",value:e.value,type:null!==(s=e.type)&&void 0!==s?s:""})}})),fetch("".concat(settings.templateDir,"/post/form.php"),{credentials:"same-origin",mode:"same-origin",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({parameters:i,"g-recaptcha-response":e})}).then((function(e){return 200===e.status?e.json():(o.classList.remove("loading"),t(r,"error","Der skete en fejl. Kontakt os venligst direkte til os i stedet."),Promise.reject("server"))})).then((function(){o.disabled=!0,o.classList.remove("loading"),t(r,"success","Tak for din henvendelse. Vi vender tilbage til dig hurtigst muligt.")})).catch((function(e){o.classList.remove("loading"),"server"!==e&&console.log(e)}))}catch(e){console.error(e)}}
//# sourceMappingURL=index.min.js.map