File: /var/www/html/wpbiancoarte/wp-content/plugins/qi-blocks/assets/dist/counter-script.js
(()=>{"use strict";document.addEventListener("DOMContentLoaded",function(){t.init()});const t={interval:[],init:function(){this.holder=document.querySelectorAll(".qi-block-counter"),this.holder.length&&[...this.holder].map(e=>{t.initItem(e)})},getRealCurrentItem:function(t){return"string"==typeof t&&""!==t&&(t=qiBlocksEditor.qodefGetCurrentBlockElement.get(t)),t},initItem:function(e,i){const n=i?e:"";if(!(e=t.getRealCurrentItem(e)))return;const r=e.querySelector(".qodef-m-digit"),a=t.generateOptions(e);("object"!=typeof qiBlocksEditor?qiBlocks:qiBlocksEditor).qodefIsInViewport.check(e,function(){t.counterScript(r,a,i,n)})},sanitizeAttributeValue:function(t){return t?t.replace(/[^\w\s%.-]/g,""):""},generateOptions:function(e){let i={};return i.start=void 0!==e.getAttribute("data-start-digit")&&""!==e.getAttribute("data-start-digit")?parseInt(e.getAttribute("data-start-digit")):0,i.end=void 0!==e.getAttribute("data-end-digit")&&""!==e.getAttribute("data-end-digit")?parseInt(e.getAttribute("data-end-digit")):null,i.step=void 0!==e.getAttribute("data-step-digit")&&""!==e.getAttribute("data-step-digit")?parseInt(e.getAttribute("data-step-digit")):1,i.delay=void 0!==e.getAttribute("data-step-delay")&&""!==e.getAttribute("data-step-delay")?parseInt(e.getAttribute("data-step-delay"),10):100,i.txt=void 0!==e.getAttribute("data-digit-label")&&""!==e.getAttribute("data-digit-label")?t.sanitizeAttributeValue(e.getAttribute("data-digit-label")):"",i},counterScript:function(e,i,n,r){let a=Object.assign({start:0,end:null,step:1,delay:50,txt:""},i||{}),d=a.start,o=a.end;e.textContent=d+a.txt,n&&r&&clearInterval(t.interval[r]);const l=t.interval[r]=setInterval(function(){null!==o&&d>=o||(d+=a.step,d>=o&&(d=o,clearInterval(r?t.interval[r]:l)),e.textContent=d+a.txt)},a.delay)}}})();