(()=>{var e={799(){window.WPConsent={displayChecks:[],checksPassed:!0,settingsHooks:[],settingsProcessed:!1,listeners:[],lastPreferences:null,cssPromise:null,registerListener:function(e){if(this.listeners.push(e),this.lastPreferences)try{e(this.lastPreferences)}catch(e){console.error("Error in WPConsent listener:",e)}},registerDisplayCheck:function(e){this.displayChecks.push(e),this.checksPassed=!1},registerSettingsHook:function(e){this.settingsHooks.push(e),this.settingsProcessed=!1},runDisplayChecks:function(){return 0===this.displayChecks.length?(this.checksPassed=!0,Promise.resolve()):Promise.all(this.displayChecks.map(e=>e())).then(()=>(this.checksPassed=!0,Promise.resolve())).catch(e=>(console.error("Error in WPConsent display check:",e),this.checksPassed=!0,Promise.resolve()))},runSettingsHooks:function(){return 0===this.settingsHooks.length?(this.settingsProcessed=!0,Promise.resolve()):Promise.all(this.settingsHooks.map(e=>e(window.wpconsent))).then(()=>(this.settingsProcessed=!0,Promise.resolve())).catch(e=>(console.error("Error in WPConsent settings hook:",e),this.settingsProcessed=!0,Promise.resolve()))},hooks:{beforeShowPreferences:[],afterShowPreferences:[],beforeHideBanner:[],afterHideBanner:[],beforeShowBanner:[],afterShowBanner:[],accordionToggled:[]},addHook:function(e,t){this.hooks[e]&&this.hooks[e].push(t)},runHooks:function(e,...t){this.hooks[e]&&this.hooks[e].length>0&&this.hooks[e].forEach(n=>{try{n(...t)}catch(t){console.error(`Error in WPConsent hook ${e}:`,t)}})},showToast:function(e,t=2500){this.ensureCSS().then(()=>{const n=this.shadowRoot.querySelector("#wpconsent-gpc-toast");if(!n)return;const o=n.querySelector(".wpconsent-toast-message");o&&e&&(o.textContent=e),n.style.display="block",setTimeout(()=>{n.classList.add("wpconsent-toast-visible")},10);const s=()=>{n.classList.remove("wpconsent-toast-visible"),setTimeout(()=>{n.style.display="none"},300)},c=setTimeout(s,t),r=n.querySelector(".wpconsent-toast-close");r&&(r.onclick=()=>{clearTimeout(c),s()})})},highlightGPCOverride:function(){const e=this.shadowRoot.querySelector("#wpconsent-gpc-override-toggle-label"),t=this.shadowRoot.querySelector("#wpconsent-gpc-override-checkbox"),n=this.shadowRoot.querySelector("#wpconsent-gpc-override-container");e&&(e.classList.add("wpconsent-gpc-override-error"),e.classList.add("wpconsent-shake"),setTimeout(()=>{e.classList.remove("wpconsent-shake")},300),t&&t.focus(),n&&setTimeout(()=>{n.scrollIntoView({behavior:"smooth",block:"center"})},100),t&&t.addEventListener("change",function(){t.checked&&e.classList.remove("wpconsent-gpc-override-error")},{once:!0}))},acceptAll:function(){const e={};Array.isArray(wpconsent.slugs)&&wpconsent.slugs.forEach(t=>{e[t]=!0}),this.savePreferences(e),this.closePreferences()},checkGPC:function(){if(!wpconsent.respect_gpc||!0!==navigator.globalPrivacyControl)return;const e=this.getCookie("wpconsent_preferences");let t={};if(e)try{t=JSON.parse(e)}catch(e){console.error("WPConsent: Error parsing existing preferences:",e)}if(t.hasOwnProperty("respect_gpc"))return;const n={};if(wpconsent.slugs.forEach(e=>{const t=this.shadowRoot?.querySelector(`#wpconsent-preferences-modal input[type="checkbox"][id="cookie-service-${e}"]`);t&&t.disabled?n[e]=!0:n[e]=!1}),n.essential=!0,n.respect_gpc=!0,this.savePreferences(n,!0),!1!==wpconsent.gpc_toast_enabled){const e=wpconsent.gpc_toast_message||"GPC Signal Honored",t=wpconsent.gpc_toast_duration||1e4;this.showToast(e,t)}this.checksPassed=!1},savePreferences:function(e,t=!1){const n=this.getCookie("wpconsent_preferences");let o=!1,s=null;if(n)try{s=JSON.parse(n)}catch(e){console.error("WPConsent: Error parsing existing preferences:",e)}if(wpconsent.respect_gpc&&!t&&s){const t=!0===navigator.globalPrivacyControl,n=!0===s.respect_gpc;if(t&&n){const t=this.shadowRoot.querySelector("#wpconsent-gpc-override-checkbox");if(t&&!t.checked)return void this.highlightGPCOverride();e.respect_gpc=!1}}t||(s&&JSON.stringify(s)!==JSON.stringify(e)||wpconsent.default_allow&&Object.values(e).some(e=>!1===e))&&(this.clearCookies(),o=!0),wpconsent.respect_gpc&&!t&&s&&s.hasOwnProperty("respect_gpc")&&(e.respect_gpc=!1),this.setCookie("wpconsent_preferences",JSON.stringify(e),wpconsent.consent_duration),this.hideBanner(),this.closePreferences(),this.unlockScripts(e),this.unlockIframes(e),this.showFloatingButtonIfEnabled(),this.updateWordPressConsent(e),window.dispatchEvent(new CustomEvent("wpconsent_consent_saved",{detail:e})),n&&window.dispatchEvent(new CustomEvent("wpconsent_consent_updated",{detail:e})),o&&(Object.defineProperty(document,"cookie",{get:function(){return""},set:function(e){}}),window.location.reload())},showPreferences:function(){return this.ensureCSS().then(()=>{const e=this.shadowRoot?.querySelector("#wpconsent-preferences-modal");if(e){e.style.display="flex",this.setupFocusTrap(e),this.runHooks("afterShowPreferences");const t=this.shadowRoot?.querySelector("#wpconsent-preferences-title");t&&setTimeout(()=>{t.focus({preventScroll:!0}),this.lastFocusedElement=t},100);const n=this.getCookie("wpconsent_preferences");if(n)try{const e=JSON.parse(n);this.shadowRoot.querySelectorAll('#wpconsent-preferences-modal input[type="checkbox"]').forEach(t=>{let n=null;n=t.id.startsWith("cookie-category-")?t.id.replace("cookie-category-",""):t.id.startsWith("cookie-service-")?t.id.replace("cookie-service-",""):t.value,n&&n in e&&(t.checked=e[n])});const t=this.shadowRoot.querySelector("#wpconsent-gpc-override-container");if(t){const n=!0===navigator.globalPrivacyControl,o=e&&!0===e.respect_gpc;t.style.display=n&&o?"block":"none"}}catch(e){console.error("Error parsing WPConsent preferences:",e)}}})},closePreferences:function(){const e=this.shadowRoot?.querySelector("#wpconsent-preferences-modal");e&&(e.style.display="none",this.removeFocusTrap(),this.previouslyFocusedElement&&(this.previouslyFocusedElement.focus({preventScroll:!0}),this.previouslyFocusedElement=null))},showBanner:function(){if(!wpconsent.enable_consent_banner)return;const e=this.shadowRoot?.querySelector("#wpconsent-banner-holder");e&&this.ensureCSS().then(()=>{this.runHooks("beforeShowBanner"),e.classList.add("wpconsent-banner-visible"),this.updateButtonVisibility(wpconsent),this.setupFocusTrap(e),this.runHooks("afterShowBanner")})},hideBanner:function(){const e=this.shadowRoot?.querySelector("#wpconsent-banner-holder");e&&(this.runHooks("beforeHideBanner"),e.classList.remove("wpconsent-banner-visible"),this.removeFocusTrap(),this.previouslyFocusedElement&&(this.previouslyFocusedElement.focus({preventScroll:!0}),this.previouslyFocusedElement=null),this.runHooks("afterHideBanner"))},setCookie:function(e,t,n){let o="";if(n>0){const e=new Date;e.setTime(e.getTime()+24*n*60*60*1e3),o="expires="+e.toUTCString()+";"}const s=this.getCookieDomain();document.cookie=e+"="+t+";"+o+s+"path=/"},getCookieDomain:function(){return wpconsent.enable_shared_consent&&wpconsent.cookie_domain&&""!==wpconsent.cookie_domain?"domain="+(wpconsent.cookie_domain.startsWith(".")?wpconsent.cookie_domain:"."+wpconsent.cookie_domain)+";":""},getCookie:function(e){const t=`; ${document.cookie}`.split(`; ${e}=`);if(2===t.length)return t.pop().split(";").shift()},hasConsent:function(e){const t=this.getCookie("wpconsent_preferences");if(!t)return!1;try{const n=JSON.parse(t);return"essential"===e||!0===n[e]}catch(e){return console.error("Error parsing WPConsent preferences:",e),!1}},shouldUnlockContent:function(e,t,n){return"essential"===n||(wpconsent.manual_toggle_services?!(!t||void 0===e[t])&&e[t]:!0===e[n])},unlockScripts:function(e){this.lastPreferences=e,this.listeners&&this.listeners.length>0&&this.listeners.forEach(t=>{try{t(e)}catch(e){console.error("Error in WPConsent listener:",e)}}),document.querySelectorAll('script[type="text/plain"]').forEach(t=>{const n=t.getAttribute("data-wpconsent-category"),o=t.getAttribute("data-wpconsent-name");if(this.shouldUnlockContent(e,o,n)){const e=document.createElement("script");t.getAttributeNames().forEach(n=>{"type"!==n&&e.setAttribute(n,t.getAttribute(n))});const n=t.getAttribute("data-wpconsent-src");n?e.src=n:e.text=t.text,t.parentNode.replaceChild(e,t)}}),document.dispatchEvent(new CustomEvent("wpconsent_consent_processed",{detail:e})),WPConsent.localGtag("set","developer_id.dMmRkYz",!0),WPConsent.localGtag("consent","update",{ad_storage:e.marketing?"granted":"denied",analytics_storage:e.statistics?"granted":"denied",ad_user_data:e.marketing?"granted":"denied",ad_personalization:e.marketing?"granted":"denied",personalization_storage:e.marketing?"granted":"denied"}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"wpconsent_consent_processed",wpconsentPreferences:e})},unlockIframes:function(e){document.querySelectorAll("iframe[data-wpconsent-src]").forEach(t=>{const n=t.getAttribute("data-wpconsent-category"),o=t.getAttribute("data-wpconsent-name");if(this.shouldUnlockContent(e,o,n)){const e=t.getAttribute("data-wpconsent-src");e&&(t.src=e),t.removeAttribute("data-wpconsent-src"),t.removeAttribute("data-wpconsent-name"),t.removeAttribute("data-wpconsent-category")}}),document.querySelectorAll(".wpconsent-iframe-placeholder").forEach(t=>{const n=t.getAttribute("data-wpconsent-category"),o=t.getAttribute("data-wpconsent-name");if(this.shouldUnlockContent(e,o,n)){const e=t.querySelector(".wpconsent-iframe-thumbnail"),n=t.querySelector(".wpconsent-iframe-overlay-content");e&&e.remove(),n&&n.remove(),t.classList.remove("wpconsent-iframe-placeholder")}})},init:function(){this.runSettingsHooks().then(()=>{this.initWordPress(),this.updateButtonVisibility(wpconsent);const e=document.getElementById("wpconsent-container"),t=document.getElementById("wpconsent-template");if(e&&t)if(this.shadowRoot=e.shadowRoot,this.shadowRoot)this.runDisplayChecks().then(()=>{this.processBannerDisplay()});else{this.shadowRoot=e.attachShadow({mode:"open"});const n=t.content.cloneNode(!0);this.shadowRoot.appendChild(n),t.remove(),this.initializeEventListeners(),this.initializeAccordions(),this.initializeKeyboardHandlers(),this.runDisplayChecks().then(()=>{this.processBannerDisplay()})}})},processBannerDisplay:function(){this.checkGPC();const e=this.getCookie("wpconsent_preferences");if(e){let t={};try{if(t=JSON.parse(e),wpconsent.slugs&&Array.isArray(wpconsent.slugs)&&!wpconsent.slugs.every(e=>t.hasOwnProperty(e)))return this.setCookie("wpconsent_preferences","",-1),void(this.checksPassed&&this.showBanner());this.unlockScripts(t),this.unlockIframes(t)}catch(e){console.error("Error parsing WPConsent preferences:",e)}this.showFloatingButtonIfEnabled()}else if(this.checksPassed&&this.showBanner(),wpconsent.default_allow||!wpconsent.enable_script_blocking){const e={};wpconsent.slugs.forEach(t=>{e[t]=!0}),this.unlockScripts(e),this.unlockIframes(e)}else if(!wpconsent.enable_content_blocking){const e={};wpconsent.slugs.forEach(t=>{e[t]=!0}),this.unlockIframes(e)}document.querySelectorAll(".wpconsent-iframe-overlay-content.wpconsent-content-hidden").forEach(function(e){e.classList.remove("wpconsent-content-hidden")}),window.dispatchEvent(new CustomEvent("wpconsent_banner_initialized"))},ensureCSS:function(){if(this.cssPromise)return this.cssPromise;const e=document.getElementById("wpconsent-container");return this.cssPromise=this.loadExternalCSS(e),this.cssPromise},revealContainer:function(e){e&&(e.style.display="block")},loadExternalCSS:function(e){return new Promise(t=>{if(this.shadowRoot&&this.shadowRoot.querySelector("link[data-wpconsent-css]"))return this.revealContainer(e),void t();if(!this.shadowRoot)return void t();const n=`${wpconsent.css_url}?ver=${wpconsent.css_version}`;let o=!1;const s=()=>{o||(o=!0,t())},c=t=>{let o=null;const r=document.createElement("link");r.rel="stylesheet",r.href=1===t?n:`${n}&wpcretry=${t}`,r.setAttribute("data-wpconsent-css","");const i=()=>{o&&(clearTimeout(o),o=null),r.onload=null,r.onerror=null},a=o=>{i(),r.parentNode&&r.parentNode.removeChild(r),t<2&&!o?c(t+1):(this.applyCSSFallback(e,n),s())};r.onload=()=>{i(),this.revealContainer(e),s()},r.onerror=()=>a(!1),o=setTimeout(()=>a(!0),5e3);try{this.shadowRoot.appendChild(r)}catch(e){console.error("WPConsent: failed to inject stylesheet link:",e),a()}};c(1)})},applyCSSFallback:function(e,t){if(this.shadowRoot&&!this.shadowRoot.querySelector("style[data-wpconsent-css-fallback]")){const e=document.createElement("style");e.setAttribute("data-wpconsent-css-fallback",""),e.textContent="\n#wpconsent-banner-holder {\n\tdisplay: none;\n\tposition: fixed;\n\tleft: 0;\n\tright: 0;\n\tbottom: 0;\n\tz-index: var(--wpconsent-z-index, 900000);\n}\n#wpconsent-banner-holder.wpconsent-banner-visible {\n\tdisplay: block;\n}\n#wpconsent-banner-holder .wpconsent-banner {\n\tbox-sizing: border-box;\n\tmargin: 10px;\n\tpadding: var(--wpconsent-padding, 15px 20px);\n\tbackground: var(--wpconsent-background, #ffffff);\n\tcolor: var(--wpconsent-text, #1a1a1a);\n\tborder-radius: 10px;\n\tbox-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);\n\tfont-size: var(--wpconsent-font-size, 14px);\n\tline-height: 1.4;\n}\n#wpconsent-banner-holder .wpconsent-banner-footer {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 8px;\n\tmargin-top: 12px;\n}\n#wpconsent-banner-holder button,\n#wpconsent-preferences-modal button {\n\tcursor: pointer;\n\tpadding: 8px 16px;\n\tborder: 1px solid rgba(0, 0, 0, 0.2);\n\tborder-radius: 4px;\n\tfont-size: inherit;\n}\n#wpconsent-banner-holder .wpconsent-accept-all,\n#wpconsent-preferences-modal .wpconsent-accept-all {\n\tbackground: var(--wpconsent-accept-bg, #2563eb);\n\tcolor: var(--wpconsent-accept-color, #ffffff);\n\tborder-color: transparent;\n}\n#wpconsent-banner-holder .wpconsent-cancel-cookies,\n#wpconsent-preferences-modal .wpconsent-cancel-cookies {\n\tbackground: var(--wpconsent-cancel-bg, #f3f4f6);\n\tcolor: var(--wpconsent-cancel-color, #1a1a1a);\n}\n#wpconsent-preferences-modal {\n\tposition: fixed;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbackground-color: rgba(0, 0, 0, 0.5);\n\tz-index: 10202020;\n\talign-items: center;\n\tjustify-content: center;\n}\n#wpconsent-preferences-modal .wpconsent-preferences-content {\n\tbox-sizing: border-box;\n\twidth: 800px;\n\tmax-width: 90%;\n\tmax-height: 90vh;\n\tmargin: auto;\n\tpadding: 20px;\n\toverflow: auto;\n\tbackground: var(--wpconsent-background, #ffffff);\n\tcolor: var(--wpconsent-text, #1a1a1a);\n\tborder-radius: 10px;\n\tbox-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);\n}\n#wpconsent-consent-floating {\n\tdisplay: none;\n\tposition: fixed;\n\tbottom: 20px;\n\tleft: 20px;\n\tz-index: 9999;\n\tcursor: pointer;\n}\n#wpconsent-gpc-toast {\n\tposition: fixed;\n\tbottom: 20px;\n\tright: 20px;\n\tmax-width: 280px;\n\tpadding: 10px 14px;\n\tz-index: calc(var(--wpconsent-z-index, 900000) + 1);\n\tbackground: var(--wpconsent-background, #ffffff);\n\tcolor: var(--wpconsent-text, #1a1a1a);\n\tborder-radius: 8px;\n\tbox-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n}\n",this.shadowRoot.appendChild(e)}this.revealContainer(e),console.error(`WPConsent: failed to load styles from ${t}; showing the consent UI with fallback styling.`),window.dispatchEvent(new CustomEvent("wpconsent_css_failed",{detail:{url:t}}))},initializeEventListeners:function(){this.shadowRoot.querySelectorAll(".wpconsent-accept-all").forEach(e=>e.addEventListener("click",()=>this.acceptAll())),this.shadowRoot.querySelectorAll(".wpconsent-cancel-cookies").forEach(e=>e.addEventListener("click",()=>{const e={};wpconsent.slugs.forEach(t=>{const n=this.shadowRoot.querySelector(`#wpconsent-preferences-modal input[type="checkbox"][id="cookie-service-${t}"]`);n&&n.disabled?e[t]=!0:e[t]=!1}),e.essential=!0,this.savePreferences(e)})),this.shadowRoot.querySelector("#wpconsent-banner-close")?.addEventListener("click",()=>this.hideBanner()),this.shadowRoot.querySelector("#wpconsent-preferences-all")?.addEventListener("click",()=>this.showPreferences());const e=this.shadowRoot.querySelector("#wpconsent-consent-floating");e&&e.addEventListener("click",()=>this.showPreferences()),this.initializeCheckboxListeners(),document.addEventListener("click",e=>{const t=e.target.closest(".wpconsent-iframe-accept-button");if(t){const e=t.getAttribute("data-category"),n=t.closest(".wpconsent-iframe-placeholder"),o=n?.getAttribute("data-wpconsent-name");if(e){let t={};try{t=JSON.parse(this.getCookie("wpconsent_preferences")||"{}")}catch(e){console.error("Failed to parse wpconsent_preferences cookie:",e)}const n=!0===navigator.globalPrivacyControl,s=!0===t.respect_gpc;if(wpconsent.respect_gpc&&n&&s)this.showPreferences().then(()=>{const t=this.shadowRoot.querySelector(`#cookie-category-${e}`);if(t&&(t.checked=!0),o){const e=this.shadowRoot.querySelector(`#cookie-service-${o}`);e&&(e.checked=!0)}const n=this.shadowRoot.querySelector("#wpconsent-gpc-override-container");n&&(n.style.display="block"),this.highlightGPCOverride()});else{const n={...t,essential:!0,[e]:!0};o&&(n[o]=!0),this.savePreferences(n)}}}}),document.addEventListener("click",e=>{e.target.closest(".wpconsent-open-preferences")&&(e.preventDefault(),this.showPreferences())}),this.shadowRoot.querySelector(".wpconsent-preferences-header-close")?.addEventListener("click",()=>this.closePreferences()),this.shadowRoot.querySelector(".wpconsent-save-preferences")?.addEventListener("click",()=>{const e=this.shadowRoot.querySelectorAll('#wpconsent-preferences-modal input[type="checkbox"]'),t=Array.from(e).filter(e=>e.checked).map(e=>e.value),n={};wpconsent.slugs.forEach(e=>{n[e]=t.includes(e)}),n.essential=!0,this.savePreferences(n)}),this.shadowRoot.querySelector(".wpconsent-close-preferences")?.addEventListener("click",()=>this.closePreferences()),window.addEventListener("wpconsent_consent_saved",function(e){if("function"!=typeof window.clarity)return;const t=e.detail;window.clarity("consentv2",{ad_Storage:t.marketing?"granted":"denied",analytics_Storage:t.statistics?"granted":"denied"})})},localGtag:function(){window.dataLayer=window.dataLayer||[],function(){dataLayer.push(arguments)}.apply(window,arguments)},initializeCheckboxListeners:function(){this.shadowRoot.querySelectorAll('#wpconsent-preferences-modal input[type="checkbox"][id^="cookie-category-"]').forEach(e=>{e.addEventListener("change",e=>{this.handleCategoryCheckboxChange(e.target)})}),this.shadowRoot.querySelectorAll('#wpconsent-preferences-modal input[type="checkbox"][id^="cookie-service-"]').forEach(e=>{e.addEventListener("change",e=>{this.handleServiceCheckboxChange(e.target)})})},handleCategoryCheckboxChange:function(e){const t=e.id.replace("cookie-category-","");this.shadowRoot.querySelectorAll('#wpconsent-preferences-modal input[type="checkbox"][id^="cookie-service-"]').forEach(n=>{n.closest(`.wpconsent-cookie-category-${t}`)&&(n.checked=e.checked)})},handleServiceCheckboxChange:function(e){const t=e.closest(".wpconsent-cookie-category");if(!t)return;const n=t.querySelector('input[type="checkbox"][id^="cookie-category-"]');if(!n)return;const o=t.querySelectorAll('input[type="checkbox"][id^="cookie-service-"]');let s=!1;o.forEach(e=>{e.checked&&(s=!0)}),n.checked=s},initializeAccordions(){this.shadowRoot.querySelectorAll(".wpconsent-preferences-accordion-item").forEach(e=>{const t=e.querySelector(".wpconsent-preferences-accordion-header"),n=e.querySelector(".wpconsent-preferences-accordion-content");t&&n&&t.addEventListener("click",t=>{t.target.closest(".wpconsent-preferences-checkbox-toggle")||this.toggleAccordion(e,n)})})},toggleAccordion(e,t){e.classList.contains("active");const n=e.parentElement,o=e.classList.contains("wpconsent-cookie-service"),s=e.classList.contains("wpconsent-cookie-category");s?n&&n.querySelectorAll(":scope > .wpconsent-preferences-accordion-item.wpconsent-cookie-category").forEach(t=>{if(t!==e){t.classList.remove("active");const e=t.querySelector(".wpconsent-preferences-accordion-toggle");e&&e.setAttribute("aria-expanded","false"),t.querySelectorAll(".wpconsent-cookie-service").forEach(e=>{e.classList.remove("active");const t=e.querySelector(".wpconsent-preferences-accordion-toggle");t&&t.setAttribute("aria-expanded","false"),this.runHooks("accordionToggled",{accordion:e,content:e.querySelector(".wpconsent-preferences-accordion-content"),isActive:!1,isService:!0,isCategory:!1})})}}):o&&n&&n.querySelectorAll(":scope > .wpconsent-preferences-accordion-item.wpconsent-cookie-service").forEach(t=>{if(t!==e){t.classList.remove("active");const e=t.querySelector(".wpconsent-preferences-accordion-toggle");e&&e.setAttribute("aria-expanded","false"),this.runHooks("accordionToggled",{accordion:t,content:t.querySelector(".wpconsent-preferences-accordion-content"),isActive:!1,isService:!0,isCategory:!1})}}),e.classList.toggle("active");const c=e.querySelector(".wpconsent-preferences-accordion-toggle");if(c){const t=e.classList.contains("active");c.setAttribute("aria-expanded",t?"true":"false")}const r=e.classList.contains("active");this.runHooks("accordionToggled",{accordion:e,content:t,isActive:r,isService:o,isCategory:s})},initializeKeyboardHandlers:function(){document.addEventListener("keydown",e=>{"Tab"===e.key?this.handleTabKey(e):"Escape"===e.key&&this.handleEscapeKey(e)})},handleEscapeKey:function(e){const t=this.shadowRoot?.querySelector("#wpconsent-preferences-modal"),n=this.shadowRoot?.querySelector("#wpconsent-banner-holder");t&&"flex"===t.style.display?this.closePreferences():n&&n.classList.contains("wpconsent-banner-visible")&&this.hideBanner()},handleTabKey:function(e){const t=this.shadowRoot?.querySelector("#wpconsent-banner-holder"),n=this.shadowRoot?.querySelector("#wpconsent-preferences-modal"),o=t&&t.classList.contains("wpconsent-banner-visible"),s=n&&"flex"===n.style.display;if(!o&&!s)return;const c=s?n:t,r=this.getFocusableElements(c);if(0===r.length)return;e.preventDefault();const i=r[0],a=r[r.length-1];let l;this.lastFocusedElement&&r.includes(this.lastFocusedElement)?l=this.lastFocusedElement:(l=i,this.lastFocusedElement=l);const d=r.indexOf(l);let p;p=e.shiftKey?d<=0?a:r[d-1]:d>=r.length-1?i:r[d+1],p.focus({preventScroll:!0}),this.lastFocusedElement=p},setupFocusTrap:function(e){this.previouslyFocusedElement=document.activeElement,this.lastFocusedElement=null},removeFocusTrap:function(){this.lastFocusedElement=null},setInitialFocus:function(e){const t=this.getFocusableElements(e);t.length>0&&setTimeout(()=>{t[0].focus({preventScroll:!0}),this.lastFocusedElement=t[0]},100)},getFocusableElements:function(e){return Array.from(e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(t=>{let n=t;for(;n&&n!==e;){const e=window.getComputedStyle(n);if("none"===e.display||"hidden"===e.visibility||"0"===e.opacity||n.disabled||"true"===n.getAttribute("aria-hidden"))return!1;n=n.parentElement}return!0})},isElementInContainer:function(e,t){return!(!e||!t)&&(t.shadowRoot?t.shadowRoot.contains(e):t.contains(e))},clearCookies:function(){for(var e=document.cookie.split("; "),t=0;t<e.length;t++)for(var n=window.location.hostname.split(".");n.length>0;){var o=encodeURIComponent(e[t].split(";")[0].split("=")[0])+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain="+n.join(".")+" ;path=",s=location.pathname.split("/");for(document.cookie=o+"/";s.length>0;)document.cookie=o+s.join("/"),s.pop();n.shift()}},initWordPress:function(){window.wp_consent_type=wpconsent.consent_type;let e=new CustomEvent("wp_consent_type_defined");document.dispatchEvent(e)},showFloatingButtonIfEnabled:function(){wpconsent.enable_consent_floating&&this.ensureCSS().then(()=>{const e=this.shadowRoot?.querySelector("#wpconsent-consent-floating");e&&(e.style.display="block")})},updateButtonVisibility:function(e){this.shadowRoot&&["accept","cancel","preferences"].forEach(t=>{const n=this.shadowRoot.querySelector(`#wpconsent-${t}-all`);n&&(e[`${t}_button_enabled`]?(n.classList.remove("wpconsent-button-disabled"),n.removeAttribute("data-disabled")):(n.classList.add("wpconsent-button-disabled"),n.setAttribute("data-disabled","true")))})},updateWordPressConsent:function(e){"function"==typeof wp_set_consent&&(wp_set_consent("functional","allow"),wp_set_consent("preferences","allow"),wp_set_consent("statistics",e.statistics?"allow":"deny"),wp_set_consent("statistics-anonymous",e.statistics?"allow":"deny"),wp_set_consent("marketing",e.marketing?"allow":"deny"))}},document.addEventListener("DOMContentLoaded",()=>WPConsent.init())}},t={};function n(o){var s=t[o];if(void 0!==s)return s.exports;var c=t[o]={exports:{}};return e[o](c,c.exports,n),c.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";n(799)})()})();
(function(){
const prefersReducedMotion=window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function onReady(fn){
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', fn, {once:true});
return;
}
fn();
}
function hydrateSlideMedia(slide){
if(!slide) return;
slide.querySelectorAll('source[data-srcset]').forEach(function(source){
source.setAttribute('srcset', source.getAttribute('data-srcset'));
source.removeAttribute('data-srcset');
});
const img=slide.querySelector('.jsa-slide__media[data-src]');
if(!img) return;
if(img.getAttribute('data-srcset')){
img.setAttribute('srcset', img.getAttribute('data-srcset'));
img.removeAttribute('data-srcset');
}
img.src=img.getAttribute('data-src');
img.removeAttribute('data-src');
}
function prepareReviewsWidget(){
document.querySelectorAll('.jsa-footer__reviews-full iframe').forEach(function(iframe){
iframe.setAttribute('loading', 'lazy');
if(!iframe.getAttribute('title')){
iframe.setAttribute('title', 'Avis clients Google JSA CLIM');
}});
document.querySelectorAll('.jsa-footer__reviews-full img').forEach(function(img){
img.setAttribute('loading', 'lazy');
img.setAttribute('decoding', 'async');
});
}
function setImageDimensions(img){
if(!img||(img.getAttribute('width')&&img.getAttribute('height'))) return;
if(img.naturalWidth&&img.naturalHeight){
img.setAttribute('width', String(img.naturalWidth));
img.setAttribute('height', String(img.naturalHeight));
return;
}
img.addEventListener('load', function(){
setImageDimensions(img);
}, {once:true});
}
function prepareLooseImages(root){
(root||document).querySelectorAll('img').forEach(setImageDimensions);
}
function silenceAriaHiddenFocusables(root){
const selector='a[aria-hidden="true"],button[aria-hidden="true"],input[aria-hidden="true"],select[aria-hidden="true"],textarea[aria-hidden="true"],[aria-hidden="true"] a,[aria-hidden="true"] button,[aria-hidden="true"] input,[aria-hidden="true"] select,[aria-hidden="true"] textarea,[aria-hidden="true"] [tabindex]';
(root||document).querySelectorAll(selector).forEach(function(el){
el.setAttribute('tabindex', '-1');
});
}
function call(fn){
try{
if(typeof fn==='function'){
fn();
return true;
}}catch(e){}
return false;
}
function clickFirst(selectors, root){
root=root||document;
for(let i=0;i<selectors.length;i++){
const el=root.querySelector&&root.querySelector(selectors[i]);
if(el){
el.click();
return true;
}}
return false;
}
function openCookiePanel(){
if(call(window.wpconsent&&(window.wpconsent.openPreferences||window.wpconsent.openPreferencesModal||window.wpconsent.openPreferenceCenter))) return true;
if(call(window.WPConsent&&(window.WPConsent.openPreferences||window.WPConsent.openPreferencesModal||window.WPConsent.openPreferenceCenter))) return true;
if(window.Cookiebot&&call(window.Cookiebot.renew)) return true;
if(window.tarteaucitron&&window.tarteaucitron.userInterface&&call(window.tarteaucitron.userInterface.openPanel)) return true;
if(window.axeptioSDK&&call(window.axeptioSDK.openCookies)) return true;
if(window.Didomi&&window.Didomi.preferences&&call(window.Didomi.preferences.show)) return true;
if(call(window.ckyShow)) return true;
const selectors=[
'#wpconsent-consent-floating',
'#wpconsent-root button#wpconsent-consent-floating',
'#wpconsent-root [part="wpconsent-settings-button"]',
'.wpconsent-settings-button',
'.wpconsent-floating-button',
'.cmplz-show-banner',
'.cmplz-manage-consent button',
'.cmplz-manage-consent',
'.cky-btn-revisit',
'.cky-btn-customize',
'[data-cky-tag="settings-button"]',
'.cli_settings_button',
'[data-cli_action="show_settings"]',
'.moove-gdpr-infobar-settings-btn',
'#tarteaucitronManager',
'.tarteaucitronOpenPanel',
'#axeptio_btn_configure',
'[data-testid="uc-privacy-button"]'
];
if(clickFirst(selectors)) return true;
const host=document.getElementById('wpconsent-container')||document.querySelector('[id*="wpconsent"]');
const shadow=host&&host.shadowRoot ? host.shadowRoot:null;
return !!(shadow&&clickFirst(selectors, shadow));
}
function initArticleGalleries(){
const galleries=document.querySelectorAll('.single-post .entry-content .wp-block-gallery, .single-post .entry-content .jsa-story-gallery, .page .entry-content .jsa-story-gallery, .entry-content .wp-block-gallery.jsa-home-gallery, .entry-content .jsa-story-gallery.jsa-home-gallery');
galleries.forEach(function(gallery){
const items=Array.from(gallery.querySelectorAll('figure, .wp-block-image')).filter(function(item){
return !!item.querySelector('img');
});
if(items.length < 2) return;
if(gallery.closest('.jsa-gallery-wrap')) return;
const galleryMode=gallery.classList.contains('jsa-story-gallery--strip') ? 'strip':(items.length===2 ? 'two':'center');
gallery.classList.add('jsa-gallery-carousel');
gallery.classList.add('jsa-gallery-carousel--' + galleryMode);
gallery.setAttribute('data-jsa-gallery-count', String(items.length));
const wrap=document.createElement('div');
wrap.className='jsa-gallery-wrap jsa-gallery-wrap--' + galleryMode;
wrap.setAttribute('data-jsa-gallery-count', String(items.length));
gallery.parentNode.insertBefore(wrap, gallery);
wrap.appendChild(gallery);
const prev=document.createElement('button');
prev.type='button';
prev.className='jsa-gallery-btn jsa-gallery-btn--prev';
prev.setAttribute('aria-label', 'Photo précédente');
prev.innerHTML='‹';
const next=document.createElement('button');
next.type='button';
next.className='jsa-gallery-btn jsa-gallery-btn--next';
next.setAttribute('aria-label', 'Photo suivante');
next.innerHTML='›';
const controls=document.createElement('div');
controls.className='jsa-gallery-controls';
const thumbs=document.createElement('div');
thumbs.className='jsa-gallery-thumbs';
thumbs.setAttribute('aria-label', 'Miniatures des photos');
const dots=document.createElement('div');
dots.className='jsa-gallery-dots';
dots.setAttribute('aria-label', 'Navigation des photos');
const counter=document.createElement('div');
counter.className='jsa-gallery-counter';
counter.setAttribute('aria-live', 'polite');
const dotButtons=[];
const thumbButtons=[];
items.forEach(function(item, index){
const image=item.querySelector('img');
if(galleryMode==='strip'){
upgradeStripImageSource(image);
}
function setOrientation(){
const w=image.naturalWidth||image.width||0;
const h=image.naturalHeight||image.height||0;
item.classList.remove('is-landscape','is-portrait','is-square');
if(!w||!h) return;
if(w > h * 1.12){ item.classList.add('is-landscape'); }
else if(h > w * 1.12){ item.classList.add('is-portrait'); }else{ item.classList.add('is-square'); }}
if(image.complete){ setOrientation(); }else{ image.addEventListener('load', setOrientation, {once:true});}
const dot=document.createElement('button');
dot.type='button';
dot.className='jsa-gallery-dot';
dot.setAttribute('aria-label', 'Afficher la photo ' + (index + 1));
dot.addEventListener('click', function(){ pauseAuto(10000); goTo(index); });
dots.appendChild(dot);
dotButtons.push(dot);
const thumb=document.createElement('button');
thumb.type='button';
thumb.className='jsa-gallery-thumb';
thumb.setAttribute('aria-label', 'Afficher la photo ' + (index + 1));
const thumbImg=document.createElement('img');
thumbImg.src=image.currentSrc||image.src;
thumbImg.alt='';
thumbImg.loading='lazy';
thumbImg.decoding='async';
thumb.appendChild(thumbImg);
thumb.addEventListener('click', function(){ pauseAuto(10000); goTo(index); });
thumbs.appendChild(thumb);
thumbButtons.push(thumb);
});
wrap.appendChild(prev);
wrap.appendChild(next);
controls.appendChild(thumbs);
controls.appendChild(dots);
controls.appendChild(counter);
wrap.appendChild(controls);
let activeIndex=0;
const shouldLoopGallery=gallery.classList.contains('jsa-home-realisation-gallery')||gallery.classList.contains('jsa-install-gallery');
let ticking=false;
let autoTimer=null;
let autoPausedUntil=0;
function getActiveIndex(){
const galleryRect=gallery.getBoundingClientRect();
const center=galleryRect.left + galleryRect.width / 2;
let bestIndex=0;
let bestDistance=Infinity;
items.forEach(function(item, index){
const rect=item.getBoundingClientRect();
const itemCenter=rect.left + rect.width / 2;
const distance=Math.abs(center - itemCenter);
if(distance < bestDistance){
bestDistance=distance;
bestIndex=index;
}});
return bestIndex;
}
function update(){
activeIndex=getActiveIndex();
items.forEach(function(item, index){
item.classList.toggle('is-active', index===activeIndex);
});
dotButtons.forEach(function(dot, index){
dot.classList.toggle('is-active', index===activeIndex);
dot.setAttribute('aria-current', index===activeIndex ? 'true':'false');
});
thumbButtons.forEach(function(thumb, index){
thumb.classList.toggle('is-active', index===activeIndex);
thumb.setAttribute('aria-current', index===activeIndex ? 'true':'false');
});
counter.textContent=(activeIndex + 1) + '/' + items.length;
prev.disabled=shouldLoopGallery ? false:activeIndex <=0;
next.disabled=shouldLoopGallery ? false:activeIndex >=items.length - 1;
const activeThumb=thumbButtons[activeIndex];
if(activeThumb&&activeThumb.parentElement){
const thumbsEl=activeThumb.parentElement;
const targetLeft=activeThumb.offsetLeft - (thumbsEl.clientWidth - activeThumb.clientWidth) / 2;
if(typeof thumbsEl.scrollTo==='function'){
thumbsEl.scrollTo({left: Math.max(0, targetLeft), behavior: 'auto'});
}else{
thumbsEl.scrollLeft=Math.max(0, targetLeft);
}}
}
function requestUpdate(){
if(ticking) return;
ticking=true;
window.requestAnimationFrame(function(){
update();
ticking=false;
});
}
function clearAutoTimer(){
if(autoTimer){
window.clearTimeout(autoTimer);
autoTimer=null;
}}
function canAutoPlay(){
if(galleryMode!=='strip') return false;
if(prefersReducedMotion) return false;
if(items.length < 2) return false;
if(window.matchMedia&&window.matchMedia('(max-width: 700px)').matches&&!gallery.classList.contains('jsa-home-realisation-gallery')) return false;
if(document.hidden) return false;
if(Date.now() < autoPausedUntil) return false;
if(wrap.matches&&wrap.matches(':hover')) return false;
if(wrap.contains&&document.activeElement&&wrap.contains(document.activeElement)) return false;
const openLightbox=document.querySelector('.jsa-lightbox.is-open');
if(openLightbox) return false;
return true;
}
function scheduleAuto(delay){
if(galleryMode!=='strip') return;
clearAutoTimer();
autoTimer=window.setTimeout(function(){
if(!canAutoPlay()){
scheduleAuto(1000);
return;
}
const nextIndex=activeIndex >=items.length - 1 ? 0:activeIndex + 1;
goTo(nextIndex, true);
window.setTimeout(function(){
update();
scheduleAuto(5000);
}, prefersReducedMotion ? 0:340);
}, delay||5000);
}
function pauseAuto(ms){
if(galleryMode!=='strip') return;
autoPausedUntil=Date.now() + (ms||10000);
scheduleAuto(ms||10000);
}
function goTo(index, isAuto){
const safeIndex=Math.max(0, Math.min(items.length - 1, index));
const target=items[safeIndex];
if(!target) return;
const targetLeft=target.offsetLeft - (gallery.clientWidth - target.offsetWidth) / 2;
const left=Math.max(0, targetLeft);
if(typeof gallery.scrollTo==='function'){
gallery.scrollTo({
left: left,
behavior: prefersReducedMotion ? 'auto':'smooth'
});
}else{
gallery.scrollLeft=left;
}
activeIndex=safeIndex;
window.setTimeout(update, prefersReducedMotion ? 0:280);
if(!isAuto&&galleryMode==='strip') pauseAuto(10000);
}
prev.addEventListener('click', function(){
pauseAuto(10000);
goTo(shouldLoopGallery&&activeIndex <=0 ? items.length - 1:activeIndex - 1);
});
next.addEventListener('click', function(){
pauseAuto(10000);
goTo(shouldLoopGallery&&activeIndex >=items.length - 1 ? 0:activeIndex + 1);
});
gallery.addEventListener('scroll', requestUpdate, {passive:true});
window.addEventListener('resize', requestUpdate);
if(galleryMode==='strip'){
wrap.addEventListener('mouseenter', function(){ pauseAuto(6000); });
wrap.addEventListener('mouseleave', function(){ scheduleAuto(2500); });
wrap.addEventListener('focusin', function(){ pauseAuto(12000); });
wrap.addEventListener('focusout', function(){ scheduleAuto(3000); });
wrap.addEventListener('touchstart', function(){ pauseAuto(9000); }, {passive:true});
document.addEventListener('visibilitychange', function(){
if(document.hidden) clearAutoTimer();
else scheduleAuto(2500);
});
}
update();
window.setTimeout(update, 120);
scheduleAuto(5000);
});
if(!document.querySelector('.jsa-lightbox')){
const lb=document.createElement('div');
lb.className='jsa-lightbox';
lb.innerHTML='<button type="button" class="jsa-lightbox__close" aria-label="Fermer">×</button><button type="button" class="jsa-lightbox__nav jsa-lightbox__nav--prev" aria-label="Photo précédente">‹</button><div class="jsa-lightbox__stage"><img alt=""></div><button type="button" class="jsa-lightbox__nav jsa-lightbox__nav--next" aria-label="Photo suivante">›</button><div class="jsa-lightbox__counter" aria-live="polite"></div>';
document.body.appendChild(lb);
}
const lightbox=document.querySelector('.jsa-lightbox');
const lightboxImg=lightbox ? lightbox.querySelector('img'):null;
const lightboxStage=lightbox ? lightbox.querySelector('.jsa-lightbox__stage'):null;
const lightboxCounter=lightbox ? lightbox.querySelector('.jsa-lightbox__counter'):null;
const lightboxPrev=lightbox ? lightbox.querySelector('.jsa-lightbox__nav--prev'):null;
const lightboxNext=lightbox ? lightbox.querySelector('.jsa-lightbox__nav--next'):null;
let lightboxImages=[];
let activeLightboxIndex=-1;
function closeLightbox(){
if(!lightbox||!lightboxImg) return;
lightbox.classList.remove('is-open');
document.documentElement.classList.remove('jsa-lightbox-open');
document.body.classList.remove('jsa-lightbox-open');
lightboxImg.removeAttribute('src');
activeLightboxIndex=-1;
}
function refreshLightboxNav(){
if(!lightbox) return;
const hasMany=lightboxImages.length > 1;
if(lightboxPrev) lightboxPrev.hidden = !hasMany;
if(lightboxNext) lightboxNext.hidden = !hasMany;
if(lightboxCounter){
lightboxCounter.hidden = !hasMany;
lightboxCounter.textContent=hasMany&&activeLightboxIndex >=0 ? (activeLightboxIndex + 1) + '/' + lightboxImages.length:'';
}
if(lightboxPrev) lightboxPrev.disabled = !hasMany||activeLightboxIndex <=0;
if(lightboxNext) lightboxNext.disabled = !hasMany||activeLightboxIndex >=lightboxImages.length - 1;
}
function openLightboxByIndex(index){
if(!lightbox||!lightboxImg||!lightboxImages.length) return;
activeLightboxIndex=Math.max(0, Math.min(lightboxImages.length - 1, index));
const sourceImg=lightboxImages[activeLightboxIndex];
if(!sourceImg) return;
const fullUrl=getFullImageUrl(sourceImg);
lightboxImg.removeAttribute('src');
lightboxImg.classList.remove('is-portrait','is-landscape','is-square');
lightboxImg.alt=sourceImg.alt||'Photo de réalisation JSA CLIM';
lightbox.classList.add('is-open');
document.documentElement.classList.add('jsa-lightbox-open');
document.body.classList.add('jsa-lightbox-open');
refreshLightboxNav();
if(lightboxStage){
lightboxStage.scrollLeft=0;
lightboxStage.scrollTop=0;
}
lightboxImg.onload=function(){
const w=lightboxImg.naturalWidth||0;
const h=lightboxImg.naturalHeight||0;
lightboxImg.classList.remove('is-portrait','is-landscape','is-square');
if(w&&h){
if(h > w * 1.12){ lightboxImg.classList.add('is-portrait'); }
else if(w > h * 1.12){ lightboxImg.classList.add('is-landscape'); }else{ lightboxImg.classList.add('is-square'); }}
};
lightboxImg.src=fullUrl;
}
if(lightbox&&!lightbox.dataset.jsaLightboxEvents){
lightbox.dataset.jsaLightboxEvents='1';
const closeBtn=lightbox.querySelector('.jsa-lightbox__close');
if(closeBtn){
['click','touchend'].forEach(function(evtName){
closeBtn.addEventListener(evtName, function(e){
e.preventDefault();
e.stopPropagation();
closeLightbox();
}, {passive:false});
});
}
lightbox.addEventListener('click', function(e){ if(e.target===lightbox) closeLightbox(); });
if(lightboxPrev) lightboxPrev.addEventListener('click', function(e){ e.stopPropagation(); openLightboxByIndex(activeLightboxIndex - 1); });
if(lightboxNext) lightboxNext.addEventListener('click', function(e){ e.stopPropagation(); openLightboxByIndex(activeLightboxIndex + 1); });
document.addEventListener('keydown', function(e){
if(!lightbox.classList.contains('is-open')) return;
if(e.key==='Escape') closeLightbox();
if(e.key==='ArrowLeft') openLightboxByIndex(activeLightboxIndex - 1);
if(e.key==='ArrowRight') openLightboxByIndex(activeLightboxIndex + 1);
});
let touchStartX=0;
let touchStartY=0;
lightbox.addEventListener('touchstart', function(e){
if(!e.touches||!e.touches.length) return;
touchStartX=e.touches[0].clientX;
touchStartY=e.touches[0].clientY;
}, {passive:true});
lightbox.addEventListener('touchend', function(e){
if(!e.changedTouches||!e.changedTouches.length) return;
const dx=e.changedTouches[0].clientX - touchStartX;
const dy=e.changedTouches[0].clientY - touchStartY;
if(Math.abs(dx) > 56&&Math.abs(dx) > Math.abs(dy) * 1.35){
if(dx < 0) openLightboxByIndex(activeLightboxIndex + 1);
else openLightboxByIndex(activeLightboxIndex - 1);
}}, {passive:true});
}
function isDirectImageUrl(url){
return !!(url&&/\.(jpe?g|png|webp|gif|avif)(\?.*)?(#.*)?$/i.test(url));
}
function getLargestSrcsetUrl(srcset){
if(!srcset) return '';
let bestUrl='';
let bestWidth=0;
srcset.split(',').forEach(function(part){
const cleaned=part.trim();
if(!cleaned) return;
const pieces=cleaned.split(/\s+/);
const url=pieces[0];
const descriptor=pieces[1]||'';
let width=0;
if(/\d+w$/.test(descriptor)){
width=parseInt(descriptor, 10)||0;
}else if(/\d+(\.\d+)?x$/.test(descriptor)){
width=Math.round((parseFloat(descriptor)||1) * 1000);
}
if(url&&width >=bestWidth){
bestUrl=url;
bestWidth=width;
}});
return bestUrl;
}
function getWpOriginalCandidate(url){
if(!url||url.indexOf('/wp-content/uploads/')===-1) return url||'';
return url
.replace(/-\d+x\d+(\.(?:jpe?g|png|webp|gif|avif)(?:[?#].*)?)$/i, '$1')
.replace(/-scaled(\.(?:jpe?g|png|webp|gif|avif)(?:[?#].*)?)$/i, '$1');
}
function upgradeStripImageSource(img){
if(!img||img.dataset.jsaStripSharpReady==='1') return;
img.dataset.jsaStripSharpReady='1';
const candidates=[
img.getAttribute('data-wpfc-original-src'),
img.getAttribute('data-src'),
getLargestSrcsetUrl(img.getAttribute('data-wpfc-original-srcset')),
getLargestSrcsetUrl(img.getAttribute('data-srcset')),
getLargestSrcsetUrl(img.getAttribute('srcset')),
img.currentSrc,
img.getAttribute('src')
];
let best='';
for(let i=0; i < candidates.length; i +=1){
const candidate=getWpOriginalCandidate(candidates[i]||'');
if(isDirectImageUrl(candidate)){
best=candidate;
break;
}}
if(!best) return;
img.setAttribute('src', best);
img.removeAttribute('srcset');
img.removeAttribute('sizes');
img.removeAttribute('data-srcset');
img.removeAttribute('data-wpfc-original-srcset');
img.classList.add('jsa-strip-img-sharp');
img.decoding='async';
}
function getFullImageUrl(img){
const directLink=img.closest('a[href]');
if(directLink&&isDirectImageUrl(directLink.href)){
return getWpOriginalCandidate(directLink.href);
}
const holder=img.closest('figure, .wp-block-image, .wp-block-gallery, .jsa-story-gallery');
const dataCandidates=[
img.getAttribute('data-full-url'),
img.getAttribute('data-orig-file'),
img.getAttribute('data-large-file'),
img.getAttribute('data-src'),
holder ? holder.getAttribute('data-full-url'):'',
holder ? holder.getAttribute('data-link'):''
];
for(let i=0; i < dataCandidates.length; i +=1){
if(isDirectImageUrl(dataCandidates[i])) return getWpOriginalCandidate(dataCandidates[i]);
}
const largest=getLargestSrcsetUrl(img.getAttribute('srcset'));
if(largest) return getWpOriginalCandidate(largest);
return getWpOriginalCandidate(img.getAttribute('src')||img.currentSrc||img.src);
}
const lightboxSelector='.single-post .entry-content .wp-block-gallery img, .single-post .entry-content .jsa-story-gallery img, .single-post .entry-content figure.wp-block-image img, .page .entry-content .jsa-story-gallery img, .entry-content .wp-block-gallery.jsa-home-gallery img, .entry-content .jsa-story-gallery.jsa-home-gallery img';
lightboxImages=Array.from(document.querySelectorAll(lightboxSelector)).filter(function(img){
return !img.closest('.jsa-lightbox');
});
lightboxImages.forEach(function(img, index){
if(img.dataset.jsaLightboxReady) return;
img.dataset.jsaLightboxReady='1';
img.addEventListener('click', function(e){
if(!lightbox||!lightboxImg) return;
if(img.closest('a[href]')) e.preventDefault();
openLightboxByIndex(index);
});
});
}
function initMobileDoubleTapGuard(){
let lastTapTime=0;
let lastTapX=0;
let lastTapY=0;
document.addEventListener('touchend', function(e){
if(!e.changedTouches||!e.changedTouches.length) return;
const target=e.target;
if(target&&target.closest&&target.closest('input, textarea, select, [contenteditable="true"], .jsa-lightbox')) return;
const touch=e.changedTouches[0];
const now=Date.now();
const dx=Math.abs(touch.clientX - lastTapX);
const dy=Math.abs(touch.clientY - lastTapY);
if(now - lastTapTime < 320&&dx < 24&&dy < 24){
e.preventDefault();
}
lastTapTime=now;
lastTapX=touch.clientX;
lastTapY=touch.clientY;
}, {passive:false});
}
onReady(function(){
initMobileDoubleTapGuard();
const nav=document.querySelector('.jsa-nav-wrap');
const toggle=document.querySelector('.jsa-menu-toggle');
const siteHeader=document.querySelector('.jsa-site-header');
if(siteHeader){
const setHeaderOut=function(out){
document.body.classList.toggle('jsa-header-out', !!out);
};
if('IntersectionObserver' in window){
const observer=new IntersectionObserver(function(entries){
if(entries&&entries[0]){
setHeaderOut(!entries[0].isIntersecting);
}}, {threshold:0, rootMargin:'-1px 0px 0px 0px'});
observer.observe(siteHeader);
}else{
const updateHeaderOut=function(){
setHeaderOut(siteHeader.getBoundingClientRect().bottom <=0);
};
updateHeaderOut();
window.addEventListener('scroll', updateHeaderOut, {passive:true});
window.addEventListener('resize', updateHeaderOut);
}}
if(nav&&toggle){
const menu=document.getElementById(toggle.getAttribute('aria-controls'));
function setOpen(open){
nav.classList.toggle('is-open', open);
toggle.setAttribute('aria-expanded', open ? 'true':'false');
toggle.setAttribute('aria-label', open ? 'Fermer le menu principal':'Ouvrir le menu principal');
document.documentElement.classList.toggle('jsa-menu-open', open);
}
toggle.addEventListener('click', function(){
setOpen(!nav.classList.contains('is-open'));
});
if(menu){
menu.addEventListener('click', function(event){
if(event.target.closest('a')) setOpen(false);
});
}
document.addEventListener('click', function(event){
if(!nav.classList.contains('is-open')) return;
if(nav.contains(event.target)) return;
setOpen(false);
});
document.addEventListener('keydown', function(event){
if(event.key==='Escape') setOpen(false);
});
window.addEventListener('resize', function(){
if(window.innerWidth > 781) setOpen(false);
});
}
document.querySelectorAll('[data-jsa-carousel]').forEach(function(box){
const slides=Array.from(box.querySelectorAll('.jsa-slide'));
const dots=Array.from(box.querySelectorAll('.jsa-slide__dot'));
if(slides.length < 2) return;
let i=Math.max(0, slides.findIndex(function(slide){ return slide.classList.contains('is-active'); }));
const speed=parseInt(box.getAttribute('data-jsa-carousel'), 10)||4500;
const durations=(box.getAttribute('data-jsa-durations')||'').split(',').map(function(v){ return parseInt(v, 10); });
let timer=null;
let preloadTimer=null;
let started=false;
function clearTimers(){
window.clearTimeout(timer);
window.clearTimeout(preloadTimer);
}
function sync(){
box.setAttribute('data-active-slide', String(i + 1));
box.setAttribute('data-active-slide-key', slides[i].getAttribute('data-slide-key')||String(i + 1));
slides.forEach(function(slide, index){ slide.classList.toggle('is-active', index===i); });
dots.forEach(function(dot, index){
let target=parseInt(dot.getAttribute('data-slide-target')||String(index), 10);
if(!Number.isFinite(target)) target=index;
const active=target===i;
dot.classList.toggle('is-active', active);
dot.setAttribute('aria-current', active ? 'true':'false');
});
}
function schedule(){
clearTimers();
if(prefersReducedMotion||document.hidden) return;
const duration=durations[i]&&durations[i] >=1500 ? durations[i]:speed;
const nextIndex=(i + 1) % slides.length;
preloadTimer=window.setTimeout(function(){
hydrateSlideMedia(slides[nextIndex]);
}, Math.max(0, duration - 900));
timer=window.setTimeout(function(){ show(i + 1); }, duration);
}
function show(n){
i=((n % slides.length) + slides.length) % slides.length;
hydrateSlideMedia(slides[i]);
sync();
schedule();
}
dots.forEach(function(dot, index){
let target=parseInt(dot.getAttribute('data-slide-target')||String(index), 10);
if(!Number.isFinite(target)) target=index;
if(dot.tagName.toLowerCase()!=='button'){
dot.setAttribute('role', 'button');
dot.setAttribute('tabindex', '0');
}
if(!dot.getAttribute('aria-label')){
dot.setAttribute('aria-label', 'Afficher la slide ' + (index + 1));
}
dot.addEventListener('click', function(){ show(target); });
dot.addEventListener('keydown', function(event){
if(event.key==='Enter'||event.key===' '){
event.preventDefault();
show(target);
}});
});
function start(){
if(started) return;
started=true;
schedule();
}
document.addEventListener('visibilitychange', function(){
if(document.hidden){
clearTimers();
return;
}
schedule();
});
sync();
if(!prefersReducedMotion){
if(document.readyState==='complete'){
window.requestAnimationFrame(start);
}else{
window.addEventListener('load', function(){
window.requestAnimationFrame(start);
}, {once:true});
}}
});
prepareLooseImages(document);
silenceAriaHiddenFocusables(document);
prepareReviewsWidget();
function updateMobileFabViewportOffset(){
const root=document.documentElement;
if(!root||!window.visualViewport){
if(root){ root.style.setProperty('--jsa-fab-vv-offset', '0px'); }
return;
}
const vv=window.visualViewport;
const diff=Math.max(0, Math.round(window.innerHeight - vv.height - vv.offsetTop));
root.style.setProperty('--jsa-fab-vv-offset', diff + 'px');
}
updateMobileFabViewportOffset();
if(window.visualViewport){
window.visualViewport.addEventListener('resize', updateMobileFabViewportOffset);
window.visualViewport.addEventListener('scroll', updateMobileFabViewportOffset);
}
window.addEventListener('orientationchange', function(){
window.setTimeout(updateMobileFabViewportOffset, 250);
});
document.querySelectorAll('[data-jsa-mobile-fab]').forEach(function(fab){
const toggle=fab.querySelector('.jsa-mobile-fab__toggle');
const actions=fab.querySelector('.jsa-mobile-fab__actions');
if(!toggle) return;
const delay=Math.max(0, parseFloat(fab.getAttribute('data-delay')||'0')||0);
const autoOpen=fab.getAttribute('data-auto-open')==='1';
function setFabOpen(open){
fab.classList.toggle('is-open', !!open);
toggle.setAttribute('aria-expanded', open ? 'true':'false');
toggle.setAttribute('aria-label', open ? 'Fermer le contact rapide':'Ouvrir le contact rapide');
if(actions){
actions.setAttribute('aria-hidden', open ? 'false':'true');
actions.querySelectorAll('a,button,[tabindex]').forEach(function(el){
if(open){
const original=el.getAttribute('data-jsa-fab-tabindex');
if(original){
el.setAttribute('tabindex', original);
}else{
el.removeAttribute('tabindex');
}
return;
}
const current=el.getAttribute('tabindex');
if(current!==null&&current!=='-1'){
el.setAttribute('data-jsa-fab-tabindex', current);
}
el.setAttribute('tabindex', '-1');
});
}}
setFabOpen(false);
function revealFab(){
fab.classList.add('is-visible');
if(autoOpen){
window.setTimeout(function(){ setFabOpen(true); }, 120);
}}
if(delay > 0){
window.setTimeout(revealFab, delay * 1000);
}else{
window.requestAnimationFrame(revealFab);
}
toggle.addEventListener('click', function(event){
event.preventDefault();
setFabOpen(!fab.classList.contains('is-open'));
});
fab.addEventListener('click', function(event){
if(event.target.closest('a')){
setFabOpen(false);
}});
document.addEventListener('click', function(event){
if(!fab.classList.contains('is-open')) return;
if(fab.contains(event.target)) return;
setFabOpen(false);
});
document.addEventListener('keydown', function(event){
if(event.key==='Escape') setFabOpen(false);
});
});
window.addEventListener('load', function(){
prepareLooseImages(document);
silenceAriaHiddenFocusables(document);
prepareReviewsWidget();
initArticleGalleries();
window.setTimeout(function(){
prepareLooseImages(document);
silenceAriaHiddenFocusables(document);
prepareReviewsWidget();
initArticleGalleries();
}, 1200);
}, {once:true});
document.addEventListener('click', function(e){
const a=e.target.closest&&e.target.closest('a');
if(!a) return;
const text=(a.textContent||'').trim().toLowerCase();
const href=(a.getAttribute('href')||'').trim();
if(a.classList.contains('jsa-cookie-settings-link') ||
a.hasAttribute('data-jsa-cookie-settings') ||
(href==='#'&&(text.indexOf('gérer mes cookies')!==-1||text.indexOf('gerer mes cookies')!==-1||text.indexOf('cookies')!==-1))){
e.preventDefault();
openCookiePanel();
}}, false);
});
})();