document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelectorAll(".wp-block-mousquetaires-key-figure:not(.has-background) .key-figure-wrapper, .wp-block-mousquetaires-key-figure:not(.has-background) figure, .wp-block-mousquetaires-key-figure.has-background");if(e.length>0){const t=[1,2,3,4,5];for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}let r=0;const o=new IntersectionObserver((e,o)=>{e.forEach(e=>{if(e.isIntersecting){const n=e.target,s=t[r%t.length];r++;const i=`/wp-content/themes/mousquetaires/dist/images/motif-${s}.svg`;n.style.setProperty("--dynamic-background-image",`url('${i}')`),n.classList.add("is-visible"),o.unobserve(n)}})},{threshold:.1});e.forEach(e=>{o.observe(e)})}const t=document.querySelectorAll(".key-figure-value");if(!t.length)return;const r=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&((e=>{const t=e.dataset.figureValue;if(!t)return;const r=t.match(/(\d+(?:[.,]\d+)?)/);if(!r)return;const o=r[0],n=parseFloat(o.replace(",",".")),s=(o.split(/[.,]/)[1]||"").length,i=Array.from(e.childNodes).find(e=>e.nodeType===Node.TEXT_NODE);if(!i)return;const a=i.nodeValue;let c=0;const u=()=>{const e=c/100;let t;e<1?(t=(e*n).toLocaleString("fr-FR",{minimumFractionDigits:s,maximumFractionDigits:s}),i.nodeValue=a.replace(o,t),c++,requestAnimationFrame(u)):(t=n.toLocaleString("fr-FR",{minimumFractionDigits:s,maximumFractionDigits:s}),i.nodeValue=a.replace(o,t))};requestAnimationFrame(u)})(e.target),t.unobserve(e.target))})},{threshold:.1});t.forEach(e=>r.observe(e))});