// source --> https://so-design.fr/wp-content/cache/autoptimize/js/autoptimize_single_53ae41ea4478ae6c093310ccedc7661f.js?ver=2.83.48.1784056066 
'use strict';const feI18n=window.rpFrontendI18n||{};const throttle=(func,delay)=>{let lastCall=0;return(...args)=>{const now=Date.now();if(now-lastCall>=delay){lastCall=now;func(...args);}};};const debounce=(func,delay)=>{let timeoutId;return(...args)=>{clearTimeout(timeoutId);timeoutId=setTimeout(()=>func(...args),delay);};};const onReady=(callback)=>{if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',callback);}else{callback();}};const repositionOnMobile=()=>{};const initProgressBar=()=>{const bar=document.createElement('div');bar.className='po-reading-progress';document.body.prepend(bar);const updateProgress=throttle(()=>{const scrollHeight=document.documentElement.scrollHeight-document.documentElement.clientHeight;const scrollPercent=(document.documentElement.scrollTop/scrollHeight)*100;bar.style.width=`${scrollPercent}%`;},16);window.addEventListener('scroll',updateProgress,{passive:true});};const initLazyImages=()=>{document.querySelectorAll('.po-main-content img').forEach(img=>{img.loading='lazy';});};const initResponsiveTables=()=>{document.querySelectorAll('.po-main-content table').forEach(table=>{if(table.closest('.po-table-wrapper'))return;const wrapper=document.createElement('div');wrapper.className='po-table-wrapper';const responsive=document.createElement('div');responsive.className='po-table-responsive';const rows=table.querySelectorAll('tbody tr');table.before(wrapper);wrapper.appendChild(responsive);responsive.appendChild(table);if(table.offsetWidth>responsive.offsetWidth){const scrollIndicator=document.createElement('div');scrollIndicator.className='po-table-scroll-indicator';scrollIndicator.innerHTML='<i class="fas fa-arrows-left-right"></i> '+(feI18n.scrollRight||'Scroll →');wrapper.appendChild(scrollIndicator);responsive.addEventListener('scroll',()=>{if(responsive.scrollLeft>50){scrollIndicator.style.opacity='0';setTimeout(()=>scrollIndicator.remove(),300);}},{once:true});}});};const initFAQ=()=>{const closeAllFAQ=(exceptItem)=>{document.querySelectorAll('.po-faq-item').forEach(item=>{if(item===exceptItem)return;item.classList.remove('active');const answer=item.querySelector('.po-faq-answer');const question=item.querySelector('.po-faq-question');if(answer)answer.style.maxHeight='0';if(question)question.setAttribute('aria-expanded','false');});};document.querySelectorAll('.po-faq-item').forEach(item=>{const question=item.querySelector('.po-faq-question');const answer=item.querySelector('.po-faq-answer');const answerContent=item.querySelector('.po-faq-answer-content');if(!question||!answer||!answerContent)return;question.addEventListener('click',()=>{const isActive=item.classList.contains('active');closeAllFAQ(item);if(isActive){item.classList.remove('active');answer.style.maxHeight='0';question.setAttribute('aria-expanded','false');}else{item.classList.add('active');answer.style.maxHeight=`${answerContent.scrollHeight}px`;question.setAttribute('aria-expanded','true');}});});};const initTOC=()=>{const toc=document.getElementById('po-toc-nav');const tocToggle=document.getElementById('po-toc-toggle');if(!toc||!tocToggle)return;const isMobile=window.innerWidth<768;if(isMobile){let overlay=document.querySelector('.po-toc-overlay');if(!overlay){overlay=document.createElement('div');overlay.className='po-toc-overlay';document.body.appendChild(overlay);}
let progressBar=tocToggle.querySelector('.po-toc-mobile-progress');if(!progressBar){progressBar=document.createElement('div');progressBar.className='po-toc-mobile-progress';tocToggle.appendChild(progressBar);}
tocToggle.addEventListener('click',(e)=>{e.stopPropagation();const isExpanded=toc.classList.toggle('expanded');overlay.classList.toggle('active',isExpanded);document.body.style.overflow=isExpanded?'hidden':'';});overlay.addEventListener('click',()=>{toc.classList.remove('expanded');overlay.classList.remove('active');document.body.style.overflow='';});let lastScrollY=window.scrollY;let ticking=false;let scrollingDown=false;let scrollDownStart=0;const scrollThreshold=80;setTimeout(()=>{if(window.scrollY>scrollThreshold){toc.classList.add('po-toc-visible');}},1000);const handleSmartSticky=()=>{const currentScrollY=window.scrollY;const scrollDiff=lastScrollY-currentScrollY;const isDrawerOpen=toc.classList.contains('expanded');const scrollHeight=document.documentElement.scrollHeight-window.innerHeight;const scrollPercent=(currentScrollY/scrollHeight)*100;if(scrollPercent>92&&!isDrawerOpen){toc.classList.remove('po-toc-visible');lastScrollY=currentScrollY;ticking=false;return;}
if(scrollDiff>10&&currentScrollY>scrollThreshold){toc.classList.add('po-toc-visible');scrollingDown=false;}
else if(scrollDiff<-10&&!isDrawerOpen){if(!scrollingDown){scrollingDown=true;scrollDownStart=Date.now();}else{if(Date.now()-scrollDownStart>3000){toc.classList.remove('po-toc-visible');}}}
if(currentScrollY<50){toc.classList.remove('po-toc-visible');scrollingDown=false;}
lastScrollY=currentScrollY;ticking=false;};const tocLinks=Array.from(document.querySelectorAll('.po-toc-link'));const sections=tocLinks.map(link=>document.getElementById(link.dataset.section)).filter(Boolean);const updateMobileProgress=()=>{const scrollHeight=document.documentElement.scrollHeight-document.documentElement.clientHeight;const scrollPercent=(window.scrollY/scrollHeight)*100;progressBar.style.width=`${Math.min(100, Math.max(0, scrollPercent))}%`;const scrollPos=window.scrollY+150;let currentSectionId='';sections.forEach((section,index)=>{const sectionTop=section.offsetTop;const nextSection=sections[index+1];const sectionHeight=nextSection?nextSection.offsetTop-sectionTop:document.documentElement.scrollHeight-sectionTop;if(scrollPos>=sectionTop&&scrollPos<sectionTop+sectionHeight){currentSectionId=section.id;}});tocLinks.forEach(link=>{const isActive=link.dataset.section===currentSectionId;link.classList.toggle('active',isActive);});};const onScroll=()=>{if(!ticking){requestAnimationFrame(()=>{handleSmartSticky();updateMobileProgress();});ticking=true;}};window.addEventListener('scroll',onScroll,{passive:true});updateMobileProgress();}
else{const isTopPosition=document.body.classList.contains('po-toc-position-top');if(!isTopPosition){toc.classList.add('expanded');}
tocToggle.addEventListener('click',()=>{toc.classList.toggle('expanded');});const tocLinks=Array.from(document.querySelectorAll('.po-toc-link'));const tocElement=document.getElementById('po-toc-nav');const sections=tocLinks.map(link=>document.getElementById(link.dataset.section)).filter(Boolean);const updateTOCProgress=throttle(()=>{const scrollPos=window.scrollY+100;let currentSectionId='';let currentProgress=0;sections.forEach((section,index)=>{const sectionTop=section.offsetTop;const nextSection=sections[index+1];const sectionHeight=nextSection?nextSection.offsetTop-sectionTop:document.documentElement.scrollHeight-sectionTop;if(scrollPos>=sectionTop&&scrollPos<sectionTop+sectionHeight){currentSectionId=section.id;currentProgress=Math.min(100,Math.max(0,((scrollPos-sectionTop)/sectionHeight)*100));}});tocLinks.forEach(link=>{const progressBar=link.querySelector('.po-toc-progress');const isActive=link.dataset.section===currentSectionId;link.classList.toggle('active',isActive);if(progressBar){progressBar.style.width=isActive?`${currentProgress}%`:'0%';}
if(isActive&&tocElement&&tocElement.scrollHeight>tocElement.clientHeight){const linkTop=link.offsetTop;const linkHeight=link.offsetHeight;const tocScrollTop=tocElement.scrollTop;const tocHeight=tocElement.clientHeight;if(linkTop<tocScrollTop){tocElement.scrollTop=linkTop-20;}else if(linkTop+linkHeight>tocScrollTop+tocHeight){tocElement.scrollTop=linkTop+linkHeight-tocHeight+20;}}});},16);window.addEventListener('scroll',updateTOCProgress,{passive:true});updateTOCProgress();}};const initSmoothScroll=()=>{const toc=document.getElementById('po-toc-nav');const overlay=document.querySelector('.po-toc-overlay');document.querySelectorAll('.po-toc-link').forEach(link=>{link.addEventListener('click',(e)=>{e.preventDefault();const targetId=link.getAttribute('href');const target=document.querySelector(targetId);if(!target)return;const offset=20;const targetPosition=target.offsetTop-offset;window.scrollTo({top:targetPosition,behavior:'smooth'});if(window.innerWidth<768&&toc){toc.classList.remove('expanded');if(overlay){overlay.classList.remove('active');}
document.body.style.overflow='';}});});document.querySelectorAll('.tldr-container .action-btn').forEach(btn=>{btn.addEventListener('click',(e)=>{const href=btn.getAttribute('href');if(!href||href==='#')return;e.preventDefault();const target=document.querySelector(href);if(!target)return;const offset=20;const targetPosition=target.offsetTop-offset;window.scrollTo({top:targetPosition,behavior:'smooth'});});});};const initResizeHandler=()=>{const handleResize=debounce(()=>{repositionOnMobile();},250);window.addEventListener('resize',handleResize,{passive:true});};const initVisualAnimations=()=>{const visuals=document.querySelectorAll('.rp-visual[data-animate="true"]');if(!visuals.length)return;document.documentElement.classList.add('rp-js-enabled');if(!('IntersectionObserver'in window)){visuals.forEach(visual=>visual.classList.add('is-visible'));return;}
const observer=new IntersectionObserver((entries)=>{entries.forEach(entry=>{if(entry.isIntersecting){entry.target.classList.add('is-visible');observer.unobserve(entry.target);}});},{root:null,rootMargin:'0px 0px -50px 0px',threshold:0.1});visuals.forEach(visual=>observer.observe(visual));};const initCTAButtons=()=>{document.querySelectorAll('.rp-cta-sales').forEach(cta=>{const targetUrl=cta.dataset.targetUrl;if(!targetUrl)return;const btn=cta.querySelector('.rp-cta-sales-button');if(!btn)return;if(btn.tagName==='A'){if(!btn.getAttribute('href')||btn.getAttribute('href')==='#'){btn.setAttribute('href',targetUrl);btn.setAttribute('target','_blank');btn.setAttribute('rel','noopener noreferrer');}}else{btn.style.cursor='pointer';btn.addEventListener('click',()=>{window.open(targetUrl,'_blank','noopener,noreferrer');});}});};const initCTATracking=()=>{const ajaxUrl=feI18n.ajaxUrl;const nonce=feI18n.ctaTrackNonce;const postId=feI18n.postId;if(!ajaxUrl||!nonce||!postId)return;document.addEventListener('click',(e)=>{let cta=null;let ctaKind='';let ctaSelector='';const premiumBtn=e.target.closest('.rp-cta-rankpress-button');if(premiumBtn){cta=premiumBtn.closest('.rp-cta-rankpress');ctaKind='premium';ctaSelector='.rp-cta-rankpress';}else{const salesBtn=e.target.closest('.rp-cta-sales-button');if(salesBtn){cta=salesBtn.closest('.rp-cta-sales');ctaKind='sales';ctaSelector='.rp-cta-sales';}}
if(!cta||!ctaKind)return;const allCtas=document.querySelectorAll(ctaSelector);let ctaPosition=1;allCtas.forEach((el,i)=>{if(el===cta)ctaPosition=i+1;});const data=new FormData();data.append('action','rankpress_track_cta_click');data.append('nonce',nonce);data.append('post_id',postId);data.append('target_url',cta.dataset.targetUrl||'');data.append('target_title',cta.dataset.targetTitle||'');data.append('cta_position',ctaPosition);data.append('cta_kind',ctaKind);if(navigator.sendBeacon){navigator.sendBeacon(ajaxUrl,data);}else{fetch(ajaxUrl,{method:'POST',body:data,keepalive:true}).catch(()=>{});}});};onReady(()=>{repositionOnMobile();initProgressBar();initLazyImages();initResponsiveTables();initFAQ();initTOC();initSmoothScroll();initResizeHandler();initVisualAnimations();initCTAButtons();initCTATracking();});