{"version":3,"file":"elements-stats-media-js-Bzj6VQg4.js","sources":["../src/entries/elements/stats-media.js"],"sourcesContent":["import { CountUp } from \"countup.js\";\nimport Swiper from \"swiper\";\nimport { A11y, Autoplay, Grid, Pagination } from \"swiper/modules\";\nimport \"@/styles/components/slider.css\";\n\nconst runCounter = (el) => {\n if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n return;\n }\n\n const useGrouping = el.dataset.useGrouping;\n const decimalPlaces = el.dataset.decimalPlaces;\n const end = el.dataset.end;\n\n const opts = {\n useGrouping: !!+useGrouping,\n };\n\n if (decimalPlaces) {\n opts.decimalPlaces = decimalPlaces;\n }\n\n const counter = new CountUp(el, end, opts);\n\n counter.start();\n};\n\ndocument.querySelectorAll(\".element-statsmedia .stats-slider\").forEach((el) => {\n const container = el.querySelector(\".swiper\");\n\n const swiper = new Swiper(container, {\n modules: [A11y, Autoplay, Grid, Pagination],\n autoplay: {\n delay: 3000,\n },\n speed: 750,\n loop: true,\n pagination: {\n el: el.querySelector(\".slider-pagination\"),\n clickable: true,\n },\n slidesPerView: 1,\n spaceBetween: 24,\n breakpoints: {\n 768: {\n enabled: false,\n slidesPerView: 3,\n grid: {\n fill: \"row\",\n rows: 2,\n },\n loop: false,\n },\n },\n on: {\n init: (swiper) => {\n if (swiper.isLocked) {\n el.classList.add(\"is-locked\");\n } else {\n el.classList.remove(\"is-locked\");\n }\n },\n resize: (swiper) => {\n if (swiper.isLocked) {\n el.classList.add(\"is-locked\");\n } else {\n el.classList.remove(\"is-locked\");\n }\n },\n },\n });\n\n swiper.autoplay.stop();\n\n const handleActiveSlide = (activeSlide) => {\n if (!activeSlide.classList.contains(\"did-run\")) {\n const counters = activeSlide.querySelectorAll(\"[data-counter]\");\n counters.forEach((counter) => runCounter(counter));\n\n activeSlide.classList.add(\"did-run\");\n }\n };\n\n swiper.on(\"autoplayStart\", () => {\n if (swiper.enabled) {\n const activeSlide = swiper.slides[swiper.activeIndex];\n handleActiveSlide(activeSlide);\n } else {\n el.querySelectorAll(\".swiper-slide\").forEach((slide) => {\n handleActiveSlide(slide);\n });\n }\n });\n\n swiper.on(\"slideChange\", () => {\n const activeSlide = swiper.slides[swiper.activeIndex];\n handleActiveSlide(activeSlide);\n });\n\n const observer = new IntersectionObserver(\n ([e]) => {\n if (e.isIntersecting) {\n swiper.autoplay.start();\n observer.disconnect();\n }\n },\n {\n threshold: [0.7],\n },\n );\n\n observer.observe(el);\n});\n"],"names":["runCounter","el","useGrouping","decimalPlaces","end","opts","CountUp","container","swiper","Swiper","A11y","Autoplay","Grid","Pagination","handleActiveSlide","activeSlide","counter","slide","observer"],"mappings":"6NAKA,MAAMA,EAAcC,GAAO,CACzB,GAAI,OAAO,WAAW,kCAAkC,EAAE,QACxD,OAGF,MAAMC,EAAcD,EAAG,QAAQ,YACzBE,EAAgBF,EAAG,QAAQ,cAC3BG,EAAMH,EAAG,QAAQ,IAEjBI,EAAO,CACX,YAAa,CAAC,CAAC,CAACH,CACpB,EAEMC,IACFE,EAAK,cAAgBF,GAGP,IAAIG,EAAQL,EAAIG,EAAKC,CAAI,EAEjC,MAAK,CACf,EAEA,SAAS,iBAAiB,mCAAmC,EAAE,QAASJ,GAAO,CAC7E,MAAMM,EAAYN,EAAG,cAAc,SAAS,EAEtCO,EAAS,IAAIC,EAAOF,EAAW,CACnC,QAAS,CAACG,EAAMC,EAAUC,EAAMC,CAAU,EAC1C,SAAU,CACR,MAAO,GACR,EACD,MAAO,IACP,KAAM,GACN,WAAY,CACV,GAAIZ,EAAG,cAAc,oBAAoB,EACzC,UAAW,EACZ,EACD,cAAe,EACf,aAAc,GACd,YAAa,CACX,IAAK,CACH,QAAS,GACT,cAAe,EACf,KAAM,CACJ,KAAM,MACN,KAAM,CACP,EACD,KAAM,EACP,CACF,EACD,GAAI,CACF,KAAOO,GAAW,CACZA,EAAO,SACTP,EAAG,UAAU,IAAI,WAAW,EAE5BA,EAAG,UAAU,OAAO,WAAW,CAElC,EACD,OAASO,GAAW,CACd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