(()=>{"use strict";const t=class{constructor(t){if(this.ablocksCounter=t,!this.ablocksCounter)return;const e=t;this.startValue=Number(e?.getAttribute("data-start"))||0,this.endValue=Number(e?.getAttribute("data-end"))||0,this.totalNumber=Number(e?.getAttribute("data-total"))||0,this.duration=Number(e?.getAttribute("data-duration")),this.separator=e?.getAttribute("data-separator"),this.decimalPlaces=Number(e?.getAttribute("data-decimalPlaces"))||0,this.circleSize=Number(e?.getAttribute("data-circleSize"))||220;const r=e?.getAttribute("data-layout");this.animationRepeat=e?.getAttribute("data-animationRepeat"),this.layout=r,r?("number"!==r&&this.endValue>=this.totalNumber&&(this.endValue=this.totalNumber),new window.IntersectionObserver(this.IOCallback.bind(this),{root:null,rootMargin:"0px",threshold:.5}).observe(this.ablocksCounter)):console.error(`Missing 'data-layout' attribute for '${e}'.`)}init=()=>{"number"===this.layout?this.numberCounter():"circle"===this.layout?this.circleCounter():"bar"===this.layout?this.bar():console.error(`Unsupported layout '${this.layout}' for '${this.countElement}'.`)};playOnce=!1;IOCallback(t){t.forEach(t=>{t.isIntersecting&&("false"!==this.animationRepeat||this.playOnce||(this.playOnce=!0,this.init()),"true"===this.animationRepeat&&this.init())})}numberCounter(){const t=this.ablocksCounter?.querySelector(".ablocks-counter__content-number");if(!t)return void console.error("'.ablocks-counter__content-number' element not found.");const{startValue:e,endValue:r,duration:o,separator:a,decimalPlaces:i}=this;let n=null;const s=r-e,u=r=>{n||(n=r);const l=r-n,c=0===o?1:Math.min(l/o,1),b=e+c*s;t.innerHTML=this.formatNumberWithSeparator(b,a,i),l<o&&window.requestAnimationFrame(u)};window.requestAnimationFrame(u)}circleCounter(){this.numberCounter();const t=this.ablocksCounter?.querySelector(".ablocks-circle-counter__progress");if(!t)return void console.error("'.ablocks-circle-counter__progress' element not found.");const{startValue:e,endValue:r,totalNumber:o,duration:a,circleSize:i}=this,n=i/2,s=2*Math.PI*n,u=[{strokeDashoffset:s-e/o*100/100*s},{strokeDashoffset:s-r/o*100/100*s}],l={duration:a,fill:"forwards"};t.animate(u,l)}bar(){this.numberCounter();const t=this.ablocksCounter?.querySelector(".ablocks-bar-counter__progress");if(!t)return void console.error("'.ablocks-bar-counter__progress' element not found.");const{startValue:e,endValue:r,totalNumber:o,duration:a}=this,i=[{width:e/o*100+"%"},{width:r/o*100+"%"}],n={duration:a,fill:"forwards"};t.animate(i,n)}formatNumberWithSeparator(t,e,r){const o={minimumFractionDigits:r,maximumFractionDigits:r};return t.toLocaleString("en-US",o).replace(/,/g,e)}};document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".ablocks-block--counter").forEach(e=>{new t(e)})})})();