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AM,GACP,iBAAiB,2BACpC,QAAQ,GAAU,CACxB,EAAO,MAAM,QAAU,UAGzB,EAAqB,QAAQ,GAAa,CACxC,EAAU,UAAY,GAAG,EAAc,OAAO,OAKpD,UAAe","file":"scripts/491.bundle.js","sourcesContent":["import { Component } from '@verndale/core';\nimport Swiper, { Navigation, Pagination, A11y } from 'swiper';\n\nSwiper.use([Navigation, Pagination, A11y]);\n\nclass Module extends Component {\n setupDefaults() {\n this.dom = {\n swiperContainer: this.el.querySelector('.image-slider__carousel'),\n cards: this.el.querySelectorAll('.image-card'),\n buttons: this.el.querySelectorAll('.image-card__slider-btn')\n };\n\n this.initSlider();\n this.makeButtonsNotFocusable();\n if (this.dom.cards.length > 1) this.setPagination(0, this.dom.cards.length);\n }\n\n addListeners() {\n this.dom.cards.forEach(card => {\n const nextButton = card.querySelector('.swiper-button-next');\n const prevButton = card.querySelector('.swiper-button-prev');\n nextButton.addEventListener('keydown', e => this.keyPress(e));\n prevButton.addEventListener('keydown', e => this.keyPress(e));\n });\n }\n\n keyPress(e) {\n if (e.keyCode === 13) {\n if (e.target.classList.contains('swiper-button-next')) {\n this.swiper.slideNext();\n } else if (e.target.classList.contains('swiper-button-prev')) {\n this.swiper.slidePrev();\n }\n this.setActivePagination();\n }\n }\n\n setActivePagination() {\n const activeSlide = this.el.querySelector('.swiper-slide-active');\n const totalSlides = this.swiper.slides.length;\n this.setPagination(\n Number(activeSlide.dataset.swiperSlideIndex),\n totalSlides\n );\n }\n\n initSlider() {\n this.swiper = new Swiper(this.dom.swiperContainer, {\n keyboard: true,\n autoHeight: false,\n loop: true,\n navigation: {\n nextEl: '.swiper-button-next',\n prevEl: '.swiper-button-prev'\n },\n on: {\n navigationNext: () => {\n this.setActivePagination();\n },\n navigationPrev: () => {\n this.setActivePagination();\n },\n transitionEnd: () => {\n this.setActivePagination();\n }\n }\n });\n }\n\n makeButtonsNotFocusable() {\n this.dom.buttons.forEach(button => {\n button.style.display = 'none';\n });\n }\n\n setPagination(activeSlide, totalSlides) {\n const paginationContainers = this.el.querySelectorAll(\n '.image-card__pagination-count'\n );\n this.makeButtonsNotFocusable();\n const activeCard = this.dom.cards[activeSlide]\n const buttons = activeCard.querySelectorAll('.image-card__slider-btn')\n buttons.forEach(button => {\n button.style.display = 'block';\n })\n\n paginationContainers.forEach(container => {\n container.innerHTML = `${activeSlide + 1} / ${totalSlides}`;\n });\n }\n}\n\nexport default Module;\n"],"sourceRoot":""}