{"version":3,"sources":["dtyb.js"],"names":["$","carousel","document","querySelector","classes","slides","querySelectorAll","prevArrow","nextArrow","slideCount","dataset","setSlide","e","slideIndex","currentTarget","slide","newSlides","concat","activeSlides","forEach","activeSlide","classList","remove","newSlide","add","navigateSlide","direction","newIndex","parseInt","arrowPos","imageBlock","headerBlock","topHeight","offsetHeight","arrowTop","Math","floor","style","top","imageSlider","currentSlide","fn","time","timeout","images","on","slick","arrows","dots","draggable","window","addEventListener","_arguments","arguments","_this","this","clearTimeout","setTimeout","functionCall","apply","contains","jQuery"],"mappings":"AAAA,cAAC,SAASA,GACR,IAAMC,EAAWC,SAASC,cAAc,kBAExC,GAAKF,EAAL,CAIA,IAAMG,EACG,cADHA,EAEI,qBAFJA,EAGI,sBAHJA,EAII,oCAJJA,EAKK,gBALLA,EAMC,YAGDC,EAASJ,EAASK,iBAAiBF,GACnCG,EAAYN,EAASE,cAAc,sBACnCK,EAAYP,EAASE,cAAc,sBACnCM,EAAaR,EAASS,QAAQD,WAkB9BE,EAAWC,SAAAA,GACf,IAAMC,EAAaD,EAAEE,cAAcJ,QAAQK,MACrCC,EAAYd,SAASI,iBAAgB,GAAAW,OAAIb,EAAa,iBAAAa,OAAgBJ,EAAAA,OACtEK,EAAehB,SAASI,iBAAiBF,GAE1Cc,GAAiBF,IAItBE,EAAaC,SAAQC,SAAAA,GACnBA,EAAYC,UAAUC,OAAO,SAC/B,IAEAN,EAAUG,SAAQI,SAAAA,GAChBA,EAASF,UAAUG,IAAI,SACzB,IACF,EAEMC,EAAgBC,SAAAA,GACpB,IAAIb,EAAa,EACXK,EAAehB,SAASI,iBAAiBF,GAE/C,GAAKc,EAAL,CAIAA,EAAaC,SAAQC,SAAAA,GACnBA,EAAYC,UAAUC,OAAO,UAC7BT,EAAaO,EAAYV,QAAQK,KAAK,IAGxC,IAAIY,EAAWC,SAASf,GAAc,EAEpB,SAAda,GAAwBC,EAAWlB,IACrCkB,EAAW,GAGK,SAAdD,IACFC,EAAWC,SAASf,GAAc,GAEnB,IACbc,EAAWlB,GAIGP,SAASI,iBAAgB,GAAAW,OAAIb,EAAa,iBAAAa,OAAgBU,EAAAA,OAElER,SAAQI,SAAAA,GAChBA,EAASF,UAAUG,IAAI,SACzB,GAzBA,CA0BF,EAKMK,EAAW,WACf,IAAMC,EAAa7B,EAASE,cAAcC,GACpC2B,EAAc9B,EAASE,cAAcC,GACrC4B,EAAYF,EAAWG,aAAeF,EAAYE,aAClDC,EAAWC,KAAKC,MAAMJ,EAAY,GACxCzB,EAAU8B,MAAMC,IAAG,GAAArB,OAAMiB,EAAAA,MACzB1B,EAAU6B,MAAMC,IAAG,GAAArB,OAAMiB,EAAAA,KAAY,EAGjCK,EAAcC,SAAAA,GAClB,IA5EgBC,EAAIC,EAChBC,EA2EEC,EAASJ,EAAarC,cAAcC,GAErCwC,IAIL5C,EAAE4C,GACCC,GAAG,QAAQ,WACVhB,GACF,IACCiB,MAAM,CACLC,QAAQ,EACRC,MAAM,EACNC,WAAW,IAGfC,OAAOC,iBACL,UA7FcV,EA8FL,WACPZ,GACF,EAhGkBa,EAgGf,IA7FE,WAAA,IAAAU,EAAAC,UAAAC,EAAAC,KAGLC,aAAab,GACbA,EAAUc,YAHW,WAAfC,OAAqBjB,EAAGkB,MAAML,EAAMD,EAAAA,GAGPX,EACrC,IA0FF,EAEArC,EAAOc,SAAQJ,SAAAA,GACbwB,EAAYxB,IAEPA,EAAMM,UAAUuC,SAASxD,IAAqBW,EAAMM,UAAUuC,SAASxD,KAI5EW,EAAMoC,iBAAiB,QAASxC,EAClC,IAEAJ,EAAU4C,iBAAiB,SAAS,WAClC1B,EAAc,OAChB,IACAjB,EAAU2C,iBAAiB,SAAS,WAClC1B,EAAc,OAChB,GAxIA,CAyIF,CA9IC,CA8IEoC","file":"../dtyb.js","sourcesContent":["(function($) {\n const carousel = document.querySelector('.dtyb-carousel');\n\n if (!carousel) {\n return;\n }\n\n const classes = {\n slide: '.dtyb-slide',\n active: '.dtyb-slide.active',\n header: '.dtyb-slide__header',\n images: '.dtyb-slide__images .image-slider',\n details: 'details-slide',\n tab: 'tab-slide',\n };\n\n const slides = carousel.querySelectorAll(classes.slide);\n const prevArrow = carousel.querySelector('.arrow.arrow--prev');\n const nextArrow = carousel.querySelector('.arrow.arrow--next');\n const slideCount = carousel.dataset.slideCount;\n\n /**\n * Standard debounce function\n * @param {function} fn - The function to call\n * @param {function} time - How long to wait\n */\n const debounce = (fn, time) => {\n let timeout;\n\n return function() {\n const functionCall = () => fn.apply(this, arguments);\n\n clearTimeout(timeout);\n timeout = setTimeout(functionCall, time);\n };\n };\n\n const setSlide = e => {\n const slideIndex = e.currentTarget.dataset.slide;\n const newSlides = document.querySelectorAll(`${classes.slide}[data-slide=\"${slideIndex}\"]`);\n const activeSlides = document.querySelectorAll(classes.active);\n\n if (!activeSlides || !newSlides) {\n return;\n }\n\n activeSlides.forEach(activeSlide => {\n activeSlide.classList.remove('active');\n });\n\n newSlides.forEach(newSlide => {\n newSlide.classList.add('active');\n });\n };\n\n const navigateSlide = direction => {\n let slideIndex = 1;\n const activeSlides = document.querySelectorAll(classes.active);\n\n if (!activeSlides) {\n return;\n }\n\n activeSlides.forEach(activeSlide => {\n activeSlide.classList.remove('active');\n slideIndex = activeSlide.dataset.slide;\n });\n\n let newIndex = parseInt(slideIndex) + 1;\n\n if (direction !== 'prev' && newIndex > slideCount) {\n newIndex = 1;\n }\n\n if (direction === 'prev') {\n newIndex = parseInt(slideIndex) - 1;\n\n if (newIndex < 1) {\n newIndex = slideCount;\n }\n }\n\n const newSlides = document.querySelectorAll(`${classes.slide}[data-slide=\"${newIndex}\"]`);\n\n newSlides.forEach(newSlide => {\n newSlide.classList.add('active');\n });\n };\n\n /**\n * Set arrow position\n */\n const arrowPos = () => {\n const imageBlock = carousel.querySelector(classes.images);\n const headerBlock = carousel.querySelector(classes.header);\n const topHeight = imageBlock.offsetHeight + headerBlock.offsetHeight;\n const arrowTop = Math.floor(topHeight / 2);\n prevArrow.style.top = `${arrowTop}px`;\n nextArrow.style.top = `${arrowTop}px`;\n };\n\n const imageSlider = currentSlide => {\n const images = currentSlide.querySelector(classes.images);\n\n if (!images) {\n return;\n }\n\n $(images)\n .on('init', () => {\n arrowPos();\n })\n .slick({\n arrows: false,\n dots: true,\n draggable: true,\n });\n\n window.addEventListener(\n 'resize',\n debounce(() => {\n arrowPos();\n }, 300)\n );\n };\n\n slides.forEach(slide => {\n imageSlider(slide);\n\n if (!slide.classList.contains(classes.details) && !slide.classList.contains(classes.tab)) {\n return;\n }\n\n slide.addEventListener('click', setSlide);\n });\n\n prevArrow.addEventListener('click', () => {\n navigateSlide('prev');\n });\n nextArrow.addEventListener('click', () => {\n navigateSlide('next');\n });\n})(jQuery); // jQuery for slick\n"]}